Changed data structures related to function parameters

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@568 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-07-11 19:42:41 +00:00
commit 4756fefcef
13 changed files with 364 additions and 366 deletions

View file

@ -427,7 +427,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
int i = 0; int i = 0;
int first_arg = 1; int first_arg = 1;
for (p = l->get_first(); p != 0; ++i, p = l->get_next()) { for (p = ParmList_first(l); p != 0; ++i, p = ParmList_next(l)) {
if (p->ignore) if (p->ignore)
continue; continue;
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
@ -457,29 +457,29 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
i = 0; i = 0;
int j = 0; int j = 0;
for (i = 0; i < pcount; ++i) { for (i = 0; i < pcount; ++i) {
Parm &p = (*l)[i]; Parm *p = ParmList_get(l,i);
// Produce names of source and target // Produce names of source and target
sprintf(source,"s_%d",i); sprintf(source,"s_%d",i);
sprintf(target,"_arg%d",i); sprintf(target,"_arg%d",i);
sprintf(argnum,"%d",i); sprintf(argnum,"%d",i);
strcpy(arg,p.name); strcpy(arg,p->name);
// Handle parameter types. // Handle parameter types.
if (p.ignore) if (p->ignore)
Printv(f->code, "/* ", p.name, " ignored... */\n", 0); Printv(f->code, "/* ", p->name, " ignored... */\n", 0);
else { else {
++numargs; ++numargs;
if ((tm = typemap_lookup ((char*)"in", typemap_lang, if ((tm = typemap_lookup ((char*)"in", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
Printv(f->code,tm,"\n",0); Printv(f->code,tm,"\n",0);
mreplace (f->code, argnum, arg, proc_name); mreplace (f->code, argnum, arg, proc_name);
} }
else if (p.t->is_pointer) else if (p->t->is_pointer)
get_pointer (iname, i, p.t, f, proc_name, numargs); get_pointer (iname, i, p->t, f, proc_name, numargs);
else { else {
throw_unhandled_guile_type_error (p.t); throw_unhandled_guile_type_error (p->t);
} }
++j; ++j;
} }
@ -487,7 +487,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Check if there are any constraints. // Check if there are any constraints.
if ((tm = typemap_lookup ((char*)"check", typemap_lang, if ((tm = typemap_lookup ((char*)"check", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
Printv(f->code,tm,"\n",0); Printv(f->code,tm,"\n",0);
mreplace (f->code, argnum, arg, proc_name); mreplace (f->code, argnum, arg, proc_name);
} }
@ -495,7 +495,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Pass output arguments back to the caller. // Pass output arguments back to the caller.
if ((tm = typemap_lookup ((char*)"argout", typemap_lang, if ((tm = typemap_lookup ((char*)"argout", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
Printv(outarg,tm,"\n",0); Printv(outarg,tm,"\n",0);
mreplace (outarg, argnum, arg, proc_name); mreplace (outarg, argnum, arg, proc_name);
} }
@ -503,7 +503,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Free up any memory allocated for the arguments. // Free up any memory allocated for the arguments.
if ((tm = typemap_lookup ((char*)"freearg", typemap_lang, if ((tm = typemap_lookup ((char*)"freearg", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
Printv(cleanup, tm, "\n", 0); Printv(cleanup, tm, "\n", 0);
mreplace (cleanup, argnum, arg, proc_name); mreplace (cleanup, argnum, arg, proc_name);
} }
@ -806,7 +806,7 @@ GUILE::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
// Now go through and print parameters // Now go through and print parameters
for (p = l->get_first(); p != 0; p = l->get_next()) { for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
if (p->ignore) if (p->ignore)
continue; continue;
@ -853,7 +853,7 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
// go through and see if any are output. // go through and see if any are output.
for (p = l->get_first(); p != 0; p = l->get_next()) { for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
if (strcmp (p->name,"BOTH") && strcmp (p->name,"OUTPUT")) if (strcmp (p->name,"BOTH") && strcmp (p->name,"OUTPUT"))
continue; continue;

View file

@ -587,7 +587,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
// Now walk the function parameter list and generate code to get arguments // Now walk the function parameter list and generate code to get arguments
for (int i = 0; i < pcount ; i++) { for (int i = 0; i < pcount ; i++) {
Parm *p = l->get(i); // Get the ith argument Parm *p = ParmList_get(l,i); // Get the ith argument
char *target_copy = NULL; char *target_copy = NULL;
char *target_length = NULL; char *target_length = NULL;
char *local_i = NULL; char *local_i = NULL;
@ -1068,7 +1068,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
int pcount = l->nparms; int pcount = l->nparms;
for (int i = 0; i < pcount ; i++) { for (int i = 0; i < pcount ; i++) {
Parm *p = l->get(i); // Get the ith argument Parm *p = ParmList_get(l,i); // Get the ith argument
// Produce string representation of source and target arguments // Produce string representation of source and target arguments
if(p->name && *(p->name)) if(p->name && *(p->name))
strcpy(arg,p->name); strcpy(arg,p->name);
@ -1138,7 +1138,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
int gencomma = 0; int gencomma = 0;
for (int i = 0; i < pcount ; i++) { for (int i = 0; i < pcount ; i++) {
Parm *p = l->get(i); // Get the ith argument Parm *p = ParmList_get(l,i); // Get the ith argument
// Produce string representation of source and target arguments // Produce string representation of source and target arguments
if(p->name && *(p->name)) if(p->name && *(p->name))
strcpy(arg,p->name); strcpy(arg,p->name);
@ -1203,7 +1203,7 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
have_default_constructor = 1; have_default_constructor = 1;
for (int i = 0; i < pcount ; i++) { for (int i = 0; i < pcount ; i++) {
Parm *p = l->get(i); // Get the ith argument Parm *p = ParmList_get(l,i); // Get the ith argument
// Produce string representation of source and target arguments // Produce string representation of source and target arguments
if(p->name && *(p->name)) if(p->name && *(p->name))
strcpy(arg,p->name); strcpy(arg,p->name);

View file

@ -336,39 +336,39 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
int i = 0; int i = 0;
for (i = 0; i < pcount; ++i) { for (i = 0; i < pcount; ++i) {
Parm &p = (*l)[i]; Parm *p = ParmList_get(l,i);
// Produce names of source and target // Produce names of source and target
sprintf(source,"argv[%d]",i); sprintf(source,"argv[%d]",i);
sprintf(target,"_arg%d",i); sprintf(target,"_arg%d",i);
sprintf(argnum,"%d",i); sprintf(argnum,"%d",i);
strcpy(arg,p.name); strcpy(arg,p->name);
// Handle parameter types. // Handle parameter types.
if (p.ignore) if (p->ignore)
Printv(f->code, "/* ", p.name, " ignored... */\n", 0); Printv(f->code, "/* ", p->name, " ignored... */\n", 0);
else { else {
++numargs; ++numargs;
if ((tm = typemap_lookup ((char*)"in", typemap_lang, if ((tm = typemap_lookup ((char*)"in", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
Printv(f->code, tm, "\n", 0); Printv(f->code, tm, "\n", 0);
mreplace (f->code, argnum, arg, proc_name); mreplace (f->code, argnum, arg, proc_name);
} }
// no typemap found // no typemap found
// assume it's a Scheme_Object containing the C pointer // assume it's a Scheme_Object containing the C pointer
else if (p.t->is_pointer) { else if (p->t->is_pointer) {
get_pointer (proc_name, i, p.t, f); get_pointer (proc_name, i, p->t, f);
} }
// no typemap found and not a pointer // no typemap found and not a pointer
else throw_unhandled_mzscheme_type_error (p.t); else throw_unhandled_mzscheme_type_error (p->t);
} }
// Check if there are any constraints. // Check if there are any constraints.
if ((tm = typemap_lookup ((char*)"check", typemap_lang, if ((tm = typemap_lookup ((char*)"check", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
// Yep. Use it instead of the default // Yep. Use it instead of the default
Printv(f->code,tm,"\n", 0); Printv(f->code,tm,"\n", 0);
mreplace (f->code, argnum, arg, proc_name); mreplace (f->code, argnum, arg, proc_name);
@ -377,7 +377,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Pass output arguments back to the caller. // Pass output arguments back to the caller.
if ((tm = typemap_lookup ((char*)"argout", typemap_lang, if ((tm = typemap_lookup ((char*)"argout", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
// Yep. Use it instead of the default // Yep. Use it instead of the default
Printv(outarg, tm, "\n", 0); Printv(outarg, tm, "\n", 0);
mreplace (outarg, argnum, arg, proc_name); mreplace (outarg, argnum, arg, proc_name);
@ -386,7 +386,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Free up any memory allocated for the arguments. // Free up any memory allocated for the arguments.
if ((tm = typemap_lookup ((char*)"freearg", typemap_lang, if ((tm = typemap_lookup ((char*)"freearg", typemap_lang,
p.t, p.name, source, target, f))) { p->t, p->name, source, target, f))) {
// Yep. Use it instead of the default // Yep. Use it instead of the default
Printv(cleanup, tm, "\n", 0); Printv(cleanup, tm, "\n", 0);
mreplace (cleanup, argnum, arg, proc_name); mreplace (cleanup, argnum, arg, proc_name);
@ -701,7 +701,7 @@ MZSCHEME::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
// Now go through and print parameters // Now go through and print parameters
for (p = l->get_first(); p != 0; p = l->get_next()) { for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
if (p->ignore) if (p->ignore)
continue; continue;
@ -749,7 +749,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
// go through and see if any are output. // go through and see if any are output.
for (p = l->get_first(); p != 0; p = l->get_next()) { for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
if (strcmp (p->name,"BOTH") && strcmp (p->name,"OUTPUT")) if (strcmp (p->name,"BOTH") && strcmp (p->name,"OUTPUT"))
continue; continue;

View file

@ -764,14 +764,14 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
Printv(f->code, tab4, "cv = cv;\n", 0); Printv(f->code, tab4, "cv = cv;\n", 0);
pcount = emit_args(d, l, f); pcount = emit_args(d, l, f);
numopt = l->numopt(); numopt = ParmList_numopt(l);
Wrapper_add_local(f,"argvi","int argvi = 0"); Wrapper_add_local(f,"argvi","int argvi = 0");
// Check the number of arguments // Check the number of arguments
usage = usage_func(iname,d,l); usage = usage_func(iname,d,l);
Printf(f->code," if ((items < %d) || (items > %d)) \n", pcount-numopt, l->numarg()); Printf(f->code," if ((items < %d) || (items > %d)) \n", pcount-numopt, ParmList_numarg(l));
Printf(f->code," croak(\"Usage: %s\");\n", usage); Printf(f->code," croak(\"Usage: %s\");\n", usage);
// Write code to extract parameters. // Write code to extract parameters.
@ -780,7 +780,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0; i = 0;
j = 0; j = 0;
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
// Produce string representation of source and target arguments // Produce string representation of source and target arguments
sprintf(source,"ST(%d)",j); sprintf(source,"ST(%d)",j);
@ -909,7 +909,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
Printv(f->code, tab4, temp, " = ", source, ";\n", 0); Printv(f->code, tab4, temp, " = ", source, ";\n", 0);
num_saved++; num_saved++;
} }
p = l->get_next(); p = ParmList_next(l);
i++; i++;
} }
@ -1051,7 +1051,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
// arguments to our function correspond to other Perl objects, we // arguments to our function correspond to other Perl objects, we
// need to extract them from a tied-hash table object. // need to extract them from a tied-hash table object.
Parm *p = l->get_first(); Parm *p = ParmList_first(l);
int i = 0; int i = 0;
while(p) { while(p) {
@ -1073,7 +1073,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
} }
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
} }
Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0); Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0);
@ -1529,7 +1529,7 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */ /* Now go through and print parameters */
p = l->get_first(); p = ParmList_first(l);
i = 0; i = 0;
while (p != 0) { while (p != 0) {
if (!p->ignore) { if (!p->ignore) {
@ -1543,12 +1543,12 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
} }
} }
i++; i++;
p = l->get_next(); p = ParmList_next(l);
if (p) if (p)
if (!p->ignore) if (!p->ignore)
Putc(',',temp); Putc(',',temp);
} else { } else {
p = l->get_next(); p = ParmList_next(l);
if (p) if (p)
if ((i>0) && (!p->ignore)) if ((i>0) && (!p->ignore))
Putc(',',temp); Putc(',',temp);
@ -1885,9 +1885,9 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
// arguments to our function correspond to other Perl objects, we // arguments to our function correspond to other Perl objects, we
// need to extract them from a tied-hash table object. // need to extract them from a tied-hash table object.
p = l->get_first(); p = ParmList_first(l);
pcount = l->nparms; pcount = l->nparms;
numopt = l->numopt(); numopt = ParmList_numopt(l);
i = 1; i = 1;
while(p) { while(p) {
if (!p->ignore) { if (!p->ignore) {
@ -1910,7 +1910,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
} }
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
} }
// Okay. We've made argument adjustments, now call into the package // Okay. We've made argument adjustments, now call into the package
@ -2090,7 +2090,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
// arguments to our function correspond to other Perl objects, we // arguments to our function correspond to other Perl objects, we
// need to extract them from a tied-hash table object. // need to extract them from a tied-hash table object.
p = l->get_first(); p = ParmList_first(l);
i = 0; i = 0;
while(p) { while(p) {
@ -2101,7 +2101,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
// Yep. This smells alot like an object, patch up the arguments // Yep. This smells alot like an object, patch up the arguments
Printf(pcode, " $args[%d] = tied(%%{$args[%d]});\n", i, i); Printf(pcode, " $args[%d] = tied(%%{$args[%d]});\n", i, i);
} }
p = l->get_next(); p = ParmList_next(l);
i++; i++;
} }

View file

@ -680,9 +680,9 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0; i = 0;
j = 0; j = 0;
numopt = l->numopt(); // Get number of optional arguments numopt = ParmList_numopt(l); // Get number of optional arguments
if (numopt) have_defarg = 1; if (numopt) have_defarg = 1;
p = l->get_first(); p = ParmList_first(l);
Printf(kwargs,"{ "); Printf(kwargs,"{ ");
while (p != 0) { while (p != 0) {
@ -838,7 +838,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
Replace(outarg,"$arg",source, DOH_REPLACE_ANY); Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
have_output++; have_output++;
} }
p = l->get_next(); p = ParmList_next(l);
i++; i++;
} }
@ -1411,7 +1411,7 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
// You probably don't need to change this // You probably don't need to change this
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if (!p->ignore) { if (!p->ignore) {
i++; i++;
@ -1424,13 +1424,13 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
Printf(temp,"%s", p->t->print_type()); Printf(temp,"%s", p->t->print_type());
} }
} }
p = l->get_next(); p = ParmList_next(l);
if (p != 0) { if (p != 0) {
if (!p->ignore) if (!p->ignore)
Putc(',',temp); Putc(',',temp);
} }
} else { } else {
p = l->get_next(); p = ParmList_next(l);
if (p) { if (p) {
if ((!p->ignore) && (i > 0)) if ((!p->ignore) && (i > 0))
Putc(',',temp); Putc(',',temp);

View file

@ -426,8 +426,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
} }
// Get number of arguments // Get number of arguments
int numarg = l->numarg(); int numarg = ParmList_numarg(l);
int numopt = l->numopt(); int numopt = ParmList_numopt(l);
int numignore = l->nparms - numarg; int numignore = l->nparms - numarg;
int start = 0; int start = 0;
int use_self = 0; int use_self = 0;
@ -443,7 +443,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
int numreq = 0; int numreq = 0;
int numoptreal = 0; int numoptreal = 0;
for (i = start; i < l->nparms; i++) { for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) { if (!ParmList_get(l,i)->ignore) {
if (i >= l->nparms - numopt) numoptreal++; if (i >= l->nparms - numopt) numoptreal++;
else numreq++; else numreq++;
} }
@ -457,7 +457,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
} else { } else {
Printv(f->def, "VALUE self", 0); Printv(f->def, "VALUE self", 0);
for (i = start; i < l->nparms; i++) { for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) { if (!ParmList_get(l,i)->ignore) {
Printf(f->def,", VALUE varg%d", i); Printf(f->def,", VALUE varg%d", i);
} }
} }
@ -467,7 +467,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
// Emit all of the local variables for holding arguments. // Emit all of the local variables for holding arguments.
if (vararg) { if (vararg) {
for (i = start; i < l->nparms; i++) { for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) { if (!ParmList_get(l,i)->ignore) {
char s[256]; char s[256];
sprintf(s,"varg%d",i); sprintf(s,"varg%d",i);
Wrapper_add_localv(f,s,"VALUE",s,0); Wrapper_add_localv(f,s,"VALUE",s,0);
@ -497,7 +497,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
if (vararg) { if (vararg) {
Printf(f->code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal); Printf(f->code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
for (i = start; i < l->nparms; i++) { for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) { if (!ParmList_get(l,i)->ignore) {
Printf(f->code,", &varg%d", i); Printf(f->code,", &varg%d", i);
} }
} }
@ -509,7 +509,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
int j = 0; // Total number of non-optional arguments int j = 0; // Total number of non-optional arguments
for (i = 0; i < pcount ; i++) { for (i = 0; i < pcount ; i++) {
Parm &p = (*l)[i]; // Get the ith argument Parm *p = ParmList_get(l,i);
// Produce string representation of source and target arguments // Produce string representation of source and target arguments
int selfp = (use_self && i == 0); int selfp = (use_self && i == 0);
@ -520,7 +520,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
sprintf(target,"_arg%d",i); sprintf(target,"_arg%d",i);
if (!p.ignore) { if (!p->ignore) {
char *tab = (char*)tab4; char *tab = (char*)tab4;
if (j >= (pcount-numopt)) { // Check if parsing an optional argument if (j >= (pcount-numopt)) { // Check if parsing an optional argument
Printf(f->code," if (argc > %d) {\n", j - start); Printf(f->code," if (argc > %d) {\n", j - start);
@ -528,7 +528,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
} }
// Get typemap for this argument // Get typemap for this argument
tm = ruby_typemap_lookup((char*)"in",p.t,p.name,source,target,f); tm = ruby_typemap_lookup((char*)"in",p->t,p->name,source,target,f);
if (tm) { if (tm) {
DOHString *s = NewString(tm); DOHString *s = NewString(tm);
indent(s,tab); indent(s,tab);
@ -537,7 +537,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
Delete(s); Delete(s);
} else { } else {
Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n", Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n",
input_file,line_number, p.t->print_type()); input_file,line_number, p->t->print_type());
} }
if (j >= (pcount-numopt)) if (j >= (pcount-numopt))
Printv(f->code, tab4, "} \n"); Printv(f->code, tab4, "} \n");
@ -545,7 +545,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
} }
// Check to see if there was any sort of a constaint typemap // Check to see if there was any sort of a constaint typemap
tm = ruby_typemap_lookup((char*)"check",p.t,p.name,source,target); tm = ruby_typemap_lookup((char*)"check",p->t,p->name,source,target);
if (tm) { if (tm) {
DOHString *s = NewString(tm); DOHString *s = NewString(tm);
indent(s); indent(s);
@ -555,7 +555,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
} }
// Check if there was any cleanup code (save it for later) // Check if there was any cleanup code (save it for later)
tm = ruby_typemap_lookup((char*)"freearg",p.t,p.name,target,source); tm = ruby_typemap_lookup((char*)"freearg",p->t,p->name,target,source);
if (tm) { if (tm) {
DOHString *s = NewString(tm); DOHString *s = NewString(tm);
indent(s); indent(s);
@ -564,7 +564,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
Delete(s); Delete(s);
} }
tm = ruby_typemap_lookup((char*)"argout",p.t,p.name,target,(char*)"vresult"); tm = ruby_typemap_lookup((char*)"argout",p->t,p->name,target,(char*)"vresult");
if (tm) { if (tm) {
DOHString *s = NewString(tm); DOHString *s = NewString(tm);
indent(s); indent(s);

View file

@ -494,7 +494,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Print out variables for storing arguments. // Print out variables for storing arguments.
pcount = emit_args(d, l, f); pcount = emit_args(d, l, f);
numopt = l->numopt(); numopt = ParmList_numopt(l);
// Create a local variable for holding the interpreter result value // Create a local variable for holding the interpreter result value
@ -507,7 +507,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0; i = 0;
j = 0; j = 0;
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
// Produce string representations of the source and target arguments // Produce string representations of the source and target arguments
sprintf(source,"objv[%d]",j+1); sprintf(source,"objv[%d]",j+1);
@ -643,7 +643,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
Replace(outarg,"$arg",source, DOH_REPLACE_ANY); Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
} }
i++; i++;
p = l->get_next(); // Get next parameter and continue p = ParmList_next(l); // Get next parameter and continue
} }
Printf(argstr,":%s\"",usage); Printf(argstr,":%s\"",usage);
Printv(f->code, Printv(f->code,
@ -1139,8 +1139,8 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */ /* Now go through and print parameters */
i = 0; i = 0;
pcount = l->nparms; pcount = l->nparms;
numopt = l->numopt(); numopt = ParmList_numopt(l);
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
// Only print an argument if not ignored // Only print an argument if not ignored
@ -1164,7 +1164,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
Putc(' ',temp); Putc(' ',temp);
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
} }
return Char(temp); return Char(temp);
} }

View file

@ -88,6 +88,7 @@ static int Inherit_mode = 0; // Set if we're inheriting members
static char *ccode = 0; // Set to optional C code (if available) static char *ccode = 0; // Set to optional C code (if available)
static DOHHash *localtypes = 0; // Localtype hash static DOHHash *localtypes = 0; // Localtype hash
static int abstract =0; // Status bit set during code generation static int abstract =0; // Status bit set during code generation
int IsVirtual = 0;
static int cpp_id = 0; static int cpp_id = 0;
@ -152,7 +153,7 @@ static void update_local_type(DataType *type) {
static void update_parms(ParmList *l) { static void update_parms(ParmList *l) {
Parm *p; Parm *p;
p = l->get_first(); p = ParmList_first(l);
while (p) { while (p) {
update_local_type(p->t); update_local_type(p->t);
@ -166,7 +167,7 @@ static void update_parms(ParmList *l) {
p->defvalue = copy_string(s); p->defvalue = copy_string(s);
} }
} }
p = l->get_next(); p = ParmList_next(l);
} }
} }
@ -210,7 +211,7 @@ public:
name = copy_string(n); name = copy_string(n);
iname = copy_string(i); iname = copy_string(i);
ret_type = new DataType(t); ret_type = new DataType(t);
parms = new ParmList(l); parms = CopyParmList(l);
is_static = s; is_static = s;
is_virtual = v; is_virtual = v;
new_method = AddMethods; new_method = AddMethods;
@ -260,10 +261,11 @@ public:
line_number = line; // Restore line and file line_number = line; // Restore line and file
input_file = file; input_file = file;
ccode = code; ccode = code;
IsVirtual = is_virtual;
// Make a copy of the parameter list and upgrade its types // Make a copy of the parameter list and upgrade its types
l = new ParmList(parms); l = CopyParmList(parms);
t = new DataType(ret_type); t = new DataType(ret_type);
update_parms(l); update_parms(l);
update_local_type(t); update_local_type(t);
@ -272,8 +274,9 @@ public:
} else { } else {
lang->cpp_member_func(name, iname, t, l); lang->cpp_member_func(name, iname, t, l);
} }
delete l; DelParmList(l);
delete t; delete t;
IsVirtual = 0;
} }
}; };
@ -289,7 +292,7 @@ public:
CPP_constructor(char *n, char *i, ParmList *l) { CPP_constructor(char *n, char *i, ParmList *l) {
name = copy_string(n); name = copy_string(n);
iname = copy_string(i); iname = copy_string(i);
parms = new ParmList(l); parms = CopyParmList(l);
new_method = AddMethods; new_method = AddMethods;
inherited = 0; inherited = 0;
next = 0; next = 0;
@ -315,10 +318,10 @@ public:
// Make a copy of the parameter list and upgrade its types // Make a copy of the parameter list and upgrade its types
l = new ParmList(parms); l = CopyParmList(parms);
update_parms(l); update_parms(l);
lang->cpp_constructor(name,iname,l); lang->cpp_constructor(name,iname,l);
delete l; DelParmList(l);
} }
} }
}; };
@ -638,7 +641,7 @@ public:
AddMethods = 0; AddMethods = 0;
if ((!have_constructor) && (1)) { if ((!have_constructor) && (1)) {
ParmList *l; ParmList *l;
l = new ParmList(); l = NewParmList();
cplus_constructor(classname,0,l); cplus_constructor(classname,0,l);
}; };
@ -1518,7 +1521,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
// If so, we'll just use the existing wrapper. // If so, we'll just use the existing wrapper.
Printf(key,"%s+",cname); Printf(key,"%s+",cname);
l->print_types(key); ParmList_print_types(l,key);
char *temp = copy_string(iname); char *temp = copy_string(iname);
if (!member_hash) member_hash = NewHash(); if (!member_hash) member_hash = NewHash();
if (Getattr(member_hash,key)) { if (Getattr(member_hash,key)) {
@ -1542,13 +1545,13 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
// Walk down the parameter list and Spit out arguments // Walk down the parameter list and Spit out arguments
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
Printf(wrap,",_swigarg%d",i); Printf(wrap,",_swigarg%d",i);
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
} }
Printf(wrap,") ("); Printf(wrap,") (");
@ -1558,14 +1561,14 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
Printv(wrap, "[ _swigobj ", mname, 0); // Objective C invocation Printv(wrap, "[ _swigobj ", mname, 0); // Objective C invocation
} }
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while(p != 0) { while(p != 0) {
if (ObjCClass) Printf(wrap," %s", p->objc_separator); if (ObjCClass) Printf(wrap," %s", p->objc_separator);
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
Printf(wrap,"_swigarg%d",i); Printf(wrap,"_swigarg%d",i);
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
if ((p != 0) && (!ObjCClass)) if ((p != 0) && (!ObjCClass))
Putc(',',wrap); Putc(',',wrap);
} }
@ -1591,7 +1594,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
// Walk down the parameter list and Spit out arguments // Walk down the parameter list and Spit out arguments
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
Printf(wrap,","); Printf(wrap,",");
@ -1606,7 +1609,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
} }
Printf(wrap," %s", p->name); Printf(wrap," %s", p->name);
} }
p = l->get_next(); p = ParmList_next(l);
} }
Printf(wrap,") %s", ccode); Printf(wrap,") %s", ccode);
fprintf(f_wrappers,"%s\n",Char(wrap)); fprintf(f_wrappers,"%s\n",Char(wrap));
@ -1616,8 +1619,8 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
// Now add a parameter to the beginning of the function and call // Now add a parameter to the beginning of the function and call
// a language specific function to add it. // a language specific function to add it.
newparms = new ParmList(l); newparms = CopyParmList(l);
p = new Parm(0,0); p = NewParm(0,0);
p->t = new DataType; p->t = new DataType;
p->t->type = T_USER; p->t->type = T_USER;
p->t->is_pointer = 1; p->t->is_pointer = 1;
@ -1626,12 +1629,12 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
sprintf(p->t->name,"%s%s", classtype,classname); sprintf(p->t->name,"%s%s", classtype,classname);
p->name = (char*)"self"; p->name = (char*)"self";
newparms->insert(p,0); // Attach parameter to beginning of list ParmList_insert(newparms,p,0); // Attach parameter to beginning of list
// Now wrap the thing. The name of the function is iname // Now wrap the thing. The name of the function is iname
lang->create_function(cname, iname, type, newparms); lang->create_function(cname, iname, type, newparms);
delete newparms; DelParmList(newparms);
} else { } else {
// Already wrapped this function. Just patch it up // Already wrapped this function. Just patch it up
lang->create_command(prev_wrap, iname); lang->create_command(prev_wrap, iname);
@ -1735,7 +1738,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
// Perform a hash table lookup to see if we've wrapped anything like this before // Perform a hash table lookup to see if we've wrapped anything like this before
Printf(key,"%s+",cname); Printf(key,"%s+",cname);
l->print_types(key); ParmList_print_types(l,key);
char *temp = copy_string(iname); char *temp = copy_string(iname);
if (!member_hash) member_hash = NewHash(); if (!member_hash) member_hash = NewHash();
if (Getattr(member_hash,key)) { if (Getattr(member_hash,key)) {
@ -1760,7 +1763,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
Printv(wrap,"static ", type->print_full(), " ", cname, "(", 0); Printv(wrap,"static ", type->print_full(), " ", cname, "(", 0);
// Walk down the parameter list and Spit out arguments // Walk down the parameter list and Spit out arguments
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
if (p->t->is_reference) { if (p->t->is_reference) {
@ -1773,7 +1776,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
} }
Printf(wrap," %s", p->name); Printf(wrap," %s", p->name);
} }
p = l->get_next(); p = ParmList_next(l);
if (p) Printf(wrap, ","); if (p) Printf(wrap, ",");
} }
Printf(wrap, ") "); Printf(wrap, ") ");
@ -1800,7 +1803,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
} }
Printv(wrap, "[ ", classname, " ", mname,0); // Objective C invocation Printv(wrap, "[ ", classname, " ", mname,0); // Objective C invocation
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while(p != 0) { while(p != 0) {
Printf(wrap," %s", p->objc_separator); Printf(wrap," %s", p->objc_separator);
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
@ -1810,7 +1813,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
Printf(wrap,p->name); Printf(wrap,p->name);
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
} }
Printf(wrap,"];\n"); Printf(wrap,"];\n");
@ -1912,8 +1915,8 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
// Make a parameter list for this function // Make a parameter list for this function
l = new ParmList; l = NewParmList();
p = new Parm(0,0); p = NewParm(0,0);
p->t = new DataType; p->t = new DataType;
p->t->type = T_USER; p->t->type = T_USER;
p->t->is_pointer = 1; p->t->is_pointer = 1;
@ -1921,7 +1924,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
p->call_type = 0; p->call_type = 0;
sprintf(p->t->name,"%s%s", classtype, classname); sprintf(p->t->name,"%s%s", classtype, classname);
p->name = (char*)"self"; p->name = (char*)"self";
l->insert(p,0); ParmList_insert(l,p,0);
type = new DataType; type = new DataType;
type->type = T_VOID; type->type = T_VOID;
@ -1934,7 +1937,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
lang->create_function(cname,iname,type,l); lang->create_function(cname,iname,type,l);
delete type; delete type;
delete l; DelParmList(l);
Delete(wrap); Delete(wrap);
} }
@ -2007,7 +2010,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
// Walk down the parameter list and spit out arguments // Walk down the parameter list and spit out arguments
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if (ObjCClass) Printf(fcall," %s", p->objc_separator); if (ObjCClass) Printf(fcall," %s", p->objc_separator);
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
@ -2020,7 +2023,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
} }
} }
i++; i++;
p = l->get_next(); p = ParmList_next(l);
if (p) { if (p) {
Printf(wrap,","); Printf(wrap,",");
if ((CPlusPlus) && (!ObjCClass)) if ((CPlusPlus) && (!ObjCClass))
@ -2039,7 +2042,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
// Walk down the parameter list and spit out arguments // Walk down the parameter list and spit out arguments
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
if (p->call_type & CALL_REFERENCE) { if (p->call_type & CALL_REFERENCE) {
@ -2049,12 +2052,12 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
if (p->call_type & CALL_REFERENCE) { if (p->call_type & CALL_REFERENCE) {
p->t->is_pointer++; p->t->is_pointer++;
} }
p = l->get_next(); p = ParmList_next(l);
if (p) { if (p) {
Printf(wrap,","); Printf(wrap,",");
} }
} else { } else {
p = l->get_next(); p = ParmList_next(l);
} }
} }
Printv(wrap,") ", ccode, "\n", 0); Printv(wrap,") ", ccode, "\n", 0);
@ -2065,10 +2068,10 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
// If we had any C++ references, get rid of them now // If we had any C++ references, get rid of them now
if (!mode) { if (!mode) {
p = l->get_first(); p = ParmList_first(l);
while (p) { while (p) {
// p->t->is_reference = 0; // p->t->is_reference = 0;
p = l->get_next(); p = ParmList_next(l);
} }
} }
@ -2224,8 +2227,8 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
// Wrap this function // Wrap this function
l = new ParmList; l = NewParmList();
p = new Parm(0,0); p = NewParm(0,0);
p->t = new DataType; p->t = new DataType;
p->t->type = T_USER; p->t->type = T_USER;
p->t->is_pointer = 1; p->t->is_pointer = 1;
@ -2233,7 +2236,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
p->call_type = 0; p->call_type = 0;
p->name = (char*)"self"; p->name = (char*)"self";
sprintf(p->t->name,"%s%s", classtype,classname); sprintf(p->t->name,"%s%s", classtype,classname);
l->insert(p,0); ParmList_insert(l,p,0);
if ((type->type == T_USER) && (!type->is_pointer)) { if ((type->type == T_USER) && (!type->is_pointer)) {
type->is_pointer++; type->is_pointer++;
@ -2245,7 +2248,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
lang->create_function(cname,iname, type, l); lang->create_function(cname,iname, type, l);
type->is_reference = is_ref; type->is_reference = is_ref;
} }
delete l; DelParmList(l);
} else { } else {
// Already wrapped this function. Just patch it up // Already wrapped this function. Just patch it up
lang->create_command(prev_wrap,iname); lang->create_command(prev_wrap,iname);
@ -2444,8 +2447,8 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
fprintf(f_wrappers,"%s",Char(wrap)); fprintf(f_wrappers,"%s",Char(wrap));
// Now wrap it. // Now wrap it.
l = new ParmList; l = NewParmList();
p = new Parm(0,0); p = NewParm(0,0);
p->t = new DataType(type); p->t = new DataType(type);
p->t->is_reference = 0; p->t->is_reference = 0;
p->call_type = 0; p->call_type = 0;
@ -2455,8 +2458,8 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
p->name = mrename; p->name = mrename;
else else
p->name = mname; p->name = mname;
l->insert(p,0); ParmList_insert(l,p,0);
p = new Parm(0,0); p = NewParm(0,0);
p->t = new DataType; p->t = new DataType;
p->t->type = T_USER; p->t->type = T_USER;
p->call_type = 0; p->call_type = 0;
@ -2464,7 +2467,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
p->t->id = cpp_id; p->t->id = cpp_id;
sprintf(p->t->name,"%s%s", classtype,classname); sprintf(p->t->name,"%s%s", classtype,classname);
p->name = (char*)"self"; p->name = (char*)"self";
l->insert(p,0); ParmList_insert(l,p,0);
if ((type->type == T_USER) && (!type->is_pointer)) { if ((type->type == T_USER) && (!type->is_pointer)) {
type->is_pointer++; type->is_pointer++;
@ -2476,7 +2479,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
lang->create_function(cname,iname, type, l); lang->create_function(cname,iname, type, l);
type->is_reference = is_ref; type->is_reference = is_ref;
} }
delete l; DelParmList(l);
} else { } else {
lang->create_command(prev_wrap,iname); lang->create_command(prev_wrap,iname);
} }

View file

@ -111,7 +111,7 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
L->print_types(f); ParmList_print_types(L,f);
fprintf(f,");\n"); fprintf(f,");\n");
break; break;
case 1: case 1:
@ -125,7 +125,7 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
fprintf(f,"extern %s", t->print_full()); fprintf(f,"extern %s", t->print_full());
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
L->print_types(f); ParmList_print_types(L,f);
fprintf(f,");\n"); fprintf(f,");\n");
break; break;
case 2: case 2:
@ -139,7 +139,7 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
fprintf(f,"extern \"C\" %s", t->print_full()); fprintf(f,"extern \"C\" %s", t->print_full());
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
L->print_types(f); ParmList_print_types(L,f);
fprintf(f,");\n"); fprintf(f,");\n");
break; break;
case 3: case 3:
@ -153,7 +153,7 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
L->print_args(f); ParmList_print_args(L,f);
fprintf(f,")\n"); fprintf(f,")\n");
break; break;
default: default:
@ -211,7 +211,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
// Emit function arguments // Emit function arguments
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while (p != 0) { while (p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)) { if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
char *temp = emit_local(i); char *temp = emit_local(i);
@ -247,7 +247,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
} }
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
} }
// i now contains number of parameters // i now contains number of parameters
@ -314,7 +314,7 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
Printv(fcall, decl, "(", 0); Printv(fcall, decl, "(", 0);
i = 0; i = 0;
p = l->get_first(); p = ParmList_first(l);
while(p != 0) { while(p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)){ if ((p->t->type != T_VOID) || (p->t->is_pointer)){
Printf(fcall,p->t->print_arraycast()); Printf(fcall,p->t->print_arraycast());
@ -326,7 +326,7 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
Printf(fcall, emit_local(i)); Printf(fcall, emit_local(i));
i++; i++;
} }
p = l->get_next(); p = ParmList_next(l);
if (p != 0) if (p != 0)
Printf(fcall,","); Printf(fcall,",");
} }
@ -456,12 +456,12 @@ void emit_set_get(char *name, char *iname, DataType *t) {
// Now wrap it. // Now wrap it.
l = new ParmList; l = NewParmList();
p = new Parm(t,0); p = NewParm(t,0);
if ((t->type == T_USER) && (!t->is_pointer)) p->t->is_pointer++; if ((t->type == T_USER) && (!t->is_pointer)) p->t->is_pointer++;
p->name = new char[1]; p->name = new char[1];
p->name[0] = 0; p->name[0] = 0;
l->append(p); ParmList_append(l,p);
new_name = copy_string(Swig_name_set(name)); new_name = copy_string(Swig_name_set(name));
new_iname = copy_string(Swig_name_set(iname)); new_iname = copy_string(Swig_name_set(iname));
@ -473,8 +473,8 @@ void emit_set_get(char *name, char *iname, DataType *t) {
} else { } else {
lang->create_function(new_name, new_iname, t, l); lang->create_function(new_name, new_iname, t, l);
} }
delete l; DelParmList(l);
delete p; DelParm(p);
} }
// Now write a function to get the value of the variable // Now write a function to get the value of the variable
@ -495,7 +495,7 @@ void emit_set_get(char *name, char *iname, DataType *t) {
// Wrap this function // Wrap this function
l = new ParmList; l = NewParmList();
if (new_name) delete [] new_name; if (new_name) delete [] new_name;
if (new_iname) delete [] new_iname; if (new_iname) delete [] new_iname;
@ -510,7 +510,7 @@ void emit_set_get(char *name, char *iname, DataType *t) {
} else { } else {
lang->create_function(new_name, new_iname, t, l); lang->create_function(new_name, new_iname, t, l);
} }
delete l; DelParmList(l);
delete [] new_name; delete [] new_name;
delete [] new_iname; delete [] new_iname;
} }

View file

@ -21,243 +21,245 @@ extern "C" {
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Parm::Parm(DataType *type, char *n) // NewParm()
// //
// Create a new parameter from datatype 'type' and name 'n'. // Create a new parameter from datatype 'type' and name 'n'.
// Copies will be made of type and n, unless they aren't specified. // Copies will be made of type and n, unless they aren't specified.
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
Parm::Parm(DataType *type, char *n) { Parm *NewParm(DataType *type, char *n) {
Parm *p = (Parm *) malloc(sizeof(Parm));
if (type) { if (type) {
t = new DataType(type); p->t = new DataType(type);
} else { } else {
t = 0; p->t = 0;
} }
name = copy_string(n); p->name = copy_string(n);
call_type = 0; p->call_type = 0;
defvalue = 0; p->defvalue = 0;
ignore = 0; p->ignore = 0;
objc_separator = 0; p->objc_separator = 0;
return p;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Parm::Parm(Parm *p) // CopyParm(Parm *p)
// //
// Make a copy of a parameter // Make a copy of a parameter
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
Parm::Parm(Parm *p) { Parm *CopyParm(Parm *p) {
if (p->t) t = new DataType(p->t); Parm *np = (Parm *) malloc(sizeof(Parm));
name = copy_string(p->name); if (p->t) np->t = new DataType(p->t);
call_type = p->call_type; np->name = copy_string(p->name);
defvalue = copy_string(p->defvalue); np->call_type = p->call_type;
ignore = p->ignore; np->defvalue = copy_string(p->defvalue);
objc_separator = copy_string(p->objc_separator); np->ignore = p->ignore;
np->objc_separator = copy_string(p->objc_separator);
return np;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Parm::~Parm() // DelParm()
// //
// Destroy a parameter // Destroy a parameter
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
Parm::~Parm() { void DelParm(Parm *p) {
if (t) delete t; if (p->t) delete p->t;
if (name) delete name; if (p->name) delete p->name;
if (defvalue) delete defvalue; if (p->defvalue) delete p->defvalue;
if (objc_separator) delete objc_separator; if (p->objc_separator) delete p->objc_separator;
free(p);
} }
/********************************************************************
class ParmList
These functions are used to manipulate lists of parameters
********************************************************************/
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// ParmList::ParmList() // NewParmList()
// //
// Create a new (empty) parameter list // Create a new (empty) parameter list
// ------------------------------------------------------------------ // ------------------------------------------------------------------
ParmList::ParmList() { ParmList *NewParmList() {
int i;
nparms = 0; ParmList *l = (ParmList *) malloc(sizeof(ParmList));
maxparms = MAXPARMS; l->nparms = 0;
parms = new Parm *[maxparms]; // Create an array of parms l->maxparms = MAXPARMS;
for (int i = 0; i < MAXPARMS; i++) l->parms = (Parm **) malloc(MAXPARMS*sizeof(Parm *));
parms[i] = (Parm *) 0; for (i = 0; i < MAXPARMS; i++) {
l->parms[i] = 0;
}
return l;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// ParmList::ParmList(ParmList *l) // CopyParmList()
// //
// Make a copy of parameter list // Make a copy of parameter list
// ------------------------------------------------------------------ // ------------------------------------------------------------------
ParmList::ParmList(ParmList *l) { ParmList *
CopyParmList(ParmList *l) {
ParmList *nl;
int i; int i;
if (l) { if (l) {
nparms = l->nparms; nl = (ParmList *) malloc(sizeof(ParmList));
maxparms = l->maxparms; nl->nparms = l->nparms;
parms = new Parm *[maxparms]; nl->maxparms = l->maxparms;
nl->parms = (Parm **) malloc(l->maxparms*sizeof(Parm*));
for (i = 0; i < maxparms; i++) { for (i = 0; i < l->maxparms; i++) {
if (l->parms[i]) if (l->parms[i])
parms[i] = new Parm(l->parms[i]); nl->parms[i] = CopyParm(l->parms[i]);
else else
parms[i] = 0; nl->parms[i] = 0;
} }
return nl;
} else { } else {
nparms = 0; return NewParmList();
maxparms = MAXPARMS;
parms = new Parm *[maxparms]; // Create an array of parms
for (i = 0; i < MAXPARMS; i++)
parms[i] = (Parm *) 0;
} }
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// ParmList::~ParmList() // DelParmList()
// //
// Delete a parameter list // Delete a parameter list
// ------------------------------------------------------------------ // ------------------------------------------------------------------
ParmList::~ParmList() { void DelParmList(ParmList *l) {
for (int i = 0; i < maxparms; i++) { int i;
if (parms[i]) delete parms[i]; for (i = 0; i < l->maxparms; i++) {
if (l->parms[i]) DelParm(l->parms[i]);
} }
free(l->parms);
free(l);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// void ParmList::moreparms() (PRIVATE) // moreparms() (PRIVATE)
// //
// Doubles the amount of parameter memory available. // Doubles the amount of parameter memory available.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void ParmList::moreparms() { static void moreparms(ParmList *l) {
Parm **newparms; Parm **newparms;
int i; int i;
newparms = new Parm *[maxparms*2]; newparms = (Parm **) malloc(2*l->maxparms*sizeof(Parm *));
for (i = 0; i < 2*maxparms; i++) for (i = 0; i < 2*l->maxparms; i++)
newparms[i] = (Parm *) 0; newparms[i] = (Parm *) 0;
for (i = 0; i < maxparms; i++) { for (i = 0; i < l->maxparms; i++) {
newparms[i] = parms[i]; newparms[i] = l->parms[i];
} }
maxparms = 2*maxparms; l->maxparms = 2*l->maxparms;
delete parms; free(l->parms);
parms = newparms; l->parms = newparms;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// void ParmList::append(Parm *p) // void ParmList_append(ParmList *l, Parm *p)
// //
// Add a new parameter to the end of a parameter list // Add a new parameter to the end of a parameter list
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void ParmList::append(Parm *p) { void ParmList_append(ParmList *l, Parm *p) {
if (nparms == maxparms) moreparms(); if (l->nparms == l->maxparms) moreparms(l);
// Add parm onto the end // Add parm onto the end
parms[nparms] = new Parm(p); l->parms[l->nparms] = CopyParm(p);
nparms++; l->nparms++;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// void ParmList::insert(Parm *p, int pos) // void ParmList_insert()
// //
// Inserts a parameter at position pos. Parameters are inserted // Inserts a parameter at position pos. Parameters are inserted
// *before* any existing parameter at position pos. // *before* any existing parameter at position pos.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void ParmList::insert(Parm *p, int pos) { void ParmList_insert(ParmList *l, Parm *p, int pos) {
// If pos is out of range, we'd better fix it // If pos is out of range, we'd better fix it
if (pos < 0) pos = 0; if (pos < 0) pos = 0;
if (pos > nparms) pos = nparms; if (pos > l->nparms) pos = l->nparms;
// If insertion is going to need more memory, take care of that now // If insertion is going to need more memory, take care of that now
if (nparms >= maxparms) moreparms(); if (l->nparms >= l->maxparms) moreparms(l);
// Now shift all of the existing parms to the right // Now shift all of the existing parms to the right
for (int i = nparms; i > pos; i--) { for (int i = l->nparms; i > pos; i--) {
parms[i] = parms[i-1]; l->parms[i] = l->parms[i-1];
} }
// Set new parameter // Set new parameter
parms[pos] = new Parm(p); l->parms[pos] = CopyParm(p);
nparms++; l->nparms++;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// void ParmList::del(int pos) // void ParmList_del()
// //
// Deletes the parameter at position pos. // Deletes the parameter at position pos.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void ParmList::del(int pos) { void ParmList_del(ParmList *l, int pos) {
if (nparms <= 0) return; if (l->nparms <= 0) return;
if (pos < 0) pos = 0; if (pos < 0) pos = 0;
if (pos >= nparms) pos = nparms-1; if (pos >= l->nparms) pos = l->nparms-1;
// Delete the parameter (if it exists) // Delete the parameter (if it exists)
if (parms[pos]) delete parms[pos]; if (l->parms[pos]) DelParm(l->parms[pos]);
// Now slide all of the parameters to the left // Now slide all of the parameters to the left
for (int i = pos; i < nparms-1; i++) { for (int i = pos; i < l->nparms-1; i++) {
parms[i] = parms[i+1]; l->parms[i] = l->parms[i+1];
} }
nparms--; l->nparms--;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Parm *ParmList::get(int pos) // Parm *ParmList_get(ParmList *l, int pos)
// //
// Gets the parameter at location pos. Returns 0 if invalid // Gets the parameter at location pos. Returns 0 if invalid
// position. // position.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
Parm *ParmList::get(int pos) { Parm *ParmList_get(ParmList *l, int pos) {
if ((pos < 0) || (pos >= nparms)) return 0; if ((pos < 0) || (pos >= l->nparms)) return 0;
return parms[pos]; return l->parms[pos];
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// int ParmList::numopt() // int ParmList_numopt()
// //
// Gets the number of optional arguments. // Gets the number of optional arguments.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int ParmList::numopt() { int ParmList_numopt(ParmList *l) {
int n = 0; int n = 0;
int state = 0; int state = 0;
for (int i = 0; i < nparms; i++) { for (int i = 0; i < l->nparms; i++) {
if (parms[i]->defvalue) { if (l->parms[i]->defvalue) {
n++; n++;
state = 1; state = 1;
} else if (typemap_check((char*)"default",typemap_lang,parms[i]->t,parms[i]->name)) { } else if (typemap_check((char*)"default",typemap_lang,l->parms[i]->t,l->parms[i]->name)) {
n++; n++;
state = 1; state = 1;
} else if (typemap_check((char*)"ignore",typemap_lang,parms[i]->t,parms[i]->name)) { } else if (typemap_check((char*)"ignore",typemap_lang,l->parms[i]->t,l->parms[i]->name)) {
n++;
} else if (typemap_check((char*)"build",typemap_lang,parms[i]->t,parms[i]->name)) {
n++; n++;
} else { } else {
if (state) { if (state) {
@ -273,58 +275,41 @@ int ParmList::numopt() {
// //
// Gets the number of arguments // Gets the number of arguments
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int ParmList::numarg() { int ParmList_numarg(ParmList *l) {
int n = 0; int n = 0;
for (int i = 0; i < nparms; i++) { for (int i = 0; i < l->nparms; i++) {
if (!parms[i]->ignore) if (!l->parms[i]->ignore)
n++; n++;
} }
return n; return n;
} }
// ------------------------------------------------------------------
// Parm &ParmList::operator[](int n)
//
// Returns parameter n in the parameter list. May generate
// an error if that parameter is out of range.
// ------------------------------------------------------------------
Parm &ParmList::operator[](int n) {
if ((n < 0) || (n >= nparms)) {
fprintf(stderr,"ParmList : Fatal error. subscript out of range in ParmList.operator[]\n");
SWIG_exit(1);
}
return *parms[n];
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Parm * ParmList::get_first() // Parm * ParmList_first()
// //
// Returns the first item on a parameter list. // Returns the first item on a parameter list.
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
Parm *ParmList::get_first() { Parm *ParmList_first(ParmList *l) {
current_parm = 0; l->current_parm = 0;
if (nparms > 0) return parms[current_parm++]; if (l->nparms > 0) return l->parms[l->current_parm++];
else return (Parm *) 0; else return (Parm *) 0;
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Parm *ParmList::get_next() // Parm *ParmList_next()
// //
// Returns the next item on the parameter list. // Returns the next item on the parameter list.
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
Parm * ParmList::get_next() { Parm * ParmList_next(ParmList *l) {
if (current_parm >= nparms) return 0; if (l->current_parm >= l->nparms) return 0;
else return parms[current_parm++]; else return l->parms[l->current_parm++];
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// void ParmList::print_types(DOHFile *f) // void ParmList_print_types(DOHFile *f)
// //
// Prints a comma separated list of all of the parameter types. // Prints a comma separated list of all of the parameter types.
// This is for generating valid C prototypes. Has to do some // This is for generating valid C prototypes. Has to do some
@ -332,63 +317,64 @@ Parm * ParmList::get_next() {
// variable has been set. // variable has been set.
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void ParmList::print_types(DOHFile *f) { void ParmList_print_types(ParmList *l, DOHFile *f) {
int is_pointer; int is_pointer;
int pn; int pn;
pn = 0; pn = 0;
while(pn < nparms) { while(pn < l->nparms) {
is_pointer = parms[pn]->t->is_pointer; is_pointer = l->parms[pn]->t->is_pointer;
if (parms[pn]->t->is_reference) { if (l->parms[pn]->t->is_reference) {
if (parms[pn]->t->is_pointer) { if (l->parms[pn]->t->is_pointer) {
parms[pn]->t->is_pointer--; l->parms[pn]->t->is_pointer--;
Printf(f,"%s&", parms[pn]->t->print_real()); Printf(f,"%s&", l->parms[pn]->t->print_real());
parms[pn]->t->is_pointer++; l->parms[pn]->t->is_pointer++;
} else { } else {
Printf(f,"%s&", parms[pn]->t->print_real()); Printf(f,"%s&", l->parms[pn]->t->print_real());
} }
} else { } else {
if (parms[pn]->call_type & CALL_VALUE) parms[pn]->t->is_pointer++; if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
if (parms[pn]->call_type & CALL_REFERENCE) parms[pn]->t->is_pointer--; if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
Printf(f,"%s", parms[pn]->t->print_real()); Printf(f,"%s", l->parms[pn]->t->print_real());
parms[pn]->t->is_pointer = is_pointer; l->parms[pn]->t->is_pointer = is_pointer;
} }
pn++; pn++;
if (pn < nparms) if (pn < l->nparms)
Printf(f,","); Printf(f,",");
} }
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// void ParmList::print_args(FILE *f) // void ParmList_print_args()
// //
// Prints a comma separated list of all of the parameter arguments. // Prints a comma separated list of all of the parameter arguments.
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void ParmList::print_args(FILE *f) { void ParmList_print_args(ParmList *l, DOHFile *f) {
int is_pointer; int is_pointer;
int pn; int pn;
pn = 0; pn = 0;
while(pn < nparms) { while(pn < l->nparms) {
is_pointer = parms[pn]->t->is_pointer; is_pointer = l->parms[pn]->t->is_pointer;
if (parms[pn]->t->is_reference) { if (l->parms[pn]->t->is_reference) {
if (parms[pn]->t->is_pointer) { if (l->parms[pn]->t->is_pointer) {
parms[pn]->t->is_pointer--; l->parms[pn]->t->is_pointer--;
fprintf(f,"%s&", parms[pn]->t->print_full()); Printf(f,"%s&", l->parms[pn]->t->print_full());
parms[pn]->t->is_pointer++; l->parms[pn]->t->is_pointer++;
} else { } else {
fprintf(f,"%s&", parms[pn]->t->print_full()); Printf(f,"%s&", l->parms[pn]->t->print_full());
} }
} else { } else {
if (parms[pn]->call_type & CALL_VALUE) parms[pn]->t->is_pointer++; if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
if (parms[pn]->call_type & CALL_REFERENCE) parms[pn]->t->is_pointer--; if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
fprintf(f,"%s", parms[pn]->t->print_full()); Printf(f,"%s", l->parms[pn]->t->print_full());
parms[pn]->t->is_pointer = is_pointer; l->parms[pn]->t->is_pointer = is_pointer;
} }
fprintf(f,"%s",parms[pn]->name); Printf(f,"%s",l->parms[pn]->name);
pn++; pn++;
if (pn < nparms) if (pn < l->nparms)
fprintf(f,","); Printf(f,",");
} }
} }

View file

@ -609,7 +609,7 @@ statement : INCLUDE STRING LBRACE {
$2->is_reference = $3.is_reference; $2->is_reference = $3.is_reference;
create_function($1, $3.id, $2, $5); create_function($1, $3.id, $2, $5);
delete $2; delete $2;
delete $5; DelParmList($5);
} stail { } } stail { }
/* A function declaration with code after it */ /* A function declaration with code after it */
@ -620,7 +620,7 @@ statement : INCLUDE STRING LBRACE {
$2->is_reference = $3.is_reference; $2->is_reference = $3.is_reference;
create_function($1, $3.id, $2, $5); create_function($1, $3.id, $2, $5);
delete $2; delete $2;
delete $5; DelParmList($5);
}; };
/* A function declared without any return datatype */ /* A function declared without any return datatype */
@ -646,7 +646,7 @@ statement : INCLUDE STRING LBRACE {
} }
} }
delete $2; delete $2;
delete $5; DelParmList($5);
}; };
/* A function with an explicit inline directive. Not safe to use inside a %inline block */ /* A function with an explicit inline directive. Not safe to use inside a %inline block */
@ -667,7 +667,7 @@ statement : INCLUDE STRING LBRACE {
create_function(0, $3.id, $2, $5); create_function(0, $3.id, $2, $5);
} }
delete $2; delete $2;
delete $5; DelParmList($5);
}; };
/* A static function declaration (ignored) */ /* A static function declaration (ignored) */
@ -675,7 +675,7 @@ statement : INCLUDE STRING LBRACE {
| STATIC type declaration LPAREN parms RPAREN cpp_const { | STATIC type declaration LPAREN parms RPAREN cpp_const {
Active_static = 1; Active_static = 1;
delete $2; delete $2;
delete $5; DelParmList($5);
} stail { } stail {
Active_static = 0; Active_static = 0;
} }
@ -750,7 +750,7 @@ statement : INCLUDE STRING LBRACE {
} }
} }
delete $6; delete $6;
delete $9; DelParmList($9);
} }
/* %title directive */ /* %title directive */
@ -1002,7 +1002,7 @@ statement : INCLUDE STRING LBRACE {
} }
delete $3; delete $3;
delete $5; delete $5;
delete $9->p; DelParm($9->p);
delete $9; delete $9;
} }
@ -1022,7 +1022,7 @@ statement : INCLUDE STRING LBRACE {
} }
} }
delete $3; delete $3;
delete $7->p; DelParm($7->p);
delete $7; delete $7;
} }
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
@ -1037,7 +1037,7 @@ statement : INCLUDE STRING LBRACE {
p = p->next; p = p->next;
} }
delete $4; delete $4;
delete $2->args; DelParmList($2->args);
delete $2; delete $2;
} }
| CLEAR tm_list SEMI { | CLEAR tm_list SEMI {
@ -1165,7 +1165,7 @@ typedef_decl : TYPEDEF type declaration {
cplus_register_type($5); cplus_register_type($5);
delete $2; delete $2;
delete $5; delete $5;
delete $8; DelParmList($8);
} }
/* A typedef involving function pointers again */ /* A typedef involving function pointers again */
@ -1187,7 +1187,7 @@ typedef_decl : TYPEDEF type declaration {
cplus_register_type($6); cplus_register_type($6);
delete $2; delete $2;
delete $6; delete $6;
delete $9; DelParmList($9);
} }
/* A typedef involving arrays */ /* A typedef involving arrays */
@ -1296,7 +1296,7 @@ stail : SEMI { }
temp_typeptr->is_reference = $2.is_reference; temp_typeptr->is_reference = $2.is_reference;
create_function(Active_extern, $2.id, temp_typeptr, $4); create_function(Active_extern, $2.id, temp_typeptr, $4);
delete temp_typeptr; delete temp_typeptr;
delete $4; DelParmList($4);
} stail { } } stail { }
; ;
@ -1325,19 +1325,19 @@ func_end : cpp_const LBRACE { skip_brace(); }
parms : parm ptail { parms : parm ptail {
if (($1->t->type != T_VOID) || ($1->t->is_pointer)) if (($1->t->type != T_VOID) || ($1->t->is_pointer))
$2->insert($1,0); ParmList_insert($2,$1,0);
$$ = $2; $$ = $2;
delete $1; DelParm($1);
} }
| empty { $$ = new ParmList;} | empty { $$ = NewParmList(); }
; ;
ptail : COMMA parm ptail { ptail : COMMA parm ptail {
$3->insert($2,0); ParmList_insert($3,$2,0);
$$ = $3; $$ = $3;
delete $2; DelParm($2);
} }
| empty { $$ = new ParmList;} | empty { $$ = NewParmList(); }
; ;
parm : parm_type { parm : parm_type {
@ -1366,7 +1366,7 @@ parm_type : type pname {
// Add array string to the type // Add array string to the type
$1->arraystr = copy_string(Char(ArrayString)); $1->arraystr = copy_string(Char(ArrayString));
} }
$$ = new Parm($1,$2); $$ = NewParm($1,$2);
$$->call_type = 0; $$->call_type = 0;
$$->defvalue = DefArg; $$->defvalue = DefArg;
if (($1->type == T_USER) && !($1->is_pointer)) { if (($1->type == T_USER) && !($1->is_pointer)) {
@ -1378,7 +1378,7 @@ parm_type : type pname {
} }
| type stars pname { | type stars pname {
$$ = new Parm($1,$3); $$ = NewParm($1,$3);
$$->t->is_pointer += $2; $$->t->is_pointer += $2;
$$->call_type = 0; $$->call_type = 0;
$$->defvalue = DefArg; $$->defvalue = DefArg;
@ -1392,7 +1392,7 @@ parm_type : type pname {
} }
| type AND pname { | type AND pname {
$$ = new Parm($1,$3); $$ = NewParm($1,$3);
$$->t->is_reference = 1; $$->t->is_reference = 1;
$$->call_type = 0; $$->call_type = 0;
$$->t->is_pointer++; $$->t->is_pointer++;
@ -1406,17 +1406,17 @@ parm_type : type pname {
| type LPAREN stars pname RPAREN LPAREN parms RPAREN { | type LPAREN stars pname RPAREN LPAREN parms RPAREN {
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number); fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
FatalError(); FatalError();
$$ = new Parm($1,$4); $$ = NewParm($1,$4);
$$->t->type = T_ERROR; $$->t->type = T_ERROR;
$$->name = copy_string($4); $$->name = copy_string($4);
strcpy($$->t->name,"<function ptr>"); strcpy($$->t->name,"<function ptr>");
delete $1; delete $1;
delete $4; delete $4;
delete $7; DelParmList($7);
} }
| PERIOD PERIOD PERIOD { | PERIOD PERIOD PERIOD {
fprintf(stderr,"%s : Line %d. Variable length arguments not supported (ignored).\n", input_file, line_number); fprintf(stderr,"%s : Line %d. Variable length arguments not supported (ignored).\n", input_file, line_number);
$$ = new Parm(new DataType(T_INT),(char *) "varargs"); $$ = NewParm(new DataType(T_INT),(char *) "varargs");
$$->t->type = T_ERROR; $$->t->type = T_ERROR;
$$->name = copy_string((char*)"varargs"); $$->name = copy_string((char*)"varargs");
strcpy($$->t->name,"<varargs>"); strcpy($$->t->name,"<varargs>");
@ -2207,7 +2207,7 @@ cpp_other :/* A dummy class name */
} }
create_function($1, temp_name, $2, $7); create_function($1, temp_name, $2, $7);
delete $2; delete $2;
delete $7; DelParmList($7);
} }
/* A static C++ member data */ /* A static C++ member data */
@ -2293,7 +2293,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
} }
scanner_clear_start(); scanner_clear_start();
delete $1; delete $1;
delete $4; DelParmList($4);
} }
/* Virtual member function */ /* Virtual member function */
@ -2310,7 +2310,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
} }
scanner_clear_start(); scanner_clear_start();
delete $2; delete $2;
delete $5; DelParmList($5);
} }
/* Possibly a constructor */ /* Possibly a constructor */
@ -2323,7 +2323,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
cplus_constructor($1,iname, $3); cplus_constructor($1,iname, $3);
} }
scanner_clear_start(); scanner_clear_start();
delete $3; DelParmList($3);
} }
/* A destructor (hopefully) */ /* A destructor (hopefully) */
@ -2337,6 +2337,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
cplus_destructor($2,iname); cplus_destructor($2,iname);
} }
scanner_clear_start(); scanner_clear_start();
DelParmList($4);
} }
/* A virtual destructor */ /* A virtual destructor */
@ -2455,7 +2456,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
} }
scanner_clear_start(); scanner_clear_start();
delete $2; delete $2;
delete $5; DelParmList($5);
} }
/* Turn on public: mode */ /* Turn on public: mode */
@ -2828,7 +2829,7 @@ cpptype : CLASS { $$ = (char*)"class"; }
; ;
cpp_const : CONST {} cpp_const : CONST {}
| THROW LPAREN parms RPAREN { delete $3;} | THROW LPAREN parms RPAREN { DelParmList($3);}
| empty {} | empty {}
; ;
@ -3094,7 +3095,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
scanner_clear_start(); scanner_clear_start();
delete $2; delete $2;
delete $3; delete $3;
delete $4; DelParmList($4);
} }
} }
| PLUS objc_ret_type ID objc_args objc_end { | PLUS objc_ret_type ID objc_args objc_end {
@ -3112,7 +3113,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
scanner_clear_start(); scanner_clear_start();
delete $2; delete $2;
delete $3; delete $3;
delete $4; DelParmList($4);
} }
; ;
@ -3137,7 +3138,7 @@ objc_ret_type : LPAREN type RPAREN {
objc_arg_type : LPAREN parm RPAREN { objc_arg_type : LPAREN parm RPAREN {
$$ = new DataType($2->t); $$ = new DataType($2->t);
delete $2; DelParm($2);
} }
| empty { | empty {
$$ = new DataType(T_VOID); $$ = new DataType(T_VOID);
@ -3148,13 +3149,13 @@ objc_arg_type : LPAREN parm RPAREN {
; ;
objc_args : objc_args objc_separator objc_arg_type ID { objc_args : objc_args objc_separator objc_arg_type ID {
Parm *p= new Parm($3,$4); Parm *p= NewParm($3,$4);
p->objc_separator = $2; p->objc_separator = $2;
$$ = $1; $$ = $1;
$$->append(p); ParmList_append($$,p);
} }
| empty { | empty {
$$ = new ParmList; $$ = NewParmList();
} }
; ;
@ -3237,7 +3238,7 @@ typemap_parm : type typemap_name {
$1->arraystr = copy_string(Char(ArrayString)); $1->arraystr = copy_string(Char(ArrayString));
} }
$$ = new TMParm; $$ = new TMParm;
$$->p = new Parm($1,$2); $$->p = NewParm($1,$2);
$$->p->call_type = 0; $$->p->call_type = 0;
$$->args = tm_parm; $$->args = tm_parm;
delete $1; delete $1;
@ -3246,7 +3247,7 @@ typemap_parm : type typemap_name {
| type stars typemap_name { | type stars typemap_name {
$$ = new TMParm; $$ = new TMParm;
$$->p = new Parm($1,$3); $$->p = NewParm($1,$3);
$$->p->t->is_pointer += $2; $$->p->t->is_pointer += $2;
$$->p->call_type = 0; $$->p->call_type = 0;
if (InArray) { if (InArray) {
@ -3260,7 +3261,7 @@ typemap_parm : type typemap_name {
| type AND typemap_name { | type AND typemap_name {
$$ = new TMParm; $$ = new TMParm;
$$->p = new Parm($1,$3); $$->p = NewParm($1,$3);
$$->p->t->is_reference = 1; $$->p->t->is_reference = 1;
$$->p->call_type = 0; $$->p->call_type = 0;
$$->p->t->is_pointer++; $$->p->t->is_pointer++;
@ -3275,14 +3276,14 @@ typemap_parm : type typemap_name {
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number); fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
FatalError(); FatalError();
$$ = new TMParm; $$ = new TMParm;
$$->p = new Parm($1,$4); $$->p = NewParm($1,$4);
$$->p->t->type = T_ERROR; $$->p->t->type = T_ERROR;
$$->p->name = copy_string($4); $$->p->name = copy_string($4);
strcpy($$->p->t->name,"<function ptr>"); strcpy($$->p->t->name,"<function ptr>");
$$->args = tm_parm; $$->args = tm_parm;
delete $1; delete $1;
delete $4; delete $4;
delete $7; DelParmList($7);
} }
; ;

View file

@ -58,6 +58,7 @@ extern int error_count;
extern char *copy_string(char *); extern char *copy_string(char *);
extern char output_dir[512]; // Output directory extern char output_dir[512]; // Output directory
extern int Verbose; extern int Verbose;
extern int IsVirtual;
#define FatalError() if ((error_count++) > 20) { fprintf(stderr,"Confused by earlier errors. Bailing out\n"); SWIG_exit(1); } #define FatalError() if ((error_count++) > 20) { fprintf(stderr,"Confused by earlier errors. Bailing out\n"); SWIG_exit(1); }
@ -168,17 +169,25 @@ static void record_base(char *derived, char *base);
#define CALL_REFERENCE 0x02 #define CALL_REFERENCE 0x02
#define CALL_OUTPUT 0x04 #define CALL_OUTPUT 0x04
struct Parm { typedef class Parm {
public:
DataType *t; // Datatype of this parameter DataType *t; // Datatype of this parameter
int call_type; // Call type (value or reference or value) int call_type; // Call type (value or reference or value)
char *name; // Name of parameter (optional) char *name; // Name of parameter (optional)
char *defvalue; // Default value (as a string) char *defvalue; // Default value (as a string)
int ignore; // Ignore flag int ignore; // Ignore flag
char *objc_separator; // Parameter separator for Objective-C char *objc_separator; // Parameter separator for Objective-C
Parm(DataType *type, char *n);
Parm(Parm *p); private:
~Parm(); // Note: This should uncover and remaining uses of these functions
}; Parm(DataType *type, char *n) { abort(); }
Parm(Parm *p) { abort(); }
~Parm() {abort();}
} Parm;
extern Parm *NewParm(DataType *type, char *n);
extern Parm *CopyParm(Parm *p);
extern void DelParm(Parm *p);
// ------------------------------------------------------------- // -------------------------------------------------------------
// class ParmList // class ParmList
@ -189,33 +198,32 @@ struct Parm {
#define MAXPARMS 16 #define MAXPARMS 16
class ParmList { typedef class ParmList {
private: public:
int maxparms; // Max parms possible in current list int maxparms; // Max parms possible in current list
Parm **parms; // Pointer to parms array Parm **parms; // Pointer to parms array
void moreparms(); // Increase number of stored parms int current_parm; // Internal state for get_first,get_next
int current_parm; // Internal state for get_first,get_next int nparms; // Number of parms in list
public: private:
int nparms; // Number of parms in list // Note: This is here to force any use of these to fail miserably.
void append(Parm *p); // Append a parameter to the end ParmList() { abort(); }
void insert(Parm *p, int pos); // Insert a parameter into the list ParmList(ParmList *l) { abort(); }
void del(int pos); // Delete a parameter at position pos ~ParmList() { abort(); }
int numopt(); // Get number of optional arguments } ParmList;
int numarg(); // Get number of active arguments
Parm *get(int pos); // Get the parameter at position pos
Parm &operator[](int); // An alias for get().
ParmList();
ParmList(ParmList *l);
~ParmList();
// Keep this for backwards compatibility extern ParmList *NewParmList();
extern ParmList *CopyParmList(ParmList *);
Parm *get_first(); // Get first parameter from list extern void DelParmList(ParmList *);
Parm *get_next(); // Get next parameter from list extern Parm *ParmList_get(ParmList *l, int pos);
extern void ParmList_append(ParmList *, Parm *);
void print_types(void *f); // Print list of datatypes extern void ParmList_insert(ParmList *, Parm *, int);
void print_args(FILE *f); // Print argument list extern void ParmList_del(ParmList *, int);
}; extern int ParmList_numopt(ParmList *);
extern int ParmList_numarg(ParmList *);
extern Parm *ParmList_first(ParmList *);
extern Parm *ParmList_next(ParmList *);
extern void ParmList_print_types(ParmList*,DOHFile *f);
extern void ParmList_print_args(ParmList *, DOHFile *f);
// Modes for different types of inheritance // Modes for different types of inheritance

View file

@ -84,7 +84,7 @@ struct TypeMap {
next = 0; next = 0;
previous = 0; previous = 0;
if (p) { if (p) {
args = new ParmList(p); args = CopyParmList(p);
} else { } else {
args = 0; args = 0;
} }
@ -108,7 +108,7 @@ struct TypeMap {
next = 0; next = 0;
previous = t->previous; previous = t->previous;
if (args) { if (args) {
args = new ParmList(args); args = CopyParmList(args);
} else { } else {
args = 0; args = 0;
} }
@ -308,7 +308,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
if (args) { if (args) {
Parm *p; Parm *p;
p = tm->args->get_first(); p = ParmList_first(tm->args);
while (p) { while (p) {
if (p->name) { if (p->name) {
// printf(" %s %s\n", p->t->print_type(),p->name); // printf(" %s %s\n", p->t->print_type(),p->name);
@ -321,7 +321,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
p->t->is_pointer--; p->t->is_pointer--;
p->call_type = 0; p->call_type = 0;
} }
p = tm->args->get_next(); p = ParmList_next(tm->args);
} }
} }
} }
@ -482,7 +482,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
Parm *p; Parm *p;
char *new_name; char *new_name;
p = l->get_first(); p = ParmList_first(l);
while (p) { while (p) {
if (p->name) { if (p->name) {
if (strlen(p->name) > 0) { if (strlen(p->name) > 0) {
@ -528,7 +528,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
Replace(s,p->name,new_name,DOH_REPLACE_ID); Replace(s,p->name,new_name,DOH_REPLACE_ID);
} }
} }
p = l->get_next(); p = ParmList_next(l);
} }
// If the original datatype was an array. We're going to go through and substitute // If the original datatype was an array. We're going to go through and substitute
// it's array dimensions // it's array dimensions