rollback 10737:10749, this work is better left on a branch until it is
in support a significant feature enhancement. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10794 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3ecb83fc0b
commit
2ee3d98d79
3 changed files with 32 additions and 81 deletions
|
|
@ -1,9 +1,6 @@
|
||||||
Version 1.3.37 (in progress)
|
Version 1.3.37 (in progress)
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
2008-08-09: talby
|
|
||||||
[Perl5] Unify Perl and C portions of constructor wrappers.
|
|
||||||
|
|
||||||
2008-08-02: wuzzeb
|
2008-08-02: wuzzeb
|
||||||
[Chicken,Allegro] Commit Patch 2019314
|
[Chicken,Allegro] Commit Patch 2019314
|
||||||
Fixes a build error in chicken, and several build errors and other errors
|
Fixes a build error in chicken, and several build errors and other errors
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use imports_b;
|
use imports_b;
|
||||||
use imports_a;
|
use imports_a;
|
||||||
|
|
||||||
$x = imports_b::B->new();
|
$x = imports_bc::new_B();
|
||||||
imports_ac::A_hello($x);
|
imports_ac::A_hello($x);
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ static int have_constructor = 0;
|
||||||
static int have_destructor = 0;
|
static int have_destructor = 0;
|
||||||
static int have_data_members = 0;
|
static int have_data_members = 0;
|
||||||
static String *class_name = 0; /* Name of the class (what Perl thinks it is) */
|
static String *class_name = 0; /* Name of the class (what Perl thinks it is) */
|
||||||
|
static String *real_classname = 0; /* Real name of C/C++ class */
|
||||||
|
static String *fullclassname = 0;
|
||||||
|
|
||||||
static String *pcode = 0; /* Perl code associated with each class */
|
static String *pcode = 0; /* Perl code associated with each class */
|
||||||
/* static String *blessedmembers = 0; *//* Member data associated with each class */
|
/* static String *blessedmembers = 0; *//* Member data associated with each class */
|
||||||
|
|
@ -556,7 +558,6 @@ public:
|
||||||
String *iname = Getattr(n, "sym:name");
|
String *iname = Getattr(n, "sym:name");
|
||||||
SwigType *d = Getattr(n, "type");
|
SwigType *d = Getattr(n, "type");
|
||||||
ParmList *l = Getattr(n, "parms");
|
ParmList *l = Getattr(n, "parms");
|
||||||
ParmList *outer = Getattr(n, "perl5:implicits");
|
|
||||||
String *overname = 0;
|
String *overname = 0;
|
||||||
|
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
@ -566,7 +567,7 @@ public:
|
||||||
String *tm;
|
String *tm;
|
||||||
String *cleanup, *outarg;
|
String *cleanup, *outarg;
|
||||||
int num_saved = 0;
|
int num_saved = 0;
|
||||||
int num_arguments, num_required, num_implicits;
|
int num_arguments, num_required;
|
||||||
int varargs = 0;
|
int varargs = 0;
|
||||||
|
|
||||||
if (Getattr(n, "sym:overloaded")) {
|
if (Getattr(n, "sym:overloaded")) {
|
||||||
|
|
@ -588,19 +589,6 @@ public:
|
||||||
Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */
|
Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */
|
||||||
NIL);
|
NIL);
|
||||||
|
|
||||||
num_implicits = 0;
|
|
||||||
if (outer) {
|
|
||||||
Parm *tmp = outer;
|
|
||||||
Parm *tail;
|
|
||||||
while(tmp) {
|
|
||||||
tail = tmp;
|
|
||||||
num_implicits++;
|
|
||||||
tmp = nextSibling(tmp);
|
|
||||||
}
|
|
||||||
/* link the outer with inner parms */
|
|
||||||
set_nextSibling(tail, l);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit_parameter_variables(l, f);
|
emit_parameter_variables(l, f);
|
||||||
emit_attach_parmmaps(l, f);
|
emit_attach_parmmaps(l, f);
|
||||||
Setattr(n, "wrap:parms", l);
|
Setattr(n, "wrap:parms", l);
|
||||||
|
|
@ -613,29 +601,13 @@ public:
|
||||||
|
|
||||||
/* Check the number of arguments */
|
/* Check the number of arguments */
|
||||||
if (!varargs) {
|
if (!varargs) {
|
||||||
Printf(f->code, " if ((items < %d) || (items > %d)) {\n",
|
Printf(f->code, " if ((items < %d) || (items > %d)) {\n", num_required, num_arguments);
|
||||||
num_required + num_implicits, num_arguments + num_implicits);
|
|
||||||
} else {
|
} else {
|
||||||
Printf(f->code, " if (items < %d) {\n",
|
Printf(f->code, " if (items < %d) {\n", num_required);
|
||||||
num_required + num_implicits);
|
|
||||||
}
|
}
|
||||||
Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer, l));
|
Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, l));
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
if (num_implicits) {
|
|
||||||
/* TODO: support implicits of types other than SVs */
|
|
||||||
Parm *p = outer;
|
|
||||||
for(i = 0; i < num_implicits; i++) {
|
|
||||||
String *pname = Getattr(p, "name");
|
|
||||||
String *pinit = SwigType_str(Getattr(p, "type"), pname);
|
|
||||||
Wrapper_add_local(f, pname, pinit);
|
|
||||||
Delete(pinit);
|
|
||||||
Printf(f->code, "%s = ST(%d);\n", pname, i++);
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
|
||||||
if (l)
|
|
||||||
Printf(f->code, "ax += %d;\n", num_implicits);
|
|
||||||
}
|
|
||||||
/* Write code to extract parameters. */
|
/* Write code to extract parameters. */
|
||||||
i = 0;
|
i = 0;
|
||||||
for (i = 0, p = l; i < num_arguments; i++) {
|
for (i = 0, p = l; i < num_arguments; i++) {
|
||||||
|
|
@ -748,9 +720,6 @@ 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);
|
||||||
|
|
@ -797,11 +766,6 @@ 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 */
|
||||||
|
|
@ -833,10 +797,6 @@ public:
|
||||||
Printv(df->def, "XS(", dname, ") {\n", NIL);
|
Printv(df->def, "XS(", dname, ") {\n", NIL);
|
||||||
|
|
||||||
Wrapper_add_local(df, "dXSARGS", "dXSARGS");
|
Wrapper_add_local(df, "dXSARGS", "dXSARGS");
|
||||||
if (num_implicits) {
|
|
||||||
Printf(df->code, "ax += %d;\n", num_implicits);
|
|
||||||
Printf(df->code, "items -= %d;\n", num_implicits);
|
|
||||||
}
|
|
||||||
Printv(df->code, dispatch, "\n", NIL);
|
Printv(df->code, dispatch, "\n", NIL);
|
||||||
Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname);
|
Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname);
|
||||||
Printf(df->code, "XSRETURN(0);\n");
|
Printf(df->code, "XSRETURN(0);\n");
|
||||||
|
|
@ -1073,7 +1033,7 @@ public:
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* usage_func()
|
* usage_func()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
char *usage_func(char *iname, SwigType *, ParmList *il, ParmList *l) {
|
char *usage_func(char *iname, SwigType *, ParmList *l) {
|
||||||
static String *temp = 0;
|
static String *temp = 0;
|
||||||
Parm *p;
|
Parm *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -1083,17 +1043,13 @@ public:
|
||||||
Clear(temp);
|
Clear(temp);
|
||||||
Printf(temp, "%s(", iname);
|
Printf(temp, "%s(", iname);
|
||||||
|
|
||||||
i = 0;
|
/* Now go through and print parameters */
|
||||||
/* Print implicit parameters */
|
|
||||||
for(p = il; p; p = nextSibling(p))
|
|
||||||
Printv(temp, (i > 0 ? "," : ""), Getattr(p, "name"), NIL);
|
|
||||||
/* Now go through and print normal parameters */
|
|
||||||
p = l;
|
p = l;
|
||||||
|
i = 0;
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
SwigType *pt = Getattr(p, "type");
|
SwigType *pt = Getattr(p, "type");
|
||||||
String *pn = Getattr(p, "name");
|
String *pn = Getattr(p, "name");
|
||||||
if (!checkAttribute(p,"tmap:in:numinputs","0")) {
|
if (!checkAttribute(p,"tmap:in:numinputs","0")) {
|
||||||
if (i > 0) Append(temp, ",");
|
|
||||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||||
if (SwigType_type(pt) != T_VOID) {
|
if (SwigType_type(pt) != T_VOID) {
|
||||||
if (Len(pn) > 0) {
|
if (Len(pn) > 0) {
|
||||||
|
|
@ -1103,8 +1059,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
if (p)
|
||||||
|
if (!checkAttribute(p,"tmap:in:numinputs","0"))
|
||||||
|
Putc(',', temp);
|
||||||
|
} else {
|
||||||
|
p = nextSibling(p);
|
||||||
|
if (p)
|
||||||
|
if ((i > 0) && (!checkAttribute(p,"tmap:in:numinputs","0")))
|
||||||
|
Putc(',', temp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Printf(temp, ");");
|
Printf(temp, ");");
|
||||||
return Char(temp);
|
return Char(temp);
|
||||||
|
|
@ -1222,8 +1186,6 @@ public:
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int classHandler(Node *n) {
|
virtual int classHandler(Node *n) {
|
||||||
String *name = 0; /* Real name of C/C++ class */
|
|
||||||
String *fullclassname = 0;
|
|
||||||
|
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
have_constructor = 0;
|
have_constructor = 0;
|
||||||
|
|
@ -1243,7 +1205,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
fullclassname = NewString(class_name);
|
fullclassname = NewString(class_name);
|
||||||
}
|
}
|
||||||
name = Getattr(n, "name");
|
real_classname = Getattr(n, "name");
|
||||||
pcode = NewString("");
|
pcode = NewString("");
|
||||||
// blessedmembers = NewString("");
|
// blessedmembers = NewString("");
|
||||||
}
|
}
|
||||||
|
|
@ -1255,7 +1217,7 @@ public:
|
||||||
/* Finish the rest of the class */
|
/* Finish the rest of the class */
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
/* Generate a client-data entry */
|
/* Generate a client-data entry */
|
||||||
SwigType *ct = NewStringf("p.%s", name);
|
SwigType *ct = NewStringf("p.%s", real_classname);
|
||||||
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL);
|
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL);
|
||||||
SwigType_remember(ct);
|
SwigType_remember(ct);
|
||||||
Delete(ct);
|
Delete(ct);
|
||||||
|
|
@ -1528,15 +1490,6 @@ public:
|
||||||
|
|
||||||
String *symname = Getattr(n, "sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
|
|
||||||
{
|
|
||||||
String *type = NewString("SV");
|
|
||||||
SwigType_add_pointer(type);
|
|
||||||
Parm *p = NewParm(type, "proto");
|
|
||||||
Delete(type);
|
|
||||||
Setattr(n, "perl5:implicits", p);
|
|
||||||
Delete(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
member_func = 1;
|
member_func = 1;
|
||||||
Language::constructorHandler(n);
|
Language::constructorHandler(n);
|
||||||
|
|
||||||
|
|
@ -1548,16 +1501,17 @@ 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 */
|
||||||
String *cname = Swig_name_construct(symname);
|
Printf(pcode, "sub new {\n");
|
||||||
char *pname;
|
} else {
|
||||||
/* override Class->Class to be Class->new */
|
/* Constructor doesn't match classname so we'll just use the normal name */
|
||||||
if (Cmp(symname, class_name) == 0)
|
Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
|
||||||
pname = "new";
|
}
|
||||||
else
|
|
||||||
pname = Char(cname);
|
Printv(pcode,
|
||||||
Printf(pcode, "*%s = *%s::%s;\n", pname, cmodule, cname);
|
tab4, "my $pkg = shift;\n",
|
||||||
Delete(cname);
|
tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||||
|
|
||||||
have_constructor = 1;
|
have_constructor = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue