Cleanup. Replaced Parm and ParmList data structures with new implementation.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@606 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-07-24 21:48:56 +00:00
commit 6bc7b11a9b
18 changed files with 486 additions and 724 deletions

View file

@ -436,10 +436,10 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
int i = 0;
int first_arg = 1;
for (p = ParmList_first(l); p != 0; ++i, p = ParmList_next(l)) {
DataType *pt = Parm_Gettype(p);
for (p = Firstitem(l); p != 0; ++i, p = Nextitem(l)) {
DataType *pt = Gettype(p);
if (Parm_Getignore(p))
if (Getignore(p))
continue;
if ((pt->type != T_VOID) || (pt->is_pointer)) {
if (!first_arg)
@ -468,19 +468,19 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
i = 0;
int j = 0;
for (i = 0; i < pcount; ++i) {
Parm *p = ParmList_get(l,i);
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i);
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce names of source and target
sprintf(source,"s_%d",i);
sprintf(target,"%s",Parm_Getlname(p));
sprintf(target,"%s",Getlname(p));
sprintf(argnum,"%d",i);
strcpy(arg,pn);
// Handle parameter types.
if (Parm_Getignore(p))
if (Getignore(p))
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
else {
++numargs;
@ -819,11 +819,11 @@ GUILE::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
// Now go through and print parameters
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (Parm_Getignore(p))
if (Getignore(p))
continue;
// Print the type. If the parameter has been named, use that as well.
@ -868,9 +868,9 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
// go through and see if any are output.
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
continue;

View file

@ -587,16 +587,16 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
// Now walk the function parameter list and generate code to get arguments
for (int i = 0; i < pcount ; i++) {
Parm *p = ParmList_get(l,i); // Get the ith argument
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i); // Get the ith argument
DataType *pt = Gettype(p);
char *pn = Getname(p);
char *target_copy = NULL;
char *target_length = NULL;
char *local_i = NULL;
// Produce string representation of source and target arguments
sprintf(source,"jarg%d",i);
sprintf(target,"%s", Parm_Getlname(p));
sprintf(target,"%s", Getlname(p));
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
@ -606,7 +606,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
Printv(javaParameterSignature, JavaMethodSignature(pt, 0, 0), 0);
}
if(Parm_Getignore(p)) continue;
if(Getignore(p)) continue;
// Add to java function header
if(shadow && member_func) {
@ -1067,12 +1067,12 @@ 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 = l->nparms;
int pcount = Len(l);
for (int i = 0; i < pcount ; i++) {
Parm *p = ParmList_get(l,i); // Get the ith argument
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i); // Get the ith argument
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce string representation of source and target arguments
if(pn && *(pn))
@ -1139,13 +1139,13 @@ 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 = l->nparms;
int pcount = Len(l);
int gencomma = 0;
for (int i = 0; i < pcount ; i++) {
Parm *p = ParmList_get(l,i); // Get the ith argument
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i); // Get the ith argument
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce string representation of source and target arguments
if(pn && *(pn))
@ -1206,14 +1206,14 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
else
Printv(nativecall, tab8, " _self = ", module, ".", Swig_name_construct(shadow_classname), "(", 0);
int pcount = l->nparms;
int pcount = Len(l);
if(pcount == 0) // We must have a default constructor
have_default_constructor = 1;
for (int i = 0; i < pcount ; i++) {
Parm *p = ParmList_get(l,i); // Get the ith argument
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i); // Get the ith argument
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce string representation of source and target arguments
if(pn && *(pn))

View file

@ -322,20 +322,20 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
int i = 0;
for (i = 0; i < pcount; ++i) {
Parm *p = ParmList_get(l,i);
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i);
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce names of source and target
sprintf(source,"argv[%d]",i);
sprintf(target,"%s", Parm_Getlname(p));
sprintf(target,"%s", Getlname(p));
sprintf(argnum,"%d",i);
strcpy(arg,pn);
// Handle parameter types.
if (Parm_Getignore(p))
if (Getignore(p))
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
else {
++numargs;
@ -689,11 +689,11 @@ MZSCHEME::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
// Now go through and print parameters
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (Parm_Getignore(p))
if (Getignore(p))
continue;
// Print the type. If the parameter has been named, use that as well.
@ -739,9 +739,9 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
// go through and see if any are output.
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
continue;

View file

@ -778,19 +778,19 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0;
j = 0;
p = ParmList_first(l);
p = Firstitem(l);
while (p != 0) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce string representation of source and target arguments
sprintf(source,"ST(%d)",j);
sprintf(target,"%s", Parm_Getlname(p));
sprintf(target,"%s", Getlname(p));
sprintf(argnum,"%d",j+1);
// Check to see if this argument is being ignored
if (!Parm_Getignore(p)) {
if (!Getignore(p)) {
// If there are optional arguments, check for this
@ -909,11 +909,11 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
}
// If we needed a saved variable, we need to emit to emit some code for that
// This only applies if the argument actually existed (not ignore)
if ((need_save) && (!Parm_Getignore(p))) {
if ((need_save) && (!Getignore(p))) {
Printv(f->code, tab4, temp, " = ", source, ";\n", 0);
num_saved++;
}
p = ParmList_next(l);
p = Nextitem(l);
i++;
}
@ -1055,12 +1055,12 @@ 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 = ParmList_first(l);
Parm *p = Firstitem(l);
int i = 0;
while(p) {
DataType *pt = Parm_Gettype(p);
DataType *pt = Gettype(p);
if (!Parm_Getignore(p)) {
if (!Getignore(p)) {
// Look up the datatype name here
char sourceNtarget[256];
sprintf(sourceNtarget,"$args[%d]",i);
@ -1078,7 +1078,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
}
i++;
}
p = ParmList_next(l);
p = Nextitem(l);
}
Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0);
@ -1534,12 +1534,12 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */
p = ParmList_first(l);
p = Firstitem(l);
i = 0;
while (p != 0) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
if (!Parm_Getignore(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (!Getignore(p)) {
/* If parameter has been named, use that. Otherwise, just print a type */
if ((pt->type != T_VOID) || (pt->is_pointer)) {
@ -1550,14 +1550,14 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
}
}
i++;
p = ParmList_next(l);
p = Nextitem(l);
if (p)
if (!Parm_Getignore(p))
if (!Getignore(p))
Putc(',',temp);
} else {
p = ParmList_next(l);
p = Nextitem(l);
if (p)
if ((i>0) && (!Parm_Getignore(p)))
if ((i>0) && (!Getignore(p)))
Putc(',',temp);
}
}
@ -1891,13 +1891,13 @@ 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 = ParmList_first(l);
pcount = l->nparms;
p = Firstitem(l);
pcount = Len(l);
numopt = check_numopt(l);
i = 1;
while(p) {
DataType *pt = Parm_Gettype(p);
if (!Parm_Getignore(p)) {
DataType *pt = Gettype(p);
if (!Getignore(p)) {
char sourceNtarget[512];
sprintf(sourceNtarget, "$args[%d]", i);
@ -1917,7 +1917,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
}
i++;
}
p = ParmList_next(l);
p = Nextitem(l);
}
// Okay. We've made argument adjustments, now call into the package
@ -2097,10 +2097,10 @@ 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 = ParmList_first(l);
p = Firstitem(l);
i = 0;
while(p) {
DataType *pt = Parm_Gettype(p);
DataType *pt = Gettype(p);
// Look up the datatype name here
if ((Getattr(classes,pt->name)) && (pt->is_pointer <= 1)) {
@ -2108,7 +2108,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 = ParmList_next(l);
p = Nextitem(l);
i++;
}

View file

@ -679,22 +679,22 @@ 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 = ParmList_first(l);
p = Firstitem(l);
Printf(kwargs,"{ ");
while (p != 0) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
char *pv = Parm_Getvalue(p);
DataType *pt = Gettype(p);
char *pn = Getname(p);
char *pv = Getvalue(p);
// Generate source and target strings
sprintf(source,"obj%d",i);
sprintf(target,Parm_Getlname(p));
sprintf(target,Getlname(p));
sprintf(argnum,"%d",j+1);
// Only consider this argument if it's not ignored
if (!Parm_Getignore(p)) {
if (!Getignore(p)) {
Putc(',',arglist);
// Add an optional argument separator if needed
@ -782,7 +782,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
Putc('O',parse_args);
sprintf(source,"argo%d", i);
sprintf(target,Parm_Getlname(p));
sprintf(target,Getlname(p));
sprintf(temp,"argument %d",i+1);
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
@ -801,7 +801,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Emit code for parameter list
if ((pt->type != T_VOID) && (pt->type != T_BOOL) && (pt->type != T_USER))
Printf(arglist,"&%s",Parm_Getlname(p));
Printf(arglist,"&%s",Getlname(p));
} else {
@ -809,7 +809,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
Putc('s',parse_args);
Printf(arglist,"&%s", Parm_Getlname(p));
Printf(arglist,"&%s", Getlname(p));
} else {
// Have some sort of pointer variable. Create a temporary local
@ -817,7 +817,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
Putc('O',parse_args);
sprintf(source,"argo%d", i);
sprintf(target,"%s",Parm_Getlname(p));
sprintf(target,"%s",Getlname(p));
sprintf(temp,"argument %d",i+1);
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
@ -845,7 +845,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
have_output++;
}
p = ParmList_next(l);
p = Nextitem(l);
i++;
}
@ -1417,11 +1417,11 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
// You probably don't need to change this
i = 0;
p = ParmList_first(l);
p = Firstitem(l);
while (p != 0) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
if (!Parm_Getignore(p)) {
DataType *pt = Gettype(p);
char *pn = Getname(p);
if (!Getignore(p)) {
i++;
/* If parameter has been named, use that. Otherwise, just print a type */
@ -1432,15 +1432,15 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
Printf(temp,"%s", DataType_str(pt,0));
}
}
p = ParmList_next(l);
p = Nextitem(l);
if (p != 0) {
if (!Parm_Getignore(p))
if (!Getignore(p))
Putc(',',temp);
}
} else {
p = ParmList_next(l);
p = Nextitem(l);
if (p) {
if ((!Parm_Getignore(p)) && (i > 0))
if ((!Getignore(p)) && (i > 0))
Putc(',',temp);
}
}

View file

@ -443,9 +443,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
int numreq = 0;
int numoptreal = 0;
for (i = start; i < l->nparms; i++) {
if (!Parm_Getignore(ParmList_get(l,i))) {
if (i >= l->nparms - numopt) numoptreal++;
for (i = start; i < Len(l); i++) {
if (!Getignore(Getitem(l,i))) {
if (i >= Len(l) - numopt) numoptreal++;
else numreq++;
}
}
@ -457,8 +457,8 @@ 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);
for (i = start; i < l->nparms; i++) {
if (!Parm_Getignore(ParmList_get(l,i))) {
for (i = start; i < Len(l); i++) {
if (!Getignore(Getitem(l,i))) {
Printf(f->def,", VALUE varg%d", i);
}
}
@ -467,8 +467,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
// Emit all of the local variables for holding arguments.
if (vararg) {
for (i = start; i < l->nparms; i++) {
if (!Parm_Getignore(ParmList_get(l,i))) {
for (i = start; i < Len(l); i++) {
if (!Getignore(Getitem(l,i))) {
char s[256];
sprintf(s,"varg%d",i);
Wrapper_add_localv(f,s,"VALUE",s,0);
@ -497,8 +497,8 @@ 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);
for (i = start; i < l->nparms; i++) {
if (!Parm_Getignore(ParmList_get(l,i))) {
for (i = start; i < Len(l); i++) {
if (!Getignore(Getitem(l,i))) {
Printf(f->code,", &varg%d", i);
}
}
@ -510,9 +510,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
int j = 0; // Total number of non-optional arguments
for (i = 0; i < pcount ; i++) {
Parm *p = ParmList_get(l,i);
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
Parm *p = Getitem(l,i);
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce string representation of source and target arguments
int selfp = (use_self && i == 0);
@ -521,9 +521,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
else
sprintf(source,"varg%d",i);
sprintf(target,"%s", Parm_Getlname(p));
sprintf(target,"%s", Getlname(p));
if (!Parm_Getignore(p)) {
if (!Getignore(p)) {
char *tab = (char*)tab4;
if (j >= (pcount-numopt)) { // Check if parsing an optional argument
Printf(f->code," if (argc > %d) {\n", j - start);

View file

@ -505,19 +505,19 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0;
j = 0;
p = ParmList_first(l);
p = Firstitem(l);
while (p != 0) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Produce string representations of the source and target arguments
sprintf(source,"objv[%d]",j+1);
sprintf(target,"%s", Parm_Getlname(p));
sprintf(target,"%s", Getlname(p));
sprintf(argnum,"%d",j+1);
// See if this argument is being ignored
if (!Parm_Getignore(p)) {
if (!Getignore(p)) {
if (j == (pcount-numopt))
Putc('|',argstr);
@ -648,7 +648,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
}
i++;
p = ParmList_next(l); // Get next parameter and continue
p = Nextitem(l); // Get next parameter and continue
}
Printf(argstr,":%s\"",usage);
Printv(f->code,
@ -1132,13 +1132,13 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */
i = 0;
pcount = l->nparms;
pcount = Len(l);
numopt = check_numopt(l);
p = ParmList_first(l);
p = Firstitem(l);
while (p != 0) {
DataType *pt = Parm_Gettype(p);
char *pn = Parm_Getname(p);
DataType *pt = Gettype(p);
char *pn = Getname(p);
// Only print an argument if not ignored
@ -1161,7 +1161,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
Putc(' ',temp);
i++;
}
p = ParmList_next(l);
p = Nextitem(l);
}
return Char(temp);
}
@ -1287,9 +1287,13 @@ void TCL8::cpp_close_class() {
t->is_pointer = 1;
if (have_destructor) {
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n",
tab4, Swig_name_destroy(real_classname), "((", DataType_str(t,0), ") obj);\n",
"}\n",0);
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n", 0);
if (CPlusPlus) {
Printv(code," delete (", DataType_str(t,0), ") obj;\n",0);
} else {
Printv(code," free((char *) obj);\n",0);
}
Printf(code,"}\n");
}
Printf(methods, " {0,0}\n};\n");