From 7ef1b04a86acf27b4a7304a576f106084f7f1405 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Fri, 8 Apr 2016 12:13:43 +0900 Subject: [PATCH 1/2] ruby: use nodeType attribute to determine whether functions are constructors. get return type each time. --- Source/Modules/ruby.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index ddf47c1b0f7..3ba816dee1f 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2110,13 +2110,11 @@ class RUBY:public Language { // Generate prototype list, go to first node Node *sibl = n; - String* type = SwigType_str(Getattr(sibl,"type"),NULL); - while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up // Constructors will be treated specially - const bool isCtor = Cmp(Getattr(sibl,"feature:new"), "1") == 0; + const bool isCtor = (!Cmp(Getattr(sibl, "nodeType"), "constructor")); const bool isMethod = ( Cmp(Getattr(sibl, "ismember"), "1") == 0 && (!isCtor) ); @@ -2138,7 +2136,7 @@ class RUBY:public Language { String *protoTypes = NewString(""); do { Append( protoTypes, "\n\" "); - if ( !isCtor ) Printv( protoTypes, type, " ", NIL ); + if ( !isCtor ) Printv( protoTypes, SwigType_str(Getattr(sibl,"type"), NULL), " ", NIL ); Printv(protoTypes, methodName, NIL ); Parm* p = Getattr(sibl, "wrap:parms"); if (p && (current == MEMBER_FUNC || current == MEMBER_VAR || @@ -2159,7 +2157,6 @@ class RUBY:public Language { Append(f->code, "\nreturn Qnil;\n"); Delete(methodName); - Delete(type); Delete(protoTypes); Printv(f->code, "}\n", NIL); From 133033749100b037bafe1baee69fec1df5ba6c07 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 May 2016 20:04:24 +0100 Subject: [PATCH 2/2] Revert introduction of minor memory leak in Ruby wrappers --- Source/Modules/ruby.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 3ba816dee1f..2ed16b7d8e8 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2136,7 +2136,11 @@ class RUBY:public Language { String *protoTypes = NewString(""); do { Append( protoTypes, "\n\" "); - if ( !isCtor ) Printv( protoTypes, SwigType_str(Getattr(sibl,"type"), NULL), " ", NIL ); + if (!isCtor) { + SwigType *type = SwigType_str(Getattr(sibl, "type"), NULL); + Printv(protoTypes, type, " ", NIL); + Delete(type); + } Printv(protoTypes, methodName, NIL ); Parm* p = Getattr(sibl, "wrap:parms"); if (p && (current == MEMBER_FUNC || current == MEMBER_VAR ||