Converted parameter lists to linked lists

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@641 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-08-10 18:37:30 +00:00
commit dae32de1c5
15 changed files with 160 additions and 187 deletions

View file

@ -436,7 +436,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
int i = 0;
int first_arg = 1;
for (p = Firstitem(l); p != 0; ++i, p = Nextitem(l)) {
for (p = l; p != 0; ++i, p = Getnext(p)) {
DataType *pt = Gettype(p);
if (Getignore(p))
@ -467,7 +467,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
i = 0;
int j = 0;
p = Firstitem(l);
p = l;
for (i = 0; i < pcount; ++i) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -520,7 +520,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
Printv(cleanup, tm, "\n", 0);
mreplace (cleanup, argnum, arg, proc_name);
}
p = Nextitem(l);
p = Getnext(p);
}
// Now write code to make the function call
@ -819,7 +819,7 @@ GUILE::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
// Now go through and print parameters
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
for (p = l; p != 0; p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -869,7 +869,7 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
// go through and see if any are output.
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
for (p = l; p != 0; p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);

View file

@ -594,8 +594,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
int gencomma = 0;
// Now walk the function parameter list and generate code to get arguments
p = Firstitem(l);
for (int i = 0; i < pcount ; i++, p = Nextitem(l)) {
p = l;
for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
char *target_copy = NULL;
@ -1076,10 +1076,10 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
}
Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(_self", 0);
int pcount = Len(l);
int pcount = ParmList_len(l);
Parm *p = Firstitem(l);
for (int i = 0; i < pcount ; i++, p = Nextitem(l)) {
Parm *p = l;
for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -1148,11 +1148,11 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
}
Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(", 0);
int pcount = Len(l);
int pcount = ParmList_len(l);
int gencomma = 0;
Parm *p = Firstitem(l);
for (int i = 0; i < pcount ; i++, p = Nextitem(l)) {
Parm *p = l;
for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -1215,12 +1215,12 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
else
Printv(nativecall, tab8, " _self = ", module, ".", Swig_name_construct(shadow_classname), "(", 0);
int pcount = Len(l);
int pcount = ParmList_len(l);
if(pcount == 0) // We must have a default constructor
have_default_constructor = 1;
Parm *p = Firstitem(l);
for (int i = 0; i < pcount ; i++, p = Nextitem(l)) {
Parm *p = l;
for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);

View file

@ -321,8 +321,8 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Now write code to extract the parameters (this is super ugly)
int i = 0;
p = Firstitem(l);
for (i = 0; i < pcount; ++i, p = Nextitem(l)) {
p = l;
for (i = 0; i < pcount; ++i, p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -689,7 +689,7 @@ MZSCHEME::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
// Now go through and print parameters
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
for (p = l; p != 0; p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -740,7 +740,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
// go through and see if any are output.
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
for (p = l; p != 0; p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);

View file

@ -780,7 +780,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0;
j = 0;
p = Firstitem(l);
p = l;
while (p != 0) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -902,7 +902,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
Printv(f->code, tab4, temp, " = ", source, ";\n", 0);
num_saved++;
}
p = Nextitem(l);
p = Getnext(p);
i++;
}
@ -1037,7 +1037,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
// arguments to our function correspond to other Perl objects, we
// need to extract them from a tied-hash table object.
Parm *p = Firstitem(l);
Parm *p = l;
int i = 0;
while(p) {
DataType *pt = Gettype(p);
@ -1060,7 +1060,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
}
i++;
}
p = Nextitem(l);
p = Getnext(p);
}
Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0);
@ -1507,7 +1507,7 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */
p = Firstitem(l);
p = l;
i = 0;
while (p != 0) {
DataType *pt = Gettype(p);
@ -1523,12 +1523,12 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
}
}
i++;
p = Nextitem(l);
p = Getnext(p);
if (p)
if (!Getignore(p))
Putc(',',temp);
} else {
p = Nextitem(l);
p = Getnext(p);
if (p)
if ((i>0) && (!Getignore(p)))
Putc(',',temp);
@ -1864,8 +1864,8 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
// arguments to our function correspond to other Perl objects, we
// need to extract them from a tied-hash table object.
p = Firstitem(l);
pcount = Len(l);
p = l;
pcount = ParmList_len(l);
numopt = check_numopt(l);
i = 1;
while(p) {
@ -1890,7 +1890,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
}
i++;
}
p = Nextitem(l);
p = Getnext(p);
}
// Okay. We've made argument adjustments, now call into the package
@ -2070,7 +2070,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
// arguments to our function correspond to other Perl objects, we
// need to extract them from a tied-hash table object.
p = Firstitem(l);
p = l;
i = 0;
while(p) {
DataType *pt = Gettype(p);
@ -2081,7 +2081,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
// Yep. This smells alot like an object, patch up the arguments
Printf(pcode, " $args[%d] = tied(%%{$args[%d]});\n", i, i);
}
p = Nextitem(l);
p = Getnext(p);
i++;
}

View file

@ -679,8 +679,8 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
j = 0;
numopt = check_numopt(l); // Get number of optional arguments
if (numopt) have_defarg = 1;
p = Firstitem(l);
p = l;
Printf(kwargs,"{ ");
while (p != 0) {
DataType *pt = Gettype(p);
@ -835,7 +835,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
have_output++;
}
p = Nextitem(l);
p = Getnext(p);
i++;
}
@ -1364,7 +1364,7 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
// You probably don't need to change this
i = 0;
p = Firstitem(l);
p = l;
while (p != 0) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -1379,13 +1379,13 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
Printf(temp,"%s", DataType_str(pt,0));
}
}
p = Nextitem(l);
p = Getnext(p);
if (p != 0) {
if (!Getignore(p))
Putc(',',temp);
}
} else {
p = Nextitem(l);
p = Getnext(p);
if (p) {
if ((!Getignore(p)) && (i > 0))
Putc(',',temp);

View file

@ -441,11 +441,11 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
int numreq = 0;
int numoptreal = 0;
Parm *p = Firstitem(l);
for (i = 0; i < start; i++) p = Nextitem(l);
for (i = start; p; i++, p = Nextitem(l)) {
Parm *p = l;
for (i = 0; i < start; i++) p = Getnext(p);
for (i = start; p; i++, p = Getnext(p)) {
if (!Getignore(p)) {
if (i >= Len(l) - numopt) numoptreal++;
if (i >= ParmList_len(l) - numopt) numoptreal++;
else numreq++;
}
}
@ -457,9 +457,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
Printv(f->def, "int argc, VALUE *argv, VALUE self",0);
} else {
Printv(f->def, "VALUE self", 0);
p = Firstitem(l);
for (i = 0; i < start; i++) p = Nextitem(l);
for (i = start; p; i++, p = Nextitem(l)) {
p = l;
for (i = 0; i < start; i++) p = Getnext(p);
for (i = start; p; i++, p = Getnext(p)) {
if (!Getignore(p)) {
Printf(f->def,", VALUE varg%d", i);
}
@ -469,9 +469,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
// Emit all of the local variables for holding arguments.
if (vararg) {
p = Firstitem(l);
for (i = 0; i < start; i++) p = Nextitem(l);
for (i = start; p; i++, p = Nextitem(l)) {
p = l;
for (i = 0; i < start; i++) p = Getnext(p);
for (i = start; p; i++, p = Getnext(p)) {
if (!Getignore(p)) {
char s[256];
sprintf(s,"varg%d",i);
@ -501,9 +501,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
// Emit count to check the number of arguments
if (vararg) {
Printf(f->code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
p = Firstitem(l);
for (i = 0; i < start; i++) p = Nextitem(l);
for (i = start; p; i++, p = Nextitem(l)) {
p = l;
for (i = 0; i < start; i++) p = Getnext(p);
for (i = start; p; i++, p = Getnext(p)) {
if (!Getignore(p)) {
Printf(f->code,", &varg%d", i);
}
@ -515,8 +515,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
// to get arguments
int j = 0; // Total number of non-optional arguments
p = Firstitem(l);
for (i = 0; i < pcount ; i++, p = Nextitem(l)) {
p = l;
for (i = 0; i < pcount ; i++, p = Getnext(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);

View file

@ -505,7 +505,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0;
j = 0;
p = Firstitem(l);
p = l;
while (p != 0) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -641,7 +641,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
}
i++;
p = Nextitem(l); // Get next parameter and continue
p = Getnext(p); // Get next parameter and continue
}
Printf(argstr,":%s\"",usage);
Printv(f->code,
@ -1107,9 +1107,9 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */
i = 0;
pcount = Len(l);
pcount = ParmList_len(l);
numopt = check_numopt(l);
p = Firstitem(l);
p = l;
while (p != 0) {
DataType *pt = Gettype(p);
@ -1135,7 +1135,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
Putc(' ',temp);
i++;
}
p = Nextitem(l);
p = Getnext(p);
}
return Char(temp);
}

View file

@ -151,9 +151,7 @@ static void update_local_type(DataType *type) {
// (if neccessary).
// -----------------------------------------------------------------------------
static void update_parms(ParmList *l) {
Parm *p;
p = Firstitem(l);
static void update_parms(ParmList *p) {
while (p) {
DataType *pt = Gettype(p);
char *pvalue = Getvalue(p);
@ -169,7 +167,7 @@ static void update_parms(ParmList *l) {
Setvalue(p,s);
}
}
p = Nextitem(l);
p = Getnext(p);
}
}
@ -639,9 +637,7 @@ public:
Clear(CCode);
AddMethods = 0;
if ((!have_constructor) && (1)) {
ParmList *l;
l = NewParmList();
cplus_constructor(classname,0,l);
cplus_constructor(classname,0,0);
};
if (!have_destructor) {

View file

@ -43,7 +43,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
Swig_cargs(f, l);
i = 0;
p = Firstitem(l);
p = l;
while (p != 0) {
lname = Getlname(p);
pt = Gettype(p);
@ -65,7 +65,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
Setignore(p,1);
}
i++;
p = Nextitem(l);
p = Getnext(p);
}
return(i);
}

View file

@ -1435,18 +1435,21 @@ func_end : cpp_const LBRACE { skip_brace(); }
parms : parm ptail {
DataType *pt = Gettype($1);
if (DataType_type(pt) != T_VOID)
Insert($2,0,$1);
$$ = $2;
if (DataType_type(pt) != T_VOID) {
Setnext($1,$2);
$$ = $1;
} else {
$$ = $2;
}
}
| empty { $$ = NewParmList(); }
| empty { $$ = 0; }
;
ptail : COMMA parm ptail {
Insert($3,0,$2);
$$ = $3;
Setnext($2,$3);
$$ = $2;
}
| empty { $$ = NewParmList(); }
| empty { $$ = 0; }
;
parm : parm_type {
@ -3230,10 +3233,20 @@ objc_args : objc_args objc_separator objc_arg_type ID {
Parm *p= NewParm($3,$4);
/* p->objc_separator = $2; */
$$ = $1;
Append($$,p);
if (!$$) {
$$ = p;
} else {
Parm *np, *pp;
np = $$;
while(np) {
pp = np;
np = Getnext(np);
}
Setnext(pp,p);
}
}
| empty {
$$ = NewParmList();
$$ = 0;
}
;

View file

@ -308,8 +308,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
/* Just a sanity check to make sure args look okay. */
if (args) {
Parm *p;
p = Firstitem(tm->args);
Parm *p = tm->args;
while (p) {
char *pn = Getname(p);
if (pn) {
@ -318,7 +317,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
fprintf(stderr,"%s:%d: Typemap error. Local variables must have a name\n",
input_file, line_number);
}
p = Nextitem(tm->args);
p = Getnext(p);
}
}
}
@ -481,7 +480,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
Parm *p;
char *new_name;
p = Firstitem(l);
p = l;
while (p) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
@ -529,7 +528,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
Replace(s,pn,new_name,DOH_REPLACE_ID);
}
}
p = Nextitem(l);
p = Getnext(l);
}
/* If the original datatype was an array. We're going to go through and substitute
it's array dimensions */
@ -1122,12 +1121,12 @@ typemap_initialize() {
* Gets the number of optional arguments for a ParmList.
* ------------------------------------------------------------------ */
int check_numopt(ParmList *l) {
int check_numopt(ParmList *p) {
int n = 0;
int i = 0;
int state = 0;
for (int i = 0; i < Len(l); i++) {
Parm *p = Getitem(l,i);
for (;p; p = Getnext(p),i++) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (Getvalue(p)) {
@ -1156,80 +1155,58 @@ int check_numopt(ParmList *l) {
* of hash table objects containing all of the matches.
* ----------------------------------------------------------------------------- */
static void extend(ParmList *l, ParmList *e) {
Parm *p;
if (!(l && e)) return;
p = Firstitem(e);
while (p) {
Append(l,CopyParm(p));
p = Nextitem(e);
}
}
DOHList *
typemap_match_parms(ParmList *l) {
DOHList *tl;
DOHHash *tm;
Parm *p;
ParmList *nl;
char *s;
tl = NewList();
p = Firstitem(l);
p = l;
while (p) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
ParmList *vars = 0;
tm = NewHash();
vars = NewList();
/* Look up all of the argument related typemaps */
/* "in" */
if ((s = typemap_lookup((char*)"in",typemap_lang,pt,pn,(char *)"$source",(char *)"$target",0))) {
Setattr(tm,"in",s);
extend(vars,last_args);
}
/* "ignore" */
if ((s = typemap_lookup((char*)"ignore",typemap_lang,pt,pn,(char *)"$source",(char *)"$target",0))) {
Setattr(tm,"ignore",s);
extend(vars,last_args);
}
/* "argout" */
if ((s = typemap_lookup((char*)"argout",typemap_lang,pt,pn,(char *)"$source",(char *)"$target",0))) {
Setattr(tm,"argout",s);
extend(vars,last_args);
}
/* "default" */
if ((s = typemap_lookup((char*)"default",typemap_lang,pt,pn,(char *)"$source",(char *)"$target",0))) {
Setattr(tm,"default",s);
extend(vars,last_args);
}
/* "check" */
if ((s = typemap_lookup((char*)"check",typemap_lang,pt,pn,(char *)"$source",(char *)"$target",0))) {
Setattr(tm,"check",s);
extend(vars,last_args);
}
/* "arginit" */
if ((s = typemap_lookup((char*)"arginit",typemap_lang,pt,pn,(char *)"$source",(char *)"$target",0))) {
Setattr(tm,"arginit",s);
extend(vars,last_args);
}
Setattr(tm,"locals", vars);
Append(tl,tm);
Delete(vars);
Delete(tm);
p = Nextitem(l);
p = Getnext(p);
}
return tl;
}

View file

@ -153,8 +153,7 @@ Swig_clocal_assign(DataType *t, DOHString_or_char *name) {
* number of parameters.
* ----------------------------------------------------------------------------- */
int Swig_cargs(Wrapper *w, ParmList *l) {
Parm *p;
int Swig_cargs(Wrapper *w, ParmList *p) {
int i;
DataType *pt;
char *pvalue;
@ -163,7 +162,6 @@ int Swig_cargs(Wrapper *w, ParmList *l) {
char *lname;
i = 0;
p = Firstitem(l);
while (p != 0) {
lname = Swig_cparm_name(p,i);
pt = Gettype(p);
@ -172,7 +170,7 @@ int Swig_cargs(Wrapper *w, ParmList *l) {
local = Swig_clocal(pt,lname,pvalue);
Wrapper_add_localv(w,lname,local,0);
i++;
p = Nextitem(l);
p = Getnext(p);
}
return(i);
}
@ -292,20 +290,18 @@ char *
Swig_cfunction_call(DOHString_or_char *name, ParmList *parms) {
static DOH *func = 0;
int i = 0;
Parm *p;
Parm *p = parms;
DataType *pt;
if (!func) func = NewString("");
Clear(func);
Printf(func,"%s(", name);
p = Firstitem(parms);
while (p) {
pt = Gettype(p);
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
i++;
p = Nextitem(parms);
p = Getnext(p);
if (p)
Printf(func,",");
}
@ -326,23 +322,21 @@ char *
Swig_cmethod_call(DOHString_or_char *name, ParmList *parms) {
static DOH *func = 0;
int i = 0;
Parm *p;
Parm *p = parms;
DataType *pt;
if (!func) func = NewString("");
Clear(func);
p = Firstitem(parms);
if (!p) return "";
Printf(func,"%s->%s(", Swig_cparm_name(p,0), name);
i++;
p = Nextitem(parms);
p = Getnext(p);
while (p) {
pt = Gettype(p);
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
i++;
p = Nextitem(parms);
p = Getnext(p);
if (p)
Printf(func,",");
}
@ -384,18 +378,17 @@ char *
Swig_cppconstructor_call(DOHString_or_char *name, ParmList *parms) {
static DOH *func = 0;
int i = 0;
Parm *p;
Parm *p = parms;
DataType *pt;
if (!func) func = NewString("");
Clear(func);
Printf(func,"new %s(", name);
p = Firstitem(parms);
while (p) {
pt = Gettype(p);
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
i++;
p = Nextitem(parms);
p = Getnext(p);
if (p)
Printf(func,",");
}
@ -491,11 +484,8 @@ Swig_cmemberget_call(DOHString_or_char *name, DataType *t) {
}
static void fix_parm_names(ParmList *l) {
static void fix_parm_names(ParmList *p) {
int i = 0;
Parm *p;
p = Firstitem(l);
while (p) {
if (!Getname(p)) {
char temp[64];
@ -503,7 +493,7 @@ static void fix_parm_names(ParmList *l) {
Setname(p,temp);
}
i++;
p = Nextitem(l);
p = Getnext(p);
}
}
@ -529,18 +519,15 @@ Swig_cfunction_wrapper(DOHString_or_char *funcname,
Wrapper_Setname(w,funcname);
l = CopyParmList(parms);
fix_parm_names(l);
Printf(w->def,"%s %s(%s) {", DataType_str(rtype,0), funcname, ParmList_str(l));
if (code) {
Printv(w->code, code, "\n", 0);
}
Printf(w->code,"}\n");
Wrapper_Settype(w,rtype);
Wrapper_Setparms(w,l);
Delete(l);
return w;
}
@ -574,9 +561,10 @@ Swig_cmethod_wrapper(DOHString_or_char *classname,
DataType_Setname(t, Char(classname));
DataType_add_pointer(t);
p = NewParm(t,"self");
Insert(l,0,p);
Setnext(p,l);
DelDataType(t);
l = p;
fix_parm_names(l);
Printf(w->def,"%s %s(%s) {", DataType_str(rtype,0), Swig_name_member(classname, methodname), ParmList_str(l));
@ -588,11 +576,10 @@ Swig_cmethod_wrapper(DOHString_or_char *classname,
}
Printf(w->code,"self->%s(", methodname);
p = Firstitem(l);
p = Nextitem(l);
p = Getnext(l);
while (p) {
Printf(w->code,"%s", Getname(p));
p = Nextitem(l);
p = Getnext(p);
if (p)
Printf(w->code,",");
}
@ -688,12 +675,12 @@ Swig_cppconstructor_wrapper(DOHString_or_char *classname,
if (!code) {
/* No code supplied. Write a function manually */
Printf(w->code,"return new %s", DataType_str(t,0));
p = Firstitem(l);
p = l;
if (p) {
Printf(w->code,"(");
while (p) {
Printf(w->code,"%s", Getname(p));
p = Nextitem(l);
p = Getnext(p);
if (p)
Printf(w->code,",");
}
@ -732,12 +719,11 @@ Swig_cdestructor_wrapper(DOHString_or_char *classname,
/* Set the name of the function */
Wrapper_Setname(w,Swig_name_destroy(classname));
l = NewParmList();
t = NewDataType(T_USER);
DataType_Setname(t,classname);
DataType_add_pointer(t);
p = NewParm(t,"self");
Append(l,p);
l = p;
DelDataType(t);
t = NewDataType(T_VOID);
@ -779,13 +765,12 @@ Swig_cppdestructor_wrapper(DOHString_or_char *classname,
/* Set the name of the function */
Wrapper_Setname(w,Swig_name_destroy(classname));
l = NewParmList();
t = NewDataType(T_USER);
DataType_Setname(t,classname);
DataType_add_pointer(t);
p = NewParm(t,"self");
Append(l,p);
l = p;
DelDataType(t);
t = NewDataType(T_VOID);
@ -829,17 +814,16 @@ Swig_cmemberset_wrapper(DOHString_or_char *classname,
/* Set the name of the function */
Wrapper_Setname(w,Swig_name_member(classname, Swig_name_set(membername)));
l = NewParmList();
t = NewDataType(T_USER);
DataType_Setname(t, Char(classname));
DataType_add_pointer(t);
p = NewParm(t,"self");
Append(l,p);
l = p;
DelDataType(t);
lt = Swig_clocal_type(type);
p = NewParm(lt,"value");
Append(l,p);
Setnext(l,p);
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
@ -882,12 +866,11 @@ Swig_cmemberget_wrapper(DOHString_or_char *classname,
/* Set the name of the function */
Wrapper_Setname(w,Swig_name_member(classname, Swig_name_get(membername)));
l = NewParmList();
t = NewDataType(T_USER);
DataType_Setname(t, Char(classname));
DataType_add_pointer(t);
p = NewParm(t,"self");
Append(l,p);
l = p;
DelDataType(t);
lt = Swig_clocal_type(type);
@ -928,10 +911,9 @@ Swig_cvarset_wrapper(DOHString_or_char *varname,
/* Set the name of the function */
Wrapper_Setname(w,Swig_name_set(varname));
l = NewParmList();
lt = Swig_clocal_type(type);
p = NewParm(lt,"value");
Append(l,p);
l = p;
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
@ -966,7 +948,7 @@ Swig_cvarget_wrapper(DOHString_or_char *varname,
DOHString_or_char *code)
{
Wrapper *w;
ParmList *l;
ParmList *l = 0;
DataType *lt;
w = NewWrapper();
@ -974,8 +956,6 @@ Swig_cvarget_wrapper(DOHString_or_char *varname,
/* Set the name of the function */
Wrapper_Setname(w, Swig_name_get(varname));
l = NewParmList();
lt = Swig_clocal_type(type);
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));

View file

@ -66,66 +66,73 @@ Parm *CopyParm(Parm *p) {
return np;
}
/* ------------------------------------------------------------------
* NewParmList()
* ------------------------------------------------------------------ */
ParmList *NewParmList() {
return NewList();
}
/* ------------------------------------------------------------------
* CopyParmList()
* ------------------------------------------------------------------ */
ParmList *
CopyParmList(ParmList *l) {
ParmList *nl;
int i, len;
CopyParmList(ParmList *p) {
Parm *np;
Parm *pp = 0;
Parm *fp = 0;
nl = NewList();
len = Len(l);
for (i = 0; i < len; i++) {
Parm *p = Getitem(l,i);
Append(nl, CopyParm(p));
if (!p) return 0;
while (p) {
np = CopyParm(p);
if (pp) {
Setnext(pp,np);
} else {
fp = np;
}
pp = np;
p = Getnext(p);
}
return nl;
return fp;
}
/* ------------------------------------------------------------------
* int ParmList_numarg()
* ------------------------------------------------------------------ */
int ParmList_numarg(ParmList *l) {
int ParmList_numarg(ParmList *p) {
int n = 0;
Parm *p;
p = Firstitem(l);
while (p) {
if (!Getignore(p)) n++;
p = Nextitem(l);
p = Getnext(p);
}
return n;
}
/* -----------------------------------------------------------------------------
* int ParmList_len()
* ----------------------------------------------------------------------------- */
int ParmList_len(ParmList *p) {
int i = 0;
while (p) {
i++;
p = Getnext(p);
}
return i;
}
/* ---------------------------------------------------------------------
* ParmList_str()
*
* Generates a string of parameters
* ---------------------------------------------------------------------- */
char *ParmList_str(ParmList *l) {
char *ParmList_str(ParmList *p) {
static DOHString *out = 0;
Parm *p;
DataType *t;
if (!out) out = NewString("");
Clear(out);
p = Firstitem(l);
while(p) {
t = Gettype(p);
Printf(out,"%s", DataType_str(t,Getname(p)));
p = Nextitem(l);
p = Getnext(p);
if (p)
Printf(out,",");
}
@ -138,18 +145,16 @@ char *ParmList_str(ParmList *l) {
* Generate a prototype string.
* ---------------------------------------------------------------------- */
char *ParmList_protostr(ParmList *l) {
char *ParmList_protostr(ParmList *p) {
static DOHString *out = 0;
Parm *p;
DataType *t;
if (!out) out = NewString("");
Clear(out);
p = Firstitem(l);
while(p) {
t = Gettype(p);
Printf(out,"%s", DataType_str(t,0));
p = Nextitem(l);
p = Getnext(p);
if (p)
Printf(out,",");
}

View file

@ -133,6 +133,7 @@ typedef DOH ParmList;
extern ParmList *NewParmList();
extern ParmList *CopyParmList(ParmList *);
extern int ParmList_len(ParmList *);
extern int ParmList_numarg(ParmList *);
extern char *ParmList_str(ParmList *);
extern char *ParmList_protostr(ParmList *);

View file

@ -52,8 +52,8 @@ DelWrapper(Wrapper *w) {
Delete(w->code);
Delete(w->def);
if (w->_type) DelDataType(w->_type);
if (w->_parms) Delete(w->_parms);
if (w->_name) Delete(w->_name);
Delete(w->_parms);
Delete(w->_name);
free(w);
}
@ -291,8 +291,9 @@ Wrapper_Getparms(Wrapper *w) {
void
Wrapper_Setparms(Wrapper *w, ParmList *l) {
if (w->_parms) Delete(w->_parms);
w->_parms = CopyParmList(l);
Delete(w->_parms);
w->_parms = l;
DohIncref(l);
}
/* -----------------------------------------------------------------------------
@ -310,7 +311,7 @@ Wrapper_Getname(Wrapper *w) {
void
Wrapper_Setname(Wrapper *w, DOHString_or_char *n) {
if (w->_name) Delete(w->_name);
Delete(w->_name);
w->_name = NewString(n);
}