ruby-changes:13972
From: nobu <ko1@a...>
Date: Mon, 16 Nov 2009 01:14:26 +0900 (JST)
Subject: [ruby-changes:13972] Ruby:r25779 (mvm): * vm.c (rb_vm_current): new method RubyVM.current.
nobu 2009-11-16 01:14:10 +0900 (Mon, 16 Nov 2009) New Revision: 25779 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25779 Log: * vm.c (rb_vm_current): new method RubyVM.current. * vm.c (rb_vm_to_s): include address of rb_vm_t in RubyVM#to_s. Index: vm.c =================================================================== --- vm.c (revision 25770) +++ vm.c (working copy) @@ -2003,4 +2003,22 @@ rb_vm_initialize(int argc, VALUE *argv, } +static VALUE +rb_vm_current(VALUE self) +{ + return GET_VM()->self; +} + +static VALUE +rb_vm_to_s(VALUE self) +{ + rb_vm_t *vm; + VALUE str = rb_call_super(0, 0); + + rb_str_set_len(str, RSTRING_LEN(str)-1); + GetVMPtr(self, vm); + rb_str_catf(str, ":(%p)>", vm); + return str; +} + static rb_thread_t *vm_make_main_thread(rb_vm_t *vm); @@ -2060,6 +2078,8 @@ InitVM_VM(void) rb_define_alloc_func(rb_cRubyVM, rb_vm_s_alloc); rb_define_method(rb_cRubyVM, "initialize", rb_vm_initialize, -1); + rb_define_method(rb_cRubyVM, "to_s", rb_vm_to_s, 0); rb_define_method(rb_cRubyVM, "start", rb_vm_start, 0); rb_define_method(rb_cRubyVM, "join", rb_vm_join, 0); + rb_define_singleton_method(rb_cRubyVM, "current", rb_vm_current, 0); /* ::VM::FrozenCore */ Modified files: branches/mvm/ChangeLog branches/mvm/vm.c Index: mvm/ChangeLog =================================================================== --- mvm/ChangeLog (revision 25778) +++ mvm/ChangeLog (revision 25779) @@ -1,3 +1,9 @@ +Mon Nov 16 01:14:02 2009 Nobuyoshi Nakada <nobu@r...> + + * vm.c (rb_vm_current): new method RubyVM.current. + + * vm.c (rb_vm_to_s): include address of rb_vm_t in RubyVM#to_s. + Mon Nov 16 01:11:02 2009 Nobuyoshi Nakada <nobu@r...> * mvm.c (ruby_vm_new): create new vm unless initial vm. Index: mvm/vm.c =================================================================== --- mvm/vm.c (revision 25778) +++ mvm/vm.c (revision 25779) @@ -2002,6 +2002,24 @@ return self; } +static VALUE +rb_vm_current(VALUE self) +{ + return GET_VM()->self; +} + +static VALUE +rb_vm_to_s(VALUE self) +{ + rb_vm_t *vm; + VALUE str = rb_call_super(0, 0); + + rb_str_set_len(str, RSTRING_LEN(str)-1); + GetVMPtr(self, vm); + rb_str_catf(str, ":(%p)>", vm); + return str; +} + static rb_thread_t *vm_make_main_thread(rb_vm_t *vm); static VALUE @@ -2059,8 +2077,10 @@ rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); rb_define_alloc_func(rb_cRubyVM, rb_vm_s_alloc); rb_define_method(rb_cRubyVM, "initialize", rb_vm_initialize, -1); + rb_define_method(rb_cRubyVM, "to_s", rb_vm_to_s, 0); rb_define_method(rb_cRubyVM, "start", rb_vm_start, 0); rb_define_method(rb_cRubyVM, "join", rb_vm_join, 0); + rb_define_singleton_method(rb_cRubyVM, "current", rb_vm_current, 0); /* ::VM::FrozenCore */ fcore = rb_class_new(rb_cBasicObject); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/