diff --git a/CHANGES.current b/CHANGES.current index 6c9251502..b730bb13f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,9 @@ Version 1.3.20 (In progress) ============================ +04/15/2003: ljohnson (Lyle Johnson) + [Ruby] Incorporated Nobu Nakada's patches for supporting the Ruby + 1.8 allocation framework. + 04/15/2003: ljohnson (Lyle Johnson) [Ruby] Replaced all uses of the deprecated STR2CSTR() macro with the safer StringValuePtr() macro. For more information, see ruby-talk:67059 diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 77e87d216..800f1fbde 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -478,8 +478,13 @@ public: iname, "\", ", wname, ", -1);\n", NIL); break; case CONSTRUCTOR_ALLOCATE: + Printv(s, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n", NIL); + Printv(s, tab4, "rb_define_alloc_func(", klass->vname, + ", ", wname, ");\n", NIL); + Printv(s, "#else\n", NIL); Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"new\", ", wname, ", -1);\n", NIL); + Printv(s, "#endif\n", NIL); Replaceall(klass->init,"$allocator", s); break; case CONSTRUCTOR_INITIALIZE: @@ -829,7 +834,9 @@ public: if (current == CONSTRUCTOR_ALLOCATE) { need_result = 1; Printf(f->code, "VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE%s);\n", Char(SwigType_manglestr(t))); + Printf(f->code, "#ifndef HAVE_RB_DEFINE_ALLOC_FUNC\n"); Printf(f->code, "rb_obj_call_init(vresult, argc, argv);\n"); + Printf(f->code, "#endif\n"); } else if (current == CONSTRUCTOR_INITIALIZE) { need_result = 1; // Printf(f->code, "DATA_PTR(self) = result;\n"); @@ -1328,8 +1335,10 @@ public: Printv(f_header, klass->header,NIL); String *s = NewString(""); + Printv(s, "#ifndef HAVE_RB_DEFINE_ALLOC_FUNC\n", NIL); Printv(s, tab4, "rb_undef_method(CLASS_OF(", klass->vname, "), \"new\");\n", NIL); + Printv(s, "#endif\n", NIL); Replaceall(klass->init,"$allocator", s); Replaceall(klass->init,"$initializer", ""); Replaceall(klass->init,"$super", "rb_cObject"); diff --git a/TODO b/TODO index 335294eec..5904d735c 100644 --- a/TODO +++ b/TODO @@ -203,14 +203,14 @@ Ruby **** Add Ruby support for Mark Rose's polymorphism code. -**** Investigate the new object allocation framework that has been +[DONE] Investigate the new object allocation framework that has been implemented for Ruby 1.8 and determine what (if anything) needs to be changed for the wrapper code generated by SWIG. For background see ruby-talk messages 23358 and 38856 (and related threads). *** Add support for keyword arguments (by collecting them in a hash?). -** Add support for defining nested modules. This should work like it does +[DONE] Add support for defining nested modules. This should work like it does for the SWIG Perl module. ** In a post to the SWIG users' mailing list (June 5: "Multiple Inheritance