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 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)
continue;
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;
int j = 0;
for (i = 0; i < pcount; ++i) {
Parm &p = (*l)[i];
Parm *p = ParmList_get(l,i);
// Produce names of source and target
sprintf(source,"s_%d",i);
sprintf(target,"_arg%d",i);
sprintf(argnum,"%d",i);
strcpy(arg,p.name);
strcpy(arg,p->name);
// Handle parameter types.
if (p.ignore)
Printv(f->code, "/* ", p.name, " ignored... */\n", 0);
if (p->ignore)
Printv(f->code, "/* ", p->name, " ignored... */\n", 0);
else {
++numargs;
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);
mreplace (f->code, argnum, arg, proc_name);
}
else if (p.t->is_pointer)
get_pointer (iname, i, p.t, f, proc_name, numargs);
else if (p->t->is_pointer)
get_pointer (iname, i, p->t, f, proc_name, numargs);
else {
throw_unhandled_guile_type_error (p.t);
throw_unhandled_guile_type_error (p->t);
}
++j;
}
@ -487,7 +487,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Check if there are any constraints.
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);
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.
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);
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.
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);
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
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)
continue;
@ -853,7 +853,7 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
// 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"))
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
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_length = 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;
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
if(p->name && *(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;
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
if(p->name && *(p->name))
strcpy(arg,p->name);
@ -1203,7 +1203,7 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
have_default_constructor = 1;
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
if(p->name && *(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;
for (i = 0; i < pcount; ++i) {
Parm &p = (*l)[i];
Parm *p = ParmList_get(l,i);
// Produce names of source and target
sprintf(source,"argv[%d]",i);
sprintf(target,"_arg%d",i);
sprintf(argnum,"%d",i);
strcpy(arg,p.name);
strcpy(arg,p->name);
// Handle parameter types.
if (p.ignore)
Printv(f->code, "/* ", p.name, " ignored... */\n", 0);
if (p->ignore)
Printv(f->code, "/* ", p->name, " ignored... */\n", 0);
else {
++numargs;
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);
mreplace (f->code, argnum, arg, proc_name);
}
// no typemap found
// assume it's a Scheme_Object containing the C pointer
else if (p.t->is_pointer) {
get_pointer (proc_name, i, p.t, f);
else if (p->t->is_pointer) {
get_pointer (proc_name, i, p->t, f);
}
// 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.
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
Printv(f->code,tm,"\n", 0);
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.
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
Printv(outarg, tm, "\n", 0);
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.
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
Printv(cleanup, tm, "\n", 0);
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
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)
continue;
@ -749,7 +749,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
// 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"))
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);
pcount = emit_args(d, l, f);
numopt = l->numopt();
numopt = ParmList_numopt(l);
Wrapper_add_local(f,"argvi","int argvi = 0");
// Check the number of arguments
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);
// Write code to extract parameters.
@ -780,7 +780,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 0;
j = 0;
p = l->get_first();
p = ParmList_first(l);
while (p != 0) {
// Produce string representation of source and target arguments
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);
num_saved++;
}
p = l->get_next();
p = ParmList_next(l);
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
// need to extract them from a tied-hash table object.
Parm *p = l->get_first();
Parm *p = ParmList_first(l);
int i = 0;
while(p) {
@ -1073,7 +1073,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
}
i++;
}
p = l->get_next();
p = ParmList_next(l);
}
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 */
p = l->get_first();
p = ParmList_first(l);
i = 0;
while (p != 0) {
if (!p->ignore) {
@ -1543,12 +1543,12 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
}
}
i++;
p = l->get_next();
p = ParmList_next(l);
if (p)
if (!p->ignore)
Putc(',',temp);
} else {
p = l->get_next();
p = ParmList_next(l);
if (p)
if ((i>0) && (!p->ignore))
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
// need to extract them from a tied-hash table object.
p = l->get_first();
p = ParmList_first(l);
pcount = l->nparms;
numopt = l->numopt();
numopt = ParmList_numopt(l);
i = 1;
while(p) {
if (!p->ignore) {
@ -1910,7 +1910,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
}
i++;
}
p = l->get_next();
p = ParmList_next(l);
}
// 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
// need to extract them from a tied-hash table object.
p = l->get_first();
p = ParmList_first(l);
i = 0;
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
Printf(pcode, " $args[%d] = tied(%%{$args[%d]});\n", i, i);
}
p = l->get_next();
p = ParmList_next(l);
i++;
}

View file

@ -680,9 +680,9 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
i = 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;
p = l->get_first();
p = ParmList_first(l);
Printf(kwargs,"{ ");
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);
have_output++;
}
p = l->get_next();
p = ParmList_next(l);
i++;
}
@ -1411,7 +1411,7 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
// You probably don't need to change this
i = 0;
p = l->get_first();
p = ParmList_first(l);
while (p != 0) {
if (!p->ignore) {
i++;
@ -1424,13 +1424,13 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
Printf(temp,"%s", p->t->print_type());
}
}
p = l->get_next();
p = ParmList_next(l);
if (p != 0) {
if (!p->ignore)
Putc(',',temp);
}
} else {
p = l->get_next();
p = ParmList_next(l);
if (p) {
if ((!p->ignore) && (i > 0))
Putc(',',temp);

View file

@ -426,8 +426,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
}
// Get number of arguments
int numarg = l->numarg();
int numopt = l->numopt();
int numarg = ParmList_numarg(l);
int numopt = ParmList_numopt(l);
int numignore = l->nparms - numarg;
int start = 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 numoptreal = 0;
for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) {
if (!ParmList_get(l,i)->ignore) {
if (i >= l->nparms - numopt) numoptreal++;
else numreq++;
}
@ -457,7 +457,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
} else {
Printv(f->def, "VALUE self", 0);
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);
}
}
@ -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.
if (vararg) {
for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) {
if (!ParmList_get(l,i)->ignore) {
char s[256];
sprintf(s,"varg%d",i);
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) {
Printf(f->code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
for (i = start; i < l->nparms; i++) {
if (!l->get(i)->ignore) {
if (!ParmList_get(l,i)->ignore) {
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
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
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);
if (!p.ignore) {
if (!p->ignore) {
char *tab = (char*)tab4;
if (j >= (pcount-numopt)) { // Check if parsing an optional argument
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
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) {
DOHString *s = NewString(tm);
indent(s,tab);
@ -537,7 +537,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
Delete(s);
} else {
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))
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
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) {
DOHString *s = NewString(tm);
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)
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) {
DOHString *s = NewString(tm);
indent(s);
@ -564,7 +564,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
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) {
DOHString *s = NewString(tm);
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.
pcount = emit_args(d, l, f);
numopt = l->numopt();
numopt = ParmList_numopt(l);
// 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;
j = 0;
p = l->get_first();
p = ParmList_first(l);
while (p != 0) {
// Produce string representations of the source and target arguments
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);
}
i++;
p = l->get_next(); // Get next parameter and continue
p = ParmList_next(l); // Get next parameter and continue
}
Printf(argstr,":%s\"",usage);
Printv(f->code,
@ -1139,8 +1139,8 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
/* Now go through and print parameters */
i = 0;
pcount = l->nparms;
numopt = l->numopt();
p = l->get_first();
numopt = ParmList_numopt(l);
p = ParmList_first(l);
while (p != 0) {
// Only print an argument if not ignored
@ -1164,7 +1164,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
Putc(' ',temp);
i++;
}
p = l->get_next();
p = ParmList_next(l);
}
return Char(temp);
}