Moved parms and types to C. Changed parameter API
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@578 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2425f87f23
commit
c780f4bcf4
20 changed files with 974 additions and 917 deletions
|
|
@ -324,7 +324,7 @@ GUILE::emit_linkage (char *module_name)
|
|||
void
|
||||
GUILE::close (void)
|
||||
{
|
||||
emit_ptr_equivalence (f_init);
|
||||
emit_ptr_equivalence (f_wrappers,f_init);
|
||||
Printf (f_init, "}\n\n");
|
||||
char module_name[256];
|
||||
|
||||
|
|
@ -428,9 +428,11 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
int i = 0;
|
||||
int first_arg = 1;
|
||||
for (p = ParmList_first(l); p != 0; ++i, p = ParmList_next(l)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (p->ignore)
|
||||
continue;
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (!first_arg)
|
||||
Printf(f->def,", ");
|
||||
Printf(f->def,"SCM s_%d", i);
|
||||
|
|
@ -458,28 +460,30 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
int j = 0;
|
||||
for (i = 0; i < pcount; ++i) {
|
||||
Parm *p = ParmList_get(l,i);
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Produce names of source and target
|
||||
sprintf(source,"s_%d",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(argnum,"%d",i);
|
||||
strcpy(arg,p->name);
|
||||
strcpy(arg,pn);
|
||||
|
||||
// Handle parameter types.
|
||||
|
||||
if (p->ignore)
|
||||
Printv(f->code, "/* ", p->name, " ignored... */\n", 0);
|
||||
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
|
||||
else {
|
||||
++numargs;
|
||||
if ((tm = typemap_lookup ((char*)"in", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
else if (p->t->is_pointer)
|
||||
get_pointer (iname, i, p->t, f, proc_name, numargs);
|
||||
else if (pt->is_pointer)
|
||||
get_pointer (iname, i, pt, f, proc_name, numargs);
|
||||
else {
|
||||
throw_unhandled_guile_type_error (p->t);
|
||||
throw_unhandled_guile_type_error (pt);
|
||||
}
|
||||
++j;
|
||||
}
|
||||
|
|
@ -487,7 +491,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Check if there are any constraints.
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"check", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -495,7 +499,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Pass output arguments back to the caller.
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"argout", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
Printv(outarg,tm,"\n",0);
|
||||
mreplace (outarg, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -503,7 +507,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Free up any memory allocated for the arguments.
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"freearg", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
Printv(cleanup, tm, "\n", 0);
|
||||
mreplace (cleanup, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -807,26 +811,28 @@ GUILE::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
|
|||
// Now go through and print parameters
|
||||
|
||||
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
if (p->ignore)
|
||||
continue;
|
||||
|
||||
// Print the type. If the parameter has been named, use that as well.
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
|
||||
// Print the type.
|
||||
Printv(usage, " <", p->t->name, 0);
|
||||
if (p->t->is_pointer) {
|
||||
for (int j = 0; j < (p->t->is_pointer - p->t->implicit_ptr); j++) {
|
||||
Printv(usage, " <", pt->name, 0);
|
||||
if (pt->is_pointer) {
|
||||
for (int j = 0; j < (pt->is_pointer - pt->implicit_ptr); j++) {
|
||||
Putc('*', usage);
|
||||
}
|
||||
}
|
||||
Putc('>',usage);
|
||||
|
||||
// Print the name if it exists.
|
||||
if (strlen (p->name) > 0) {
|
||||
Printv(usage," ", p->name, 0);
|
||||
if (strlen (pn) > 0) {
|
||||
Printv(usage," ", pn, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -854,19 +860,21 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
|
|||
// go through and see if any are output.
|
||||
|
||||
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
if (strcmp (p->name,"BOTH") && strcmp (p->name,"OUTPUT"))
|
||||
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
|
||||
continue;
|
||||
|
||||
// Print the type. If the parameter has been named, use that as well.
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
++have_param;
|
||||
|
||||
// Print the type.
|
||||
Printv(param," $", p->t->name, 0);
|
||||
if (p->t->is_pointer) {
|
||||
for (j = 0; j < (p->t->is_pointer - p->t->implicit_ptr - 1); j++) {
|
||||
Printv(param," $", pt->name, 0);
|
||||
if (pt->is_pointer) {
|
||||
for (j = 0; j < (pt->is_pointer - pt->implicit_ptr - 1); j++) {
|
||||
Putc('*', param);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -588,6 +588,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// Now walk the function parameter list and generate code to get arguments
|
||||
for (int i = 0; i < pcount ; i++) {
|
||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
char *target_copy = NULL;
|
||||
char *target_length = NULL;
|
||||
char *local_i = NULL;
|
||||
|
|
@ -596,12 +598,12 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
sprintf(source,"jarg%d",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
|
||||
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, p->t, p->name);
|
||||
if(!jnitype) jnitype = SwigTcToJniType(p->t, 0);
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, p->t, p->name);
|
||||
if(!jtype) jtype = SwigTcToJavaType(p->t, 0, 0);
|
||||
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
|
||||
if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
|
||||
if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
|
||||
if (useRegisterNatives) {
|
||||
Printv(javaParameterSignature, JavaMethodSignature(p->t, 0, 0), 0);
|
||||
Printv(javaParameterSignature, JavaMethodSignature(pt, 0, 0), 0);
|
||||
}
|
||||
|
||||
if(p->ignore) continue;
|
||||
|
|
@ -624,32 +626,32 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
Printv(f->def, ", ", jnitype, " ", source, 0);
|
||||
|
||||
// Get typemap for this argument
|
||||
tm = typemap_lookup((char*)"in",typemap_lang,p->t,p->name,source,target,f);
|
||||
tm = typemap_lookup((char*)"in",typemap_lang,pt,pn,source,target,f);
|
||||
if (tm) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
if(!p->t->is_pointer)
|
||||
Printv(f->code, tab4, target, " = ", DataType_print_cast(p->t), source, ";\n", 0);
|
||||
else if((p->t->type == T_VOID && p->t->is_pointer == 1) ||
|
||||
(p->t->type == T_USER && p->t->is_pointer == 1)) {
|
||||
p->t->is_pointer++;
|
||||
Printv(f->code, tab4, target, " = *", DataType_print_cast(p->t), "&", source, ";\n", 0);
|
||||
p->t->is_pointer--;
|
||||
if(!pt->is_pointer)
|
||||
Printv(f->code, tab4, target, " = ", DataType_print_cast(pt), source, ";\n", 0);
|
||||
else if((pt->type == T_VOID && pt->is_pointer == 1) ||
|
||||
(pt->type == T_USER && pt->is_pointer == 1)) {
|
||||
pt->is_pointer++;
|
||||
Printv(f->code, tab4, target, " = *", DataType_print_cast(pt), "&", source, ";\n", 0);
|
||||
pt->is_pointer--;
|
||||
} else {
|
||||
if(p->t->type == T_CHAR && p->t->is_pointer == 1) {
|
||||
if(pt->type == T_CHAR && pt->is_pointer == 1) {
|
||||
Printv(f->code, tab4, target, " = (", source, ") ? (char *)", JNICALL((char*)"GetStringUTFChars"), source, ", 0) : NULL;\n", 0);
|
||||
} else {
|
||||
char *scalarType = SwigTcToJniScalarType(p->t);
|
||||
char *cptrtype = DataType_print_type(p->t);
|
||||
p->t->is_pointer--;
|
||||
const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0);
|
||||
char *ctype = DataType_print_type(p->t);
|
||||
char *scalarType = SwigTcToJniScalarType(pt);
|
||||
char *cptrtype = DataType_print_type(pt);
|
||||
pt->is_pointer--;
|
||||
const char *basic_jnitype = (pt->is_pointer > 0) ? "jlong" : SwigTcToJniType(pt, 0);
|
||||
char *ctype = DataType_print_type(pt);
|
||||
if(scalarType == NULL || basic_jnitype == NULL) {
|
||||
Printf(stderr, "\'%s\' does not have a in/jni typemap, and is not a basic type.\n", ctype);
|
||||
SWIG_exit(1);
|
||||
};
|
||||
p->t->is_pointer++;
|
||||
pt->is_pointer++;
|
||||
|
||||
DOHString *basic_jniptrtype = NewStringf("%s*",basic_jnitype);
|
||||
DOHString *source_length = NewStringf("%s%s)", JNICALL((char*)"GetArrayLength"), source);
|
||||
|
|
@ -661,14 +663,14 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType);
|
||||
|
||||
Printv(f->code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0);
|
||||
Printv(f->code, tab4, target, " = ", DataType_print_cast(p->t), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
|
||||
Printv(f->code, tab4, target, " = ", DataType_print_cast(pt), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
|
||||
Printv(f->code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
|
||||
if(p->t->is_pointer > 1) {
|
||||
Printv(f->code, tab8, target, "[i] = *", DataType_print_cast(p->t), "&", target_copy, "[i];\n", 0);
|
||||
if(pt->is_pointer > 1) {
|
||||
Printv(f->code, tab8, target, "[i] = *", DataType_print_cast(pt), "&", target_copy, "[i];\n", 0);
|
||||
} else {
|
||||
p->t->is_pointer--;
|
||||
Printv(f->code, tab8, target, "[i] = ", DataType_print_cast(p->t), target_copy, "[i];\n", 0);
|
||||
p->t->is_pointer++;
|
||||
pt->is_pointer--;
|
||||
Printv(f->code, tab8, target, "[i] = ", DataType_print_cast(pt), target_copy, "[i];\n", 0);
|
||||
pt->is_pointer++;
|
||||
}
|
||||
Delete(scalarFunc);
|
||||
Delete(source_length);
|
||||
|
|
@ -678,45 +680,45 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
}
|
||||
|
||||
// Check to see if there was any sort of a constaint typemap
|
||||
if ((tm = typemap_lookup((char*)"check",typemap_lang,p->t,p->name,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"check",typemap_lang,pt,pn,source,target))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
// Check if there was any cleanup code (save it for later)
|
||||
if ((tm = typemap_lookup((char*)"freearg",typemap_lang,p->t,p->name,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"freearg",typemap_lang,pt,pn,source,target))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(cleanup,"%s\n", tm);
|
||||
Replace(cleanup,"$arg",source, DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
if ((tm = typemap_lookup((char*)"argout",typemap_lang,p->t,p->name,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"argout",typemap_lang,pt,pn,source,target))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(outarg,"%s\n", tm);
|
||||
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
// if(p->t->is_pointer && p->t->type != T_USER && p->t->type != T_VOID) {
|
||||
if(p->t->is_pointer) {
|
||||
if(p->t->type == T_CHAR && p->t->is_pointer == 1) {
|
||||
// if(pt->is_pointer && pt->type != T_USER && pt->type != T_VOID) {
|
||||
if(pt->is_pointer) {
|
||||
if(pt->type == T_CHAR && pt->is_pointer == 1) {
|
||||
Printv(outarg, tab4, "if(", target,") ", JNICALL((char*)"ReleaseStringUTFChars"), source, ", ", target, ");\n", 0);
|
||||
} else if((p->t->type == T_VOID && p->t->is_pointer == 1) ||
|
||||
(p->t->type == T_USER && p->t->is_pointer == 1)) {
|
||||
} else if((pt->type == T_VOID && pt->is_pointer == 1) ||
|
||||
(pt->type == T_USER && pt->is_pointer == 1)) {
|
||||
// nothing to do
|
||||
} else {
|
||||
char *scalarType = SwigTcToJniScalarType(p->t);
|
||||
char *cptrtype = DataType_print_type(p->t);
|
||||
p->t->is_pointer--;
|
||||
const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0);
|
||||
char *ctype = DataType_print_type(p->t);
|
||||
char *scalarType = SwigTcToJniScalarType(pt);
|
||||
char *cptrtype = DataType_print_type(pt);
|
||||
pt->is_pointer--;
|
||||
const char *basic_jnitype = (pt->is_pointer > 0) ? "jlong" : SwigTcToJniType(pt, 0);
|
||||
char *ctype = DataType_print_type(pt);
|
||||
if(scalarType == NULL || basic_jnitype == NULL) {
|
||||
Printf(stderr, "\'%s\' does not have a argout/jni typemap, and is not a basic type.\n", ctype);
|
||||
SWIG_exit(1);
|
||||
};
|
||||
p->t->is_pointer++;
|
||||
pt->is_pointer++;
|
||||
Printf(outarg, " for(i=0; i< %d; i++)\n", target_length);
|
||||
if(p->t->is_pointer > 1) {
|
||||
Printv(outarg, tab8, "*", DataType_print_cast(p->t), "&", target_copy, "[i] = ", target, "[i];\n", 0);
|
||||
if(pt->is_pointer > 1) {
|
||||
Printv(outarg, tab8, "*", DataType_print_cast(pt), "&", target_copy, "[i] = ", target, "[i];\n", 0);
|
||||
} else {
|
||||
Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0);
|
||||
}
|
||||
|
|
@ -1069,23 +1071,26 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
for (int i = 0; i < pcount ; i++) {
|
||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Produce string representation of source and target arguments
|
||||
if(p->name && *(p->name))
|
||||
strcpy(arg,p->name);
|
||||
if(pn && *(pn))
|
||||
strcpy(arg,pn);
|
||||
else {
|
||||
sprintf(arg,"arg%d",i);
|
||||
}
|
||||
|
||||
if(p->t->type == T_USER && p->t->is_pointer <= 1 && Getattr(shadow_classes,p->t->name)) {
|
||||
if(pt->type == T_USER && pt->is_pointer <= 1 && Getattr(shadow_classes,pt->name)) {
|
||||
Printv(nativecall, ", ", arg, "._self", 0);
|
||||
} else Printv(nativecall, ", ", arg, 0);
|
||||
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, p->t, p->name);
|
||||
if(!jtype) jtype = SwigTcToJavaType(p->t, 0, 0);
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
|
||||
if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
|
||||
|
||||
char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, p->t, p->name);
|
||||
if(!jstype && p->t->type == T_USER && p->t->is_pointer <= 1) {
|
||||
jstype = GetChar(shadow_classes,p->t->name);
|
||||
char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, pt, pn);
|
||||
if(!jstype && pt->type == T_USER && pt->is_pointer <= 1) {
|
||||
jstype = GetChar(shadow_classes,pt->name);
|
||||
}
|
||||
|
||||
// Add to java function header
|
||||
|
|
@ -1139,27 +1144,30 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
for (int i = 0; i < pcount ; i++) {
|
||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Produce string representation of source and target arguments
|
||||
if(p->name && *(p->name))
|
||||
strcpy(arg,p->name);
|
||||
if(pn && *(pn))
|
||||
strcpy(arg,pn);
|
||||
else {
|
||||
sprintf(arg,"arg%d",i);
|
||||
}
|
||||
|
||||
if(gencomma) Printf(nativecall,", ");
|
||||
|
||||
if(p->t->type == T_USER && p->t->is_pointer <= 1 && Getattr(shadow_classes,p->t->name)) {
|
||||
if(pt->type == T_USER && pt->is_pointer <= 1 && Getattr(shadow_classes,pt->name)) {
|
||||
Printv(nativecall, arg, "._self", 0);
|
||||
} else Printv(nativecall,arg,0);
|
||||
|
||||
gencomma = 1;
|
||||
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, p->t, p->name);
|
||||
if(!jtype) jtype = SwigTcToJavaType(p->t, 0, 0);
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
|
||||
if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
|
||||
|
||||
char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, p->t, p->name);
|
||||
if(!jstype && p->t->type == T_USER && p->t->is_pointer <= 1) {
|
||||
jstype = GetChar(shadow_classes, p->t->name);
|
||||
char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, pt, pn);
|
||||
if(!jstype && pt->type == T_USER && pt->is_pointer <= 1) {
|
||||
jstype = GetChar(shadow_classes, pt->name);
|
||||
}
|
||||
|
||||
// Add to java function header
|
||||
|
|
@ -1204,23 +1212,26 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
|
||||
for (int i = 0; i < pcount ; i++) {
|
||||
Parm *p = ParmList_get(l,i); // Get the ith argument
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Produce string representation of source and target arguments
|
||||
if(p->name && *(p->name))
|
||||
strcpy(arg,p->name);
|
||||
if(pn && *(pn))
|
||||
strcpy(arg,pn);
|
||||
else {
|
||||
sprintf(arg,"arg%d",i);
|
||||
}
|
||||
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, p->t, p->name);
|
||||
if(!jtype) jtype = SwigTcToJavaType(p->t, 0, 0);
|
||||
char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, p->t, p->name);
|
||||
if(!jstype) jstype = SwigTcToJavaType(p->t, 0, 1);
|
||||
char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
|
||||
if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
|
||||
char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, pt, pn);
|
||||
if(!jstype) jstype = SwigTcToJavaType(pt, 0, 1);
|
||||
if(strcmp(jtype, jstype) == 0) jstype = NULL;
|
||||
|
||||
// Add to java function header
|
||||
Printf(f_shadow, "%s %s", (jstype) ? jstype : jtype, arg);
|
||||
|
||||
if(p->t->type == T_USER && p->t->is_pointer <= 1 && Getattr(shadow_classes,p->t->name)) {
|
||||
if(pt->type == T_USER && pt->is_pointer <= 1 && Getattr(shadow_classes,pt->name)) {
|
||||
Printv(nativecall,arg, "._self", 0);
|
||||
} else Printv(nativecall, arg, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -337,38 +337,40 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
int i = 0;
|
||||
for (i = 0; i < pcount; ++i) {
|
||||
Parm *p = ParmList_get(l,i);
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Produce names of source and target
|
||||
|
||||
sprintf(source,"argv[%d]",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(argnum,"%d",i);
|
||||
strcpy(arg,p->name);
|
||||
strcpy(arg,pn);
|
||||
|
||||
// Handle parameter types.
|
||||
|
||||
if (p->ignore)
|
||||
Printv(f->code, "/* ", p->name, " ignored... */\n", 0);
|
||||
Printv(f->code, "/* ", pn, " ignored... */\n", 0);
|
||||
else {
|
||||
++numargs;
|
||||
if ((tm = typemap_lookup ((char*)"in", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
Printv(f->code, tm, "\n", 0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
// no typemap found
|
||||
// assume it's a Scheme_Object containing the C pointer
|
||||
else if (p->t->is_pointer) {
|
||||
get_pointer (proc_name, i, p->t, f);
|
||||
else if (pt->is_pointer) {
|
||||
get_pointer (proc_name, i, pt, f);
|
||||
}
|
||||
// no typemap found and not a pointer
|
||||
else throw_unhandled_mzscheme_type_error (p->t);
|
||||
else throw_unhandled_mzscheme_type_error (pt);
|
||||
}
|
||||
|
||||
// Check if there are any constraints.
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"check", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printv(f->code,tm,"\n", 0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
|
|
@ -377,7 +379,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Pass output arguments back to the caller.
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"argout", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printv(outarg, tm, "\n", 0);
|
||||
mreplace (outarg, argnum, arg, proc_name);
|
||||
|
|
@ -386,7 +388,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Free up any memory allocated for the arguments.
|
||||
if ((tm = typemap_lookup ((char*)"freearg", typemap_lang,
|
||||
p->t, p->name, source, target, f))) {
|
||||
pt, pn, source, target, f))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printv(cleanup, tm, "\n", 0);
|
||||
mreplace (cleanup, argnum, arg, proc_name);
|
||||
|
|
@ -702,26 +704,28 @@ MZSCHEME::usage_func (char *iname, DataType *d, ParmList *l, DOHString *usage)
|
|||
// Now go through and print parameters
|
||||
|
||||
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
if (p->ignore)
|
||||
continue;
|
||||
|
||||
// Print the type. If the parameter has been named, use that as well.
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
|
||||
// Print the type.
|
||||
Printv(usage," <", p->t->name, 0);
|
||||
if (p->t->is_pointer) {
|
||||
for (int j = 0; j < (p->t->is_pointer - p->t->implicit_ptr); j++) {
|
||||
Printv(usage," <", pt->name, 0);
|
||||
if (pt->is_pointer) {
|
||||
for (int j = 0; j < (pt->is_pointer - pt->implicit_ptr); j++) {
|
||||
Putc('*', usage);
|
||||
}
|
||||
}
|
||||
Putc('>',usage);
|
||||
|
||||
// Print the name if it exists.
|
||||
if (strlen (p->name) > 0) {
|
||||
Printv(usage," ", p->name, 0);
|
||||
if (strlen (pn) > 0) {
|
||||
Printv(usage," ", pn, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -750,19 +754,21 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
|
|||
// go through and see if any are output.
|
||||
|
||||
for (p = ParmList_first(l); p != 0; p = ParmList_next(l)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
if (strcmp (p->name,"BOTH") && strcmp (p->name,"OUTPUT"))
|
||||
if (strcmp (pn,"BOTH") && strcmp (pn,"OUTPUT"))
|
||||
continue;
|
||||
|
||||
// Print the type. If the parameter has been named, use that as well.
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
++have_param;
|
||||
|
||||
// Print the type.
|
||||
Printv(param," $",p->t->name, 0);
|
||||
if (p->t->is_pointer) {
|
||||
for (j = 0; j < (p->t->is_pointer - p->t->implicit_ptr - 1); j++) {
|
||||
Printv(param," $",pt->name, 0);
|
||||
if (pt->is_pointer) {
|
||||
for (j = 0; j < (pt->is_pointer - pt->implicit_ptr - 1); j++) {
|
||||
Putc('*',param);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,7 +598,7 @@ void PERL5::close(void)
|
|||
|
||||
Printf(f_header,"%s\n", magic);
|
||||
|
||||
emit_ptr_equivalence(f_init);
|
||||
emit_ptr_equivalence(f_wrappers,f_init);
|
||||
|
||||
Printf(f_init,"\t ST(0) = &PL_sv_yes;\n");
|
||||
Printf(f_init,"\t XSRETURN(1);\n");
|
||||
|
|
@ -762,7 +762,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Printv(f->code, tab4, "cv = cv;\n", 0);
|
||||
|
||||
pcount = emit_args(d, l, f);
|
||||
numopt = ParmList_numopt(l);
|
||||
numopt = check_numopt(l);
|
||||
|
||||
Wrapper_add_local(f,"argvi","int argvi = 0");
|
||||
|
||||
|
|
@ -780,6 +780,10 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
j = 0;
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
char *pv = Parm_Getvalue(p);
|
||||
|
||||
// Produce string representation of source and target arguments
|
||||
sprintf(source,"ST(%d)",j);
|
||||
sprintf(target,"_arg%d",i);
|
||||
|
|
@ -795,17 +799,17 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Printf(f->code," if (items > %d) {\n", j);
|
||||
|
||||
// See if there is a type-map
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"perl5",p->t,p->name,source,target,f))) {
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"perl5",pt,pn,source,target,f))) {
|
||||
Printf(f->code,"%s\n",tm);
|
||||
Replace(f->code,"$argnum",argnum,DOH_REPLACE_ANY);
|
||||
Replace(f->code,"$arg",source,DOH_REPLACE_ANY);
|
||||
} else {
|
||||
|
||||
if (!p->t->is_pointer) {
|
||||
if (!pt->is_pointer) {
|
||||
|
||||
// Extract a parameter by "value"
|
||||
|
||||
switch(p->t->type) {
|
||||
switch(pt->type) {
|
||||
|
||||
// Integers
|
||||
|
||||
|
|
@ -821,7 +825,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
Printf(f->code," _arg%d = %sSvIV(ST(%d));\n", i, DataType_print_cast(p->t),j);
|
||||
Printf(f->code," _arg%d = %sSvIV(ST(%d));\n", i, DataType_print_cast(pt),j);
|
||||
break;
|
||||
case T_CHAR :
|
||||
|
||||
|
|
@ -833,7 +837,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printf(f->code," _arg%d = %s SvNV(ST(%d));\n", i, DataType_print_cast(p->t), j);
|
||||
Printf(f->code," _arg%d = %s SvNV(ST(%d));\n", i, DataType_print_cast(pt), j);
|
||||
break;
|
||||
|
||||
// Void.. Do nothing.
|
||||
|
|
@ -849,7 +853,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unsupported data type
|
||||
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(p->t));
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(pt));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -857,7 +861,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Argument is a pointer type. Special case is for char *
|
||||
// since that is usually a string.
|
||||
|
||||
if ((p->t->type == T_CHAR) && (p->t->is_pointer == 1)) {
|
||||
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
||||
Printf(f->code," if (! SvOK((SV*) ST(%d))) { _arg%d = 0; }\n", j, i);
|
||||
Printf(f->code," else { _arg%d = (char *) SvPV(ST(%d),PL_na); }\n", i,j);
|
||||
} else {
|
||||
|
|
@ -866,7 +870,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// typed pointer.
|
||||
|
||||
sprintf(temp,"argument %d", i+1);
|
||||
get_pointer(iname,temp,source,target, p->t, f->code, (char*)"XSRETURN(1)");
|
||||
get_pointer(iname,temp,source,target, pt, f->code, (char*)"XSRETURN(1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -881,19 +885,19 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Check if there is any constraint code
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"perl5",p->t,p->name,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"perl5",pt,pn,source,target))) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
Replace(f->code,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
}
|
||||
need_save = 0;
|
||||
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"perl5",p->t,p->name,target,temp))) {
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"perl5",pt,pn,target,temp))) {
|
||||
Printf(cleanup,"%s\n", tm);
|
||||
Replace(cleanup,"$argnum",argnum,DOH_REPLACE_ANY);
|
||||
Replace(cleanup,"$arg",temp,DOH_REPLACE_ANY);
|
||||
need_save = 1;
|
||||
}
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"perl5",p->t,p->name,target,(char*)"ST(argvi)"))) {
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"perl5",pt,pn,target,(char*)"ST(argvi)"))) {
|
||||
DOHString *tempstr = NewString(tm);
|
||||
Replace(tempstr,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Replace(tempstr,"$arg",temp, DOH_REPLACE_ANY);
|
||||
|
|
@ -1052,15 +1056,16 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Parm *p = ParmList_first(l);
|
||||
int i = 0;
|
||||
while(p) {
|
||||
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (!p->ignore) {
|
||||
// Look up the datatype name here
|
||||
char sourceNtarget[256];
|
||||
sprintf(sourceNtarget,"$args[%d]",i);
|
||||
|
||||
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",p->t,(char*)"",sourceNtarget,sourceNtarget))) {
|
||||
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",pt,(char*)"",sourceNtarget,sourceNtarget))) {
|
||||
Printf(func,"%s\n", tm);
|
||||
} else if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
|
||||
} else if ((Getattr(classes,pt->name)) && (pt->is_pointer <= 1)) {
|
||||
if (i >= (pcount - numopt))
|
||||
Printf(func," if (scalar(@args) >= %d) {\n ", i);
|
||||
Printf(func," $args[%d] = tied(%%{$args[%d]});\n", i, i);
|
||||
|
|
@ -1530,14 +1535,16 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
|
|||
p = ParmList_first(l);
|
||||
i = 0;
|
||||
while (p != 0) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (!p->ignore) {
|
||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (strlen(p->name) > 0) {
|
||||
Printf(temp,"%s",p->name);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (strlen(pn) > 0) {
|
||||
Printf(temp,"%s",pn);
|
||||
} else {
|
||||
Printf(temp,"%s",DataType_print_type(p->t));
|
||||
Printf(temp,"%s",DataType_print_type(pt));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -1639,7 +1646,6 @@ static char fullclassname[1024] = "";
|
|||
void PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip) {
|
||||
|
||||
char temp[256];
|
||||
extern void typeeq_addtypedef(char *, char *, DataType *);
|
||||
|
||||
// Register this with the default class handler
|
||||
|
||||
|
|
@ -1885,18 +1891,19 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
p = ParmList_first(l);
|
||||
pcount = l->nparms;
|
||||
numopt = ParmList_numopt(l);
|
||||
numopt = check_numopt(l);
|
||||
i = 1;
|
||||
while(p) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
if (!p->ignore) {
|
||||
char sourceNtarget[512];
|
||||
sprintf(sourceNtarget, "$args[%d]", i);
|
||||
|
||||
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",p->t,(char*)"",sourceNtarget,sourceNtarget))) {
|
||||
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",pt,(char*)"",sourceNtarget,sourceNtarget))) {
|
||||
Printf(func,"%s\n",tm);
|
||||
}
|
||||
// Look up the datatype name here
|
||||
else if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
|
||||
else if ((Getattr(classes,pt->name)) && (pt->is_pointer <= 1)) {
|
||||
// Yep. This smells alot like an object, patch up the arguments
|
||||
|
||||
if (i >= (pcount - numopt))
|
||||
|
|
@ -2091,10 +2098,10 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
p = ParmList_first(l);
|
||||
i = 0;
|
||||
while(p) {
|
||||
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
// Look up the datatype name here
|
||||
|
||||
if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
|
||||
if ((Getattr(classes,pt->name)) && (pt->is_pointer <= 1)) {
|
||||
|
||||
// Yep. This smells alot like an object, patch up the arguments
|
||||
Printf(pcode, " $args[%d] = tied(%%{$args[%d]});\n", i, i);
|
||||
|
|
|
|||
|
|
@ -456,8 +456,7 @@ void PYTHON::close(void)
|
|||
// --------------------------------------------------------------------
|
||||
void PYTHON::close_cmodule(void)
|
||||
{
|
||||
extern void emit_type_table();
|
||||
emit_type_table();
|
||||
emit_type_table(f_runtime);
|
||||
/* emit_ptr_equivalence(f_init); */
|
||||
Printf(const_code, "{0}};\n");
|
||||
|
||||
|
|
@ -680,13 +679,16 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
i = 0;
|
||||
j = 0;
|
||||
numopt = ParmList_numopt(l); // Get number of optional arguments
|
||||
numopt = check_numopt(l); // Get number of optional arguments
|
||||
if (numopt) have_defarg = 1;
|
||||
p = ParmList_first(l);
|
||||
|
||||
Printf(kwargs,"{ ");
|
||||
while (p != 0) {
|
||||
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
char *pv = Parm_Getvalue(p);
|
||||
|
||||
// Generate source and target strings
|
||||
sprintf(source,"_obj%d",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
|
|
@ -702,15 +704,15 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Putc('|',parse_args);
|
||||
}
|
||||
|
||||
if (strlen(p->name)) {
|
||||
Printf(kwargs,"\"%s\",", p->name);
|
||||
if (strlen(pn)) {
|
||||
Printf(kwargs,"\"%s\",", pn);
|
||||
} else {
|
||||
Printf(kwargs,"\"arg%d\",", j+1);
|
||||
}
|
||||
|
||||
// Look for input typemap
|
||||
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"python",p->t,p->name,source,target,f))) {
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"python",pt,pn,source,target,f))) {
|
||||
Putc('O',parse_args);
|
||||
Wrapper_add_localv(f, source, "PyObject *",source,0);
|
||||
Printf(arglist,"&%s",source);
|
||||
|
|
@ -724,10 +726,10 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Check if this parameter is a pointer. If not, we'll get values
|
||||
|
||||
if (!p->t->is_pointer) {
|
||||
if (!pt->is_pointer) {
|
||||
// Extract a parameter by "value"
|
||||
|
||||
switch(p->t->type) {
|
||||
switch(pt->type) {
|
||||
|
||||
// Handle integers here. Usually this can be done as a single
|
||||
// case if you appropriate cast things. However, if you have
|
||||
|
|
@ -759,16 +761,16 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
{
|
||||
char tempb[128];
|
||||
char tempval[128];
|
||||
if (p->defvalue) {
|
||||
sprintf(tempval, "(int) %s", p->defvalue);
|
||||
if (pv) {
|
||||
sprintf(tempval, "(int) %s", pv);
|
||||
}
|
||||
sprintf(tempb,"tempbool%d",i);
|
||||
Putc('i',parse_args);
|
||||
if (!p->defvalue)
|
||||
if (!pv)
|
||||
Wrapper_add_localv(f,tempb,"int",tempb,0);
|
||||
else
|
||||
Wrapper_add_localv(f,tempb,"int",tempb, "=",tempval,0);
|
||||
Printv(get_pointers, tab4, target, " = ", DataType_print_cast(p->t), " ", tempb, ";\n", 0);
|
||||
Printv(get_pointers, tab4, target, " = ", DataType_print_cast(pt), " ", tempb, ";\n", 0);
|
||||
Printf(arglist,"&%s",tempb);
|
||||
}
|
||||
break;
|
||||
|
|
@ -787,20 +789,20 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unsupported data type
|
||||
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(p->t));
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(pt));
|
||||
break;
|
||||
}
|
||||
|
||||
// Emit code for parameter list
|
||||
|
||||
if ((p->t->type != T_VOID) && (p->t->type != T_BOOL))
|
||||
if ((pt->type != T_VOID) && (pt->type != T_BOOL))
|
||||
Printf(arglist,"&_arg%d",i);
|
||||
|
||||
} else {
|
||||
|
||||
// Is some other kind of variable.
|
||||
|
||||
if ((p->t->type == T_CHAR) && (p->t->is_pointer == 1)) {
|
||||
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
||||
Putc('s',parse_args);
|
||||
Printf(arglist,"&_arg%d",i);
|
||||
} else {
|
||||
|
|
@ -815,24 +817,24 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||
Printf(arglist,"&%s",source);
|
||||
get_pointer(iname, temp, source, target, p->t, get_pointers, (char*)"NULL");
|
||||
get_pointer(iname, temp, source, target, pt, get_pointers, (char*)"NULL");
|
||||
}
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
// Check if there was any constraint code
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"python",p->t,p->name,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"python",pt,pn,source,target))) {
|
||||
Printf(check,"%s\n",tm);
|
||||
Replace(check,"$argnum", argnum, DOH_REPLACE_ANY);
|
||||
}
|
||||
// Check if there was any cleanup code
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"python",p->t,p->name,target,source))) {
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"python",pt,pn,target,source))) {
|
||||
Printf(cleanup,"%s\n",tm);
|
||||
Replace(cleanup,"$argnum", argnum, DOH_REPLACE_ANY);
|
||||
Replace(cleanup,"$arg",source, DOH_REPLACE_ANY);
|
||||
}
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"python",p->t,p->name,target,(char*)"_resultobj"))) {
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"python",pt,pn,target,(char*)"_resultobj"))) {
|
||||
Printf(outarg,"%s\n", tm);
|
||||
Replace(outarg,"$argnum",argnum,DOH_REPLACE_ANY);
|
||||
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
||||
|
|
@ -1413,15 +1415,17 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (!p->ignore) {
|
||||
i++;
|
||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (strlen(p->name) > 0) {
|
||||
Printf(temp,"%s",p->name);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (strlen(pn) > 0) {
|
||||
Printf(temp,"%s",pn);
|
||||
} else {
|
||||
Printf(temp,"%s", DataType_print_type(p->t));
|
||||
Printf(temp,"%s", DataType_print_type(pt));
|
||||
}
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ void RUBY::initialize() {
|
|||
void RUBY::close(void) {
|
||||
// Finish off our init function
|
||||
Printf(f_init, "\n");
|
||||
emit_ptr_equivalence(f_init);
|
||||
emit_ptr_equivalence(f_wrappers,f_init);
|
||||
Printf(f_init,"}\n");
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +428,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
// Get number of arguments
|
||||
int numarg = ParmList_numarg(l);
|
||||
int numopt = ParmList_numopt(l);
|
||||
int numopt = check_numopt(l);
|
||||
int numignore = l->nparms - numarg;
|
||||
int start = 0;
|
||||
int use_self = 0;
|
||||
|
|
@ -511,6 +511,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
for (i = 0; i < pcount ; i++) {
|
||||
Parm *p = ParmList_get(l,i);
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Produce string representation of source and target arguments
|
||||
int selfp = (use_self && i == 0);
|
||||
|
|
@ -529,7 +531,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Get typemap for this argument
|
||||
tm = ruby_typemap_lookup((char*)"in",p->t,p->name,source,target,f);
|
||||
tm = ruby_typemap_lookup((char*)"in",pt,pn,source,target,f);
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s,tab);
|
||||
|
|
@ -538,7 +540,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
Delete(s);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n",
|
||||
input_file,line_number, DataType_print_type(p->t));
|
||||
input_file,line_number, DataType_print_type(pt));
|
||||
}
|
||||
if (j >= (pcount-numopt))
|
||||
Printv(f->code, tab4, "} \n");
|
||||
|
|
@ -546,7 +548,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Check to see if there was any sort of a constaint typemap
|
||||
tm = ruby_typemap_lookup((char*)"check",p->t,p->name,source,target);
|
||||
tm = ruby_typemap_lookup((char*)"check",pt,pn,source,target);
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
|
|
@ -556,7 +558,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Check if there was any cleanup code (save it for later)
|
||||
tm = ruby_typemap_lookup((char*)"freearg",p->t,p->name,target,source);
|
||||
tm = ruby_typemap_lookup((char*)"freearg",pt,pn,target,source);
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
|
|
@ -565,7 +567,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
Delete(s);
|
||||
}
|
||||
|
||||
tm = ruby_typemap_lookup((char*)"argout",p->t,p->name,target,(char*)"vresult");
|
||||
tm = ruby_typemap_lookup((char*)"argout",pt,pn,target,(char*)"vresult");
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
|
|
|
|||
|
|
@ -380,7 +380,6 @@ void TCL8::initialize()
|
|||
|
||||
void TCL8::close(void)
|
||||
{
|
||||
extern void emit_type_table();
|
||||
Printv(cmd_info, tab4, "{0, 0, 0}\n", "};\n",0);
|
||||
|
||||
Printv(var_info, tab4, "{0,0,0,0}\n", "};\n",0);
|
||||
|
|
@ -400,7 +399,7 @@ void TCL8::close(void)
|
|||
|
||||
// Dump the pointer equivalency table
|
||||
|
||||
emit_type_table();
|
||||
emit_type_table(f_runtime);
|
||||
|
||||
// emit_ptr_equivalence(f_init);
|
||||
|
||||
|
|
@ -494,7 +493,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Print out variables for storing arguments.
|
||||
|
||||
pcount = emit_args(d, l, f);
|
||||
numopt = ParmList_numopt(l);
|
||||
numopt = check_numopt(l);
|
||||
|
||||
// Create a local variable for holding the interpreter result value
|
||||
|
||||
|
|
@ -509,6 +508,9 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
j = 0;
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
char *pv = Parm_Getvalue(p);
|
||||
// Produce string representations of the source and target arguments
|
||||
sprintf(source,"objv[%d]",j+1);
|
||||
sprintf(target,"_arg%d",i);
|
||||
|
|
@ -520,7 +522,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
if (j == (pcount-numopt))
|
||||
Putc('|',argstr);
|
||||
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"tcl8",p->t,p->name,source,target,f))) {
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"tcl8",pt,pn,source,target,f))) {
|
||||
Putc('o',argstr);
|
||||
Printf(args,",0");
|
||||
|
||||
|
|
@ -529,11 +531,11 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Replace(incode,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Replace(incode,"$arg",source, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
if (!p->t->is_pointer) {
|
||||
if (!pt->is_pointer) {
|
||||
|
||||
// Extract a parameter by value.
|
||||
|
||||
switch(p->t->type) {
|
||||
switch(pt->type) {
|
||||
|
||||
// Signed Integers
|
||||
|
||||
|
|
@ -600,7 +602,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d: Unable to use type %s as a function argument.\n",
|
||||
input_file, line_number, DataType_print_type(p->t));
|
||||
input_file, line_number, DataType_print_type(pt));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -608,13 +610,13 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Function argument is some sort of pointer
|
||||
// Look for a string. Otherwise, just pull off a pointer.
|
||||
|
||||
if ((p->t->type == T_CHAR) && (p->t->is_pointer == 1)) {
|
||||
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
||||
Putc('s',argstr);
|
||||
Printf(args,",&%s",target);
|
||||
} else {
|
||||
DataType_remember(p->t);
|
||||
DataType_remember(pt);
|
||||
Putc('p',argstr);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", DataType_print_mangle(p->t), 0);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", DataType_print_mangle(pt), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -622,7 +624,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Check to see if there was any sort of a constaint typemap
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"tcl8",p->t,p->name,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"tcl8",pt,pn,source,target))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(incode,"%s\n", tm);
|
||||
Replace(incode,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
|
|
@ -630,14 +632,14 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Check if there was any cleanup code (save it for later)
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"tcl8",p->t,p->name,target,(char*)"tcl_result"))) {
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"tcl8",pt,pn,target,(char*)"tcl_result"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(cleanup,"%s\n", tm);
|
||||
Replace(cleanup,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Replace(cleanup,"$arg",source,DOH_REPLACE_ANY);
|
||||
}
|
||||
// Look for output arguments
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"tcl8",p->t,p->name,target,(char*)"tcl_result"))) {
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"tcl8",pt,pn,target,(char*)"tcl_result"))) {
|
||||
Printf(outarg,"%s\n", tm);
|
||||
Replace(outarg,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
||||
|
|
@ -1139,24 +1141,27 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
|||
/* Now go through and print parameters */
|
||||
i = 0;
|
||||
pcount = l->nparms;
|
||||
numopt = ParmList_numopt(l);
|
||||
numopt = check_numopt(l);
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
|
||||
// Only print an argument if not ignored
|
||||
|
||||
if (!typemap_check((char*)"ignore",(char*)"tcl8",p->t,p->name)) {
|
||||
if (!typemap_check((char*)"ignore",(char*)"tcl8",pt,pn)) {
|
||||
if (i >= (pcount-numopt))
|
||||
Putc('?',temp);
|
||||
|
||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (strlen(p->name) > 0) {
|
||||
Printf(temp,p->name);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (strlen(pn) > 0) {
|
||||
Printf(temp,pn);
|
||||
}
|
||||
else {
|
||||
Printf(temp,"{ %s }", DataType_print_type(p->t));
|
||||
Printf(temp,"{ %s }", DataType_print_type(pt));
|
||||
}
|
||||
}
|
||||
if (i >= (pcount-numopt))
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ RANLIB = @RANLIB@
|
|||
|
||||
TARGET = libswig11.a
|
||||
|
||||
OBJS = parser.o main.o scanner.o types.o parms.o \
|
||||
OBJS = parser.o main.o scanner.o \
|
||||
emit.o cplus.o lang.o sstring.o typemap.o
|
||||
|
||||
SRCS = main.cxx scanner.cxx types.cxx parms.cxx \
|
||||
SRCS = main.cxx scanner.cxx \
|
||||
emit.cxx cplus.cxx lang.cxx \
|
||||
sstring.cxx typemap.cxx
|
||||
|
||||
|
|
|
|||
|
|
@ -155,16 +155,18 @@ static void update_parms(ParmList *l) {
|
|||
Parm *p;
|
||||
p = ParmList_first(l);
|
||||
while (p) {
|
||||
update_local_type(p->t);
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pvalue = Parm_Getvalue(p);
|
||||
|
||||
update_local_type(pt);
|
||||
|
||||
// Check for default arguments
|
||||
|
||||
if ((p->defvalue) && (localtypes)) {
|
||||
if ((pvalue) && (localtypes)) {
|
||||
char *s;
|
||||
s = (char *) GetChar(localtypes,p->defvalue);
|
||||
s = (char *) GetChar(localtypes,pvalue);
|
||||
if (s) {
|
||||
delete p->defvalue;
|
||||
p->defvalue = copy_string(s);
|
||||
Parm_Setvalue(p,s);
|
||||
}
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
|
|
@ -714,7 +716,6 @@ char *cplus_base_class(char *name) {
|
|||
|
||||
void cplus_open_class(char *name, char *rname, char *ctype) {
|
||||
|
||||
extern void typeeq_derived(char *, char *, char *cast=0);
|
||||
char temp[256];
|
||||
CPP_class *c;
|
||||
|
||||
|
|
@ -756,8 +757,8 @@ void cplus_open_class(char *name, char *rname, char *ctype) {
|
|||
if (strlen(name)) {
|
||||
if (strlen(ctype) > 0) {
|
||||
sprintf(temp,"%s %s", ctype, name);
|
||||
typeeq_derived(temp,name); // Map "struct foo" to "foo"
|
||||
typeeq_derived(name,temp); // Map "foo" to "struct foo"
|
||||
typeeq_derived(temp,name,0); // Map "struct foo" to "foo"
|
||||
typeeq_derived(name,temp,0); // Map "foo" to "struct foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -952,7 +953,6 @@ void cplus_generate_types(char **baseclass) {
|
|||
DOHString *cfunc;
|
||||
DOHString *temp3;
|
||||
char temp1[512], temp2[512];
|
||||
extern void typeeq_derived(char *, char *, char *);
|
||||
|
||||
if (!baseclass) {
|
||||
return;
|
||||
|
|
@ -1544,7 +1544,8 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
Printf(wrap,",_swigarg%d",i);
|
||||
i++;
|
||||
}
|
||||
|
|
@ -1560,8 +1561,9 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while(p != 0) {
|
||||
if (ObjCClass) Printf(wrap," %s", p->objc_separator);
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
/* if (ObjCClass) Printf(wrap," %s", p->objc_separator); */
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
Printf(wrap,"_swigarg%d",i);
|
||||
i++;
|
||||
}
|
||||
|
|
@ -1593,18 +1595,19 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
Printf(wrap,",");
|
||||
if ((p->call_type & CALL_REFERENCE) || (p->t->is_reference)) {
|
||||
p->t->is_pointer--;
|
||||
if ((p->call_type & CALL_REFERENCE) || (pt->is_reference)) {
|
||||
pt->is_pointer--;
|
||||
}
|
||||
Printf(wrap, DataType_print_full(p->t));
|
||||
if ((p->call_type & CALL_REFERENCE) || (p->t->is_reference)) {
|
||||
p->t->is_pointer++;
|
||||
if (p->t->is_reference)
|
||||
Printf(wrap, DataType_print_full(pt));
|
||||
if ((p->call_type & CALL_REFERENCE) || (pt->is_reference)) {
|
||||
pt->is_pointer++;
|
||||
if (pt->is_reference)
|
||||
Printf(wrap,"&");
|
||||
}
|
||||
Printf(wrap," %s", p->name);
|
||||
Printf(wrap," %s", Parm_Getname(p));
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
}
|
||||
|
|
@ -1618,14 +1621,17 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
|
||||
newparms = CopyParmList(l);
|
||||
p = NewParm(0,0);
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
{
|
||||
DataType *pt = NewDataType(0);
|
||||
pt->type = T_USER;
|
||||
sprintf(pt->name,"%s%s", classtype,classname);
|
||||
pt->is_pointer = 1;
|
||||
pt->id = cpp_id;
|
||||
Parm_Settype(p,pt);
|
||||
DelDataType(pt);
|
||||
}
|
||||
p->call_type = 0;
|
||||
|
||||
sprintf(p->t->name,"%s%s", classtype,classname);
|
||||
p->name = (char*)"self";
|
||||
Parm_Setname(p,(char*)"self");
|
||||
ParmList_insert(newparms,p,0); // Attach parameter to beginning of list
|
||||
|
||||
// Now wrap the thing. The name of the function is iname
|
||||
|
|
@ -1762,16 +1768,17 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
// Walk down the parameter list and Spit out arguments
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (p->t->is_reference) {
|
||||
p->t->is_pointer--;
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (pt->is_reference) {
|
||||
pt->is_pointer--;
|
||||
}
|
||||
Printf(wrap, DataType_print_full(p->t));
|
||||
if (p->t->is_reference) {
|
||||
p->t->is_pointer++;
|
||||
Printf(wrap, DataType_print_full(pt));
|
||||
if (pt->is_reference) {
|
||||
pt->is_pointer++;
|
||||
Printf(wrap, "&");
|
||||
}
|
||||
Printf(wrap," %s", p->name);
|
||||
Printf(wrap," %s", Parm_Getname(p));
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
if (p) Printf(wrap, ",");
|
||||
|
|
@ -1802,12 +1809,14 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while(p != 0) {
|
||||
Printf(wrap," %s", p->objc_separator);
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (p->t->is_reference) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
/*Printf(wrap," %s", p->objc_separator); */
|
||||
Printf(wrap," ");
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (pt->is_reference) {
|
||||
Printf(wrap,"*");
|
||||
}
|
||||
Printf(wrap,p->name);
|
||||
Printf(wrap,Parm_Getname(p));
|
||||
i++;
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
|
|
@ -1914,13 +1923,17 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
{
|
||||
DataType *pt = NewDataType(0);
|
||||
pt->type = T_USER;
|
||||
pt->is_pointer = 1;
|
||||
pt->id = cpp_id;
|
||||
sprintf(pt->name,"%s%s", classtype, classname);
|
||||
Parm_Settype(p,pt);
|
||||
DelDataType(pt);
|
||||
}
|
||||
p->call_type = 0;
|
||||
sprintf(p->t->name,"%s%s", classtype, classname);
|
||||
p->name = (char*)"self";
|
||||
Parm_Setname(p,(char*)"self");
|
||||
ParmList_insert(l,p,0);
|
||||
|
||||
type = NewDataType(0);
|
||||
|
|
@ -2009,8 +2022,9 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if (ObjCClass) Printf(fcall," %s", p->objc_separator);
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
/* if (ObjCClass) Printf(fcall," %s", p->objc_separator); */
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
Printf(wrap,"_swigarg%d",i);
|
||||
|
||||
// Emit an argument in the function call if in C++ mode
|
||||
|
|
@ -2041,13 +2055,15 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
if (p->call_type & CALL_REFERENCE) {
|
||||
p->t->is_pointer--;
|
||||
pt->is_pointer--;
|
||||
}
|
||||
Printf(wrap, DataType_print_real(p->t,p->name));
|
||||
Printf(wrap, DataType_print_real(pt,Parm_Getname(p)));
|
||||
if (p->call_type & CALL_REFERENCE) {
|
||||
p->t->is_pointer++;
|
||||
pt->is_pointer++;
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
if (p) {
|
||||
|
|
@ -2226,13 +2242,18 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
{
|
||||
DataType *pt = NewDataType(0);
|
||||
pt->type = T_USER;
|
||||
pt->is_pointer = 1;
|
||||
pt->id = cpp_id;
|
||||
sprintf(pt->name,"%s%s", classtype,classname);
|
||||
Parm_Settype(p,pt);
|
||||
DelDataType(pt);
|
||||
}
|
||||
Parm_Setname(p,(char*)"self");
|
||||
p->call_type = 0;
|
||||
p->name = (char*)"self";
|
||||
sprintf(p->t->name,"%s%s", classtype,classname);
|
||||
|
||||
ParmList_insert(l,p,0);
|
||||
|
||||
if ((type->type == T_USER) && (!type->is_pointer)) {
|
||||
|
|
@ -2446,24 +2467,32 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = CopyDataType(type);
|
||||
p->t->is_reference = 0;
|
||||
{
|
||||
DataType *pt = CopyDataType(type);
|
||||
pt->is_reference = 0;
|
||||
pt->id = cpp_id;
|
||||
if ((type->type == T_USER) && (!type->is_pointer)) pt->is_pointer++;
|
||||
Parm_Settype(p,pt);
|
||||
DelDataType(pt);
|
||||
}
|
||||
p->call_type = 0;
|
||||
p->t->id = cpp_id;
|
||||
if ((type->type == T_USER) && (!type->is_pointer)) p->t->is_pointer++;
|
||||
if (mrename)
|
||||
p->name = mrename;
|
||||
Parm_Setname(p,mrename);
|
||||
else
|
||||
p->name = mname;
|
||||
Parm_Setname(p,mname);
|
||||
ParmList_insert(l,p,0);
|
||||
p = NewParm(0,0);
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
{
|
||||
DataType *pt = NewDataType(0);
|
||||
pt->type = T_USER;
|
||||
pt->is_pointer = 1;
|
||||
pt->id = cpp_id;
|
||||
sprintf(pt->name,"%s%s", classtype,classname);
|
||||
Parm_Settype(p,pt);
|
||||
DelDataType(pt);
|
||||
}
|
||||
p->call_type = 0;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
sprintf(p->t->name,"%s%s", classtype,classname);
|
||||
p->name = (char*)"self";
|
||||
Parm_Setname(p,(char*)"self");
|
||||
ParmList_insert(l,p,0);
|
||||
|
||||
if ((type->type == T_USER) && (!type->is_pointer)) {
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
Parm *p;
|
||||
int i;
|
||||
char *tm;
|
||||
|
||||
DataType *pt;
|
||||
// Declare the return variable
|
||||
|
||||
if ((rt->type != T_VOID) || (rt->is_pointer)) {
|
||||
|
|
@ -213,35 +213,38 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while (p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
pt = Parm_Gettype(p);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||
char *temp = emit_local(i);
|
||||
// Figure out default values
|
||||
if (((p->t->is_reference) && (p->defvalue)) ||
|
||||
((p->t->type == T_USER) && (p->call_type == CALL_REFERENCE) && (p->defvalue))) {
|
||||
Wrapper_add_localv(f,temp, DataType_print_type(p->t), temp," = (", DataType_print_type(p->t), ") &", p->defvalue,0);
|
||||
char *pvalue = Parm_Getvalue(p);
|
||||
char *pname = Parm_Getname(p);
|
||||
if (((pt->is_reference) && (pvalue)) ||
|
||||
((pt->type == T_USER) && (p->call_type == CALL_REFERENCE) && (pvalue))) {
|
||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp," = (", DataType_print_type(pt), ") &", pvalue,0);
|
||||
} else {
|
||||
char deftmp[1024];
|
||||
if (p->defvalue) {
|
||||
Wrapper_add_localv(f,temp, DataType_print_type(p->t), temp, " = (", DataType_print_type(p->t), ") ", p->defvalue, 0);
|
||||
if (pvalue) {
|
||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp, " = (", DataType_print_type(pt), ") ", pvalue, 0);
|
||||
} else {
|
||||
Wrapper_add_localv(f,temp, DataType_print_type(p->t), temp, 0);
|
||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp, 0);
|
||||
}
|
||||
|
||||
tm = typemap_lookup((char*)"arginit", typemap_lang, p->t,p->name,(char*)"",temp,f);
|
||||
tm = typemap_lookup((char*)"arginit", typemap_lang, pt,pname,(char*)"",temp,f);
|
||||
if (tm) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
}
|
||||
}
|
||||
// Check for ignore or default typemaps
|
||||
tm = typemap_lookup((char*)"default",typemap_lang,p->t,p->name,(char*)"",temp,f);
|
||||
tm = typemap_lookup((char*)"default",typemap_lang,pt,pname,(char*)"",temp,f);
|
||||
if (tm)
|
||||
Printv(f->code,tm,"\n",0);
|
||||
tm = typemap_lookup((char*)"ignore",typemap_lang,p->t,p->name,(char*)"",temp,f);
|
||||
tm = typemap_lookup((char*)"ignore",typemap_lang,pt,pname,(char*)"",temp,f);
|
||||
if (tm) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
p->ignore = 1;
|
||||
}
|
||||
tm = typemap_check((char*)"build",typemap_lang,p->t,p->name);
|
||||
tm = typemap_check((char*)"build",typemap_lang,pt,pname);
|
||||
if (tm) {
|
||||
p->ignore = 1;
|
||||
}
|
||||
|
|
@ -316,12 +319,13 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
|||
i = 0;
|
||||
p = ParmList_first(l);
|
||||
while(p != 0) {
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)){
|
||||
Printf(fcall,DataType_print_arraycast(p->t));
|
||||
if ((!p->t->is_reference) && (p->call_type & CALL_VALUE))
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer)){
|
||||
Printf(fcall,DataType_print_arraycast(pt));
|
||||
if ((!pt->is_reference) && (p->call_type & CALL_VALUE))
|
||||
Printf(fcall, "&");
|
||||
if ((!(p->call_type & CALL_VALUE)) &&
|
||||
((p->t->is_reference) || (p->call_type & CALL_REFERENCE)))
|
||||
((pt->is_reference) || (p->call_type & CALL_REFERENCE)))
|
||||
Printf(fcall, "*");
|
||||
Printf(fcall, emit_local(i));
|
||||
i++;
|
||||
|
|
@ -458,9 +462,9 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(t,0);
|
||||
if ((t->type == T_USER) && (!t->is_pointer)) p->t->is_pointer++;
|
||||
p->name = new char[1];
|
||||
p->name[0] = 0;
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
if ((t->type == T_USER) && (!t->is_pointer)) pt->is_pointer++;
|
||||
Parm_Setname(p,(char*)"");
|
||||
ParmList_append(l,p);
|
||||
|
||||
new_name = copy_string(Swig_name_set(name));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ extern int ForceExtern;
|
|||
extern int WrapExtern;
|
||||
extern void *CCode;
|
||||
extern int GenerateDefault;
|
||||
extern int type_id;
|
||||
extern char *objc_construct;
|
||||
extern char *objc_destruct;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ extern "C" {
|
|||
char *Config = 0;
|
||||
int NoInclude = 0;
|
||||
char *typemap_lang = 0; // Typemap name
|
||||
int type_id = 0; // Type identifier
|
||||
int error_count = 0; // Error count
|
||||
int Verbose = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,380 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* parms.cxx
|
||||
*
|
||||
* Parameter list class.
|
||||
*
|
||||
* 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 "internal.h"
|
||||
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// NewParm()
|
||||
//
|
||||
// Create a new parameter from datatype 'type' and name 'n'.
|
||||
// Copies will be made of type and n, unless they aren't specified.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Parm *NewParm(DataType *type, char *n) {
|
||||
Parm *p = (Parm *) malloc(sizeof(Parm));
|
||||
if (type) {
|
||||
p->t = CopyDataType(type);
|
||||
} else {
|
||||
p->t = 0;
|
||||
}
|
||||
p->name = copy_string(n);
|
||||
p->call_type = 0;
|
||||
p->defvalue = 0;
|
||||
p->ignore = 0;
|
||||
p->objc_separator = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// CopyParm(Parm *p)
|
||||
//
|
||||
// Make a copy of a parameter
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Parm *CopyParm(Parm *p) {
|
||||
Parm *np = (Parm *) malloc(sizeof(Parm));
|
||||
if (p->t) np->t = CopyDataType(p->t);
|
||||
np->name = copy_string(p->name);
|
||||
np->call_type = p->call_type;
|
||||
np->defvalue = copy_string(p->defvalue);
|
||||
np->ignore = p->ignore;
|
||||
np->objc_separator = copy_string(p->objc_separator);
|
||||
return np;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// DelParm()
|
||||
//
|
||||
// Destroy a parameter
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void DelParm(Parm *p) {
|
||||
if (p->t) DelDataType(p->t);
|
||||
if (p->name) delete p->name;
|
||||
if (p->defvalue) delete p->defvalue;
|
||||
if (p->objc_separator) delete p->objc_separator;
|
||||
free(p);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// NewParmList()
|
||||
//
|
||||
// Create a new (empty) parameter list
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
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()
|
||||
//
|
||||
// Make a copy of parameter list
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
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()
|
||||
//
|
||||
// Delete a parameter list
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void DelParmList(ParmList *l) {
|
||||
int i;
|
||||
for (i = 0; i < l->maxparms; i++) {
|
||||
if (l->parms[i]) DelParm(l->parms[i]);
|
||||
}
|
||||
free(l->parms);
|
||||
free(l);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// moreparms() (PRIVATE)
|
||||
//
|
||||
// Doubles the amount of parameter memory available.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
//
|
||||
// Add a new parameter to the end of a parameter list
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void ParmList_append(ParmList *l, Parm *p) {
|
||||
|
||||
if (l->nparms == l->maxparms) moreparms(l);
|
||||
|
||||
// Add parm onto the end
|
||||
|
||||
l->parms[l->nparms] = CopyParm(p);
|
||||
l->nparms++;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// void ParmList_insert()
|
||||
//
|
||||
// Inserts a parameter at position pos. Parameters are inserted
|
||||
// *before* any existing parameter at position pos.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void ParmList_insert(ParmList *l, Parm *p, int pos) {
|
||||
|
||||
// If pos is out of range, we'd better fix it
|
||||
|
||||
if (pos < 0) pos = 0;
|
||||
if (pos > 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 (int 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()
|
||||
//
|
||||
// Deletes the parameter at position pos.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void ParmList_del(ParmList *l, int pos) {
|
||||
|
||||
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 (int i = pos; i < l->nparms-1; i++) {
|
||||
l->parms[i] = l->parms[i+1];
|
||||
}
|
||||
l->nparms--;
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Parm *ParmList_get(ParmList *l, int pos)
|
||||
//
|
||||
// Gets the parameter at location pos. Returns 0 if invalid
|
||||
// position.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
Parm *ParmList_get(ParmList *l, int pos) {
|
||||
|
||||
if ((pos < 0) || (pos >= l->nparms)) return 0;
|
||||
return l->parms[pos];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// int ParmList_numopt()
|
||||
//
|
||||
// Gets the number of optional arguments.
|
||||
// ------------------------------------------------------------------
|
||||
int ParmList_numopt(ParmList *l) {
|
||||
int n = 0;
|
||||
int state = 0;
|
||||
|
||||
for (int i = 0; i < l->nparms; i++) {
|
||||
if (l->parms[i]->defvalue) {
|
||||
n++;
|
||||
state = 1;
|
||||
} else if (typemap_check((char*)"default",typemap_lang,l->parms[i]->t,l->parms[i]->name)) {
|
||||
n++;
|
||||
state = 1;
|
||||
} else if (typemap_check((char*)"ignore",typemap_lang,l->parms[i]->t,l->parms[i]->name)) {
|
||||
n++;
|
||||
} else {
|
||||
if (state) {
|
||||
fprintf(stderr,"%s : Line %d. Argument %d must have a default value!\n", input_file,line_number,i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// int ParmList::numarg()
|
||||
//
|
||||
// Gets the number of arguments
|
||||
// ------------------------------------------------------------------
|
||||
int ParmList_numarg(ParmList *l) {
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < l->nparms; i++) {
|
||||
if (!l->parms[i]->ignore)
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Parm * ParmList_first()
|
||||
//
|
||||
// Returns the first item on a parameter list.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
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()
|
||||
//
|
||||
// Returns the next item on the parameter list.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
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. Has to do some
|
||||
// manipulation of pointer types depending on how the call_type
|
||||
// variable has been set.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ParmList_print_types(ParmList *l, DOHFile *f) {
|
||||
|
||||
int is_pointer;
|
||||
int pn;
|
||||
pn = 0;
|
||||
while(pn < l->nparms) {
|
||||
is_pointer = l->parms[pn]->t->is_pointer;
|
||||
if (l->parms[pn]->t->is_reference) {
|
||||
if (l->parms[pn]->t->is_pointer) {
|
||||
l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s&", DataType_print_real(l->parms[pn]->t,0));
|
||||
l->parms[pn]->t->is_pointer++;
|
||||
} else {
|
||||
Printf(f,"%s&", DataType_print_real(l->parms[pn]->t,0));
|
||||
}
|
||||
} else {
|
||||
if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
|
||||
if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s", DataType_print_real(l->parms[pn]->t,0));
|
||||
l->parms[pn]->t->is_pointer = is_pointer;
|
||||
}
|
||||
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 is_pointer;
|
||||
int pn;
|
||||
pn = 0;
|
||||
while(pn < l->nparms) {
|
||||
is_pointer = l->parms[pn]->t->is_pointer;
|
||||
if (l->parms[pn]->t->is_reference) {
|
||||
if (l->parms[pn]->t->is_pointer) {
|
||||
l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s&", DataType_print_full(l->parms[pn]->t));
|
||||
l->parms[pn]->t->is_pointer++;
|
||||
} else {
|
||||
Printf(f,"%s&", DataType_print_full(l->parms[pn]->t));
|
||||
}
|
||||
} else {
|
||||
if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
|
||||
if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
|
||||
Printf(f,"%s", DataType_print_full(l->parms[pn]->t));
|
||||
l->parms[pn]->t->is_pointer = is_pointer;
|
||||
}
|
||||
Printf(f,"%s",l->parms[pn]->name);
|
||||
pn++;
|
||||
if (pn < l->nparms)
|
||||
Printf(f,",");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -939,7 +939,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
skip_brace();
|
||||
p = $7;
|
||||
while (p) {
|
||||
typemap_register($5,$3,p->p->t,p->p->name,Char(CCode),p->args);
|
||||
typemap_register($5,$3,Parm_Gettype(p->p),Parm_Getname(p->p),Char(CCode),p->args);
|
||||
p = p->next;
|
||||
}
|
||||
delete $3;
|
||||
|
|
@ -957,7 +957,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
skip_brace();
|
||||
p = $5;
|
||||
while (p) {
|
||||
typemap_register($3,typemap_lang,p->p->t,p->p->name,Char(CCode),p->args);
|
||||
typemap_register($3,typemap_lang,Parm_Gettype(p->p),Parm_Getname(p->p),Char(CCode),p->args);
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
|
@ -970,7 +970,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
TMParm *p;
|
||||
p = $7;
|
||||
while (p) {
|
||||
typemap_clear($5,$3,p->p->t,p->p->name);
|
||||
typemap_clear($5,$3,Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
delete $3;
|
||||
|
|
@ -987,7 +987,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
TMParm *p;
|
||||
p = $5;
|
||||
while (p) {
|
||||
typemap_clear($3,typemap_lang,p->p->t,p->p->name);
|
||||
typemap_clear($3,typemap_lang,Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
|
@ -1000,7 +1000,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
TMParm *p;
|
||||
p = $7;
|
||||
while (p) {
|
||||
typemap_copy($5,$3,$9->p->t,$9->p->name,p->p->t,p->p->name);
|
||||
typemap_copy($5,$3,Parm_Gettype($9->p),Parm_Getname($9->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
delete $3;
|
||||
|
|
@ -1020,7 +1020,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
TMParm *p;
|
||||
p = $5;
|
||||
while (p) {
|
||||
typemap_copy($3,typemap_lang,$7->p->t,$7->p->name,p->p->t,p->p->name);
|
||||
typemap_copy($3,typemap_lang,Parm_Gettype($7->p),Parm_Getname($7->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
|
@ -1036,7 +1036,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
TMParm *p;
|
||||
p = $4;
|
||||
while(p) {
|
||||
typemap_apply($2->p->t,$2->p->name,p->p->t,p->p->name);
|
||||
typemap_apply(Parm_Gettype($2->p),Parm_Getname($2->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
delete $4;
|
||||
|
|
@ -1047,7 +1047,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
TMParm *p;
|
||||
p = $2;
|
||||
while (p) {
|
||||
typemap_clear_apply(p->p->t, p->p->name);
|
||||
typemap_clear_apply(Parm_Gettype(p->p), Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
|
@ -1333,7 +1333,8 @@ func_end : cpp_const LBRACE { skip_brace(); }
|
|||
------------------------------------------------------------------------------ */
|
||||
|
||||
parms : parm ptail {
|
||||
if (($1->t->type != T_VOID) || ($1->t->is_pointer))
|
||||
DataType *pt = Parm_Gettype($1);
|
||||
if ((pt->type != T_VOID) || (pt->is_pointer))
|
||||
ParmList_insert($2,$1,0);
|
||||
$$ = $2;
|
||||
DelParm($1);
|
||||
|
|
@ -1351,7 +1352,7 @@ ptail : COMMA parm ptail {
|
|||
|
||||
parm : parm_type {
|
||||
$$ = $1;
|
||||
if (typemap_check((char *)"ignore",typemap_lang,$$->t,$$->name))
|
||||
if (typemap_check((char *)"ignore",typemap_lang,Parm_Gettype($$),Parm_Getname($$)))
|
||||
$$->ignore = 1;
|
||||
}
|
||||
| parm_specifier_list parm_type {
|
||||
|
|
@ -1361,11 +1362,12 @@ parm : parm_type {
|
|||
fprintf(stderr,"%s : Line %d. Error. Can't use %%val with an array.\n", input_file, line_number);
|
||||
FatalError();
|
||||
}
|
||||
if (!$$->t->is_pointer) {
|
||||
DataType *pt = Parm_Gettype($$);
|
||||
if (!pt->is_pointer) {
|
||||
fprintf(stderr,"%s : Line %d. Error. Can't use %%val or %%out with a non-pointer argument.\n", input_file, line_number);
|
||||
FatalError();
|
||||
} else {
|
||||
$$->t->is_pointer--;
|
||||
pt->is_pointer--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1377,10 +1379,10 @@ parm_type : type pname {
|
|||
}
|
||||
$$ = NewParm($1,$2);
|
||||
$$->call_type = 0;
|
||||
$$->defvalue = DefArg;
|
||||
Parm_Setvalue($$,DefArg);
|
||||
if (($1->type == T_USER) && !($1->is_pointer)) {
|
||||
$$->call_type = CALL_REFERENCE;
|
||||
$$->t->is_pointer++;
|
||||
Parm_Gettype($$)->is_pointer++;
|
||||
}
|
||||
DelDataType($1);
|
||||
delete $2;
|
||||
|
|
@ -1388,13 +1390,13 @@ parm_type : type pname {
|
|||
|
||||
| type stars pname {
|
||||
$$ = NewParm($1,$3);
|
||||
$$->t->is_pointer += $2;
|
||||
Parm_Gettype($$)->is_pointer+=$2;
|
||||
$$->call_type = 0;
|
||||
$$->defvalue = DefArg;
|
||||
Parm_Setvalue($$,DefArg);
|
||||
if (InArray) {
|
||||
$$->t->is_pointer++;
|
||||
Parm_Gettype($$)->is_pointer++;
|
||||
// Add array string to the type
|
||||
DataType_set_arraystr($$->t, Char(ArrayString));
|
||||
DataType_set_arraystr(Parm_Gettype($$), Char(ArrayString));
|
||||
}
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
|
|
@ -1402,10 +1404,11 @@ parm_type : type pname {
|
|||
|
||||
| type AND pname {
|
||||
$$ = NewParm($1,$3);
|
||||
$$->t->is_reference = 1;
|
||||
DataType *pt = Parm_Gettype($$);
|
||||
pt->is_reference = 1;
|
||||
$$->call_type = 0;
|
||||
$$->t->is_pointer++;
|
||||
$$->defvalue = DefArg;
|
||||
pt->is_pointer++;
|
||||
Parm_Setvalue($$,DefArg);
|
||||
if (!CPlusPlus) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
||||
}
|
||||
|
|
@ -1416,9 +1419,10 @@ parm_type : type pname {
|
|||
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
|
||||
FatalError();
|
||||
$$ = NewParm($1,$4);
|
||||
$$->t->type = T_ERROR;
|
||||
$$->name = copy_string($4);
|
||||
strcpy($$->t->name,"<function ptr>");
|
||||
DataType *pt = Parm_Gettype($$);
|
||||
pt->type = T_ERROR;
|
||||
Parm_Setname($$,$4);
|
||||
strcpy(pt->name,"<function ptr>");
|
||||
DelDataType($1);
|
||||
delete $4;
|
||||
DelParmList($7);
|
||||
|
|
@ -1426,9 +1430,10 @@ parm_type : type pname {
|
|||
| PERIOD PERIOD PERIOD {
|
||||
fprintf(stderr,"%s : Line %d. Variable length arguments not supported (ignored).\n", input_file, line_number);
|
||||
$$ = NewParm(NewDataType(T_INT),(char *) "varargs");
|
||||
$$->t->type = T_ERROR;
|
||||
$$->name = copy_string((char*)"varargs");
|
||||
strcpy($$->t->name,"<varargs>");
|
||||
DataType *pt = Parm_Gettype($$);
|
||||
pt->type = T_ERROR;
|
||||
Parm_Setname($$,(char*)"varargs");
|
||||
strcpy(pt->name,"<varargs>");
|
||||
FatalError();
|
||||
}
|
||||
;
|
||||
|
|
@ -1437,9 +1442,9 @@ pname : ID def_args {
|
|||
$$ = $1;
|
||||
InArray = 0;
|
||||
if ($2.type == T_CHAR)
|
||||
DefArg = copy_string(ConstChar);
|
||||
DefArg = Swig_copy_string(ConstChar);
|
||||
else
|
||||
DefArg = copy_string($2.id);
|
||||
DefArg = Swig_copy_string($2.id);
|
||||
if ($2.id) delete $2.id;
|
||||
}
|
||||
| ID array {
|
||||
|
|
@ -1596,7 +1601,7 @@ type : TYPE_INT {
|
|||
}
|
||||
| CONST type {
|
||||
$$ = $2;
|
||||
DataType_set_qualifier($$,"const");
|
||||
DataType_set_qualifier($$,(char*)"const");
|
||||
}
|
||||
| cpptype ID {
|
||||
$$ = NewDataType(0);
|
||||
|
|
@ -1666,7 +1671,7 @@ strict_type : TYPE_INT {
|
|||
}
|
||||
| CONST type {
|
||||
$$ = $2;
|
||||
DataType_set_qualifier($$,"const");
|
||||
DataType_set_qualifier($$,(char*)"const");
|
||||
}
|
||||
| cpptype ID {
|
||||
$$ = NewDataType(0);
|
||||
|
|
@ -3147,7 +3152,7 @@ objc_ret_type : LPAREN type RPAREN {
|
|||
;
|
||||
|
||||
objc_arg_type : LPAREN parm RPAREN {
|
||||
$$ = CopyDataType($2->t);
|
||||
$$ = CopyDataType(Parm_Gettype($2));
|
||||
DelParm($2);
|
||||
}
|
||||
| empty {
|
||||
|
|
@ -3160,7 +3165,7 @@ objc_arg_type : LPAREN parm RPAREN {
|
|||
|
||||
objc_args : objc_args objc_separator objc_arg_type ID {
|
||||
Parm *p= NewParm($3,$4);
|
||||
p->objc_separator = $2;
|
||||
/* p->objc_separator = $2; */
|
||||
$$ = $1;
|
||||
ParmList_append($$,p);
|
||||
}
|
||||
|
|
@ -3258,11 +3263,12 @@ typemap_parm : type typemap_name {
|
|||
| type stars typemap_name {
|
||||
$$ = new TMParm;
|
||||
$$->p = NewParm($1,$3);
|
||||
$$->p->t->is_pointer += $2;
|
||||
DataType *pt = Parm_Gettype($$->p);
|
||||
pt->is_pointer += $2;
|
||||
$$->p->call_type = 0;
|
||||
if (InArray) {
|
||||
$$->p->t->is_pointer++;
|
||||
DataType_set_arraystr($$->p->t,Char(ArrayString));
|
||||
pt->is_pointer++;
|
||||
DataType_set_arraystr(pt,Char(ArrayString));
|
||||
}
|
||||
$$->args = tm_parm;
|
||||
DelDataType($1);
|
||||
|
|
@ -3272,9 +3278,10 @@ typemap_parm : type typemap_name {
|
|||
| type AND typemap_name {
|
||||
$$ = new TMParm;
|
||||
$$->p = NewParm($1,$3);
|
||||
$$->p->t->is_reference = 1;
|
||||
DataType *pt = Parm_Gettype($$->p);
|
||||
pt->is_reference = 1;
|
||||
$$->p->call_type = 0;
|
||||
$$->p->t->is_pointer++;
|
||||
pt->is_pointer++;
|
||||
if (!CPlusPlus) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
||||
}
|
||||
|
|
@ -3287,9 +3294,10 @@ typemap_parm : type typemap_name {
|
|||
FatalError();
|
||||
$$ = new TMParm;
|
||||
$$->p = NewParm($1,$4);
|
||||
$$->p->t->type = T_ERROR;
|
||||
$$->p->name = copy_string($4);
|
||||
strcpy($$->p->t->name,"<function ptr>");
|
||||
DataType *pt = Parm_Gettype($$->p);
|
||||
pt->type = T_ERROR;
|
||||
Parm_Setname($$->p,$4);
|
||||
strcpy(pt->name,"<function ptr>");
|
||||
$$->args = tm_parm;
|
||||
DelDataType($1);
|
||||
delete $4;
|
||||
|
|
|
|||
|
|
@ -71,165 +71,6 @@ extern int IsVirtual;
|
|||
#define tab4 " "
|
||||
#define tab8 " "
|
||||
|
||||
/************************************************************************
|
||||
* class DataType
|
||||
*
|
||||
* Defines the basic datatypes supported by the translator.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#define T_INT 1
|
||||
#define T_SHORT 2
|
||||
#define T_LONG 3
|
||||
#define T_UINT 4
|
||||
#define T_USHORT 5
|
||||
#define T_ULONG 6
|
||||
#define T_UCHAR 7
|
||||
#define T_SCHAR 8
|
||||
#define T_BOOL 9
|
||||
#define T_DOUBLE 10
|
||||
#define T_FLOAT 11
|
||||
#define T_CHAR 12
|
||||
#define T_USER 13
|
||||
#define T_VOID 14
|
||||
#define T_SYMBOL 98
|
||||
#define T_ERROR 99
|
||||
|
||||
// These types are now obsolete, but defined for backwards compatibility
|
||||
|
||||
#define T_SINT 90
|
||||
#define T_SSHORT 91
|
||||
#define T_SLONG 92
|
||||
|
||||
// Class for storing data types
|
||||
|
||||
#define MAX_NAME 96
|
||||
|
||||
typedef struct DataType {
|
||||
int type; // SWIG Type code
|
||||
char name[MAX_NAME]; // Name of type
|
||||
char is_pointer; // Is this a pointer?
|
||||
char implicit_ptr; // Implicit ptr
|
||||
char is_reference; // A C++ reference type
|
||||
char status; // Is this datatype read-only?
|
||||
char *_qualifier; // A qualifier string (ie. const).
|
||||
char *_arraystr; // String containing array part
|
||||
int id; // type identifier (unique for every type).
|
||||
|
||||
// Temporary: catches accidental use.
|
||||
DataType() { abort(); }
|
||||
DataType(DataType *) { abort(); }
|
||||
DataType(int type) { abort();}
|
||||
~DataType() { abort(); }
|
||||
} DataType;
|
||||
|
||||
extern DataType *NewDataType(int type);
|
||||
extern DataType *CopyDataType(DataType *type);
|
||||
extern void DelDataType(DataType *type);
|
||||
|
||||
extern char *DataType_qualifier(DataType *);
|
||||
extern void DataType_set_qualifier(DataType *, char *q);
|
||||
extern char *DataType_arraystr(DataType *);
|
||||
extern void DataType_set_arraystr(DataType *, char *a);
|
||||
|
||||
extern void DataType_primitive(DataType *);
|
||||
extern char *DataType_print_type(DataType *);
|
||||
extern char *DataType_print_full(DataType *);
|
||||
extern char *DataType_print_cast(DataType *);
|
||||
extern char *DataType_print_mangle(DataType *);
|
||||
extern char *DataType_print_real(DataType *, char *local);
|
||||
extern char *DataType_print_arraycast(DataType *);
|
||||
extern char *DataType_print_mangle_default(DataType *);
|
||||
extern void DataType_set_mangle(char *(*m)(DataType *));
|
||||
extern int DataType_array_dimensions(DataType *);
|
||||
extern char *DataType_get_dimension(DataType *, int);
|
||||
|
||||
/* Typedef support */
|
||||
extern void DataType_typedef_add(DataType *, char *name, int mode);
|
||||
extern void DataType_typedef_resolve(DataType *, int level);
|
||||
extern void DataType_typedef_replace(DataType *);
|
||||
extern int DataType_is_typedef(char *name);
|
||||
extern void DataType_updatestatus(DataType *, int newstatus);
|
||||
extern void DataType_init_typedef();
|
||||
extern void DataType_merge_scope(DOHHash *h);
|
||||
extern void DataType_new_scope(DOHHash *h);
|
||||
extern void *DataType_collapse_scope(char *name);
|
||||
extern void DataType_remember(DataType *);
|
||||
extern void DataType_record_base(char *derived, char *base);
|
||||
|
||||
#define STAT_REPLACETYPE 2
|
||||
|
||||
/************************************************************************
|
||||
* class Parm
|
||||
*
|
||||
* Structure for holding information about function parameters
|
||||
*
|
||||
* CALL_VALUE --> Call by value even though function parameter
|
||||
* is a pointer.
|
||||
* ex : foo(&_arg0);
|
||||
* CALL_REF --> Call by reference even though function parameter
|
||||
* is by value
|
||||
* ex : foo(*_arg0);
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#define CALL_VALUE 0x01
|
||||
#define CALL_REFERENCE 0x02
|
||||
#define CALL_OUTPUT 0x04
|
||||
|
||||
typedef struct Parm {
|
||||
DataType *t; // Datatype of this parameter
|
||||
int call_type; // Call type (value or reference or value)
|
||||
char *name; // Name of parameter (optional)
|
||||
char *defvalue; // Default value (as a string)
|
||||
int ignore; // Ignore flag
|
||||
char *objc_separator; // Parameter separator for Objective-C
|
||||
|
||||
// Note: This is temporary
|
||||
Parm(DataType *type, char *n) { abort(); }
|
||||
Parm(Parm *p) { abort(); }
|
||||
~Parm() {abort();}
|
||||
} Parm;
|
||||
|
||||
extern Parm *NewParm(DataType *type, char *n);
|
||||
extern Parm *CopyParm(Parm *p);
|
||||
extern void DelParm(Parm *p);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// class ParmList
|
||||
//
|
||||
// This class is used for manipulating parameter lists in
|
||||
// function and type declarations.
|
||||
// -------------------------------------------------------------
|
||||
|
||||
#define MAXPARMS 16
|
||||
|
||||
typedef struct 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
|
||||
|
||||
// Note: This is temporary
|
||||
ParmList() { abort(); }
|
||||
ParmList(ParmList *l) { abort(); }
|
||||
~ParmList() { abort(); }
|
||||
} ParmList;
|
||||
|
||||
extern ParmList *NewParmList();
|
||||
extern ParmList *CopyParmList(ParmList *);
|
||||
extern void DelParmList(ParmList *);
|
||||
extern Parm *ParmList_get(ParmList *l, int pos);
|
||||
extern void ParmList_append(ParmList *, Parm *);
|
||||
extern void ParmList_insert(ParmList *, Parm *, int);
|
||||
extern void ParmList_del(ParmList *, int);
|
||||
extern int ParmList_numopt(ParmList *);
|
||||
extern int ParmList_numarg(ParmList *);
|
||||
extern Parm *ParmList_first(ParmList *);
|
||||
extern Parm *ParmList_next(ParmList *);
|
||||
extern void ParmList_print_types(ParmList*,DOHFile *f);
|
||||
extern void ParmList_print_args(ParmList *, DOHFile *f);
|
||||
|
||||
// Modes for different types of inheritance
|
||||
|
||||
#define INHERIT_FUNC 0x1
|
||||
|
|
@ -381,9 +222,8 @@ public:
|
|||
extern void emit_extern_var(char *, DataType *, int, FILE *);
|
||||
extern void emit_extern_func(char *, DataType *, ParmList *, int, FILE *);
|
||||
extern void emit_func_call(char *, DataType *, ParmList *, FILE *);
|
||||
|
||||
extern void emit_set_get(char *, char *, DataType *);
|
||||
extern void emit_ptr_equivalence(FILE *);
|
||||
|
||||
extern int SWIG_main(int, char **, Language *);
|
||||
|
||||
// Some functions for emitting some C++ helper code
|
||||
|
|
@ -444,6 +284,7 @@ extern void typemap_copy(char *op, char *lang, DataType *stype, char *sname,
|
|||
extern char *typemap_check(char *op, char *lang, DataType *type, char *pname);
|
||||
extern void typemap_apply(DataType *tm_type, char *tmname, DataType *type, char *pname);
|
||||
extern void typemap_clear_apply(DataType *type, char *pname);
|
||||
extern int check_numopt(ParmList *);
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -310,15 +310,17 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
Parm *p;
|
||||
p = ParmList_first(tm->args);
|
||||
while (p) {
|
||||
if (p->name) {
|
||||
// printf(" %s %s\n", p->t->print_type(),p->name);
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (pn) {
|
||||
// printf(" %s %s\n", pt,pn);
|
||||
} else {
|
||||
fprintf(stderr,"%s:%d: Typemap error. Local variables must have a name\n",
|
||||
input_file, line_number);
|
||||
}
|
||||
// If a call by reference thingy, fix that
|
||||
if (p->call_type & CALL_REFERENCE) {
|
||||
p->t->is_pointer--;
|
||||
pt->is_pointer--;
|
||||
p->call_type = 0;
|
||||
}
|
||||
p = ParmList_next(tm->args);
|
||||
|
|
@ -487,8 +489,10 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
|||
|
||||
p = ParmList_first(l);
|
||||
while (p) {
|
||||
if (p->name) {
|
||||
if (strlen(p->name) > 0) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (pn) {
|
||||
if (strlen(pn) > 0) {
|
||||
DOHString *str;
|
||||
DataType *tt;
|
||||
|
||||
|
|
@ -496,24 +500,24 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
|||
// If the user gave us $type as the name of the local variable, we'll use
|
||||
// the passed datatype instead
|
||||
|
||||
if (strcmp(p->t->name,"$type")==0 || strcmp(p->t->name,"$basetype")==0) {
|
||||
if (strcmp(pn,"$type")==0 || strcmp(pt->name,"$basetype")==0) {
|
||||
tt = t;
|
||||
} else {
|
||||
tt = p->t;
|
||||
tt = pt;
|
||||
}
|
||||
|
||||
// Have a real parameter here
|
||||
if (DataType_arraystr(tt)) {
|
||||
tt->is_pointer--;
|
||||
Printf(str,"%s%s",p->name, DataType_arraystr(tt));
|
||||
Printf(str,"%s%s",pn, DataType_arraystr(tt));
|
||||
}
|
||||
else {
|
||||
Printf(str,"%s",p->name);
|
||||
Printf(str,"%s",pn);
|
||||
}
|
||||
|
||||
// Substitute parameter names
|
||||
Replace(str,"$arg",pname, DOH_REPLACE_ANY);
|
||||
if (strcmp(p->t->name,"$basetype")==0) {
|
||||
if (strcmp(pt->name,"$basetype")==0) {
|
||||
// use $basetype
|
||||
char temp_ip = tt->is_pointer;
|
||||
char temp_ip1 = tt->implicit_ptr;
|
||||
|
|
@ -528,7 +532,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
|||
|
||||
if (DataType_arraystr(tt)) tt->is_pointer++;
|
||||
// Substitute
|
||||
Replace(s,p->name,new_name,DOH_REPLACE_ID);
|
||||
Replace(s,pn,new_name,DOH_REPLACE_ID);
|
||||
}
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
|
|
@ -1113,3 +1117,36 @@ typemap_initialize() {
|
|||
typemap_hash = NewHash();
|
||||
application_hash = NewHash();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// int check_numopt()
|
||||
//
|
||||
// Gets the number of optional arguments for a ParmList.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int check_numopt(ParmList *l) {
|
||||
int n = 0;
|
||||
int state = 0;
|
||||
|
||||
for (int i = 0; i < l->nparms; i++) {
|
||||
DataType *pt = Parm_Gettype(l->parms[i]);
|
||||
char *pn = Parm_Getname(l->parms[i]);
|
||||
if (Parm_Getvalue(l->parms[i])) {
|
||||
n++;
|
||||
state = 1;
|
||||
} else if (typemap_check((char*)"default",typemap_lang,pt,pn)) {
|
||||
n++;
|
||||
state = 1;
|
||||
} else if (typemap_check((char*)"ignore",typemap_lang,pt,pn)) {
|
||||
n++;
|
||||
} else {
|
||||
if (state) {
|
||||
fprintf(stderr,"%s : Line %d. Argument %d must have a default value!\n", input_file,line_number,i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@
|
|||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c
|
||||
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o
|
||||
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
|
||||
oldtypes.c oldparms.c
|
||||
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
|
||||
oldtypes.o oldparms.o
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
|
|
|||
349
SWIG/Source/Swig/oldparms.c
Normal file
349
SWIG/Source/Swig/oldparms.c
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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->call_type = 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->call_type = p->call_type;
|
||||
np->_defvalue = Swig_copy_string(p->_defvalue);
|
||||
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);
|
||||
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_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;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* 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;
|
||||
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 (!l->parms[i]->ignore)
|
||||
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. Has to do some
|
||||
* manipulation of pointer types depending on how the call_type
|
||||
* variable has been set.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
void ParmList_print_types(ParmList *l, DOHFile *f) {
|
||||
|
||||
int is_pointer;
|
||||
int pn;
|
||||
DataType *t;
|
||||
pn = 0;
|
||||
while(pn < l->nparms) {
|
||||
t = Parm_Gettype(l->parms[pn]);
|
||||
is_pointer = t->is_pointer;
|
||||
if (t->is_reference) {
|
||||
if (t->is_pointer) {
|
||||
t->is_pointer--;
|
||||
Printf(f,"%s&", DataType_print_real(t,0));
|
||||
t->is_pointer++;
|
||||
} else {
|
||||
Printf(f,"%s&", DataType_print_real(t,0));
|
||||
}
|
||||
} else {
|
||||
if (l->parms[pn]->call_type & CALL_VALUE) t->is_pointer++;
|
||||
if (l->parms[pn]->call_type & CALL_REFERENCE) t->is_pointer--;
|
||||
Printf(f,"%s", DataType_print_real(t,0));
|
||||
t->is_pointer = is_pointer;
|
||||
}
|
||||
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 is_pointer;
|
||||
int pn;
|
||||
DataType *t;
|
||||
pn = 0;
|
||||
while(pn < l->nparms) {
|
||||
t = Parm_Gettype(l->parms[pn]);
|
||||
is_pointer = t->is_pointer;
|
||||
if (t->is_reference) {
|
||||
if (t->is_pointer) {
|
||||
t->is_pointer--;
|
||||
Printf(f,"%s&", DataType_print_full(t));
|
||||
t->is_pointer++;
|
||||
} else {
|
||||
Printf(f,"%s&", DataType_print_full(t));
|
||||
}
|
||||
} else {
|
||||
if (l->parms[pn]->call_type & CALL_VALUE) t->is_pointer++;
|
||||
if (l->parms[pn]->call_type & CALL_REFERENCE) t->is_pointer--;
|
||||
Printf(f,"%s", DataType_print_full(t));
|
||||
t->is_pointer = is_pointer;
|
||||
}
|
||||
Printf(f,"%s",Parm_Getname(l->parms[pn]));
|
||||
pn++;
|
||||
if (pn < l->nparms)
|
||||
Printf(f,",");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
* types.cxx
|
||||
*
|
||||
* This file contains code for SWIG1.1 type objects.
|
||||
*
|
||||
* !!! This file is deprecated and is being replaced !!!
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
|
|
@ -14,11 +16,9 @@
|
|||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
#include "internal.h"
|
||||
#include "swig.h"
|
||||
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
int type_id = 0;
|
||||
|
||||
/* Create a data type only from the type code (used to form constants) */
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ void DataType_primitive(DataType *t) {
|
|||
char *DataType_print_type(DataType *ty) {
|
||||
static char result[8][256];
|
||||
static int ri = 0;
|
||||
|
||||
int i;
|
||||
DataType *t = ty;
|
||||
|
||||
if (ty->status & STAT_REPLACETYPE) {
|
||||
|
|
@ -207,7 +207,7 @@ char *DataType_print_type(DataType *ty) {
|
|||
}
|
||||
ri = ri % 8;
|
||||
sprintf(result[ri],"%s ", t->name);
|
||||
for (int i = 0; i < (t->is_pointer-t->implicit_ptr); i++)
|
||||
for (i = 0; i < (t->is_pointer-t->implicit_ptr); i++)
|
||||
strcat(result[ri],"*");
|
||||
|
||||
if (ty->status & STAT_REPLACETYPE) {
|
||||
|
|
@ -435,6 +435,7 @@ char *DataType_get_dimension(DataType *t, int n) {
|
|||
/* --------------------------------------------------------------------
|
||||
* typedef support. This needs to be scoped.
|
||||
* -------------------------------------------------------------------- */
|
||||
#define MAXSCOPE 16
|
||||
|
||||
static DOHHash *typedef_hash[MAXSCOPE];
|
||||
static int scope = 0; /* Current scope */
|
||||
|
|
@ -458,7 +459,7 @@ void DataType_init_typedef() {
|
|||
}
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* void DataType_typedef_add()
|
||||
* int DataType_typedef_add()
|
||||
*
|
||||
* Adds this datatype to the typedef hash table. mode is an optional
|
||||
* flag that can be used to only add the symbol as a typedef, but not
|
||||
|
|
@ -467,7 +468,7 @@ void DataType_init_typedef() {
|
|||
* arrays, and enums.
|
||||
* --------------------------------------------------------------------*/
|
||||
|
||||
void DataType_typedef_add(DataType *t,char *tname, int mode) {
|
||||
int DataType_typedef_add(DataType *t,char *tname, int mode) {
|
||||
char *name1, *name2;
|
||||
DataType *nt, *t1;
|
||||
void typeeq_addtypedef(char *name, char *eqname, DataType *);
|
||||
|
|
@ -477,9 +478,7 @@ void DataType_typedef_add(DataType *t,char *tname, int mode) {
|
|||
* that shadow global ones.*/
|
||||
|
||||
if (Getattr(typedef_hash[scope],tname)) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. Datatype %s already defined (2nd definition ignored).\n",
|
||||
input_file, line_number, tname);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Make a new datatype that we will place in our hash table */
|
||||
|
|
@ -507,6 +506,7 @@ void DataType_typedef_add(DataType *t,char *tname, int mode) {
|
|||
}
|
||||
/* Call into the target language with this typedef */
|
||||
/* lang->add_typedef(t,tname); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
|
|
@ -737,12 +737,12 @@ void *DataType_collapse_scope(char *prefix) {
|
|||
* cast is an extension needed to properly handle multiple inheritance
|
||||
* -------------------------------------------------------------- */
|
||||
|
||||
struct EqEntry {
|
||||
typedef struct EqEntry {
|
||||
char *name;
|
||||
char *cast;
|
||||
DataType *type;
|
||||
EqEntry *next;
|
||||
};
|
||||
struct EqEntry *next;
|
||||
} EqEntry;
|
||||
|
||||
static DOHHash *typeeq_hash = 0;
|
||||
static int te_init = 0;
|
||||
|
|
@ -764,7 +764,7 @@ void typeeq_init() {
|
|||
* Cast is an optional name for a pointer casting function.
|
||||
* -------------------------------------------------------------- */
|
||||
|
||||
void typeeq_add(char *name, char *eqname, char *cast = 0, DataType *type = 0) {
|
||||
void typeeq_add(char *name, char *eqname, char *cast, DataType *type) {
|
||||
EqEntry *e1,*e2;
|
||||
|
||||
if (!te_init) typeeq_init();
|
||||
|
|
@ -850,7 +850,7 @@ void typeeq_addtypedef(char *name, char *eqname, DataType *t) {
|
|||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* void emit_ptr_equivalence(FILE *f)
|
||||
* void emit_ptr_equivalence()
|
||||
*
|
||||
* Dump out the pointer equivalence table to file.
|
||||
*
|
||||
|
|
@ -858,7 +858,7 @@ void typeeq_addtypedef(char *name, char *eqname, DataType *t) {
|
|||
* to support proper type-casting (needed for multiple inheritance)
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
void emit_ptr_equivalence(FILE *f) {
|
||||
void emit_ptr_equivalence(DOHFile *tablef, DOHFile *initf) {
|
||||
|
||||
EqEntry *e1,*e2;
|
||||
DOH *k;
|
||||
|
|
@ -884,11 +884,11 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
|||
while (e2) {
|
||||
if (e2->cast)
|
||||
Printv(ttable,
|
||||
tab4, "{ \"", e1->name, "\",\"", e2->name, "\"," , e2->cast , "},\n",
|
||||
" { \"", e1->name, "\",\"", e2->name, "\"," , e2->cast , "},\n",
|
||||
0);
|
||||
else
|
||||
Printv(ttable,
|
||||
tab4, "{ \"", e1->name, "\",\"", e2->name, "\",0},\n",
|
||||
" { \"", e1->name, "\",\"", e2->name, "\",0},\n",
|
||||
0);
|
||||
|
||||
e2 = e2->next;
|
||||
|
|
@ -896,22 +896,22 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
|||
k = Nextkey(typeeq_hash);
|
||||
}
|
||||
Printf(ttable,"{0,0,0}};\n");
|
||||
fprintf(f_wrappers,"%s\n", Char(ttable));
|
||||
fprintf(f,"{\n");
|
||||
fprintf(f," int i;\n");
|
||||
fprintf(f," for (i = 0; _swig_mapping[i].n1; i++)\n");
|
||||
fprintf(f," SWIG_RegisterMapping(_swig_mapping[i].n1,_swig_mapping[i].n2,_swig_mapping[i].pcnv);\n");
|
||||
fprintf(f,"}\n");
|
||||
Printf(tablef,"%s\n", Char(ttable));
|
||||
Printf(initf,"{\n");
|
||||
Printf(initf," int i;\n");
|
||||
Printf(initf," for (i = 0; _swig_mapping[i].n1; i++)\n");
|
||||
Printf(initf," SWIG_RegisterMapping(_swig_mapping[i].n1,_swig_mapping[i].n2,_swig_mapping[i].pcnv);\n");
|
||||
Printf(initf,"}\n");
|
||||
Delete(ttable);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------
|
||||
* typeeq_derived(char *n1, char *n2, char *cast=)
|
||||
* typeeq_derived(char *n1, char *n2, char *cast)
|
||||
*
|
||||
* Adds a one-way mapping between datatypes.
|
||||
* ------------------------------------------------------------------------------ */
|
||||
|
||||
void typeeq_derived(char *n1, char *n2, char *cast=0) {
|
||||
void typeeq_derived(char *n1, char *n2, char *cast) {
|
||||
DataType *t,*t1;
|
||||
char *name, *name2;
|
||||
|
||||
|
|
@ -936,7 +936,7 @@ void typeeq_derived(char *n1, char *n2, char *cast=0) {
|
|||
* Adds a single type equivalence
|
||||
* ------------------------------------------------------------------------------ */
|
||||
|
||||
void typeeq_mangle(char *n1, char *n2, char *cast=0) {
|
||||
void typeeq_mangle(char *n1, char *n2, char *cast) {
|
||||
DataType *t,*t1;
|
||||
char *name, *name2;
|
||||
|
||||
|
|
@ -948,7 +948,7 @@ void typeeq_mangle(char *n1, char *n2, char *cast=0) {
|
|||
strcpy(t1->name,n2);
|
||||
name = DataType_print_mangle(t);
|
||||
name2 = DataType_print_mangle(t1);
|
||||
typeeq_add(name,name2,cast);
|
||||
typeeq_add(name,name2,cast,0);
|
||||
DelDataType(t);
|
||||
DelDataType(t1);
|
||||
}
|
||||
|
|
@ -963,18 +963,18 @@ void typeeq_mangle(char *n1, char *n2, char *cast=0) {
|
|||
|
||||
void typeeq_standard(void) {
|
||||
|
||||
typeeq_mangle((char*)"int", (char*)"signed int");
|
||||
typeeq_mangle((char*)"int", (char*)"unsigned int");
|
||||
typeeq_mangle((char*)"signed int", (char*)"int");
|
||||
typeeq_mangle((char*)"unsigned int", (char*)"int");
|
||||
typeeq_mangle((char*)"short",(char*)"signed short");
|
||||
typeeq_mangle((char*)"signed short",(char*)"short");
|
||||
typeeq_mangle((char*)"short",(char*)"unsigned short");
|
||||
typeeq_mangle((char*)"unsigned short",(char*)"short");
|
||||
typeeq_mangle((char*)"long",(char*)"signed long");
|
||||
typeeq_mangle((char*)"signed long",(char*)"long");
|
||||
typeeq_mangle((char*)"long",(char*)"unsigned long");
|
||||
typeeq_mangle((char*)"unsigned long",(char*)"long");
|
||||
typeeq_mangle((char*)"int", (char*)"signed int",0);
|
||||
typeeq_mangle((char*)"int", (char*)"unsigned int",0);
|
||||
typeeq_mangle((char*)"signed int", (char*)"int",0);
|
||||
typeeq_mangle((char*)"unsigned int", (char*)"int",0);
|
||||
typeeq_mangle((char*)"short",(char*)"signed short",0);
|
||||
typeeq_mangle((char*)"signed short",(char*)"short",0);
|
||||
typeeq_mangle((char*)"short",(char*)"unsigned short",0);
|
||||
typeeq_mangle((char*)"unsigned short",(char*)"short",0);
|
||||
typeeq_mangle((char*)"long",(char*)"signed long",0);
|
||||
typeeq_mangle((char*)"signed long",(char*)"long",0);
|
||||
typeeq_mangle((char*)"long",(char*)"unsigned long",0);
|
||||
typeeq_mangle((char*)"unsigned long",(char*)"long",0);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1086,7 +1086,7 @@ void DataType_remember(DataType *ty) {
|
|||
}
|
||||
|
||||
void
|
||||
emit_type_table() {
|
||||
emit_type_table(DOHFile *out) {
|
||||
DOH *key;
|
||||
DOHString *types, *table;
|
||||
int i = 0;
|
||||
|
|
@ -1097,9 +1097,9 @@ emit_type_table() {
|
|||
types = NewString("");
|
||||
Printf(table,"static _swig_type_info *_swig_types_initial[] = {\n");
|
||||
key = Firstkey(remembered);
|
||||
fprintf(f_runtime,"/* ---- TYPES TABLE (BEGIN) ---- */\n");
|
||||
Printf(out,"/* ---- TYPES TABLE (BEGIN) ---- */\n");
|
||||
while (key) {
|
||||
fprintf(f_runtime,"#define SWIGTYPE%s _swig_types[%d] \n", Char(key), i);
|
||||
Printf(out,"#define SWIGTYPE%s _swig_types[%d] \n", key, i);
|
||||
Printv(types,"static _swig_type_info _swigt_", Char(key), "[] = {", 0);
|
||||
Printv(types,"{\"", Char(key), "\",0},", 0);
|
||||
Printv(types, "{\"", Char(key), "\",0},", 0);
|
||||
|
|
@ -1110,10 +1110,11 @@ emit_type_table() {
|
|||
}
|
||||
|
||||
Printf(table, "0\n};\n");
|
||||
fprintf(f_wrappers,"%s\n", Char(types));
|
||||
fprintf(f_wrappers,"%s\n", Char(table));
|
||||
fprintf(f_runtime,"static _swig_type_info *_swig_types[%d];\n", i+1);
|
||||
fprintf(f_runtime,"/* ---- TYPES TABLE (END) ---- */\n\n");
|
||||
Printf(out,"static _swig_type_info *_swig_types[%d];\n", i+1);
|
||||
|
||||
Printf(out,"%s\n", types);
|
||||
Printf(out,"%s\n", table);
|
||||
Printf(out,"/* ---- TYPES TABLE (END) ---- */\n\n");
|
||||
Delete(types);
|
||||
Delete(table);
|
||||
}
|
||||
|
|
@ -205,6 +205,131 @@ extern DOH *Swig_map_match(DOHHash *ruleset, DOHString_or_char *rulename,
|
|||
extern char *Swig_copy_string(const char *c);
|
||||
extern void Swig_banner(DOHFile *f);
|
||||
|
||||
/* --- Legacy DataType interface. This is being replaced --- */
|
||||
|
||||
#define T_INT 1
|
||||
#define T_SHORT 2
|
||||
#define T_LONG 3
|
||||
#define T_UINT 4
|
||||
#define T_USHORT 5
|
||||
#define T_ULONG 6
|
||||
#define T_UCHAR 7
|
||||
#define T_SCHAR 8
|
||||
#define T_BOOL 9
|
||||
#define T_DOUBLE 10
|
||||
#define T_FLOAT 11
|
||||
#define T_CHAR 12
|
||||
#define T_USER 13
|
||||
#define T_VOID 14
|
||||
#define T_SYMBOL 98
|
||||
#define T_ERROR 99
|
||||
|
||||
/* These types are now obsolete, but defined for backwards compatibility */
|
||||
|
||||
#define T_SINT 90
|
||||
#define T_SSHORT 91
|
||||
#define T_SLONG 92
|
||||
|
||||
#define MAX_NAME 96
|
||||
|
||||
typedef struct DataType {
|
||||
int type; /* SWIG Type code */
|
||||
char name[MAX_NAME]; /* Name of type */
|
||||
char is_pointer; /* Is this a pointer */
|
||||
char implicit_ptr; /* Implicit ptr */
|
||||
char is_reference; /* A C++ reference type */
|
||||
char status; /* Is this datatype read-only? */
|
||||
char *_qualifier; /* A qualifier string (ie. const). */
|
||||
char *_arraystr; /* String containing array part */
|
||||
int id; /* type identifier (unique for every type). */
|
||||
} DataType;
|
||||
|
||||
extern DataType *NewDataType(int type);
|
||||
extern DataType *CopyDataType(DataType *type);
|
||||
extern void DelDataType(DataType *type);
|
||||
|
||||
extern char *DataType_qualifier(DataType *);
|
||||
extern void DataType_set_qualifier(DataType *, char *q);
|
||||
extern char *DataType_arraystr(DataType *);
|
||||
extern void DataType_set_arraystr(DataType *, char *a);
|
||||
|
||||
extern void DataType_primitive(DataType *);
|
||||
extern char *DataType_print_type(DataType *);
|
||||
extern char *DataType_print_full(DataType *);
|
||||
extern char *DataType_print_cast(DataType *);
|
||||
extern char *DataType_print_mangle(DataType *);
|
||||
extern char *DataType_print_real(DataType *, char *local);
|
||||
extern char *DataType_print_arraycast(DataType *);
|
||||
extern char *DataType_print_mangle_default(DataType *);
|
||||
extern void DataType_set_mangle(char *(*m)(DataType *));
|
||||
extern int DataType_array_dimensions(DataType *);
|
||||
extern char *DataType_get_dimension(DataType *, int);
|
||||
|
||||
/* Typedef support */
|
||||
extern int DataType_typedef_add(DataType *, char *name, int mode);
|
||||
extern void DataType_typedef_resolve(DataType *, int level);
|
||||
extern void DataType_typedef_replace(DataType *);
|
||||
extern int DataType_is_typedef(char *name);
|
||||
extern void DataType_updatestatus(DataType *, int newstatus);
|
||||
extern void DataType_init_typedef();
|
||||
extern void DataType_merge_scope(DOHHash *h);
|
||||
extern void DataType_new_scope(DOHHash *h);
|
||||
extern void *DataType_collapse_scope(char *name);
|
||||
extern void DataType_remember(DataType *);
|
||||
extern void DataType_record_base(char *derived, char *base);
|
||||
|
||||
extern int type_id;
|
||||
extern void emit_ptr_equivalence(DOHFile *tablef, DOHFile *initf);
|
||||
extern void emit_type_table(DOHFile *out);
|
||||
extern void typeeq_derived(char *n1, char *n2, char *cast);
|
||||
extern void typeeq_addtypedef(char *name, char *eqname, DataType *t);
|
||||
|
||||
#define STAT_REPLACETYPE 2
|
||||
|
||||
/* --- Deprecated parameter list structure */
|
||||
|
||||
#define CALL_VALUE 0x01
|
||||
#define CALL_REFERENCE 0x02
|
||||
#define CALL_OUTPUT 0x04
|
||||
|
||||
typedef struct Parm {
|
||||
DataType *_type; /* Datatype of this parameter */
|
||||
int call_type; /* Call type (value or reference or value) */
|
||||
char *_name; /* Name of parameter (optional) */
|
||||
char *_defvalue; /* Default value (as a string) */
|
||||
int ignore; /* Ignore flag */
|
||||
} Parm;
|
||||
|
||||
extern Parm *NewParm(DataType *type, char *n);
|
||||
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_Setvalue(Parm *p, char *value);
|
||||
extern char *Parm_Getvalue(Parm *p);
|
||||
|
||||
typedef struct 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 *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 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);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue