moves perl space constructor fixups into wrapper code.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10747 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Robert Stone 2008-08-09 04:08:26 +00:00
commit 93652cdc70

View file

@ -633,6 +633,7 @@ public:
Printf(f->code, "%s = ST(%d);\n", pname, i++); Printf(f->code, "%s = ST(%d);\n", pname, i++);
p = nextSibling(p); p = nextSibling(p);
} }
if (l)
Printf(f->code, "ax += %d;\n", num_implicits); Printf(f->code, "ax += %d;\n", num_implicits);
} }
/* Write code to extract parameters. */ /* Write code to extract parameters. */
@ -747,6 +748,9 @@ public:
Wrapper_add_localv(f, "_saved", "SV *", temp, NIL); Wrapper_add_localv(f, "_saved", "SV *", temp, NIL);
} }
if (num_implicits && l)
Printf(f->code, "ax -= %d;\n", num_implicits);
/* Now write code to make the function call */ /* Now write code to make the function call */
Swig_director_emit_dynamic_cast(n, f); Swig_director_emit_dynamic_cast(n, f);
@ -793,6 +797,11 @@ public:
Printf(f->code, "%s\n", tm); Printf(f->code, "%s\n", tm);
} }
if (blessed && Equal(nodeType(n), "constructor")) {
Append(f->code,
"if (SvOK(ST(0))) sv_bless(ST(0), gv_stashsv(proto, 0));\n");
}
Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL); Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL);
/* Add the dXSARGS last */ /* Add the dXSARGS last */
@ -1536,17 +1545,16 @@ public:
Delete(plaction); Delete(plaction);
Printv(pcode, plcode, NIL); Printv(pcode, plcode, NIL);
} else { } else {
if ((Cmp(symname, class_name) == 0)) {
/* Emit a blessed constructor */ /* Emit a blessed constructor */
Printf(pcode, "sub new {\n"); String *cname = Swig_name_construct(symname);
} else { char *pname;
/* Constructor doesn't match classname so we'll just use the normal name */ /* override Class->Class to be Class->new */
Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL); if (Cmp(symname, class_name) == 0)
} pname = "new";
else
Printv(pcode, pname = Char(cname);
tab4, "my $pkg = $_[0];\n", Printf(pcode, "*%s = *%s::%s;\n", pname, cmodule, cname);
tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); Delete(cname);
have_constructor = 1; have_constructor = 1;
} }