Moved parms and types to C. Changed parameter API
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@578 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f0759d01f7
commit
97d9d53f1b
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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue