diff options
author | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-19 03:58:57 +0000 |
---|---|---|
committer | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-19 03:58:57 +0000 |
commit | 8ed8664aa7ca657f536d507ac6de84d71e02e31b (patch) | |
tree | c38efde703164c6ecbbade0b477a7b1318c18086 /eval.c | |
parent | d3b74e1806e572592b4242bee140813ffeefdaf1 (diff) | |
download | ruby-8ed8664aa7ca657f536d507ac6de84d71e02e31b.tar.gz |
Add boot_classes to rdoc parsing, fix a couple of bugs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 55 |
1 files changed, 49 insertions, 6 deletions
@@ -6954,6 +6954,10 @@ frame_dup(frame) } } +/* + * MISSING: documentation + */ + static VALUE proc_clone(self) VALUE self; @@ -7855,12 +7859,6 @@ Init_Proc() rb_define_global_function("proc", proc_lambda, 0); rb_define_global_function("lambda", proc_lambda, 0); - rb_cBinding = rb_define_class("Binding", rb_cObject); - rb_undef_alloc_func(rb_cBinding); - rb_undef_method(CLASS_OF(rb_cBinding), "new"); - rb_define_method(rb_cBinding, "clone", proc_clone, 0); - rb_define_global_function("binding", rb_f_binding, 0); - rb_cMethod = rb_define_class("Method", rb_cObject); rb_undef_alloc_func(rb_cMethod); rb_undef_method(CLASS_OF(rb_cMethod), "new"); @@ -7887,6 +7885,51 @@ Init_Proc() rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1); } +/* + * Objects of class <code>Binding</code> encapsulate the execution + * context at some particular place in the code and retain this context + * for future use. The variables, methods, value of <code>self</code>, + * and possibly an iterator block that can be accessed in this context + * are all retained. Binding objects can be created using + * <code>Kernel#binding</code>, and are made available to the callback + * of <code>Kernel#set_trace_func</code>. + * + * These binding objects can be passed as the second argument of the + * <code>Kernel#eval</code> method, establishing an environment for the + * evaluation. + * + * class Demo + * def initialize(n) + * @secret = n + * end + * def getBinding + * return binding() + * end + * end + * + * k1 = Demo.new(99) + * b1 = k1.getBinding + * k2 = Demo.new(-3) + * b2 = k2.getBinding + * + * eval("@secret", b1) #=> 99 + * eval("@secret", b2) #=> -3 + * eval("@secret") #=> nil + * + * Binding objects have no class-specific methods. + * + */ + +void +Init_Binding() +{ + rb_cBinding = rb_define_class("Binding", rb_cObject); + rb_undef_alloc_func(rb_cBinding); + rb_undef_method(CLASS_OF(rb_cBinding), "new"); + rb_define_method(rb_cBinding, "clone", proc_clone, 0); + rb_define_global_function("binding", rb_f_binding, 0); +} + #ifdef __ia64__ #if defined(__FreeBSD__) /* |