diff --git a/Examples/test-suite/perl5/global_vars_runme.pl b/Examples/test-suite/perl5/global_vars_runme.pl new file mode 100644 index 000000000..a8d7c780a --- /dev/null +++ b/Examples/test-suite/perl5/global_vars_runme.pl @@ -0,0 +1,6 @@ +use global_vars; + + +$an = new global_vars::A(); +$global_vars::ap = $an; + diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg index c3a9ef0d6..85052a325 100644 --- a/Lib/perl5/perltypemaps.swg +++ b/Lib/perl5/perltypemaps.swg @@ -82,3 +82,19 @@ /* Include the unified typemap library */ %include +/* ------------------------------------------------------------ + * Perl extra typemaps + * ------------------------------------------------------------ */ + +%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] + "sv_setiv(SvRV($result),(IV) $1);"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE & + "sv_setiv(SvRV($result),(IV) &$1);"; + +%typemap(varout,type="$&1_descriptor") SWIGTYPE + "sv_setiv(SvRV($result), (IV) &$1);"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { + SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); +} diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 554580f36..7f2a2f08c 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -726,7 +726,7 @@ public: "fail:\n", cleanup, "croak(Nullch);\n" - "XSRETURN(0); }\n" + "}\n" "}\n", NIL); @@ -801,7 +801,6 @@ public: /* ------------------------------------------------------------ * variableWrapper() * ------------------------------------------------------------ */ - virtual int variableWrapper(Node *n) { String *name = Getattr(n,"name"); String *iname = Getattr(n,"sym:name"); @@ -809,8 +808,8 @@ public: Wrapper *getf, *setf; String *tm; - String *set_name = Swig_name_set(iname); - String *val_name = Swig_name_get(iname); + String *set_name = Swig_name_wrapper(Swig_name_set(iname)); + String *val_name = Swig_name_wrapper(Swig_name_get(iname)); if (!addSymbol(iname,n)) return SWIG_ERROR; @@ -853,7 +852,6 @@ public: int addfail = 0; if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) { - SwigType *t = Getattr(n,"type"); Replaceall(tm,"$target","sv"); Replaceall(tm,"$result","sv"); Replaceall(tm,"$source",name);