Cleanup. Replaced Parm and ParmList data structures with new implementation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@606 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5c69ec9d84
commit
6bc7b11a9b
18 changed files with 486 additions and 724 deletions
|
|
@ -96,7 +96,7 @@ typedef struct {
|
||||||
void *data; /* Data pointer */
|
void *data; /* Data pointer */
|
||||||
int type : 4; /* Object type (max 16 -- deal with it) */
|
int type : 4; /* Object type (max 16 -- deal with it) */
|
||||||
int flag_intern : 1; /* Interned object */
|
int flag_intern : 1; /* Interned object */
|
||||||
int flag_marked : 1; /* Mark flag */
|
int flag_marked : 1; /* Mark flag. Used to avoid recursive loops in places */
|
||||||
int flag_user : 1; /* User flag */
|
int flag_user : 1; /* User flag */
|
||||||
int flag_reserved : 1; /* Reserved flag */
|
int flag_reserved : 1; /* Reserved flag */
|
||||||
int refcount : 24; /* Reference count (max 16 million) */
|
int refcount : 24; /* Reference count (max 16 million) */
|
||||||
|
|
|
||||||
|
|
@ -436,10 +436,10 @@ 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 = ParmList_first(l); p != 0; ++i, p = ParmList_next(l)) {
|
for (p = Firstitem(l); p != 0; ++i, p = Nextitem(l)) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
|
|
||||||
if (Parm_Getignore(p))
|
if (Getignore(p))
|
||||||
continue;
|
continue;
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||||
if (!first_arg)
|
if (!first_arg)
|
||||||
|
|
@ -468,19 +468,19 @@ 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 = ParmList_get(l,i);
|
Parm *p = Getitem(l,i);
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// Produce names of source and target
|
// Produce names of source and target
|
||||||
sprintf(source,"s_%d",i);
|
sprintf(source,"s_%d",i);
|
||||||
sprintf(target,"%s",Parm_Getlname(p));
|
sprintf(target,"%s",Getlname(p));
|
||||||
sprintf(argnum,"%d",i);
|
sprintf(argnum,"%d",i);
|
||||||
strcpy(arg,pn);
|
strcpy(arg,pn);
|
||||||
|
|
||||||
// Handle parameter types.
|
// Handle parameter types.
|
||||||
|
|
||||||
if (Parm_Getignore(p))
|
if (Getignore(p))
|
||||||
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
|
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
|
||||||
else {
|
else {
|
||||||
++numargs;
|
++numargs;
|
||||||
|
|
@ -819,11 +819,11 @@ 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 = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
if (Parm_Getignore(p))
|
if (Getignore(p))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Print the type. If the parameter has been named, use that as well.
|
// Print the type. If the parameter has been named, use that as well.
|
||||||
|
|
@ -868,9 +868,9 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
|
||||||
|
|
||||||
// go through and see if any are output.
|
// go through and see if any are output.
|
||||||
|
|
||||||
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
|
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -587,16 +587,16 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
|
|
||||||
// Now walk the function parameter list and generate code to get arguments
|
// 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 = ParmList_get(l,i); // Get the ith argument
|
Parm *p = Getitem(l,i); // Get the ith argument
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
char *target_copy = NULL;
|
char *target_copy = NULL;
|
||||||
char *target_length = NULL;
|
char *target_length = NULL;
|
||||||
char *local_i = NULL;
|
char *local_i = NULL;
|
||||||
|
|
||||||
// Produce string representation of source and target arguments
|
// Produce string representation of source and target arguments
|
||||||
sprintf(source,"jarg%d",i);
|
sprintf(source,"jarg%d",i);
|
||||||
sprintf(target,"%s", Parm_Getlname(p));
|
sprintf(target,"%s", Getlname(p));
|
||||||
|
|
||||||
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
|
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
|
||||||
if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
|
if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
|
||||||
|
|
@ -606,7 +606,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
Printv(javaParameterSignature, JavaMethodSignature(pt, 0, 0), 0);
|
Printv(javaParameterSignature, JavaMethodSignature(pt, 0, 0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Parm_Getignore(p)) continue;
|
if(Getignore(p)) continue;
|
||||||
|
|
||||||
// Add to java function header
|
// Add to java function header
|
||||||
if(shadow && member_func) {
|
if(shadow && member_func) {
|
||||||
|
|
@ -1067,12 +1067,12 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
}
|
}
|
||||||
Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(_self", 0);
|
Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(_self", 0);
|
||||||
|
|
||||||
int pcount = l->nparms;
|
int pcount = Len(l);
|
||||||
|
|
||||||
for (int i = 0; i < pcount ; i++) {
|
for (int i = 0; i < pcount ; i++) {
|
||||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
Parm *p = Getitem(l,i); // Get the ith argument
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// Produce string representation of source and target arguments
|
// Produce string representation of source and target arguments
|
||||||
if(pn && *(pn))
|
if(pn && *(pn))
|
||||||
|
|
@ -1139,13 +1139,13 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
}
|
}
|
||||||
Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(", 0);
|
Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(", 0);
|
||||||
|
|
||||||
int pcount = l->nparms;
|
int pcount = Len(l);
|
||||||
int gencomma = 0;
|
int gencomma = 0;
|
||||||
|
|
||||||
for (int i = 0; i < pcount ; i++) {
|
for (int i = 0; i < pcount ; i++) {
|
||||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
Parm *p = Getitem(l,i); // Get the ith argument
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// Produce string representation of source and target arguments
|
// Produce string representation of source and target arguments
|
||||||
if(pn && *(pn))
|
if(pn && *(pn))
|
||||||
|
|
@ -1206,14 +1206,14 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
else
|
else
|
||||||
Printv(nativecall, tab8, " _self = ", module, ".", Swig_name_construct(shadow_classname), "(", 0);
|
Printv(nativecall, tab8, " _self = ", module, ".", Swig_name_construct(shadow_classname), "(", 0);
|
||||||
|
|
||||||
int pcount = l->nparms;
|
int pcount = Len(l);
|
||||||
if(pcount == 0) // We must have a default constructor
|
if(pcount == 0) // We must have a default constructor
|
||||||
have_default_constructor = 1;
|
have_default_constructor = 1;
|
||||||
|
|
||||||
for (int i = 0; i < pcount ; i++) {
|
for (int i = 0; i < pcount ; i++) {
|
||||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
Parm *p = Getitem(l,i); // Get the ith argument
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// Produce string representation of source and target arguments
|
// Produce string representation of source and target arguments
|
||||||
if(pn && *(pn))
|
if(pn && *(pn))
|
||||||
|
|
|
||||||
|
|
@ -322,20 +322,20 @@ 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 = ParmList_get(l,i);
|
Parm *p = Getitem(l,i);
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// Produce names of source and target
|
// Produce names of source and target
|
||||||
|
|
||||||
sprintf(source,"argv[%d]",i);
|
sprintf(source,"argv[%d]",i);
|
||||||
sprintf(target,"%s", Parm_Getlname(p));
|
sprintf(target,"%s", Getlname(p));
|
||||||
sprintf(argnum,"%d",i);
|
sprintf(argnum,"%d",i);
|
||||||
strcpy(arg,pn);
|
strcpy(arg,pn);
|
||||||
|
|
||||||
// Handle parameter types.
|
// Handle parameter types.
|
||||||
|
|
||||||
if (Parm_Getignore(p))
|
if (Getignore(p))
|
||||||
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
|
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
|
||||||
else {
|
else {
|
||||||
++numargs;
|
++numargs;
|
||||||
|
|
@ -689,11 +689,11 @@ 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 = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
if (Parm_Getignore(p))
|
if (Getignore(p))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Print the type. If the parameter has been named, use that as well.
|
// Print the type. If the parameter has been named, use that as well.
|
||||||
|
|
@ -739,9 +739,9 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
|
||||||
|
|
||||||
// go through and see if any are output.
|
// go through and see if any are output.
|
||||||
|
|
||||||
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
for (p = Firstitem(l); p != 0; p = Nextitem(l)) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
|
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -778,19 +778,19 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// 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);
|
||||||
sprintf(target,"%s", Parm_Getlname(p));
|
sprintf(target,"%s", Getlname(p));
|
||||||
sprintf(argnum,"%d",j+1);
|
sprintf(argnum,"%d",j+1);
|
||||||
|
|
||||||
// Check to see if this argument is being ignored
|
// Check to see if this argument is being ignored
|
||||||
|
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
|
|
||||||
// If there are optional arguments, check for this
|
// If there are optional arguments, check for this
|
||||||
|
|
||||||
|
|
@ -909,11 +909,11 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
}
|
}
|
||||||
// If we needed a saved variable, we need to emit to emit some code for that
|
// If we needed a saved variable, we need to emit to emit some code for that
|
||||||
// This only applies if the argument actually existed (not ignore)
|
// This only applies if the argument actually existed (not ignore)
|
||||||
if ((need_save) && (!Parm_Getignore(p))) {
|
if ((need_save) && (!Getignore(p))) {
|
||||||
Printv(f->code, tab4, temp, " = ", source, ";\n", 0);
|
Printv(f->code, tab4, temp, " = ", source, ";\n", 0);
|
||||||
num_saved++;
|
num_saved++;
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1055,12 +1055,12 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// arguments to our function correspond to other Perl objects, we
|
// 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 = ParmList_first(l);
|
Parm *p = Firstitem(l);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(p) {
|
while(p) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
|
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
// Look up the datatype name here
|
// Look up the datatype name here
|
||||||
char sourceNtarget[256];
|
char sourceNtarget[256];
|
||||||
sprintf(sourceNtarget,"$args[%d]",i);
|
sprintf(sourceNtarget,"$args[%d]",i);
|
||||||
|
|
@ -1078,7 +1078,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0);
|
Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0);
|
||||||
|
|
@ -1534,12 +1534,12 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
|
||||||
|
|
||||||
/* Now go through and print parameters */
|
/* Now go through and print parameters */
|
||||||
|
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||||
|
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||||
|
|
@ -1550,14 +1550,14 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
if (p)
|
if (p)
|
||||||
if (!Parm_Getignore(p))
|
if (!Getignore(p))
|
||||||
Putc(',',temp);
|
Putc(',',temp);
|
||||||
} else {
|
} else {
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
if (p)
|
if (p)
|
||||||
if ((i>0) && (!Parm_Getignore(p)))
|
if ((i>0) && (!Getignore(p)))
|
||||||
Putc(',',temp);
|
Putc(',',temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1891,13 +1891,13 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
// arguments to our function correspond to other Perl objects, we
|
// 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 = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
pcount = l->nparms;
|
pcount = Len(l);
|
||||||
numopt = check_numopt(l);
|
numopt = check_numopt(l);
|
||||||
i = 1;
|
i = 1;
|
||||||
while(p) {
|
while(p) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
char sourceNtarget[512];
|
char sourceNtarget[512];
|
||||||
sprintf(sourceNtarget, "$args[%d]", i);
|
sprintf(sourceNtarget, "$args[%d]", i);
|
||||||
|
|
||||||
|
|
@ -1917,7 +1917,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Okay. We've made argument adjustments, now call into the package
|
// Okay. We've made argument adjustments, now call into the package
|
||||||
|
|
@ -2097,10 +2097,10 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
// arguments to our function correspond to other Perl objects, we
|
// 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 = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
i = 0;
|
i = 0;
|
||||||
while(p) {
|
while(p) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
// Look up the datatype name here
|
// Look up the datatype name here
|
||||||
|
|
||||||
if ((Getattr(classes,pt->name)) && (pt->is_pointer <= 1)) {
|
if ((Getattr(classes,pt->name)) && (pt->is_pointer <= 1)) {
|
||||||
|
|
@ -2108,7 +2108,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
// Yep. This smells alot like an object, patch up the arguments
|
// 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 = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -679,22 +679,22 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
j = 0;
|
j = 0;
|
||||||
numopt = check_numopt(l); // Get number of optional arguments
|
numopt = check_numopt(l); // Get number of optional arguments
|
||||||
if (numopt) have_defarg = 1;
|
if (numopt) have_defarg = 1;
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
|
|
||||||
Printf(kwargs,"{ ");
|
Printf(kwargs,"{ ");
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
char *pv = Parm_Getvalue(p);
|
char *pv = Getvalue(p);
|
||||||
|
|
||||||
// Generate source and target strings
|
// Generate source and target strings
|
||||||
sprintf(source,"obj%d",i);
|
sprintf(source,"obj%d",i);
|
||||||
sprintf(target,Parm_Getlname(p));
|
sprintf(target,Getlname(p));
|
||||||
sprintf(argnum,"%d",j+1);
|
sprintf(argnum,"%d",j+1);
|
||||||
|
|
||||||
// Only consider this argument if it's not ignored
|
// Only consider this argument if it's not ignored
|
||||||
|
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
Putc(',',arglist);
|
Putc(',',arglist);
|
||||||
// Add an optional argument separator if needed
|
// Add an optional argument separator if needed
|
||||||
|
|
||||||
|
|
@ -782,7 +782,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
Putc('O',parse_args);
|
Putc('O',parse_args);
|
||||||
sprintf(source,"argo%d", i);
|
sprintf(source,"argo%d", i);
|
||||||
sprintf(target,Parm_Getlname(p));
|
sprintf(target,Getlname(p));
|
||||||
sprintf(temp,"argument %d",i+1);
|
sprintf(temp,"argument %d",i+1);
|
||||||
|
|
||||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||||
|
|
@ -801,7 +801,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Emit code for parameter list
|
// Emit code for parameter list
|
||||||
|
|
||||||
if ((pt->type != T_VOID) && (pt->type != T_BOOL) && (pt->type != T_USER))
|
if ((pt->type != T_VOID) && (pt->type != T_BOOL) && (pt->type != T_USER))
|
||||||
Printf(arglist,"&%s",Parm_Getlname(p));
|
Printf(arglist,"&%s",Getlname(p));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
@ -809,7 +809,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
||||||
Putc('s',parse_args);
|
Putc('s',parse_args);
|
||||||
Printf(arglist,"&%s", Parm_Getlname(p));
|
Printf(arglist,"&%s", Getlname(p));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Have some sort of pointer variable. Create a temporary local
|
// Have some sort of pointer variable. Create a temporary local
|
||||||
|
|
@ -817,7 +817,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
Putc('O',parse_args);
|
Putc('O',parse_args);
|
||||||
sprintf(source,"argo%d", i);
|
sprintf(source,"argo%d", i);
|
||||||
sprintf(target,"%s",Parm_Getlname(p));
|
sprintf(target,"%s",Getlname(p));
|
||||||
sprintf(temp,"argument %d",i+1);
|
sprintf(temp,"argument %d",i+1);
|
||||||
|
|
||||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||||
|
|
@ -845,7 +845,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
||||||
have_output++;
|
have_output++;
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1417,11 +1417,11 @@ 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 = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
i++;
|
i++;
|
||||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||||
|
|
||||||
|
|
@ -1432,15 +1432,15 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
|
||||||
Printf(temp,"%s", DataType_str(pt,0));
|
Printf(temp,"%s", DataType_str(pt,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
if (p != 0) {
|
if (p != 0) {
|
||||||
if (!Parm_Getignore(p))
|
if (!Getignore(p))
|
||||||
Putc(',',temp);
|
Putc(',',temp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
if (p) {
|
if (p) {
|
||||||
if ((!Parm_Getignore(p)) && (i > 0))
|
if ((!Getignore(p)) && (i > 0))
|
||||||
Putc(',',temp);
|
Putc(',',temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -443,9 +443,9 @@ 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 < Len(l); i++) {
|
||||||
if (!Parm_Getignore(ParmList_get(l,i))) {
|
if (!Getignore(Getitem(l,i))) {
|
||||||
if (i >= l->nparms - numopt) numoptreal++;
|
if (i >= Len(l) - numopt) numoptreal++;
|
||||||
else numreq++;
|
else numreq++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -457,8 +457,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
Printv(f->def, "int argc, VALUE *argv, VALUE self",0);
|
Printv(f->def, "int argc, VALUE *argv, VALUE self",0);
|
||||||
} 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 < Len(l); i++) {
|
||||||
if (!Parm_Getignore(ParmList_get(l,i))) {
|
if (!Getignore(Getitem(l,i))) {
|
||||||
Printf(f->def,", VALUE varg%d", i);
|
Printf(f->def,", VALUE varg%d", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -467,8 +467,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
|
|
||||||
// Emit all of the local variables for holding arguments.
|
// Emit all of the local variables for holding arguments.
|
||||||
if (vararg) {
|
if (vararg) {
|
||||||
for (i = start; i < l->nparms; i++) {
|
for (i = start; i < Len(l); i++) {
|
||||||
if (!Parm_Getignore(ParmList_get(l,i))) {
|
if (!Getignore(Getitem(l,i))) {
|
||||||
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,8 +497,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
// Emit count to check the number of arguments
|
// Emit count to check the number of arguments
|
||||||
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 < Len(l); i++) {
|
||||||
if (!Parm_Getignore(ParmList_get(l,i))) {
|
if (!Getignore(Getitem(l,i))) {
|
||||||
Printf(f->code,", &varg%d", i);
|
Printf(f->code,", &varg%d", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -510,9 +510,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
int j = 0; // Total number of non-optional arguments
|
int j = 0; // Total number of non-optional arguments
|
||||||
|
|
||||||
for (i = 0; i < pcount ; i++) {
|
for (i = 0; i < pcount ; i++) {
|
||||||
Parm *p = ParmList_get(l,i);
|
Parm *p = Getitem(l,i);
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
@ -521,9 +521,9 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
else
|
else
|
||||||
sprintf(source,"varg%d",i);
|
sprintf(source,"varg%d",i);
|
||||||
|
|
||||||
sprintf(target,"%s", Parm_Getlname(p));
|
sprintf(target,"%s", Getlname(p));
|
||||||
|
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
char *tab = (char*)tab4;
|
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);
|
||||||
|
|
|
||||||
|
|
@ -505,19 +505,19 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// 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);
|
||||||
sprintf(target,"%s", Parm_Getlname(p));
|
sprintf(target,"%s", Getlname(p));
|
||||||
sprintf(argnum,"%d",j+1);
|
sprintf(argnum,"%d",j+1);
|
||||||
|
|
||||||
// See if this argument is being ignored
|
// See if this argument is being ignored
|
||||||
|
|
||||||
if (!Parm_Getignore(p)) {
|
if (!Getignore(p)) {
|
||||||
if (j == (pcount-numopt))
|
if (j == (pcount-numopt))
|
||||||
Putc('|',argstr);
|
Putc('|',argstr);
|
||||||
|
|
||||||
|
|
@ -648,7 +648,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(l); // Get next parameter and continue
|
p = Nextitem(l); // Get next parameter and continue
|
||||||
}
|
}
|
||||||
Printf(argstr,":%s\"",usage);
|
Printf(argstr,":%s\"",usage);
|
||||||
Printv(f->code,
|
Printv(f->code,
|
||||||
|
|
@ -1132,13 +1132,13 @@ 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 = Len(l);
|
||||||
numopt = check_numopt(l);
|
numopt = check_numopt(l);
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
|
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
|
|
||||||
// Only print an argument if not ignored
|
// Only print an argument if not ignored
|
||||||
|
|
||||||
|
|
@ -1161,7 +1161,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
||||||
Putc(' ',temp);
|
Putc(' ',temp);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
return Char(temp);
|
return Char(temp);
|
||||||
}
|
}
|
||||||
|
|
@ -1287,9 +1287,13 @@ void TCL8::cpp_close_class() {
|
||||||
t->is_pointer = 1;
|
t->is_pointer = 1;
|
||||||
|
|
||||||
if (have_destructor) {
|
if (have_destructor) {
|
||||||
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n",
|
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n", 0);
|
||||||
tab4, Swig_name_destroy(real_classname), "((", DataType_str(t,0), ") obj);\n",
|
if (CPlusPlus) {
|
||||||
"}\n",0);
|
Printv(code," delete (", DataType_str(t,0), ") obj;\n",0);
|
||||||
|
} else {
|
||||||
|
Printv(code," free((char *) obj);\n",0);
|
||||||
|
}
|
||||||
|
Printf(code,"}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(methods, " {0,0}\n};\n");
|
Printf(methods, " {0,0}\n};\n");
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,10 @@ static void update_local_type(DataType *type) {
|
||||||
|
|
||||||
static void update_parms(ParmList *l) {
|
static void update_parms(ParmList *l) {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p) {
|
while (p) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pvalue = Parm_Getvalue(p);
|
char *pvalue = Getvalue(p);
|
||||||
|
|
||||||
update_local_type(pt);
|
update_local_type(pt);
|
||||||
|
|
||||||
|
|
@ -166,10 +166,10 @@ static void update_parms(ParmList *l) {
|
||||||
char *s;
|
char *s;
|
||||||
s = (char *) GetChar(localtypes,pvalue);
|
s = (char *) GetChar(localtypes,pvalue);
|
||||||
if (s) {
|
if (s) {
|
||||||
Parm_Setvalue(p,s);
|
Setvalue(p,s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,7 +276,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
lang->cpp_member_func(name, iname, t, l);
|
lang->cpp_member_func(name, iname, t, l);
|
||||||
}
|
}
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
IsVirtual = 0;
|
IsVirtual = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +323,7 @@ public:
|
||||||
l = CopyParmList(parms);
|
l = CopyParmList(parms);
|
||||||
update_parms(l);
|
update_parms(l);
|
||||||
lang->cpp_constructor(name,iname,l);
|
lang->cpp_constructor(name,iname,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1502,8 +1502,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||||
if (!bc) bc = classname;
|
if (!bc) bc = classname;
|
||||||
if (strlen(bc) == 0) bc = classname;
|
if (strlen(bc) == 0) bc = classname;
|
||||||
|
|
||||||
Printf(key,"%s+",Wrapper_Getname(w));
|
Printf(key,"%s+%s",Wrapper_Getname(w), ParmList_protostr(l));
|
||||||
ParmList_print_types(l,key);
|
|
||||||
if (!member_hash) member_hash = NewHash();
|
if (!member_hash) member_hash = NewHash();
|
||||||
if (Getattr(member_hash,key)) {
|
if (Getattr(member_hash,key)) {
|
||||||
prev_wrap = GetChar(member_hash,key);
|
prev_wrap = GetChar(member_hash,key);
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
||||||
Swig_cargs(f, l);
|
Swig_cargs(f, l);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
lname = Parm_Getlname(p);
|
lname = Getlname(p);
|
||||||
pt = Parm_Gettype(p);
|
pt = Gettype(p);
|
||||||
pname = Parm_Getname(p);
|
pname = Getname(p);
|
||||||
pvalue = Parm_Getvalue(p);
|
pvalue = Getvalue(p);
|
||||||
|
|
||||||
tm = typemap_lookup((char*)"arginit", typemap_lang, pt,pname,(char*)"",lname,f);
|
tm = typemap_lookup((char*)"arginit", typemap_lang, pt,pname,(char*)"",lname,f);
|
||||||
if (tm) {
|
if (tm) {
|
||||||
|
|
@ -62,10 +62,10 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
||||||
tm = typemap_lookup((char*)"ignore",typemap_lang,pt,pname,(char*)"",lname,f);
|
tm = typemap_lookup((char*)"ignore",typemap_lang,pt,pname,(char*)"",lname,f);
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Printv(f->code,tm,"\n",0);
|
Printv(f->code,tm,"\n",0);
|
||||||
Parm_Setignore(p,1);
|
Setignore(p,1);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
|
|
@ -135,21 +135,20 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
||||||
|
|
||||||
/* How to assign a C allocated string */
|
/* How to assign a C allocated string */
|
||||||
|
|
||||||
static char *c_str = (char *)" {\n\
|
static char *c_str = (char *)"\
|
||||||
if ($target) free($target);\n\
|
if ($target) free($target);\n\
|
||||||
$target = ($rtype) malloc(strlen($source)+1);\n\
|
$target = ($rtype) malloc(strlen($source)+1);\n\
|
||||||
strcpy((char *)$target,$source);\n\
|
strcpy((char *)$target,$source);\n\
|
||||||
return $ltype $target;\n\
|
return $ltype $target;\n";
|
||||||
}\n";
|
|
||||||
|
|
||||||
/* How to assign a C allocated string */
|
/* How to assign a C allocated string */
|
||||||
|
|
||||||
static char *cpp_str = (char *)" {\n\
|
static char *cpp_str = (char *)"\
|
||||||
if ($target) delete [] $target;\n\
|
if ($target) delete [] $target;\n\
|
||||||
$target = ($rtype) (new char[strlen($source)+1]);\n\
|
$target = ($rtype) (new char[strlen($source)+1]);\n\
|
||||||
strcpy((char *)$target,$source);\n\
|
strcpy((char *)$target,$source);\n\
|
||||||
return ($ltype) $target;\n\
|
return ($ltype) $target;\n;";
|
||||||
}\n";
|
|
||||||
|
|
||||||
void emit_set_get(char *name, char *iname, DataType *t) {
|
void emit_set_get(char *name, char *iname, DataType *t) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,28 +199,20 @@ static void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_ty
|
||||||
switch(extern_type) {
|
switch(extern_type) {
|
||||||
case 0:
|
case 0:
|
||||||
fprintf(f,"%s", DataType_str(t,0));
|
fprintf(f,"%s", DataType_str(t,0));
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(%s);\n", decl, ParmList_protostr(L));
|
||||||
ParmList_print_types(L,f);
|
|
||||||
fprintf(f,");\n");
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
fprintf(f,"extern %s", DataType_str(t,0));
|
fprintf(f,"extern %s", DataType_str(t,0));
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(%s);\n", decl, ParmList_protostr(L));
|
||||||
ParmList_print_types(L,f);
|
|
||||||
fprintf(f,");\n");
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* A C++ --- > C Extern */
|
/* A C++ --- > C Extern */
|
||||||
fprintf(f,"extern \"C\" %s", DataType_str(t,0));
|
fprintf(f,"extern \"C\" %s", DataType_str(t,0));
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(%s);\n", decl, ParmList_protostr(L));
|
||||||
ParmList_print_types(L,f);
|
|
||||||
fprintf(f,");\n");
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fprintf(f,"%s", DataType_str(t,0));
|
fprintf(f,"%s", DataType_str(t,0));
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(%s)\n", decl, ParmList_str(L));
|
||||||
ParmList_print_args(L,f);
|
|
||||||
fprintf(f,")\n");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -665,7 +657,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
FatalError();
|
FatalError();
|
||||||
} else {
|
} else {
|
||||||
if (DataType_qualifier($2)) {
|
if (DataType_qualifier($2)) {
|
||||||
if (!($2->is_pointer) && (strcmp(DataType_qualifier($2),"const") == 0)) {
|
if (strcmp(DataType_qualifier($2),"const") == 0) {
|
||||||
if ($5.type != T_ERROR)
|
if ($5.type != T_ERROR)
|
||||||
create_constant($3.id, $2, $5.id);
|
create_constant($3.id, $2, $5.id);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -715,7 +707,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);
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($5);
|
||||||
} stail { }
|
} stail { }
|
||||||
|
|
||||||
/* A function declaration with code after it */
|
/* A function declaration with code after it */
|
||||||
|
|
@ -726,7 +718,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);
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($5);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A function declared without any return datatype */
|
/* A function declared without any return datatype */
|
||||||
|
|
@ -752,7 +744,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($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 */
|
||||||
|
|
@ -773,7 +765,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
create_function(0, $3.id, $2, $5);
|
create_function(0, $3.id, $2, $5);
|
||||||
}
|
}
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($5);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A static function declaration (ignored) */
|
/* A static function declaration (ignored) */
|
||||||
|
|
@ -781,7 +773,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;
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($5);
|
||||||
} stail {
|
} stail {
|
||||||
Active_static = 0;
|
Active_static = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -856,7 +848,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DelDataType($6);
|
DelDataType($6);
|
||||||
DelParmList($9);
|
Delete($9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* %title directive */
|
/* %title directive */
|
||||||
|
|
@ -1044,7 +1036,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
skip_brace();
|
skip_brace();
|
||||||
p = $7;
|
p = $7;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_register($5,$3,Parm_Gettype(p->p),Parm_Getname(p->p),Char(CCode),p->args);
|
typemap_register($5,$3,Gettype(p->p),Getname(p->p),Char(CCode),p->args);
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
free($3);
|
free($3);
|
||||||
|
|
@ -1062,7 +1054,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
skip_brace();
|
skip_brace();
|
||||||
p = $5;
|
p = $5;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_register($3,typemap_lang,Parm_Gettype(p->p),Parm_Getname(p->p),Char(CCode),p->args);
|
typemap_register($3,typemap_lang,Gettype(p->p),Getname(p->p),Char(CCode),p->args);
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1075,7 +1067,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
TMParm *p;
|
TMParm *p;
|
||||||
p = $7;
|
p = $7;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_clear($5,$3,Parm_Gettype(p->p),Parm_Getname(p->p));
|
typemap_clear($5,$3,Gettype(p->p),Getname(p->p));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
free($3);
|
free($3);
|
||||||
|
|
@ -1092,7 +1084,7 @@ statement : INCLUDE STRING LBRACE {
|
||||||
TMParm *p;
|
TMParm *p;
|
||||||
p = $5;
|
p = $5;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_clear($3,typemap_lang,Parm_Gettype(p->p),Parm_Getname(p->p));
|
typemap_clear($3,typemap_lang,Gettype(p->p),Getname(p->p));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1105,12 +1097,12 @@ statement : INCLUDE STRING LBRACE {
|
||||||
TMParm *p;
|
TMParm *p;
|
||||||
p = $7;
|
p = $7;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_copy($5,$3,Parm_Gettype($9->p),Parm_Getname($9->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
typemap_copy($5,$3,Gettype($9->p),Getname($9->p),Gettype(p->p),Getname(p->p));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
free($3);
|
free($3);
|
||||||
free($5);
|
free($5);
|
||||||
DelParm($9->p);
|
Delete($9->p);
|
||||||
free($9);
|
free($9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1125,12 +1117,12 @@ statement : INCLUDE STRING LBRACE {
|
||||||
TMParm *p;
|
TMParm *p;
|
||||||
p = $5;
|
p = $5;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_copy($3,typemap_lang,Parm_Gettype($7->p),Parm_Getname($7->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
typemap_copy($3,typemap_lang,Gettype($7->p),Getname($7->p),Gettype(p->p),Getname(p->p));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free($3);
|
free($3);
|
||||||
DelParm($7->p);
|
Delete($7->p);
|
||||||
free($7);
|
free($7);
|
||||||
}
|
}
|
||||||
/* -----------------------------------------------------------------
|
/* -----------------------------------------------------------------
|
||||||
|
|
@ -1141,18 +1133,18 @@ statement : INCLUDE STRING LBRACE {
|
||||||
TMParm *p;
|
TMParm *p;
|
||||||
p = $4;
|
p = $4;
|
||||||
while(p) {
|
while(p) {
|
||||||
typemap_apply(Parm_Gettype($2->p),Parm_Getname($2->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
typemap_apply(Gettype($2->p),Getname($2->p),Gettype(p->p),Getname(p->p));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
free($4);
|
free($4);
|
||||||
DelParmList($2->args);
|
Delete($2->args);
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
| CLEAR tm_list SEMI {
|
| CLEAR tm_list SEMI {
|
||||||
TMParm *p;
|
TMParm *p;
|
||||||
p = $2;
|
p = $2;
|
||||||
while (p) {
|
while (p) {
|
||||||
typemap_clear_apply(Parm_Gettype(p->p), Parm_Getname(p->p));
|
typemap_clear_apply(Gettype(p->p), Getname(p->p));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1275,7 +1267,7 @@ typedef_decl : TYPEDEF type declaration {
|
||||||
cplus_register_type($5);
|
cplus_register_type($5);
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
free($5);
|
free($5);
|
||||||
DelParmList($8);
|
Delete($8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A typedef involving function pointers again */
|
/* A typedef involving function pointers again */
|
||||||
|
|
@ -1298,7 +1290,7 @@ typedef_decl : TYPEDEF type declaration {
|
||||||
cplus_register_type($6);
|
cplus_register_type($6);
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
free($6);
|
free($6);
|
||||||
DelParmList($9);
|
Delete($9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A typedef involving arrays */
|
/* A typedef involving arrays */
|
||||||
|
|
@ -1410,7 +1402,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);
|
||||||
DelDataType(temp_typeptr);
|
DelDataType(temp_typeptr);
|
||||||
DelParmList($4);
|
Delete($4);
|
||||||
} stail { }
|
} stail { }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -1438,27 +1430,25 @@ func_end : cpp_const LBRACE { skip_brace(); }
|
||||||
------------------------------------------------------------------------------ */
|
------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
parms : parm ptail {
|
parms : parm ptail {
|
||||||
DataType *pt = Parm_Gettype($1);
|
DataType *pt = Gettype($1);
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer))
|
if ((pt->type != T_VOID) || (pt->is_pointer))
|
||||||
ParmList_insert($2,$1,0);
|
Insert($2,0,$1);
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
DelParm($1);
|
|
||||||
}
|
}
|
||||||
| empty { $$ = NewParmList(); }
|
| empty { $$ = NewParmList(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
ptail : COMMA parm ptail {
|
ptail : COMMA parm ptail {
|
||||||
ParmList_insert($3,$2,0);
|
Insert($3,0,$2);
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
DelParm($2);
|
|
||||||
}
|
}
|
||||||
| empty { $$ = NewParmList(); }
|
| empty { $$ = NewParmList(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
parm : parm_type {
|
parm : parm_type {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
if (typemap_check((char *)"ignore",typemap_lang,Parm_Gettype($$),Parm_Getname($$)))
|
if (typemap_check((char *)"ignore",typemap_lang,Gettype($$),Getname($$)))
|
||||||
Parm_Setignore($$,1);
|
Setignore($$,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
parm_type : type pname {
|
parm_type : type pname {
|
||||||
|
|
@ -1468,19 +1458,19 @@ parm_type : type pname {
|
||||||
DataType_set_arraystr($1, Char(ArrayString));
|
DataType_set_arraystr($1, Char(ArrayString));
|
||||||
}
|
}
|
||||||
$$ = NewParm($1,$2);
|
$$ = NewParm($1,$2);
|
||||||
Parm_Setvalue($$,DefArg);
|
Setvalue($$,DefArg);
|
||||||
DelDataType($1);
|
DelDataType($1);
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
|
|
||||||
| type stars pname {
|
| type stars pname {
|
||||||
$$ = NewParm($1,$3);
|
$$ = NewParm($1,$3);
|
||||||
Parm_Gettype($$)->is_pointer+=$2;
|
Gettype($$)->is_pointer+=$2;
|
||||||
Parm_Setvalue($$,DefArg);
|
Setvalue($$,DefArg);
|
||||||
if (InArray) {
|
if (InArray) {
|
||||||
Parm_Gettype($$)->is_pointer++;
|
Gettype($$)->is_pointer++;
|
||||||
// Add array string to the type
|
// Add array string to the type
|
||||||
DataType_set_arraystr(Parm_Gettype($$), Char(ArrayString));
|
DataType_set_arraystr(Gettype($$), Char(ArrayString));
|
||||||
}
|
}
|
||||||
DelDataType($1);
|
DelDataType($1);
|
||||||
free($3);
|
free($3);
|
||||||
|
|
@ -1488,10 +1478,10 @@ parm_type : type pname {
|
||||||
|
|
||||||
| type AND pname {
|
| type AND pname {
|
||||||
$$ = NewParm($1,$3);
|
$$ = NewParm($1,$3);
|
||||||
DataType *pt = Parm_Gettype($$);
|
DataType *pt = Gettype($$);
|
||||||
pt->is_reference = 1;
|
pt->is_reference = 1;
|
||||||
pt->is_pointer++;
|
pt->is_pointer++;
|
||||||
Parm_Setvalue($$,DefArg);
|
Setvalue($$,DefArg);
|
||||||
if (!CPlusPlus) {
|
if (!CPlusPlus) {
|
||||||
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
||||||
}
|
}
|
||||||
|
|
@ -1502,20 +1492,20 @@ parm_type : type pname {
|
||||||
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();
|
||||||
$$ = NewParm($1,$4);
|
$$ = NewParm($1,$4);
|
||||||
DataType *pt = Parm_Gettype($$);
|
DataType *pt = Gettype($$);
|
||||||
pt->type = T_ERROR;
|
pt->type = T_ERROR;
|
||||||
Parm_Setname($$,$4);
|
Setname($$,$4);
|
||||||
strcpy(pt->name,"<function ptr>");
|
strcpy(pt->name,"<function ptr>");
|
||||||
DelDataType($1);
|
DelDataType($1);
|
||||||
free($4);
|
free($4);
|
||||||
DelParmList($7);
|
Delete($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);
|
||||||
$$ = NewParm(NewDataType(T_INT),(char *) "varargs");
|
$$ = NewParm(NewDataType(T_INT),(char *) "varargs");
|
||||||
DataType *pt = Parm_Gettype($$);
|
DataType *pt = Gettype($$);
|
||||||
pt->type = T_ERROR;
|
pt->type = T_ERROR;
|
||||||
Parm_Setname($$,(char*)"varargs");
|
Setname($$,(char*)"varargs");
|
||||||
strcpy(pt->name,"<varargs>");
|
strcpy(pt->name,"<varargs>");
|
||||||
FatalError();
|
FatalError();
|
||||||
}
|
}
|
||||||
|
|
@ -2292,7 +2282,7 @@ cpp_other :/* A dummy class name */
|
||||||
}
|
}
|
||||||
create_function($1, temp_name, $2, $7);
|
create_function($1, temp_name, $2, $7);
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($7);
|
Delete($7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A static C++ member data */
|
/* A static C++ member data */
|
||||||
|
|
@ -2378,7 +2368,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
||||||
}
|
}
|
||||||
scanner_clear_start();
|
scanner_clear_start();
|
||||||
DelDataType($1);
|
DelDataType($1);
|
||||||
DelParmList($4);
|
Delete($4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Virtual member function */
|
/* Virtual member function */
|
||||||
|
|
@ -2395,7 +2385,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
||||||
}
|
}
|
||||||
scanner_clear_start();
|
scanner_clear_start();
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Possibly a constructor */
|
/* Possibly a constructor */
|
||||||
|
|
@ -2408,7 +2398,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();
|
||||||
DelParmList($3);
|
Delete($3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A destructor (hopefully) */
|
/* A destructor (hopefully) */
|
||||||
|
|
@ -2422,7 +2412,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);
|
Delete($4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A virtual destructor */
|
/* A virtual destructor */
|
||||||
|
|
@ -2541,7 +2531,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
||||||
}
|
}
|
||||||
scanner_clear_start();
|
scanner_clear_start();
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
DelParmList($5);
|
Delete($5);
|
||||||
}
|
}
|
||||||
/* Turn on public: mode */
|
/* Turn on public: mode */
|
||||||
|
|
||||||
|
|
@ -2915,7 +2905,7 @@ cpptype : CLASS { $$ = (char*)"class"; }
|
||||||
;
|
;
|
||||||
|
|
||||||
cpp_const : CONST {}
|
cpp_const : CONST {}
|
||||||
| THROW LPAREN parms RPAREN { DelParmList($3);}
|
| THROW LPAREN parms RPAREN { Delete($3);}
|
||||||
| empty {}
|
| empty {}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -3181,7 +3171,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
||||||
scanner_clear_start();
|
scanner_clear_start();
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
free($3);
|
free($3);
|
||||||
DelParmList($4);
|
Delete($4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| PLUS objc_ret_type ID objc_args objc_end {
|
| PLUS objc_ret_type ID objc_args objc_end {
|
||||||
|
|
@ -3199,7 +3189,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
||||||
scanner_clear_start();
|
scanner_clear_start();
|
||||||
DelDataType($2);
|
DelDataType($2);
|
||||||
free($3);
|
free($3);
|
||||||
DelParmList($4);
|
Delete($4);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -3223,8 +3213,8 @@ objc_ret_type : LPAREN type RPAREN {
|
||||||
;
|
;
|
||||||
|
|
||||||
objc_arg_type : LPAREN parm RPAREN {
|
objc_arg_type : LPAREN parm RPAREN {
|
||||||
$$ = CopyDataType(Parm_Gettype($2));
|
$$ = CopyDataType(Gettype($2));
|
||||||
DelParm($2);
|
Delete($2);
|
||||||
}
|
}
|
||||||
| empty {
|
| empty {
|
||||||
$$ = NewDataType(T_VOID);
|
$$ = NewDataType(T_VOID);
|
||||||
|
|
@ -3238,7 +3228,7 @@ objc_args : objc_args objc_separator objc_arg_type ID {
|
||||||
Parm *p= NewParm($3,$4);
|
Parm *p= NewParm($3,$4);
|
||||||
/* p->objc_separator = $2; */
|
/* p->objc_separator = $2; */
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
ParmList_append($$,p);
|
Append($$,p);
|
||||||
}
|
}
|
||||||
| empty {
|
| empty {
|
||||||
$$ = NewParmList();
|
$$ = NewParmList();
|
||||||
|
|
@ -3333,7 +3323,7 @@ typemap_parm : type typemap_name {
|
||||||
| type stars typemap_name {
|
| type stars typemap_name {
|
||||||
$$ = NewTMParm();
|
$$ = NewTMParm();
|
||||||
$$->p = NewParm($1,$3);
|
$$->p = NewParm($1,$3);
|
||||||
DataType *pt = Parm_Gettype($$->p);
|
DataType *pt = Gettype($$->p);
|
||||||
pt->is_pointer += $2;
|
pt->is_pointer += $2;
|
||||||
if (InArray) {
|
if (InArray) {
|
||||||
pt->is_pointer++;
|
pt->is_pointer++;
|
||||||
|
|
@ -3347,7 +3337,7 @@ typemap_parm : type typemap_name {
|
||||||
| type AND typemap_name {
|
| type AND typemap_name {
|
||||||
$$ = NewTMParm();
|
$$ = NewTMParm();
|
||||||
$$->p = NewParm($1,$3);
|
$$->p = NewParm($1,$3);
|
||||||
DataType *pt = Parm_Gettype($$->p);
|
DataType *pt = Gettype($$->p);
|
||||||
pt->is_reference = 1;
|
pt->is_reference = 1;
|
||||||
pt->is_pointer++;
|
pt->is_pointer++;
|
||||||
if (!CPlusPlus) {
|
if (!CPlusPlus) {
|
||||||
|
|
@ -3362,14 +3352,14 @@ typemap_parm : type typemap_name {
|
||||||
FatalError();
|
FatalError();
|
||||||
$$ = NewTMParm();
|
$$ = NewTMParm();
|
||||||
$$->p = NewParm($1,$4);
|
$$->p = NewParm($1,$4);
|
||||||
DataType *pt = Parm_Gettype($$->p);
|
DataType *pt = Gettype($$->p);
|
||||||
pt->type = T_ERROR;
|
pt->type = T_ERROR;
|
||||||
Parm_Setname($$->p,$4);
|
Setname($$->p,$4);
|
||||||
strcpy(pt->name,"<function ptr>");
|
strcpy(pt->name,"<function ptr>");
|
||||||
$$->args = tm_parm;
|
$$->args = tm_parm;
|
||||||
DelDataType($1);
|
DelDataType($1);
|
||||||
free($4);
|
free($4);
|
||||||
DelParmList($7);
|
Delete($7);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,16 +308,16 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
p = ParmList_first(tm->args);
|
p = Firstitem(tm->args);
|
||||||
while (p) {
|
while (p) {
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
if (pn) {
|
if (pn) {
|
||||||
// printf(" %s %s\n", pt,pn);
|
// printf(" %s %s\n", pt,pn);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"%s:%d: Typemap error. Local variables must have a name\n",
|
fprintf(stderr,"%s:%d: Typemap error. Local variables must have a name\n",
|
||||||
input_file, line_number);
|
input_file, line_number);
|
||||||
}
|
}
|
||||||
p = ParmList_next(tm->args);
|
p = Nextitem(tm->args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -481,10 +481,10 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
||||||
Parm *p;
|
Parm *p;
|
||||||
char *new_name;
|
char *new_name;
|
||||||
|
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p) {
|
while (p) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Gettype(p);
|
||||||
char *pn = Parm_Getname(p);
|
char *pn = Getname(p);
|
||||||
if (pn) {
|
if (pn) {
|
||||||
if (strlen(pn) > 0) {
|
if (strlen(pn) > 0) {
|
||||||
DOHString *str;
|
DOHString *str;
|
||||||
|
|
@ -529,7 +529,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
||||||
Replace(s,pn,new_name,DOH_REPLACE_ID);
|
Replace(s,pn,new_name,DOH_REPLACE_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = Nextitem(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
|
||||||
|
|
@ -1123,10 +1123,11 @@ int check_numopt(ParmList *l) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
||||||
for (int i = 0; i < l->nparms; i++) {
|
for (int i = 0; i < Len(l); i++) {
|
||||||
DataType *pt = Parm_Gettype(l->parms[i]);
|
Parm *p = Getitem(l,i);
|
||||||
char *pn = Parm_Getname(l->parms[i]);
|
DataType *pt = Gettype(p);
|
||||||
if (Parm_Getvalue(l->parms[i])) {
|
char *pn = Getname(p);
|
||||||
|
if (Getvalue(p)) {
|
||||||
n++;
|
n++;
|
||||||
state = 1;
|
state = 1;
|
||||||
} else if (typemap_check((char*)"default",typemap_lang,pt,pn)) {
|
} else if (typemap_check((char*)"default",typemap_lang,pt,pn)) {
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ srcdir = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
|
|
||||||
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
|
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
|
||||||
oldtypes.c oldparms.c cwrap.c
|
oldtypes.c parms.c cwrap.c
|
||||||
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
|
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
|
||||||
oldtypes.o oldparms.o cwrap.o
|
oldtypes.o parms.o cwrap.o
|
||||||
|
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
exec_prefix = @exec_prefix@
|
exec_prefix = @exec_prefix@
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ Swig_cparm_name(Parm *p, int i) {
|
||||||
static char name[256];
|
static char name[256];
|
||||||
sprintf(name,"arg%d",i);
|
sprintf(name,"arg%d",i);
|
||||||
if (p) {
|
if (p) {
|
||||||
Parm_Setlname(p,name);
|
Setlname(p,name);
|
||||||
return Parm_Getlname(p);
|
return Getlname(p);
|
||||||
} else {
|
} else {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
@ -156,16 +156,16 @@ int Swig_cargs(Wrapper *w, ParmList *l) {
|
||||||
char *lname;
|
char *lname;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
lname = Swig_cparm_name(p,i);
|
lname = Swig_cparm_name(p,i);
|
||||||
pt = Parm_Gettype(p);
|
pt = Gettype(p);
|
||||||
pname = Parm_Getname(p);
|
pname = Getname(p);
|
||||||
pvalue = Parm_Getvalue(p);
|
pvalue = Getvalue(p);
|
||||||
local = Swig_clocal(pt,lname,pvalue);
|
local = Swig_clocal(pt,lname,pvalue);
|
||||||
Wrapper_add_localv(w,lname,local,0);
|
Wrapper_add_localv(w,lname,local,0);
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
|
|
@ -283,12 +283,12 @@ Swig_cfunction_call(DOHString_or_char *name, ParmList *parms) {
|
||||||
|
|
||||||
Printf(func,"%s(", name);
|
Printf(func,"%s(", name);
|
||||||
|
|
||||||
p = ParmList_first(parms);
|
p = Firstitem(parms);
|
||||||
while (p) {
|
while (p) {
|
||||||
pt = Parm_Gettype(p);
|
pt = Gettype(p);
|
||||||
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(parms);
|
p = Nextitem(parms);
|
||||||
if (p)
|
if (p)
|
||||||
Printf(func,",");
|
Printf(func,",");
|
||||||
}
|
}
|
||||||
|
|
@ -315,17 +315,17 @@ Swig_cmethod_call(DOHString_or_char *name, ParmList *parms) {
|
||||||
if (!func) func = NewString("");
|
if (!func) func = NewString("");
|
||||||
Clear(func);
|
Clear(func);
|
||||||
|
|
||||||
p = ParmList_first(parms);
|
p = Firstitem(parms);
|
||||||
|
|
||||||
if (!p) return "";
|
if (!p) return "";
|
||||||
Printf(func,"%s->%s(", Swig_cparm_name(p,0), name);
|
Printf(func,"%s->%s(", Swig_cparm_name(p,0), name);
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(parms);
|
p = Nextitem(parms);
|
||||||
while (p) {
|
while (p) {
|
||||||
pt = Parm_Gettype(p);
|
pt = Gettype(p);
|
||||||
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(parms);
|
p = Nextitem(parms);
|
||||||
if (p)
|
if (p)
|
||||||
Printf(func,",");
|
Printf(func,",");
|
||||||
}
|
}
|
||||||
|
|
@ -373,12 +373,12 @@ Swig_cppconstructor_call(DOHString_or_char *name, ParmList *parms) {
|
||||||
Clear(func);
|
Clear(func);
|
||||||
|
|
||||||
Printf(func,"new %s(", name);
|
Printf(func,"new %s(", name);
|
||||||
p = ParmList_first(parms);
|
p = Firstitem(parms);
|
||||||
while (p) {
|
while (p) {
|
||||||
pt = Parm_Gettype(p);
|
pt = Gettype(p);
|
||||||
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(parms);
|
p = Nextitem(parms);
|
||||||
if (p)
|
if (p)
|
||||||
Printf(func,",");
|
Printf(func,",");
|
||||||
}
|
}
|
||||||
|
|
@ -478,15 +478,15 @@ static void fix_parm_names(ParmList *l) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
while (p) {
|
while (p) {
|
||||||
if (!Parm_Getname(p)) {
|
if (!Getname(p)) {
|
||||||
char temp[64];
|
char temp[64];
|
||||||
sprintf(temp,"arg%d",i);
|
sprintf(temp,"arg%d",i);
|
||||||
Parm_Setname(p,temp);
|
Setname(p,temp);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -515,15 +515,16 @@ Swig_cfunction_wrapper(DOHString_or_char *funcname,
|
||||||
|
|
||||||
fix_parm_names(l);
|
fix_parm_names(l);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(rtype,0), funcname, ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(rtype,0), funcname, ParmList_str(l));
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,rtype);
|
Wrapper_Settype(w,rtype);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
|
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -556,28 +557,25 @@ Swig_cmethod_wrapper(DOHString_or_char *classname,
|
||||||
strcpy(t->name,Char(classname));
|
strcpy(t->name,Char(classname));
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
p = NewParm(t,"self");
|
p = NewParm(t,"self");
|
||||||
ParmList_insert(l,p,0);
|
Insert(l,0,p);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
DelParm(p);
|
|
||||||
|
|
||||||
fix_parm_names(l);
|
fix_parm_names(l);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(rtype,0), Swig_name_member(classname, methodname), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(rtype,0), Swig_name_member(classname, methodname), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
|
|
||||||
if ((rtype->type != T_VOID) || (rtype->is_pointer)) {
|
if ((rtype->type != T_VOID) || (rtype->is_pointer)) {
|
||||||
Printf(w->code,"return ");
|
Printf(w->code,"return ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(w->code,"self->%s(", methodname);
|
Printf(w->code,"self->%s(", methodname);
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
while (p) {
|
while (p) {
|
||||||
Printf(w->code,"%s", Parm_Getname(p));
|
Printf(w->code,"%s", Getname(p));
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
if (p)
|
if (p)
|
||||||
Printf(w->code,",");
|
Printf(w->code,",");
|
||||||
}
|
}
|
||||||
|
|
@ -585,10 +583,11 @@ Swig_cmethod_wrapper(DOHString_or_char *classname,
|
||||||
Printf(w->code,"}\n");
|
Printf(w->code,"}\n");
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
|
Printf(w->code,"}\n");
|
||||||
}
|
}
|
||||||
Wrapper_Settype(w,rtype);
|
Wrapper_Settype(w,rtype);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -621,19 +620,18 @@ Swig_cconstructor_wrapper(DOHString_or_char *classname,
|
||||||
/* Patch up the argument names */
|
/* Patch up the argument names */
|
||||||
fix_parm_names(l);
|
fix_parm_names(l);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(t,0), Swig_name_construct(classname), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(t,0), Swig_name_construct(classname), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"return (%s) calloc(1,sizeof(%s));\n", DataType_str(t,0), classname);
|
Printf(w->code,"return (%s) calloc(1,sizeof(%s));\n", DataType_str(t,0), classname);
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,t);
|
Wrapper_Settype(w,t);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -668,31 +666,30 @@ Swig_cppconstructor_wrapper(DOHString_or_char *classname,
|
||||||
/* Patch up the argument names */
|
/* Patch up the argument names */
|
||||||
fix_parm_names(l);
|
fix_parm_names(l);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(t,0), Swig_name_construct(classname), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(t,0), Swig_name_construct(classname), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"return new %s", DataType_str(t,0));
|
Printf(w->code,"return new %s", DataType_str(t,0));
|
||||||
p = ParmList_first(l);
|
p = Firstitem(l);
|
||||||
if (p) {
|
if (p) {
|
||||||
Printf(w->code,"(");
|
Printf(w->code,"(");
|
||||||
while (p) {
|
while (p) {
|
||||||
Printf(w->code,"%s", Parm_Getname(p));
|
Printf(w->code,"%s", Getname(p));
|
||||||
p = ParmList_next(l);
|
p = Nextitem(l);
|
||||||
if (p)
|
if (p)
|
||||||
Printf(w->code,",");
|
Printf(w->code,",");
|
||||||
}
|
}
|
||||||
Printf(w->code,")");
|
Printf(w->code,")");
|
||||||
}
|
}
|
||||||
Printf(w->code,";\n");
|
Printf(w->code,";\n");
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,t);
|
Wrapper_Settype(w,t);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -723,25 +720,23 @@ Swig_cdestructor_wrapper(DOHString_or_char *classname,
|
||||||
sprintf(t->name,classname);
|
sprintf(t->name,classname);
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
p = NewParm(t,"self");
|
p = NewParm(t,"self");
|
||||||
ParmList_append(l,p);
|
Append(l,p);
|
||||||
DelParm(p);
|
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
|
|
||||||
t = NewDataType(T_VOID);
|
t = NewDataType(T_VOID);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(t,0), Swig_name_destroy(classname), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(t,0), Swig_name_destroy(classname), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"free((char *) self);\n");
|
Printf(w->code,"free((char *) self);\n");
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,t);
|
Wrapper_Settype(w,t);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -772,25 +767,24 @@ Swig_cppdestructor_wrapper(DOHString_or_char *classname,
|
||||||
sprintf(t->name,classname);
|
sprintf(t->name,classname);
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
p = NewParm(t,"self");
|
p = NewParm(t,"self");
|
||||||
ParmList_append(l,p);
|
|
||||||
DelParm(p);
|
Append(l,p);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
|
|
||||||
t = NewDataType(T_VOID);
|
t = NewDataType(T_VOID);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(t,0), Swig_name_destroy(classname), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(t,0), Swig_name_destroy(classname), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"delete self;\n");
|
Printf(w->code,"delete self;\n");
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,t);
|
Wrapper_Settype(w,t);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -823,29 +817,26 @@ Swig_cmemberset_wrapper(DOHString_or_char *classname,
|
||||||
strcpy(t->name,Char(classname));
|
strcpy(t->name,Char(classname));
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
p = NewParm(t,"self");
|
p = NewParm(t,"self");
|
||||||
ParmList_append(l,p);
|
Append(l,p);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
DelParm(p);
|
|
||||||
|
|
||||||
lt = Swig_clocal_type(type);
|
lt = Swig_clocal_type(type);
|
||||||
p = NewParm(lt,"value");
|
p = NewParm(lt,"value");
|
||||||
ParmList_append(l,p);
|
Append(l,p);
|
||||||
DelParm(p);
|
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"self->%s = %s;\n", membername, Swig_clocal_deref(lt,"value"));
|
Printf(w->code,"self->%s = %s;\n", membername, Swig_clocal_deref(lt,"value"));
|
||||||
Printf(w->code,"return %s self->%s;\n", Swig_clocal_assign(lt,""), membername);
|
Printf(w->code,"return %s self->%s;\n", Swig_clocal_assign(lt,""), membername);
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,lt);
|
Wrapper_Settype(w,lt);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(lt);
|
DelDataType(lt);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -879,24 +870,22 @@ Swig_cmemberget_wrapper(DOHString_or_char *classname,
|
||||||
strcpy(t->name,Char(classname));
|
strcpy(t->name,Char(classname));
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
p = NewParm(t,"self");
|
p = NewParm(t,"self");
|
||||||
ParmList_append(l,p);
|
Append(l,p);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
DelParm(p);
|
|
||||||
|
|
||||||
lt = Swig_clocal_type(type);
|
lt = Swig_clocal_type(type);
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"return %s self->%s;", Swig_clocal_assign(lt,""), membername);
|
Printf(w->code,"return %s self->%s;", Swig_clocal_assign(lt,""), membername);
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,lt);
|
Wrapper_Settype(w,lt);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(lt);
|
DelDataType(lt);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -925,17 +914,14 @@ Swig_cvarset_wrapper(DOHString_or_char *varname,
|
||||||
l = NewParmList();
|
l = NewParmList();
|
||||||
lt = Swig_clocal_type(type);
|
lt = Swig_clocal_type(type);
|
||||||
p = NewParm(lt,"value");
|
p = NewParm(lt,"value");
|
||||||
ParmList_append(l,p);
|
Append(l,p);
|
||||||
DelParm(p);
|
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"%s = %s;\n", varname, Swig_clocal_deref(lt,"value"));
|
Printf(w->code,"%s = %s;\n", varname, Swig_clocal_deref(lt,"value"));
|
||||||
Printf(w->code,"return %s;\n", Swig_clocal_assign(lt,varname));
|
Printf(w->code,"return %s;\n", Swig_clocal_assign(lt,varname));
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
Replace(w->code,"$target",varname, DOH_REPLACE_ANY);
|
Replace(w->code,"$target",varname, DOH_REPLACE_ANY);
|
||||||
|
|
@ -943,9 +929,10 @@ Swig_cvarset_wrapper(DOHString_or_char *varname,
|
||||||
Replace(w->code,"$ltype", DataType_str(lt,""), DOH_REPLACE_ANY);
|
Replace(w->code,"$ltype", DataType_str(lt,""), DOH_REPLACE_ANY);
|
||||||
Replace(w->code,"$rtype", DataType_str(type,""), DOH_REPLACE_ANY);
|
Replace(w->code,"$rtype", DataType_str(type,""), DOH_REPLACE_ANY);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,lt);
|
Wrapper_Settype(w,lt);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(lt);
|
DelDataType(lt);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
@ -974,19 +961,18 @@ Swig_cvarget_wrapper(DOHString_or_char *varname,
|
||||||
|
|
||||||
lt = Swig_clocal_type(type);
|
lt = Swig_clocal_type(type);
|
||||||
|
|
||||||
Printf(w->def,"%s %s(%s)", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
Printf(w->def,"%s %s(%s) {", DataType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
/* No code supplied. Write a function manually */
|
/* No code supplied. Write a function manually */
|
||||||
Printf(w->def," {\n");
|
|
||||||
Printf(w->code,"return %s;", Swig_clocal_assign(type,varname));
|
Printf(w->code,"return %s;", Swig_clocal_assign(type,varname));
|
||||||
Printf(w->code,"}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printv(w->code, code, "\n", 0);
|
Printv(w->code, code, "\n", 0);
|
||||||
}
|
}
|
||||||
|
Printf(w->code,"}\n");
|
||||||
Wrapper_Settype(w,lt);
|
Wrapper_Settype(w,lt);
|
||||||
Wrapper_Setparms(w,l);
|
Wrapper_Setparms(w,l);
|
||||||
DelParmList(l);
|
Delete(l);
|
||||||
DelDataType(lt);
|
DelDataType(lt);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,361 +0,0 @@
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* parms.cxx
|
|
||||||
*
|
|
||||||
* Parameter list class.
|
|
||||||
*
|
|
||||||
* !!! This file is deprecated and is being replaced !!!
|
|
||||||
*
|
|
||||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
|
||||||
*
|
|
||||||
* Copyright (C) 1998-2000. The University of Chicago
|
|
||||||
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
|
||||||
* University of California.
|
|
||||||
*
|
|
||||||
* See the file LICENSE for information on usage and redistribution.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
|
||||||
|
|
||||||
#include "swig.h"
|
|
||||||
|
|
||||||
#define MAXPARMS 16
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
|
||||||
* NewParm()
|
|
||||||
*
|
|
||||||
* Create a new parameter from datatype 'type' and name 'n'.
|
|
||||||
* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
Parm *NewParm(DataType *type, char *n) {
|
|
||||||
Parm *p = (Parm *) malloc(sizeof(Parm));
|
|
||||||
if (type) {
|
|
||||||
p->_type = CopyDataType(type);
|
|
||||||
} else {
|
|
||||||
p->_type = 0;
|
|
||||||
}
|
|
||||||
p->_name = Swig_copy_string(n);
|
|
||||||
p->_lname = 0;
|
|
||||||
p->_defvalue = 0;
|
|
||||||
p->_ignore = 0;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
|
||||||
* CopyParm()
|
|
||||||
* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
Parm *CopyParm(Parm *p) {
|
|
||||||
Parm *np = (Parm *) malloc(sizeof(Parm));
|
|
||||||
if (p->_type) np->_type = CopyDataType(p->_type);
|
|
||||||
np->_name = Swig_copy_string(p->_name);
|
|
||||||
np->_defvalue = Swig_copy_string(p->_defvalue);
|
|
||||||
np->_lname = Swig_copy_string(p->_lname);
|
|
||||||
np->_ignore = p->_ignore;
|
|
||||||
return np;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
|
||||||
* DelParm()
|
|
||||||
* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
void DelParm(Parm *p) {
|
|
||||||
if (p->_type) DelDataType(p->_type);
|
|
||||||
if (p->_name) free(p->_name);
|
|
||||||
if (p->_defvalue) free(p->_defvalue);
|
|
||||||
if (p->_lname) free(p->_lname);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parm_Settype(Parm *p, DataType *t) {
|
|
||||||
if (p->_type) DelDataType(p->_type);
|
|
||||||
p->_type = CopyDataType(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
DataType *Parm_Gettype(Parm *p) {
|
|
||||||
return p->_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parm_Setname(Parm *p, char *n) {
|
|
||||||
if (p->_name) free(p->_name);
|
|
||||||
p->_name = Swig_copy_string(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Parm_Getname(Parm *p) {
|
|
||||||
return p->_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parm_Setlname(Parm *p, char *n) {
|
|
||||||
if (p->_lname) free(p->_lname);
|
|
||||||
p->_lname = Swig_copy_string(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Parm_Getlname(Parm *p) {
|
|
||||||
return p->_lname;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parm_Setvalue(Parm *p, char *v) {
|
|
||||||
if (p->_defvalue) free(p->_defvalue);
|
|
||||||
p->_defvalue = Swig_copy_string(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Parm_Getvalue(Parm *p) {
|
|
||||||
return p->_defvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Parm_Getignore(Parm *p) {
|
|
||||||
return p->_ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parm_Setignore(Parm *p, int i) {
|
|
||||||
p->_ignore = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* NewParmList()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* CopyParmList()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
ParmList *
|
|
||||||
CopyParmList(ParmList *l) {
|
|
||||||
ParmList *nl;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (l) {
|
|
||||||
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 < l->maxparms; i++) {
|
|
||||||
if (l->parms[i])
|
|
||||||
nl->parms[i] = CopyParm(l->parms[i]);
|
|
||||||
else
|
|
||||||
nl->parms[i] = 0;
|
|
||||||
}
|
|
||||||
return nl;
|
|
||||||
} else {
|
|
||||||
return NewParmList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* DelParmList()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
void DelParmList(ParmList *l) {
|
|
||||||
int i;
|
|
||||||
if (NULL == l) return;
|
|
||||||
for (i = 0; i < l->maxparms; i++) {
|
|
||||||
if (l->parms[i]) DelParm(l->parms[i]);
|
|
||||||
}
|
|
||||||
free(l->parms);
|
|
||||||
free(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* moreparms() - Increase memory for parameter list
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
static void moreparms(ParmList *l) {
|
|
||||||
Parm **newparms;
|
|
||||||
int 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 < l->maxparms; i++) {
|
|
||||||
newparms[i] = l->parms[i];
|
|
||||||
}
|
|
||||||
l->maxparms = 2*l->maxparms;
|
|
||||||
free(l->parms);
|
|
||||||
l->parms = newparms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* void ParmList_append(ParmList *l, Parm *p)
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
void ParmList_append(ParmList *l, Parm *p) {
|
|
||||||
|
|
||||||
if (l->nparms == l->maxparms) moreparms(l);
|
|
||||||
l->parms[l->nparms] = CopyParm(p);
|
|
||||||
l->nparms++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* void ParmList_insert()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
void ParmList_insert(ParmList *l, Parm *p, int pos) {
|
|
||||||
int i;
|
|
||||||
/* If pos is out of range, we'd better fix it */
|
|
||||||
|
|
||||||
if (pos < 0) pos = 0;
|
|
||||||
if (pos > l->nparms) pos = l->nparms;
|
|
||||||
|
|
||||||
/* If insertion is going to need more memory, take care of that now */
|
|
||||||
|
|
||||||
if (l->nparms >= l->maxparms) moreparms(l);
|
|
||||||
|
|
||||||
/* Now shift all of the existing parms to the right */
|
|
||||||
|
|
||||||
for (i = l->nparms; i > pos; i--) {
|
|
||||||
l->parms[i] = l->parms[i-1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set new parameter */
|
|
||||||
|
|
||||||
l->parms[pos] = CopyParm(p);
|
|
||||||
l->nparms++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* void ParmList_del()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
void ParmList_del(ParmList *l, int pos) {
|
|
||||||
int i;
|
|
||||||
if (l->nparms <= 0) return;
|
|
||||||
if (pos < 0) pos = 0;
|
|
||||||
if (pos >= l->nparms) pos = l->nparms-1;
|
|
||||||
|
|
||||||
/* Delete the parameter (if it exists) */
|
|
||||||
|
|
||||||
if (l->parms[pos]) DelParm(l->parms[pos]);
|
|
||||||
|
|
||||||
/* Now slide all of the parameters to the left */
|
|
||||||
|
|
||||||
for (i = pos; i < l->nparms-1; i++) {
|
|
||||||
l->parms[i] = l->parms[i+1];
|
|
||||||
}
|
|
||||||
l->nparms--;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* Parm *ParmList_get()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
Parm *ParmList_get(ParmList *l, int pos) {
|
|
||||||
|
|
||||||
if ((pos < 0) || (pos >= l->nparms)) return 0;
|
|
||||||
return l->parms[pos];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* int ParmList_numarg()
|
|
||||||
* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
int ParmList_numarg(ParmList *l) {
|
|
||||||
int n = 0;
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < l->nparms; i++) {
|
|
||||||
if (!Parm_Getignore(l->parms[i]))
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
|
||||||
* Parm * ParmList_first()
|
|
||||||
* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
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_next()
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
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)
|
|
||||||
*
|
|
||||||
* Prints a comma separated list of all of the parameter types.
|
|
||||||
* This is for generating valid C prototypes.
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void ParmList_print_types(ParmList *l, DOHFile *f) {
|
|
||||||
|
|
||||||
int pn;
|
|
||||||
DataType *t;
|
|
||||||
pn = 0;
|
|
||||||
while(pn < l->nparms) {
|
|
||||||
t = Parm_Gettype(l->parms[pn]);
|
|
||||||
Printf(f,"%s", DataType_str(t,0));
|
|
||||||
pn++;
|
|
||||||
if (pn < l->nparms)
|
|
||||||
Printf(f,",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
|
||||||
* void ParmList_print_args()
|
|
||||||
*
|
|
||||||
* Prints a comma separated list of all of the parameter arguments.
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void ParmList_print_args(ParmList *l, DOHFile *f) {
|
|
||||||
int pn;
|
|
||||||
DataType *t;
|
|
||||||
pn = 0;
|
|
||||||
while(pn < l->nparms) {
|
|
||||||
t = Parm_Gettype(l->parms[pn]);
|
|
||||||
Printf(f,"%s", DataType_str(t,Parm_Getname(l->parms[pn])));
|
|
||||||
pn++;
|
|
||||||
if (pn < l->nparms)
|
|
||||||
Printf(f,",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
|
||||||
* void ParmList_str()
|
|
||||||
*
|
|
||||||
* Generates a string of parameters
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
char *ParmList_str(ParmList *l) {
|
|
||||||
static DOHString *out = 0;
|
|
||||||
int pn;
|
|
||||||
DataType *t;
|
|
||||||
|
|
||||||
if (!out) out = NewString("");
|
|
||||||
Clear(out);
|
|
||||||
pn = 0;
|
|
||||||
while(pn < l->nparms) {
|
|
||||||
t = Parm_Gettype(l->parms[pn]);
|
|
||||||
Printf(out,"%s", DataType_str(t,Parm_Getname(l->parms[pn])));
|
|
||||||
pn++;
|
|
||||||
if (pn < l->nparms)
|
|
||||||
Printf(out,",");
|
|
||||||
}
|
|
||||||
return Char(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
160
SWIG/Source/Swig/parms.c
Normal file
160
SWIG/Source/Swig/parms.c
Normal file
|
|
@ -0,0 +1,160 @@
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* parms.cxx
|
||||||
|
*
|
||||||
|
* Parameter list class.
|
||||||
|
*
|
||||||
|
* !!! This file is deprecated and is being replaced !!!
|
||||||
|
*
|
||||||
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
|
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
||||||
|
* University of California.
|
||||||
|
*
|
||||||
|
* See the file LICENSE for information on usage and redistribution.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
|
#include "swig.h"
|
||||||
|
|
||||||
|
#define MAXPARMS 16
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------
|
||||||
|
* NewParm()
|
||||||
|
*
|
||||||
|
* Create a new parameter from datatype 'type' and name 'n'.
|
||||||
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
Parm *NewParm(DataType *type, char *n) {
|
||||||
|
Parm *p = NewHash();
|
||||||
|
|
||||||
|
if (type) {
|
||||||
|
Setattr(p,"type", NewVoid(CopyDataType(type), (void (*)(void *)) DelDataType));
|
||||||
|
}
|
||||||
|
Setattr(p,"name",n);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------
|
||||||
|
* CopyParm()
|
||||||
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
Parm *CopyParm(Parm *p) {
|
||||||
|
DataType *t;
|
||||||
|
char *name;
|
||||||
|
char *lname;
|
||||||
|
char *value;
|
||||||
|
int ignore;
|
||||||
|
|
||||||
|
Parm *np = NewHash();
|
||||||
|
t = GetVoid(p,"type");
|
||||||
|
name = GetChar(p,"name");
|
||||||
|
lname = GetChar(p,"lname");
|
||||||
|
value = GetChar(p,"value");
|
||||||
|
ignore = GetInt(p,"ignore");
|
||||||
|
|
||||||
|
Setattr(np,"type",NewVoid(CopyDataType(t), (void (*)(void *)) DelDataType));
|
||||||
|
if (name)
|
||||||
|
Setattr(np,"name",name);
|
||||||
|
if (lname)
|
||||||
|
Setattr(np,"lname", lname);
|
||||||
|
if (value)
|
||||||
|
Setattr(np,"value", value);
|
||||||
|
if (ignore)
|
||||||
|
SetInt(np,"ignore", ignore);
|
||||||
|
return np;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------
|
||||||
|
* NewParmList()
|
||||||
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
ParmList *NewParmList() {
|
||||||
|
return NewList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------
|
||||||
|
* CopyParmList()
|
||||||
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
ParmList *
|
||||||
|
CopyParmList(ParmList *l) {
|
||||||
|
ParmList *nl;
|
||||||
|
int i, len;
|
||||||
|
|
||||||
|
nl = NewList();
|
||||||
|
len = Len(l);
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
Parm *p = Getitem(l,i);
|
||||||
|
Append(nl, CopyParm(p));
|
||||||
|
}
|
||||||
|
return nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------
|
||||||
|
* int ParmList_numarg()
|
||||||
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
int ParmList_numarg(ParmList *l) {
|
||||||
|
int n = 0;
|
||||||
|
Parm *p;
|
||||||
|
|
||||||
|
p = Firstitem(l);
|
||||||
|
while (p) {
|
||||||
|
if (Getignore(p)) n++;
|
||||||
|
p = Nextitem(l);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
|
* ParmList_str()
|
||||||
|
*
|
||||||
|
* Generates a string of parameters
|
||||||
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *ParmList_str(ParmList *l) {
|
||||||
|
static DOHString *out = 0;
|
||||||
|
Parm *p;
|
||||||
|
DataType *t;
|
||||||
|
|
||||||
|
if (!out) out = NewString("");
|
||||||
|
Clear(out);
|
||||||
|
p = Firstitem(l);
|
||||||
|
while(p) {
|
||||||
|
t = Gettype(p);
|
||||||
|
Printf(out,"%s", DataType_str(t,Getname(p)));
|
||||||
|
p = Nextitem(l);
|
||||||
|
if (p)
|
||||||
|
Printf(out,",");
|
||||||
|
}
|
||||||
|
return Char(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
|
* ParmList_str()
|
||||||
|
*
|
||||||
|
* Generate a prototype string.
|
||||||
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *ParmList_protostr(ParmList *l) {
|
||||||
|
static DOHString *out = 0;
|
||||||
|
Parm *p;
|
||||||
|
DataType *t;
|
||||||
|
|
||||||
|
if (!out) out = NewString("");
|
||||||
|
Clear(out);
|
||||||
|
p = Firstitem(l);
|
||||||
|
while(p) {
|
||||||
|
t = Gettype(p);
|
||||||
|
Printf(out,"%s", DataType_str(t,0));
|
||||||
|
p = Nextitem(l);
|
||||||
|
if (p)
|
||||||
|
Printf(out,",");
|
||||||
|
}
|
||||||
|
return Char(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -100,50 +100,24 @@ extern void typeeq_addtypedef(char *name, char *eqname, DataType *t);
|
||||||
|
|
||||||
#define STAT_REPLACETYPE 2
|
#define STAT_REPLACETYPE 2
|
||||||
|
|
||||||
/* --- Deprecated parameter list structure --- */
|
/* --- Parameters and Parameter Lists --- */
|
||||||
|
|
||||||
typedef struct Parm {
|
/* Parameters are really just hidden behind a DOH object. The following
|
||||||
DataType *_type; /* Datatype of this parameter */
|
interface will probably be simplified even further. */
|
||||||
char *_name; /* Name of parameter (optional) */
|
|
||||||
char *_defvalue; /* Default value (as a string) */
|
typedef DOH Parm;
|
||||||
char *_lname; /* Local name */
|
|
||||||
int _ignore; /* Ignore flag */
|
|
||||||
} Parm;
|
|
||||||
|
|
||||||
extern Parm *NewParm(DataType *type, char *n);
|
extern Parm *NewParm(DataType *type, char *n);
|
||||||
extern Parm *CopyParm(Parm *p);
|
extern Parm *CopyParm(Parm *p);
|
||||||
extern void DelParm(Parm *p);
|
|
||||||
extern void Parm_Settype(Parm *p, DataType *t);
|
|
||||||
extern DataType *Parm_Gettype(Parm *p);
|
|
||||||
extern void Parm_Setname(Parm *p, char *name);
|
|
||||||
extern char *Parm_Getname(Parm *p);
|
|
||||||
extern void Parm_Setlname(Parm *p, char *lname);
|
|
||||||
extern char *Parm_Getlname(Parm *p);
|
|
||||||
extern void Parm_Setvalue(Parm *p, char *value);
|
|
||||||
extern char *Parm_Getvalue(Parm *p);
|
|
||||||
extern int Parm_Getignore(Parm *p);
|
|
||||||
extern void Parm_Setignore(Parm *p, int i);
|
|
||||||
|
|
||||||
typedef struct ParmList {
|
typedef DOH ParmList;
|
||||||
int maxparms; /* Max parms possible in current list */
|
|
||||||
Parm **parms; /* Pointer to parms array */
|
|
||||||
int current_parm; /* Internal state for get_first,get_next */
|
|
||||||
int nparms; /* Number of parms in list */
|
|
||||||
} ParmList;
|
|
||||||
|
|
||||||
extern ParmList *NewParmList();
|
extern ParmList *NewParmList();
|
||||||
extern ParmList *CopyParmList(ParmList *);
|
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_numarg(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);
|
|
||||||
extern char *ParmList_str(ParmList *);
|
extern char *ParmList_str(ParmList *);
|
||||||
|
extern char *ParmList_protostr(ParmList *);
|
||||||
|
|
||||||
/* --- File interface --- */
|
/* --- File interface --- */
|
||||||
|
|
||||||
|
|
@ -158,11 +132,6 @@ extern int Swig_bytes_read();
|
||||||
|
|
||||||
#define SWIG_FILE_DELIMETER "/"
|
#define SWIG_FILE_DELIMETER "/"
|
||||||
|
|
||||||
/* --- Super Strings --- */
|
|
||||||
|
|
||||||
extern DOH *NewSuperString(char *s, DOH *filename, int firstline);
|
|
||||||
extern int SuperString_check(DOH *s);
|
|
||||||
|
|
||||||
/* --- Command line parsing --- */
|
/* --- Command line parsing --- */
|
||||||
|
|
||||||
extern void Swig_init_args(int argc, char **argv);
|
extern void Swig_init_args(int argc, char **argv);
|
||||||
|
|
@ -399,6 +368,21 @@ extern Wrapper *Swig_cvarget_wrapper(DOHString_or_char *varname,
|
||||||
DataType *type,
|
DataType *type,
|
||||||
DOHString_or_char *code);
|
DOHString_or_char *code);
|
||||||
|
|
||||||
|
|
||||||
|
/* --- Attribute access macros --- */
|
||||||
|
|
||||||
|
#define Gettype(x) ((DataType *) GetVoid(x,"type"))
|
||||||
|
#define Getname(x) GetChar(x,"name")
|
||||||
|
#define Getvalue(x) GetChar(x,"value")
|
||||||
|
#define Getlname(x) GetChar(x,"lname")
|
||||||
|
#define Getignore(x) GetInt(x,"ignore")
|
||||||
|
|
||||||
|
#define Settype(x,v) Setattr(x,"type",NewVoid(CopyDataType(v), (void (*)(void *)) DelDataType));
|
||||||
|
#define Setname(x,v) SetChar(x,"name",Char(v))
|
||||||
|
#define Setlname(x,v) SetChar(x,"lname",Char(v))
|
||||||
|
#define Setvalue(x,v) SetChar(x,"value", Char(v))
|
||||||
|
#define Setignore(x,v) SetInt(x,"ignore",v)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ DelWrapper(Wrapper *w) {
|
||||||
Delete(w->code);
|
Delete(w->code);
|
||||||
Delete(w->def);
|
Delete(w->def);
|
||||||
if (w->_type) DelDataType(w->_type);
|
if (w->_type) DelDataType(w->_type);
|
||||||
if (w->_parms) DelParmList(w->_parms);
|
if (w->_parms) Delete(w->_parms);
|
||||||
if (w->_name) Delete(w->_name);
|
if (w->_name) Delete(w->_name);
|
||||||
free(w);
|
free(w);
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +291,7 @@ Wrapper_Getparms(Wrapper *w) {
|
||||||
|
|
||||||
void
|
void
|
||||||
Wrapper_Setparms(Wrapper *w, ParmList *l) {
|
Wrapper_Setparms(Wrapper *w, ParmList *l) {
|
||||||
if (w->_parms) DelParmList(w->_parms);
|
if (w->_parms) Delete(w->_parms);
|
||||||
w->_parms = CopyParmList(l);
|
w->_parms = CopyParmList(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue