From afd3a339f156292afc9a7accd257fa281ae09803 Mon Sep 17 00:00:00 2001 From: Logan Johnson Date: Wed, 16 Apr 2003 22:44:05 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4689 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubyhead.swg | 3 ++- Source/Modules/ruby.cxx | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index ba3880990..d202c7e77 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -97,6 +97,7 @@ typedef struct { #endif #ifndef HAVE_RB_DEFINE_ALLOC_FUNC -#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF(klass), "new") +#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) +#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") #endif diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 52ae0b021..cf46c51ef 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -458,7 +458,7 @@ public: void create_command(Node *n, const String_or_char *iname) { - String *alloc_func_name = Swig_name_wrapper(iname); + String *alloc_func = Swig_name_wrapper(iname); String *wname = Swig_name_wrapper(iname); if (CPlusPlus) { Insert(wname,0,"VALUEFUNC("); @@ -479,11 +479,7 @@ public: iname, "\", ", wname, ", -1);\n", NIL); break; case CONSTRUCTOR_ALLOCATE: - Printf(s, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n"); - Printv(s, tab4, "rb_define_alloc_func(", klass->vname, ", ", alloc_func_name, ");\n", NIL); - Printf(s, "#else\n"); - Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"new\", ", wname, ", -1);\n", NIL); - Printf(s, "#endif\n"); + Printv(s, tab4, "rb_define_alloc_func(", klass->vname, ", ", alloc_func, ");\n", NIL); Replaceall(klass->init,"$allocator", s); break; case CONSTRUCTOR_INITIALIZE: @@ -514,7 +510,7 @@ public: Delete(temp); Delete(s); Delete(wname); - Delete(alloc_func_name); + Delete(alloc_func); } /* ---------------------------------------------------------------------