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:
parent
dadb37699f
commit
4756fefcef
13 changed files with 364 additions and 366 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 DOHHash *localtypes = 0; // Localtype hash
|
||||
static int abstract =0; // Status bit set during code generation
|
||||
int IsVirtual = 0;
|
||||
|
||||
static int cpp_id = 0;
|
||||
|
||||
|
|
@ -152,7 +153,7 @@ static void update_local_type(DataType *type) {
|
|||
|
||||
static void update_parms(ParmList *l) {
|
||||
Parm *p;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p) {
|
||||
update_local_type(p->t);
|
||||
|
||||
|
|
@ -166,7 +167,7 @@ static void update_parms(ParmList *l) {
|
|||
p->defvalue = copy_string(s);
|
||||
}
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +211,7 @@ public:
|
|||
name = copy_string(n);
|
||||
iname = copy_string(i);
|
||||
ret_type = new DataType(t);
|
||||
parms = new ParmList(l);
|
||||
parms = CopyParmList(l);
|
||||
is_static = s;
|
||||
is_virtual = v;
|
||||
new_method = AddMethods;
|
||||
|
|
@ -260,10 +261,11 @@ public:
|
|||
line_number = line; // Restore line and file
|
||||
input_file = file;
|
||||
ccode = code;
|
||||
IsVirtual = is_virtual;
|
||||
|
||||
// Make a copy of the parameter list and upgrade its types
|
||||
|
||||
l = new ParmList(parms);
|
||||
l = CopyParmList(parms);
|
||||
t = new DataType(ret_type);
|
||||
update_parms(l);
|
||||
update_local_type(t);
|
||||
|
|
@ -272,8 +274,9 @@ public:
|
|||
} else {
|
||||
lang->cpp_member_func(name, iname, t, l);
|
||||
}
|
||||
delete l;
|
||||
DelParmList(l);
|
||||
delete t;
|
||||
IsVirtual = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -289,7 +292,7 @@ public:
|
|||
CPP_constructor(char *n, char *i, ParmList *l) {
|
||||
name = copy_string(n);
|
||||
iname = copy_string(i);
|
||||
parms = new ParmList(l);
|
||||
parms = CopyParmList(l);
|
||||
new_method = AddMethods;
|
||||
inherited = 0;
|
||||
next = 0;
|
||||
|
|
@ -315,10 +318,10 @@ public:
|
|||
|
||||
// Make a copy of the parameter list and upgrade its types
|
||||
|
||||
l = new ParmList(parms);
|
||||
l = CopyParmList(parms);
|
||||
update_parms(l);
|
||||
lang->cpp_constructor(name,iname,l);
|
||||
delete l;
|
||||
DelParmList(l);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -638,7 +641,7 @@ public:
|
|||
AddMethods = 0;
|
||||
if ((!have_constructor) && (1)) {
|
||||
ParmList *l;
|
||||
l = new ParmList();
|
||||
l = NewParmList();
|
||||
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.
|
||||
|
||||
Printf(key,"%s+",cname);
|
||||
l->print_types(key);
|
||||
ParmList_print_types(l,key);
|
||||
char *temp = copy_string(iname);
|
||||
if (!member_hash) member_hash = NewHash();
|
||||
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
|
||||
|
||||
i = 0;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
Printf(wrap,",_swigarg%d",i);
|
||||
i++;
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
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
|
||||
}
|
||||
i = 0;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while(p != 0) {
|
||||
if (ObjCClass) Printf(wrap," %s", p->objc_separator);
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
Printf(wrap,"_swigarg%d",i);
|
||||
i++;
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
if ((p != 0) && (!ObjCClass))
|
||||
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
|
||||
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
Printf(wrap,",");
|
||||
|
|
@ -1606,7 +1609,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
}
|
||||
Printf(wrap," %s", p->name);
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
Printf(wrap,") %s", ccode);
|
||||
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
|
||||
// a language specific function to add it.
|
||||
|
||||
newparms = new ParmList(l);
|
||||
p = new Parm(0,0);
|
||||
newparms = CopyParmList(l);
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t->type = T_USER;
|
||||
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);
|
||||
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
|
||||
|
||||
lang->create_function(cname, iname, type, newparms);
|
||||
delete newparms;
|
||||
DelParmList(newparms);
|
||||
} else {
|
||||
// Already wrapped this function. Just patch it up
|
||||
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
|
||||
|
||||
Printf(key,"%s+",cname);
|
||||
l->print_types(key);
|
||||
ParmList_print_types(l,key);
|
||||
char *temp = copy_string(iname);
|
||||
if (!member_hash) member_hash = NewHash();
|
||||
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);
|
||||
|
||||
// Walk down the parameter list and Spit out arguments
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (p->t->is_reference) {
|
||||
|
|
@ -1773,7 +1776,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
}
|
||||
Printf(wrap," %s", p->name);
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
if (p) 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
|
||||
i = 0;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while(p != 0) {
|
||||
Printf(wrap," %s", p->objc_separator);
|
||||
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);
|
||||
i++;
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
Printf(wrap,"];\n");
|
||||
|
||||
|
|
@ -1912,8 +1915,8 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
// Make a parameter list for this function
|
||||
|
||||
l = new ParmList;
|
||||
p = new Parm(0,0);
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
|
|
@ -1921,7 +1924,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
p->call_type = 0;
|
||||
sprintf(p->t->name,"%s%s", classtype, classname);
|
||||
p->name = (char*)"self";
|
||||
l->insert(p,0);
|
||||
ParmList_insert(l,p,0);
|
||||
|
||||
type = new DataType;
|
||||
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);
|
||||
|
||||
delete type;
|
||||
delete l;
|
||||
DelParmList(l);
|
||||
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
|
||||
|
||||
i = 0;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if (ObjCClass) Printf(fcall," %s", p->objc_separator);
|
||||
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++;
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
if (p) {
|
||||
Printf(wrap,",");
|
||||
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
|
||||
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
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) {
|
||||
p->t->is_pointer++;
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
if (p) {
|
||||
Printf(wrap,",");
|
||||
}
|
||||
} else {
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
}
|
||||
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 (!mode) {
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p) {
|
||||
// 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
|
||||
|
||||
l = new ParmList;
|
||||
p = new Parm(0,0);
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t->type = T_USER;
|
||||
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->name = (char*)"self";
|
||||
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)) {
|
||||
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);
|
||||
type->is_reference = is_ref;
|
||||
}
|
||||
delete l;
|
||||
DelParmList(l);
|
||||
} else {
|
||||
// Already wrapped this function. Just patch it up
|
||||
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));
|
||||
// Now wrap it.
|
||||
|
||||
l = new ParmList;
|
||||
p = new Parm(0,0);
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType(type);
|
||||
p->t->is_reference = 0;
|
||||
p->call_type = 0;
|
||||
|
|
@ -2455,8 +2458,8 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
p->name = mrename;
|
||||
else
|
||||
p->name = mname;
|
||||
l->insert(p,0);
|
||||
p = new Parm(0,0);
|
||||
ParmList_insert(l,p,0);
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t->type = T_USER;
|
||||
p->call_type = 0;
|
||||
|
|
@ -2464,7 +2467,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
p->t->id = cpp_id;
|
||||
sprintf(p->t->name,"%s%s", classtype,classname);
|
||||
p->name = (char*)"self";
|
||||
l->insert(p,0);
|
||||
ParmList_insert(l,p,0);
|
||||
|
||||
if ((type->type == T_USER) && (!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);
|
||||
type->is_reference = is_ref;
|
||||
}
|
||||
delete l;
|
||||
DelParmList(l);
|
||||
} else {
|
||||
lang->create_command(prev_wrap,iname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
|
|||
}
|
||||
|
||||
fprintf(f,"%s(", decl);
|
||||
L->print_types(f);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
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,"%s(", decl);
|
||||
L->print_types(f);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
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,"%s(", decl);
|
||||
L->print_types(f);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 3:
|
||||
|
|
@ -153,7 +153,7 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
|
|||
}
|
||||
|
||||
fprintf(f,"%s(", decl);
|
||||
L->print_args(f);
|
||||
ParmList_print_args(L,f);
|
||||
fprintf(f,")\n");
|
||||
break;
|
||||
default:
|
||||
|
|
@ -211,7 +211,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
// Emit function arguments
|
||||
|
||||
i = 0;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
char *temp = emit_local(i);
|
||||
|
|
@ -247,7 +247,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
}
|
||||
i++;
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
i = 0;
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while(p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)){
|
||||
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));
|
||||
i++;
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
if (p != 0)
|
||||
Printf(fcall,",");
|
||||
}
|
||||
|
|
@ -456,12 +456,12 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
|
||||
// Now wrap it.
|
||||
|
||||
l = new ParmList;
|
||||
p = new Parm(t,0);
|
||||
l = NewParmList();
|
||||
p = NewParm(t,0);
|
||||
if ((t->type == T_USER) && (!t->is_pointer)) p->t->is_pointer++;
|
||||
p->name = new char[1];
|
||||
p->name[0] = 0;
|
||||
l->append(p);
|
||||
ParmList_append(l,p);
|
||||
|
||||
new_name = copy_string(Swig_name_set(name));
|
||||
new_iname = copy_string(Swig_name_set(iname));
|
||||
|
|
@ -473,8 +473,8 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
} else {
|
||||
lang->create_function(new_name, new_iname, t, l);
|
||||
}
|
||||
delete l;
|
||||
delete p;
|
||||
DelParmList(l);
|
||||
DelParm(p);
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
l = new ParmList;
|
||||
l = NewParmList();
|
||||
|
||||
if (new_name) delete [] new_name;
|
||||
if (new_iname) delete [] new_iname;
|
||||
|
|
@ -510,7 +510,7 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
} else {
|
||||
lang->create_function(new_name, new_iname, t, l);
|
||||
}
|
||||
delete l;
|
||||
DelParmList(l);
|
||||
delete [] new_name;
|
||||
delete [] new_iname;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,243 +21,245 @@ extern "C" {
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parm::Parm(DataType *type, char *n)
|
||||
// NewParm()
|
||||
//
|
||||
// Create a new parameter from datatype 'type' and name 'n'.
|
||||
// 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) {
|
||||
t = new DataType(type);
|
||||
p->t = new DataType(type);
|
||||
} else {
|
||||
t = 0;
|
||||
p->t = 0;
|
||||
}
|
||||
name = copy_string(n);
|
||||
call_type = 0;
|
||||
defvalue = 0;
|
||||
ignore = 0;
|
||||
objc_separator = 0;
|
||||
p->name = copy_string(n);
|
||||
p->call_type = 0;
|
||||
p->defvalue = 0;
|
||||
p->ignore = 0;
|
||||
p->objc_separator = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parm::Parm(Parm *p)
|
||||
// CopyParm(Parm *p)
|
||||
//
|
||||
// Make a copy of a parameter
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Parm::Parm(Parm *p) {
|
||||
if (p->t) t = new DataType(p->t);
|
||||
name = copy_string(p->name);
|
||||
call_type = p->call_type;
|
||||
defvalue = copy_string(p->defvalue);
|
||||
ignore = p->ignore;
|
||||
objc_separator = copy_string(p->objc_separator);
|
||||
Parm *CopyParm(Parm *p) {
|
||||
Parm *np = (Parm *) malloc(sizeof(Parm));
|
||||
if (p->t) np->t = new DataType(p->t);
|
||||
np->name = copy_string(p->name);
|
||||
np->call_type = p->call_type;
|
||||
np->defvalue = copy_string(p->defvalue);
|
||||
np->ignore = p->ignore;
|
||||
np->objc_separator = copy_string(p->objc_separator);
|
||||
return np;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parm::~Parm()
|
||||
// DelParm()
|
||||
//
|
||||
// Destroy a parameter
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Parm::~Parm() {
|
||||
if (t) delete t;
|
||||
if (name) delete name;
|
||||
if (defvalue) delete defvalue;
|
||||
if (objc_separator) delete objc_separator;
|
||||
void DelParm(Parm *p) {
|
||||
if (p->t) delete p->t;
|
||||
if (p->name) delete p->name;
|
||||
if (p->defvalue) delete p->defvalue;
|
||||
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
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
ParmList::ParmList() {
|
||||
|
||||
nparms = 0;
|
||||
maxparms = MAXPARMS;
|
||||
parms = new Parm *[maxparms]; // Create an array of parms
|
||||
for (int i = 0; i < MAXPARMS; i++)
|
||||
parms[i] = (Parm *) 0;
|
||||
ParmList *NewParmList() {
|
||||
int i;
|
||||
ParmList *l = (ParmList *) malloc(sizeof(ParmList));
|
||||
l->nparms = 0;
|
||||
l->maxparms = MAXPARMS;
|
||||
l->parms = (Parm **) malloc(MAXPARMS*sizeof(Parm *));
|
||||
for (i = 0; i < MAXPARMS; i++) {
|
||||
l->parms[i] = 0;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ParmList::ParmList(ParmList *l)
|
||||
// CopyParmList()
|
||||
//
|
||||
// Make a copy of parameter list
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
ParmList::ParmList(ParmList *l) {
|
||||
ParmList *
|
||||
CopyParmList(ParmList *l) {
|
||||
ParmList *nl;
|
||||
int i;
|
||||
|
||||
|
||||
if (l) {
|
||||
nparms = l->nparms;
|
||||
maxparms = l->maxparms;
|
||||
parms = new Parm *[maxparms];
|
||||
nl = (ParmList *) malloc(sizeof(ParmList));
|
||||
nl->nparms = l->nparms;
|
||||
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])
|
||||
parms[i] = new Parm(l->parms[i]);
|
||||
nl->parms[i] = CopyParm(l->parms[i]);
|
||||
else
|
||||
parms[i] = 0;
|
||||
nl->parms[i] = 0;
|
||||
}
|
||||
|
||||
return nl;
|
||||
} else {
|
||||
nparms = 0;
|
||||
maxparms = MAXPARMS;
|
||||
parms = new Parm *[maxparms]; // Create an array of parms
|
||||
|
||||
for (i = 0; i < MAXPARMS; i++)
|
||||
parms[i] = (Parm *) 0;
|
||||
return NewParmList();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ParmList::~ParmList()
|
||||
// DelParmList()
|
||||
//
|
||||
// Delete a parameter list
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
ParmList::~ParmList() {
|
||||
for (int i = 0; i < maxparms; i++) {
|
||||
if (parms[i]) delete parms[i];
|
||||
void DelParmList(ParmList *l) {
|
||||
int 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.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void ParmList::moreparms() {
|
||||
static void moreparms(ParmList *l) {
|
||||
Parm **newparms;
|
||||
int i;
|
||||
|
||||
newparms = new Parm *[maxparms*2];
|
||||
for (i = 0; i < 2*maxparms; i++)
|
||||
newparms = (Parm **) malloc(2*l->maxparms*sizeof(Parm *));
|
||||
for (i = 0; i < 2*l->maxparms; i++)
|
||||
newparms[i] = (Parm *) 0;
|
||||
for (i = 0; i < maxparms; i++) {
|
||||
newparms[i] = parms[i];
|
||||
for (i = 0; i < l->maxparms; i++) {
|
||||
newparms[i] = l->parms[i];
|
||||
}
|
||||
maxparms = 2*maxparms;
|
||||
delete parms;
|
||||
parms = newparms;
|
||||
l->maxparms = 2*l->maxparms;
|
||||
free(l->parms);
|
||||
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
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
||||
parms[nparms] = new Parm(p);
|
||||
nparms++;
|
||||
l->parms[l->nparms] = CopyParm(p);
|
||||
l->nparms++;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// void ParmList::insert(Parm *p, int pos)
|
||||
// void ParmList_insert()
|
||||
//
|
||||
// Inserts a parameter at position pos. Parameters are inserted
|
||||
// *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 < 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 (nparms >= maxparms) moreparms();
|
||||
if (l->nparms >= l->maxparms) moreparms(l);
|
||||
|
||||
// Now shift all of the existing parms to the right
|
||||
|
||||
for (int i = nparms; i > pos; i--) {
|
||||
parms[i] = parms[i-1];
|
||||
for (int i = l->nparms; i > pos; i--) {
|
||||
l->parms[i] = l->parms[i-1];
|
||||
}
|
||||
|
||||
// Set new parameter
|
||||
|
||||
parms[pos] = new Parm(p);
|
||||
nparms++;
|
||||
l->parms[pos] = CopyParm(p);
|
||||
l->nparms++;
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// void ParmList::del(int pos)
|
||||
// void ParmList_del()
|
||||
//
|
||||
// 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 >= nparms) pos = nparms-1;
|
||||
if (pos >= l->nparms) pos = l->nparms-1;
|
||||
|
||||
// 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
|
||||
|
||||
for (int i = pos; i < nparms-1; i++) {
|
||||
parms[i] = parms[i+1];
|
||||
for (int i = pos; i < l->nparms-1; i++) {
|
||||
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
|
||||
// position.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
Parm *ParmList::get(int pos) {
|
||||
Parm *ParmList_get(ParmList *l, int pos) {
|
||||
|
||||
if ((pos < 0) || (pos >= nparms)) return 0;
|
||||
return parms[pos];
|
||||
if ((pos < 0) || (pos >= l->nparms)) return 0;
|
||||
return l->parms[pos];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// int ParmList::numopt()
|
||||
// int ParmList_numopt()
|
||||
//
|
||||
// Gets the number of optional arguments.
|
||||
// ------------------------------------------------------------------
|
||||
int ParmList::numopt() {
|
||||
int ParmList_numopt(ParmList *l) {
|
||||
int n = 0;
|
||||
int state = 0;
|
||||
|
||||
for (int i = 0; i < nparms; i++) {
|
||||
if (parms[i]->defvalue) {
|
||||
for (int i = 0; i < l->nparms; i++) {
|
||||
if (l->parms[i]->defvalue) {
|
||||
n++;
|
||||
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++;
|
||||
state = 1;
|
||||
} else if (typemap_check((char*)"ignore",typemap_lang,parms[i]->t,parms[i]->name)) {
|
||||
n++;
|
||||
} else if (typemap_check((char*)"build",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 (state) {
|
||||
|
|
@ -273,58 +275,41 @@ int ParmList::numopt() {
|
|||
//
|
||||
// Gets the number of arguments
|
||||
// ------------------------------------------------------------------
|
||||
int ParmList::numarg() {
|
||||
int ParmList_numarg(ParmList *l) {
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < nparms; i++) {
|
||||
if (!parms[i]->ignore)
|
||||
for (int i = 0; i < l->nparms; i++) {
|
||||
if (!l->parms[i]->ignore)
|
||||
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.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Parm *ParmList::get_first() {
|
||||
current_parm = 0;
|
||||
if (nparms > 0) return parms[current_parm++];
|
||||
Parm *ParmList_first(ParmList *l) {
|
||||
l->current_parm = 0;
|
||||
if (l->nparms > 0) return l->parms[l->current_parm++];
|
||||
else return (Parm *) 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Parm *ParmList::get_next()
|
||||
// Parm *ParmList_next()
|
||||
//
|
||||
// Returns the next item on the parameter list.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Parm * ParmList::get_next() {
|
||||
if (current_parm >= nparms) return 0;
|
||||
else return parms[current_parm++];
|
||||
Parm * ParmList_next(ParmList *l) {
|
||||
if (l->current_parm >= l->nparms) return 0;
|
||||
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.
|
||||
// This is for generating valid C prototypes. Has to do some
|
||||
|
|
@ -332,63 +317,64 @@ Parm * ParmList::get_next() {
|
|||
// variable has been set.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ParmList::print_types(DOHFile *f) {
|
||||
void ParmList_print_types(ParmList *l, DOHFile *f) {
|
||||
|
||||
int is_pointer;
|
||||
int pn;
|
||||
pn = 0;
|
||||
while(pn < nparms) {
|
||||
is_pointer = parms[pn]->t->is_pointer;
|
||||
if (parms[pn]->t->is_reference) {
|
||||
if (parms[pn]->t->is_pointer) {
|
||||
parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s&", parms[pn]->t->print_real());
|
||||
parms[pn]->t->is_pointer++;
|
||||
while(pn < l->nparms) {
|
||||
is_pointer = l->parms[pn]->t->is_pointer;
|
||||
if (l->parms[pn]->t->is_reference) {
|
||||
if (l->parms[pn]->t->is_pointer) {
|
||||
l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s&", l->parms[pn]->t->print_real());
|
||||
l->parms[pn]->t->is_pointer++;
|
||||
} else {
|
||||
Printf(f,"%s&", parms[pn]->t->print_real());
|
||||
Printf(f,"%s&", l->parms[pn]->t->print_real());
|
||||
}
|
||||
} else {
|
||||
if (parms[pn]->call_type & CALL_VALUE) parms[pn]->t->is_pointer++;
|
||||
if (parms[pn]->call_type & CALL_REFERENCE) parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s", parms[pn]->t->print_real());
|
||||
parms[pn]->t->is_pointer = is_pointer;
|
||||
if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
|
||||
if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s", l->parms[pn]->t->print_real());
|
||||
l->parms[pn]->t->is_pointer = is_pointer;
|
||||
}
|
||||
pn++;
|
||||
if (pn < nparms)
|
||||
if (pn < l->nparms)
|
||||
Printf(f,",");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// void ParmList::print_args(FILE *f)
|
||||
// void ParmList_print_args()
|
||||
//
|
||||
// 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 pn;
|
||||
pn = 0;
|
||||
while(pn < nparms) {
|
||||
is_pointer = parms[pn]->t->is_pointer;
|
||||
if (parms[pn]->t->is_reference) {
|
||||
if (parms[pn]->t->is_pointer) {
|
||||
parms[pn]->t->is_pointer--;
|
||||
fprintf(f,"%s&", parms[pn]->t->print_full());
|
||||
parms[pn]->t->is_pointer++;
|
||||
while(pn < l->nparms) {
|
||||
is_pointer = l->parms[pn]->t->is_pointer;
|
||||
if (l->parms[pn]->t->is_reference) {
|
||||
if (l->parms[pn]->t->is_pointer) {
|
||||
l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s&", l->parms[pn]->t->print_full());
|
||||
l->parms[pn]->t->is_pointer++;
|
||||
} else {
|
||||
fprintf(f,"%s&", parms[pn]->t->print_full());
|
||||
Printf(f,"%s&", l->parms[pn]->t->print_full());
|
||||
}
|
||||
} else {
|
||||
if (parms[pn]->call_type & CALL_VALUE) parms[pn]->t->is_pointer++;
|
||||
if (parms[pn]->call_type & CALL_REFERENCE) parms[pn]->t->is_pointer--;
|
||||
fprintf(f,"%s", parms[pn]->t->print_full());
|
||||
parms[pn]->t->is_pointer = is_pointer;
|
||||
if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
|
||||
if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s", l->parms[pn]->t->print_full());
|
||||
l->parms[pn]->t->is_pointer = is_pointer;
|
||||
}
|
||||
fprintf(f,"%s",parms[pn]->name);
|
||||
Printf(f,"%s",l->parms[pn]->name);
|
||||
pn++;
|
||||
if (pn < nparms)
|
||||
fprintf(f,",");
|
||||
if (pn < l->nparms)
|
||||
Printf(f,",");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
$2->is_reference = $3.is_reference;
|
||||
create_function($1, $3.id, $2, $5);
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
} stail { }
|
||||
|
||||
/* A function declaration with code after it */
|
||||
|
|
@ -620,7 +620,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
$2->is_reference = $3.is_reference;
|
||||
create_function($1, $3.id, $2, $5);
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
};
|
||||
|
||||
/* A function declared without any return datatype */
|
||||
|
|
@ -646,7 +646,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
}
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
};
|
||||
|
||||
/* 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);
|
||||
}
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
};
|
||||
|
||||
/* A static function declaration (ignored) */
|
||||
|
|
@ -675,7 +675,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
| STATIC type declaration LPAREN parms RPAREN cpp_const {
|
||||
Active_static = 1;
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
} stail {
|
||||
Active_static = 0;
|
||||
}
|
||||
|
|
@ -750,7 +750,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
}
|
||||
delete $6;
|
||||
delete $9;
|
||||
DelParmList($9);
|
||||
}
|
||||
|
||||
/* %title directive */
|
||||
|
|
@ -1002,7 +1002,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
delete $3;
|
||||
delete $5;
|
||||
delete $9->p;
|
||||
DelParm($9->p);
|
||||
delete $9;
|
||||
}
|
||||
|
||||
|
|
@ -1022,7 +1022,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
}
|
||||
delete $3;
|
||||
delete $7->p;
|
||||
DelParm($7->p);
|
||||
delete $7;
|
||||
}
|
||||
/* -----------------------------------------------------------------
|
||||
|
|
@ -1037,7 +1037,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
p = p->next;
|
||||
}
|
||||
delete $4;
|
||||
delete $2->args;
|
||||
DelParmList($2->args);
|
||||
delete $2;
|
||||
}
|
||||
| CLEAR tm_list SEMI {
|
||||
|
|
@ -1165,7 +1165,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
cplus_register_type($5);
|
||||
delete $2;
|
||||
delete $5;
|
||||
delete $8;
|
||||
DelParmList($8);
|
||||
}
|
||||
|
||||
/* A typedef involving function pointers again */
|
||||
|
|
@ -1187,7 +1187,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
cplus_register_type($6);
|
||||
delete $2;
|
||||
delete $6;
|
||||
delete $9;
|
||||
DelParmList($9);
|
||||
}
|
||||
|
||||
/* A typedef involving arrays */
|
||||
|
|
@ -1296,7 +1296,7 @@ stail : SEMI { }
|
|||
temp_typeptr->is_reference = $2.is_reference;
|
||||
create_function(Active_extern, $2.id, temp_typeptr, $4);
|
||||
delete temp_typeptr;
|
||||
delete $4;
|
||||
DelParmList($4);
|
||||
} stail { }
|
||||
;
|
||||
|
||||
|
|
@ -1325,19 +1325,19 @@ func_end : cpp_const LBRACE { skip_brace(); }
|
|||
|
||||
parms : parm ptail {
|
||||
if (($1->t->type != T_VOID) || ($1->t->is_pointer))
|
||||
$2->insert($1,0);
|
||||
ParmList_insert($2,$1,0);
|
||||
$$ = $2;
|
||||
delete $1;
|
||||
DelParm($1);
|
||||
}
|
||||
| empty { $$ = new ParmList;}
|
||||
| empty { $$ = NewParmList(); }
|
||||
;
|
||||
|
||||
ptail : COMMA parm ptail {
|
||||
$3->insert($2,0);
|
||||
ParmList_insert($3,$2,0);
|
||||
$$ = $3;
|
||||
delete $2;
|
||||
DelParm($2);
|
||||
}
|
||||
| empty { $$ = new ParmList;}
|
||||
| empty { $$ = NewParmList(); }
|
||||
;
|
||||
|
||||
parm : parm_type {
|
||||
|
|
@ -1366,7 +1366,7 @@ parm_type : type pname {
|
|||
// Add array string to the type
|
||||
$1->arraystr = copy_string(Char(ArrayString));
|
||||
}
|
||||
$$ = new Parm($1,$2);
|
||||
$$ = NewParm($1,$2);
|
||||
$$->call_type = 0;
|
||||
$$->defvalue = DefArg;
|
||||
if (($1->type == T_USER) && !($1->is_pointer)) {
|
||||
|
|
@ -1378,7 +1378,7 @@ parm_type : type pname {
|
|||
}
|
||||
|
||||
| type stars pname {
|
||||
$$ = new Parm($1,$3);
|
||||
$$ = NewParm($1,$3);
|
||||
$$->t->is_pointer += $2;
|
||||
$$->call_type = 0;
|
||||
$$->defvalue = DefArg;
|
||||
|
|
@ -1392,7 +1392,7 @@ parm_type : type pname {
|
|||
}
|
||||
|
||||
| type AND pname {
|
||||
$$ = new Parm($1,$3);
|
||||
$$ = NewParm($1,$3);
|
||||
$$->t->is_reference = 1;
|
||||
$$->call_type = 0;
|
||||
$$->t->is_pointer++;
|
||||
|
|
@ -1406,17 +1406,17 @@ parm_type : type pname {
|
|||
| 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);
|
||||
FatalError();
|
||||
$$ = new Parm($1,$4);
|
||||
$$ = NewParm($1,$4);
|
||||
$$->t->type = T_ERROR;
|
||||
$$->name = copy_string($4);
|
||||
strcpy($$->t->name,"<function ptr>");
|
||||
delete $1;
|
||||
delete $4;
|
||||
delete $7;
|
||||
DelParmList($7);
|
||||
}
|
||||
| PERIOD PERIOD PERIOD {
|
||||
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;
|
||||
$$->name = copy_string((char*)"varargs");
|
||||
strcpy($$->t->name,"<varargs>");
|
||||
|
|
@ -2207,7 +2207,7 @@ cpp_other :/* A dummy class name */
|
|||
}
|
||||
create_function($1, temp_name, $2, $7);
|
||||
delete $2;
|
||||
delete $7;
|
||||
DelParmList($7);
|
||||
}
|
||||
|
||||
/* A static C++ member data */
|
||||
|
|
@ -2293,7 +2293,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
}
|
||||
scanner_clear_start();
|
||||
delete $1;
|
||||
delete $4;
|
||||
DelParmList($4);
|
||||
}
|
||||
|
||||
/* Virtual member function */
|
||||
|
|
@ -2310,7 +2310,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
}
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
}
|
||||
|
||||
/* Possibly a constructor */
|
||||
|
|
@ -2323,7 +2323,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
cplus_constructor($1,iname, $3);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $3;
|
||||
DelParmList($3);
|
||||
}
|
||||
|
||||
/* A destructor (hopefully) */
|
||||
|
|
@ -2337,6 +2337,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
cplus_destructor($2,iname);
|
||||
}
|
||||
scanner_clear_start();
|
||||
DelParmList($4);
|
||||
}
|
||||
|
||||
/* A virtual destructor */
|
||||
|
|
@ -2455,7 +2456,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
}
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
delete $5;
|
||||
DelParmList($5);
|
||||
}
|
||||
/* Turn on public: mode */
|
||||
|
||||
|
|
@ -2828,7 +2829,7 @@ cpptype : CLASS { $$ = (char*)"class"; }
|
|||
;
|
||||
|
||||
cpp_const : CONST {}
|
||||
| THROW LPAREN parms RPAREN { delete $3;}
|
||||
| THROW LPAREN parms RPAREN { DelParmList($3);}
|
||||
| empty {}
|
||||
;
|
||||
|
||||
|
|
@ -3094,7 +3095,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
|||
scanner_clear_start();
|
||||
delete $2;
|
||||
delete $3;
|
||||
delete $4;
|
||||
DelParmList($4);
|
||||
}
|
||||
}
|
||||
| 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();
|
||||
delete $2;
|
||||
delete $3;
|
||||
delete $4;
|
||||
DelParmList($4);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3137,7 +3138,7 @@ objc_ret_type : LPAREN type RPAREN {
|
|||
|
||||
objc_arg_type : LPAREN parm RPAREN {
|
||||
$$ = new DataType($2->t);
|
||||
delete $2;
|
||||
DelParm($2);
|
||||
}
|
||||
| empty {
|
||||
$$ = new DataType(T_VOID);
|
||||
|
|
@ -3148,13 +3149,13 @@ objc_arg_type : LPAREN parm RPAREN {
|
|||
;
|
||||
|
||||
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;
|
||||
$$ = $1;
|
||||
$$->append(p);
|
||||
ParmList_append($$,p);
|
||||
}
|
||||
| empty {
|
||||
$$ = new ParmList;
|
||||
$$ = NewParmList();
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3237,7 +3238,7 @@ typemap_parm : type typemap_name {
|
|||
$1->arraystr = copy_string(Char(ArrayString));
|
||||
}
|
||||
$$ = new TMParm;
|
||||
$$->p = new Parm($1,$2);
|
||||
$$->p = NewParm($1,$2);
|
||||
$$->p->call_type = 0;
|
||||
$$->args = tm_parm;
|
||||
delete $1;
|
||||
|
|
@ -3246,7 +3247,7 @@ typemap_parm : type typemap_name {
|
|||
|
||||
| type stars typemap_name {
|
||||
$$ = new TMParm;
|
||||
$$->p = new Parm($1,$3);
|
||||
$$->p = NewParm($1,$3);
|
||||
$$->p->t->is_pointer += $2;
|
||||
$$->p->call_type = 0;
|
||||
if (InArray) {
|
||||
|
|
@ -3260,7 +3261,7 @@ typemap_parm : type typemap_name {
|
|||
|
||||
| type AND typemap_name {
|
||||
$$ = new TMParm;
|
||||
$$->p = new Parm($1,$3);
|
||||
$$->p = NewParm($1,$3);
|
||||
$$->p->t->is_reference = 1;
|
||||
$$->p->call_type = 0;
|
||||
$$->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);
|
||||
FatalError();
|
||||
$$ = new TMParm;
|
||||
$$->p = new Parm($1,$4);
|
||||
$$->p = NewParm($1,$4);
|
||||
$$->p->t->type = T_ERROR;
|
||||
$$->p->name = copy_string($4);
|
||||
strcpy($$->p->t->name,"<function ptr>");
|
||||
$$->args = tm_parm;
|
||||
delete $1;
|
||||
delete $4;
|
||||
delete $7;
|
||||
DelParmList($7);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ extern int error_count;
|
|||
extern char *copy_string(char *);
|
||||
extern char output_dir[512]; // Output directory
|
||||
extern int Verbose;
|
||||
extern int IsVirtual;
|
||||
|
||||
#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_OUTPUT 0x04
|
||||
|
||||
struct Parm {
|
||||
typedef class Parm {
|
||||
public:
|
||||
DataType *t; // Datatype of this parameter
|
||||
int call_type; // Call type (value or reference or value)
|
||||
char *name; // Name of parameter (optional)
|
||||
char *defvalue; // Default value (as a string)
|
||||
int ignore; // Ignore flag
|
||||
char *objc_separator; // Parameter separator for Objective-C
|
||||
Parm(DataType *type, char *n);
|
||||
Parm(Parm *p);
|
||||
~Parm();
|
||||
};
|
||||
|
||||
private:
|
||||
// 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
|
||||
|
|
@ -189,33 +198,32 @@ struct Parm {
|
|||
|
||||
#define MAXPARMS 16
|
||||
|
||||
class ParmList {
|
||||
private:
|
||||
int maxparms; // Max parms possible in current list
|
||||
typedef class ParmList {
|
||||
public:
|
||||
int maxparms; // Max parms possible in current list
|
||||
Parm **parms; // Pointer to parms array
|
||||
void moreparms(); // Increase number of stored parms
|
||||
int current_parm; // Internal state for get_first,get_next
|
||||
public:
|
||||
int nparms; // Number of parms in list
|
||||
void append(Parm *p); // Append a parameter to the end
|
||||
void insert(Parm *p, int pos); // Insert a parameter into the list
|
||||
void del(int pos); // Delete a parameter at position pos
|
||||
int numopt(); // Get number of optional arguments
|
||||
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();
|
||||
int current_parm; // Internal state for get_first,get_next
|
||||
int nparms; // Number of parms in list
|
||||
private:
|
||||
// Note: This is here to force any use of these to fail miserably.
|
||||
ParmList() { abort(); }
|
||||
ParmList(ParmList *l) { abort(); }
|
||||
~ParmList() { abort(); }
|
||||
} ParmList;
|
||||
|
||||
// Keep this for backwards compatibility
|
||||
|
||||
Parm *get_first(); // Get first parameter from list
|
||||
Parm *get_next(); // Get next parameter from list
|
||||
|
||||
void print_types(void *f); // Print list of datatypes
|
||||
void print_args(FILE *f); // Print argument list
|
||||
};
|
||||
extern ParmList *NewParmList();
|
||||
extern ParmList *CopyParmList(ParmList *);
|
||||
extern void DelParmList(ParmList *);
|
||||
extern Parm *ParmList_get(ParmList *l, int pos);
|
||||
extern void ParmList_append(ParmList *, Parm *);
|
||||
extern void ParmList_insert(ParmList *, Parm *, int);
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ struct TypeMap {
|
|||
next = 0;
|
||||
previous = 0;
|
||||
if (p) {
|
||||
args = new ParmList(p);
|
||||
args = CopyParmList(p);
|
||||
} else {
|
||||
args = 0;
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ struct TypeMap {
|
|||
next = 0;
|
||||
previous = t->previous;
|
||||
if (args) {
|
||||
args = new ParmList(args);
|
||||
args = CopyParmList(args);
|
||||
} else {
|
||||
args = 0;
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
|
||||
if (args) {
|
||||
Parm *p;
|
||||
p = tm->args->get_first();
|
||||
p = ParmList_first(tm->args);
|
||||
while (p) {
|
||||
if (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->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;
|
||||
char *new_name;
|
||||
|
||||
p = l->get_first();
|
||||
p = ParmList_first(l);
|
||||
while (p) {
|
||||
if (p->name) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
p = l->get_next();
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
// If the original datatype was an array. We're going to go through and substitute
|
||||
// it's array dimensions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue