More work on smoothing out the type system. Needs more work however.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@592 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c03b614a02
commit
9bb0ec4a19
17 changed files with 940 additions and 731 deletions
|
|
@ -363,7 +363,7 @@ GUILE::get_pointer (char *iname, int parm, DataType *t,
|
|||
if (t->type == T_VOID)
|
||||
Printf(f->code, ", (char *) 0)) {\n");
|
||||
else
|
||||
Printv(f->code, ", \"", DataType_print_mangle(t), "\")) {\n", 0);
|
||||
Printv(f->code, ", \"", DataType_manglestr(t), "\")) {\n", 0);
|
||||
/* Raise exception */
|
||||
Printv(f->code,
|
||||
tab8,
|
||||
|
|
@ -474,7 +474,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Produce names of source and target
|
||||
sprintf(source,"s_%d",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(target,"%s",Parm_Getlname(p));
|
||||
sprintf(argnum,"%d",i);
|
||||
strcpy(arg,pn);
|
||||
|
||||
|
|
@ -532,7 +532,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
if (d->type == T_VOID)
|
||||
Printv(f->code, tab4, "gswig_result = GH_UNSPECIFIED;\n", 0);
|
||||
else if ((tm = typemap_lookup ((char*)"out", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"gswig_result", f))) {
|
||||
d, name, (char*)"result", (char*)"gswig_result", f))) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -541,9 +541,9 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
look-up. */
|
||||
Printv(f->code, tab4,
|
||||
"gswig_result = SWIG_Guile_MakePtr_Str (",
|
||||
"_result, ",
|
||||
"\"", DataType_print_mangle(d), "\", ",
|
||||
"\"", DataType_print_type(d), "\"",
|
||||
"result, ",
|
||||
"\"", DataType_manglestr(d), "\", ",
|
||||
"\"", DataType_str(d,0), "\"",
|
||||
");\n",
|
||||
0);
|
||||
}
|
||||
|
|
@ -561,7 +561,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup ((char*)"newfree", typemap_lang,
|
||||
d, iname, (char*)"_result", (char*)"", f))) {
|
||||
d, iname, (char*)"result", (char*)"", f))) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -570,7 +570,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"ret", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"", f))) {
|
||||
d, name, (char*)"result", (char*)"", f))) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -672,7 +672,7 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
|
|||
if (t->type == T_VOID)
|
||||
Printf (f_wrappers, "(char *) 0)) {\n");
|
||||
else
|
||||
Printf (f_wrappers, "\"%s\")) {\n", DataType_print_mangle(t));
|
||||
Printf (f_wrappers, "\"%s\")) {\n", DataType_manglestr(t));
|
||||
/* Raise exception */
|
||||
Printf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", "
|
||||
"%d, s_0);\n", proc_name, 1);
|
||||
|
|
@ -699,8 +699,8 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
|
|||
/* MK: I would like to use SWIG_Guile_MakePtr here to save one type
|
||||
look-up. */
|
||||
Printf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str ("
|
||||
"%s, \"%s\", \"%s\");\n", name, DataType_print_mangle(t),
|
||||
DataType_print_type(t));
|
||||
"%s, \"%s\", \"%s\");\n", name, DataType_manglestr(t),
|
||||
DataType_str(t,0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -717,7 +717,7 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
|
|||
} else {
|
||||
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
|
||||
" type %s (ignored).\n",
|
||||
input_file, line_number, DataType_print_type(t));
|
||||
input_file, line_number, DataType_str(t,0));
|
||||
}
|
||||
Delete(proc_name);
|
||||
}
|
||||
|
|
@ -769,7 +769,7 @@ GUILE::declare_const (char *name, char *, DataType *type, char *value)
|
|||
} else {
|
||||
// Create variable and assign it a value
|
||||
|
||||
Printf (f_header, "static %s %s = ", DataType_print_type(type), var_name);
|
||||
Printf (f_header, "static %s %s = ", DataType_lstr(type,0), var_name);
|
||||
if ((type->type == T_CHAR) && (type->is_pointer <= 1)) {
|
||||
Printf (f_header, "\"%s\";\n", value);
|
||||
} else {
|
||||
|
|
@ -898,7 +898,7 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
|
|||
Insert(param,0," unspecified ");
|
||||
else {
|
||||
Insert(param,0,"# ");
|
||||
Insert(param,0, DataType_print_type(d));
|
||||
Insert(param,0, DataType_str(d,0));
|
||||
Insert(param,0," $");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
|
||||
// Produce string representation of source and target arguments
|
||||
sprintf(source,"jarg%d",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(target,"%s", Parm_Getlname(p));
|
||||
|
||||
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
|
||||
if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
|
||||
|
|
@ -632,21 +632,21 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
if(!pt->is_pointer)
|
||||
Printv(f->code, tab4, target, " = ", DataType_print_cast(pt), source, ";\n", 0);
|
||||
Printv(f->code, tab4, target, " = (", DataType_lstr(pt,0), ") ", 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);
|
||||
Printv(f->code, tab4, target, " = *(", DataType_lstr(pt,0), ")&", source, ";\n", 0);
|
||||
pt->is_pointer--;
|
||||
} else {
|
||||
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(pt);
|
||||
char *cptrtype = DataType_print_type(pt);
|
||||
char *cptrtype = DataType_lstr(pt,0);
|
||||
pt->is_pointer--;
|
||||
const char *basic_jnitype = (pt->is_pointer > 0) ? "jlong" : SwigTcToJniType(pt, 0);
|
||||
char *ctype = DataType_print_type(pt);
|
||||
char *ctype = DataType_lstr(pt,0);
|
||||
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);
|
||||
|
|
@ -663,13 +663,13 @@ 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(pt), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
|
||||
Printv(f->code, tab4, target, " = (", DataType_lstr(pt,0), ") malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
|
||||
Printv(f->code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
|
||||
if(pt->is_pointer > 1) {
|
||||
Printv(f->code, tab8, target, "[i] = *", DataType_print_cast(pt), "&", target_copy, "[i];\n", 0);
|
||||
Printv(f->code, tab8, target, "[i] = *(", DataType_lstr(pt,0), ")&", target_copy, "[i];\n", 0);
|
||||
} else {
|
||||
pt->is_pointer--;
|
||||
Printv(f->code, tab8, target, "[i] = ", DataType_print_cast(pt), target_copy, "[i];\n", 0);
|
||||
Printv(f->code, tab8, target, "[i] = (", DataType_lstr(pt,0), ")", target_copy, "[i];\n", 0);
|
||||
pt->is_pointer++;
|
||||
}
|
||||
Delete(scalarFunc);
|
||||
|
|
@ -707,10 +707,10 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// nothing to do
|
||||
} else {
|
||||
char *scalarType = SwigTcToJniScalarType(pt);
|
||||
char *cptrtype = DataType_print_type(pt);
|
||||
char *cptrtype = DataType_lstr(pt,0);
|
||||
pt->is_pointer--;
|
||||
const char *basic_jnitype = (pt->is_pointer > 0) ? "jlong" : SwigTcToJniType(pt, 0);
|
||||
char *ctype = DataType_print_type(pt);
|
||||
char *ctype = DataType_lstr(pt,0);
|
||||
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);
|
||||
|
|
@ -718,7 +718,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
pt->is_pointer++;
|
||||
Printf(outarg, " for(i=0; i< %d; i++)\n", target_length);
|
||||
if(pt->is_pointer > 1) {
|
||||
Printv(outarg, tab8, "*", DataType_print_cast(pt), "&", target_copy, "[i] = ", target, "[i];\n", 0);
|
||||
Printv(outarg, tab8, "*(", DataType_lstr(pt,0), ")&", target_copy, "[i] = ", target, "[i];\n", 0);
|
||||
} else {
|
||||
Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0);
|
||||
}
|
||||
|
|
@ -750,28 +750,28 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// Return value if necessary
|
||||
|
||||
if((t->type != T_VOID || t->is_pointer) && !native_func) {
|
||||
if ((tm = typemap_lookup((char*)"out",typemap_lang,t,iname,(char*)"_result",(char*)"_jresult"))) {
|
||||
if ((tm = typemap_lookup((char*)"out",typemap_lang,t,iname,(char*)"result",(char*)"_jresult"))) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
} else {
|
||||
if(t->is_pointer == 0 && t->type == T_USER) { /* return by value */
|
||||
t->is_pointer=2;
|
||||
Printv(f->code, tab4, "*", DataType_print_cast(t), "&_jresult = _result;\n", 0);
|
||||
Printv(f->code, tab4, "*(", DataType_lstr(t,0), ")&_jresult = result;\n", 0);
|
||||
t->is_pointer=0;
|
||||
} else if(t->is_pointer == 0 && t->type != T_USER) {
|
||||
Printv(f->code, tab4, "_jresult = (", jnirettype, ") _result;\n", 0);
|
||||
Printv(f->code, tab4, "_jresult = (", jnirettype, ") result;\n", 0);
|
||||
} else if((t->type == T_VOID && t->is_pointer == 1) ||
|
||||
(t->type == T_USER && t->is_pointer == 1)) {
|
||||
t->is_pointer++;
|
||||
Printv(f->code, tab4, "*", DataType_print_cast(t), "&_jresult = _result;\n", 0);
|
||||
Printv(f->code, tab4, "*(", DataType_lstr(t,0), ")&_jresult = result;\n", 0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
if(t->type == T_CHAR && t->is_pointer == 1) {
|
||||
Printv(f->code, tab4, "if(_result != NULL)\n", 0);
|
||||
Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "_result);\n", 0);
|
||||
Printv(f->code, tab4, "if(result != NULL)\n", 0);
|
||||
Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "result);\n", 0);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,DataType_print_type(t));
|
||||
Printf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,DataType_str(t,0));
|
||||
t->is_pointer++;
|
||||
Printv(f->code, tab4, "*", DataType_print_cast(t), "&_jresult = _result;\n", 0);
|
||||
Printv(f->code, tab4, "*(", DataType_lstr(t,0), ")&_jresult = result;\n", 0);
|
||||
t->is_pointer--;
|
||||
}
|
||||
}
|
||||
|
|
@ -787,13 +787,13 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",typemap_lang,t,iname,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",typemap_lang,t,iname,(char*)"result",(char*)""))) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if((t->type != T_VOID || t->is_pointer) && !native_func) {
|
||||
if ((tm = typemap_lookup((char*)"ret",typemap_lang,t,iname,(char*)"_result",(char*)"_jresult", NULL))) {
|
||||
if ((tm = typemap_lookup((char*)"ret",typemap_lang,t,iname,(char*)"result",(char*)"_jresult", NULL))) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,8 +248,8 @@ void
|
|||
MZSCHEME::get_pointer (DOHString_or_char *name, int parm, DataType *t,
|
||||
Wrapper *f)
|
||||
{
|
||||
Printf(f->code," if (!swig_get_c_pointer(argv[%d],\"%s\", (void **) &_arg%d))\n", parm, DataType_print_mangle(t), parm);
|
||||
Printf(f->code," scheme_wrong_type(\"%s\", \"%s\", %d, argc, argv);\n", name, DataType_print_mangle(t), parm);
|
||||
Printf(f->code," if (!swig_get_c_pointer(argv[%d],\"%s\", (void **) &_arg%d))\n", parm, DataType_manglestr(t), parm);
|
||||
Printf(f->code," scheme_wrong_type(\"%s\", \"%s\", %d, argc, argv);\n", name, DataType_manglestr(t), parm);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -343,7 +343,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Produce names of source and target
|
||||
|
||||
sprintf(source,"argv[%d]",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(target,"%s", Parm_Getlname(p));
|
||||
sprintf(argnum,"%d",i);
|
||||
strcpy(arg,pn);
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
else if ((tm = typemap_lookup ((char*)"out", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"swig_result", f))) {
|
||||
d, name, (char*)"result", (char*)"swig_result", f))) {
|
||||
Printv(f->code, tm, "\n", 0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -417,8 +417,8 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
Printv(f->code,
|
||||
tab4,
|
||||
"swig_result = swig_make_c_pointer(",
|
||||
"_result, \"",
|
||||
DataType_print_mangle(d),
|
||||
"result, \"",
|
||||
DataType_manglestr(d),
|
||||
"\");\n",
|
||||
0);
|
||||
}
|
||||
|
|
@ -436,7 +436,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup ((char*)"newfree", typemap_lang,
|
||||
d, iname, (char*)"_result", (char*)"", f))) {
|
||||
d, iname, (char*)"result", (char*)"", f))) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = typemap_lookup ((char*)"ret", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"", f))) {
|
||||
d, name, (char*)"result", (char*)"", f))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printv(f->code,tm,"\n",0);
|
||||
mreplace (f->code, argnum, arg, proc_name);
|
||||
|
|
@ -560,9 +560,9 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
|
|||
} else {
|
||||
// Set the value of a pointer
|
||||
Printf(f_wrappers, "\t\tif (!swig_get_c_pointer(argv[0], \"%s\", (void **) &_arg0))\n",
|
||||
DataType_print_mangle(t));
|
||||
DataType_manglestr(t));
|
||||
Printf(f_wrappers, "\t\t\tscheme_wrong_type(\"%s\", %s, 0, argc, argv", \
|
||||
var_name, DataType_print_mangle(t));
|
||||
var_name, DataType_manglestr(t));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -583,7 +583,7 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
|
|||
} else {
|
||||
// Is an ordinary pointer type.
|
||||
Printf(f_wrappers, "\tswig_result = swig_make_c_pointer(%s, \"%s\");\n",
|
||||
name, DataType_print_mangle(t));
|
||||
name, DataType_manglestr(t));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -603,7 +603,7 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
|
|||
} else {
|
||||
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
|
||||
" type %s (ignored).\n",
|
||||
input_file, line_number, DataType_print_type(t));
|
||||
input_file, line_number, DataType_str(t,0));
|
||||
}
|
||||
Delete(proc_name);
|
||||
}
|
||||
|
|
@ -656,7 +656,7 @@ MZSCHEME::declare_const (char *name, char *, DataType *type, char *value)
|
|||
} else {
|
||||
// Create variable and assign it a value
|
||||
|
||||
Printf (f_header, "static %s %s = ", DataType_print_type(type), var_name);
|
||||
Printf (f_header, "static %s %s = ", DataType_lstr(type,0), var_name);
|
||||
if ((type->type == T_CHAR) && (type->is_pointer <= 1)) {
|
||||
Printf (f_header, "\"%s\";\n", value);
|
||||
} else {
|
||||
|
|
@ -783,7 +783,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
|
|||
Insert(param,0," unspecified");
|
||||
else {
|
||||
Insert(param,0,"# ");
|
||||
Insert(param,0,DataType_print_type(d));
|
||||
Insert(param,0,DataType_str(d,0));
|
||||
Insert(param,0," $");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -704,12 +704,12 @@ void PERL5::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
|
||||
if (t->type == T_VOID) Printf(f, "(char *) 0 )) {\n");
|
||||
else
|
||||
Printv(f, "\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(t), "\")) {\n", 0);
|
||||
Printv(f, "\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_manglestr(t), "\")) {\n", 0);
|
||||
|
||||
// Change this part to return an error.
|
||||
Printv(f,
|
||||
tab8, "croak(\"Type error in ", srcname,
|
||||
" of ", iname, ". Expected ", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(t), ".\");\n",
|
||||
" of ", iname, ". Expected ", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_manglestr(t), ".\");\n",
|
||||
tab8, ret, ";\n",
|
||||
tab4, "}\n",
|
||||
0);
|
||||
|
|
@ -786,7 +786,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Produce string representation of source and target arguments
|
||||
sprintf(source,"ST(%d)",j);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(target,"%s", Parm_Getlname(p));
|
||||
sprintf(argnum,"%d",j+1);
|
||||
|
||||
// Check to see if this argument is being ignored
|
||||
|
|
@ -825,19 +825,19 @@ 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(pt),j);
|
||||
Printf(f->code," %s = (%s)SvIV(ST(%d));\n", target, DataType_lstr(pt,0),j);
|
||||
break;
|
||||
case T_CHAR :
|
||||
|
||||
|
||||
Printf(f->code," _arg%d = (char) *SvPV(ST(%d),PL_na);\n", i, j);
|
||||
Printf(f->code," %s = (char) *SvPV(ST(%d),PL_na);\n", target, j);
|
||||
break;
|
||||
|
||||
// Doubles
|
||||
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printf(f->code," _arg%d = %s SvNV(ST(%d));\n", i, DataType_print_cast(pt), j);
|
||||
Printf(f->code," %s = (%s)SvNV(ST(%d));\n", target, DataType_lstr(pt,0), j);
|
||||
break;
|
||||
|
||||
// Void.. Do nothing.
|
||||
|
|
@ -853,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(pt));
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_str(pt,0));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -862,8 +862,8 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// since that is usually a string.
|
||||
|
||||
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);
|
||||
Printf(f->code," if (! SvOK((SV*) ST(%d))) { %s = 0; }\n", j, target);
|
||||
Printf(f->code," else { %s = (char *) SvPV(ST(%d),PL_na); }\n", target,j);
|
||||
} else {
|
||||
|
||||
// Have a generic pointer type here. Read it in as a swig
|
||||
|
|
@ -927,7 +927,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
emit_func_call(name,d,l,f);
|
||||
|
||||
// See if there was a typemap
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"perl5",d,iname,(char*)"_result",(char*)"ST(argvi)"))) {
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"perl5",d,iname,(char*)"result",(char*)"ST(argvi)"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code, "%s\n", tm);
|
||||
} else if ((d->type != T_VOID) || (d->is_pointer)) {
|
||||
|
|
@ -940,18 +940,18 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_SHORT: case T_SSHORT: case T_USHORT:
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
case T_SCHAR: case T_UCHAR :
|
||||
Printf(f->code," sv_setiv(ST(argvi++),(IV) _result);\n");
|
||||
Printf(f->code," sv_setiv(ST(argvi++),(IV) result);\n");
|
||||
break;
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printf(f->code," sv_setnv(ST(argvi++), (double) _result);\n");
|
||||
Printf(f->code," sv_setnv(ST(argvi++), (double) result);\n");
|
||||
break;
|
||||
case T_CHAR :
|
||||
Wrapper_add_local(f,"_ctemp", "char _ctemp[2]");
|
||||
Wrapper_add_local(f,"_ctemp", "char ctemp[2]");
|
||||
Printv(f->code,
|
||||
tab4, "_ctemp[0] = _result;\n",
|
||||
tab4, "_ctemp[1] = 0;\n",
|
||||
tab4, "sv_setpv((SV*)ST(argvi++),_ctemp);\n",
|
||||
tab4, "ctemp[0] = result;\n",
|
||||
tab4, "ctemp[1] = 0;\n",
|
||||
tab4, "sv_setpv((SV*)ST(argvi++),ctemp);\n",
|
||||
0);
|
||||
break;
|
||||
|
||||
|
|
@ -960,13 +960,13 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_USER:
|
||||
d->is_pointer++;
|
||||
Printv(f->code,
|
||||
tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(d),
|
||||
"\", (void *) _result);\n", 0);
|
||||
tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_manglestr(d),
|
||||
"\", (void *) result);\n", 0);
|
||||
d->is_pointer--;
|
||||
break;
|
||||
|
||||
default :
|
||||
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, DataType_print_type(d), name);
|
||||
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, DataType_str(d,0), name);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -976,12 +976,12 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||
|
||||
// Return a character string
|
||||
Printf(f->code," sv_setpv((SV*)ST(argvi++),(char *) _result);\n");
|
||||
Printf(f->code," sv_setpv((SV*)ST(argvi++),(char *) result);\n");
|
||||
|
||||
} else {
|
||||
// Is an ordinary pointer type.
|
||||
Printv(f->code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(d),
|
||||
"\", (void *) _result);\n", 0);
|
||||
Printv(f->code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_manglestr(d),
|
||||
"\", (void *) result);\n", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -995,12 +995,12 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Printv(f->code,cleanup,0);
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"perl5",d,iname,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"perl5",d,iname,(char*)"result",(char*)""))) {
|
||||
Printf(f->code,"%s\n",tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"perl5",d,iname,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"perl5",d,iname,(char*)"result",(char*)""))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
|
|
@ -1188,11 +1188,11 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_SHORT : case T_SSHORT : case T_USHORT:
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
case T_UCHAR: case T_SCHAR:
|
||||
Printv(setf->code,tab4, name, " = ", DataType_print_cast(t), " SvIV(sv);\n", 0);
|
||||
Printv(setf->code,tab4, name, " = (", DataType_str(t,0), ") SvIV(sv);\n", 0);
|
||||
break;
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printv(setf->code, tab4, name, " = ", DataType_print_cast(t), " SvNV(sv);\n", 0);
|
||||
Printv(setf->code, tab4, name, " = (", DataType_str(t,0), ") SvNV(sv);\n", 0);
|
||||
break;
|
||||
case T_CHAR :
|
||||
Printv(setf->code, tab4, name, " = (char) *SvPV(sv,PL_na);\n", 0);
|
||||
|
|
@ -1206,12 +1206,12 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
t->is_pointer++;
|
||||
Wrapper_add_local(setf,"_temp", "void *_temp");
|
||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)");
|
||||
Printv(setf->code, tab4, name, " = *(", DataType_print_cast(t), " _temp);\n", 0);
|
||||
Printv(setf->code, tab4, name, " = *((", DataType_str(t,0), ") _temp);\n", 0);
|
||||
t->is_pointer--;
|
||||
break;
|
||||
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d. Unable to link with datatype %s (ignored).\n", input_file, line_number, DataType_print_type(t));
|
||||
Printf(stderr,"%s : Line %d. Unable to link with datatype %s (ignored).\n", input_file, line_number, DataType_str(t,0));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1236,7 +1236,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
|
||||
Wrapper_add_local(setf,"_temp","void *_temp");
|
||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)");
|
||||
Printv(setf->code,tab4, name, " = ", DataType_print_cast(t), " _temp;\n", 0);
|
||||
Printv(setf->code,tab4, name, " = (", DataType_str(t,0), ") _temp;\n", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1291,7 +1291,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
0);
|
||||
|
||||
Wrapper_add_local(getf,"rsv","SV *rsv");
|
||||
Printv(vinit, tab4, "sv_setref_pv(sv,\"", DataType_print_mangle(t), "\",(void *) &", name, ");\n",0);
|
||||
Printv(vinit, tab4, "sv_setref_pv(sv,\"", DataType_manglestr(t), "\",(void *) &", name, ");\n",0);
|
||||
t->is_pointer--;
|
||||
|
||||
break;
|
||||
|
|
@ -1311,7 +1311,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
0);
|
||||
|
||||
Wrapper_add_local(getf,"rsv","SV *rsv");
|
||||
Printv(vinit, tab4, "sv_setref_pv(sv,\"", DataType_print_mangle(t), "\",(void *) 1);\n",0);
|
||||
Printv(vinit, tab4, "sv_setref_pv(sv,\"", DataType_manglestr(t), "\",(void *) 1);\n",0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1475,7 +1475,7 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
|
|||
have_ref_func = 1;
|
||||
}
|
||||
Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"",
|
||||
DataType_print_mangle(type), "\");\n", 0);
|
||||
DataType_manglestr(type), "\");\n", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1544,7 +1544,7 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
|
|||
if (strlen(pn) > 0) {
|
||||
Printf(temp,"%s",pn);
|
||||
} else {
|
||||
Printf(temp,"%s",DataType_print_type(pt));
|
||||
Printf(temp,"%s",DataType_str(pt,0));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ PYTHON::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
|
||||
if (t->type == T_VOID) Printv(f, "0,1)) == -1) return ", ret, ";\n", 0);
|
||||
else
|
||||
Printv(f,"SWIGTYPE", DataType_print_mangle(t), ",1)) == -1) return ", ret, ";\n", 0);
|
||||
Printv(f,"SWIGTYPE", DataType_manglestr(t), ",1)) == -1) return ", ret, ";\n", 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -652,7 +652,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
emit_function_header(f, wname);
|
||||
|
||||
Wrapper_add_local(f,"_resultobj", "PyObject *_resultobj");
|
||||
Wrapper_add_local(f,"resultobj", "PyObject *resultobj");
|
||||
|
||||
// Get the function usage string for later use
|
||||
|
||||
|
|
@ -674,7 +674,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Printf(parse_args," if(!PyArg_ParseTuple(args,\"");
|
||||
} else {
|
||||
Printf(parse_args," if(!PyArg_ParseTupleAndKeywords(args,kwargs,\"");
|
||||
Printf(arglist,",_kwnames");
|
||||
Printf(arglist,",kwnames");
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
|
@ -690,8 +690,8 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
char *pv = Parm_Getvalue(p);
|
||||
|
||||
// Generate source and target strings
|
||||
sprintf(source,"_obj%d",i);
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(source,"obj%d",i);
|
||||
sprintf(target,Parm_Getlname(p));
|
||||
sprintf(argnum,"%d",j+1);
|
||||
|
||||
// Only consider this argument if it's not ignored
|
||||
|
|
@ -770,7 +770,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
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(pt), " ", tempb, ";\n", 0);
|
||||
Printv(get_pointers, tab4, target, " = (", DataType_lstr(pt,0), ") ", tempb, ";\n", 0);
|
||||
Printf(arglist,"&%s",tempb);
|
||||
}
|
||||
break;
|
||||
|
|
@ -783,8 +783,8 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_USER:
|
||||
|
||||
Putc('O',parse_args);
|
||||
sprintf(source,"_argo%d", i);
|
||||
sprintf(target,"_arg%d", i);
|
||||
sprintf(source,"argo%d", i);
|
||||
sprintf(target,Parm_Getlname(p));
|
||||
sprintf(temp,"argument %d",i+1);
|
||||
|
||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||
|
|
@ -796,14 +796,14 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
break;
|
||||
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(pt));
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_str(pt,0));
|
||||
break;
|
||||
}
|
||||
|
||||
// Emit code for parameter list
|
||||
|
||||
if ((pt->type != T_VOID) && (pt->type != T_BOOL) && (pt->type != T_USER))
|
||||
Printf(arglist,"&_arg%d",i);
|
||||
Printf(arglist,"&%s",Parm_Getlname(p));
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -811,15 +811,15 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
||||
Putc('s',parse_args);
|
||||
Printf(arglist,"&_arg%d",i);
|
||||
Printf(arglist,"&%s", Parm_Getlname(p));
|
||||
} else {
|
||||
|
||||
// Have some sort of pointer variable. Create a temporary local
|
||||
// variable for the string and read the pointer value into it.
|
||||
|
||||
Putc('O',parse_args);
|
||||
sprintf(source,"_argo%d", i);
|
||||
sprintf(target,"_arg%d", i);
|
||||
sprintf(source,"argo%d", i);
|
||||
sprintf(target,"%s",Parm_Getlname(p));
|
||||
sprintf(temp,"argument %d",i+1);
|
||||
|
||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||
|
|
@ -841,7 +841,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Replace(cleanup,"$argnum", argnum, DOH_REPLACE_ANY);
|
||||
Replace(cleanup,"$arg",source, DOH_REPLACE_ANY);
|
||||
}
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"python",pt,pn,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);
|
||||
|
|
@ -853,7 +853,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
Printf(kwargs," NULL }");
|
||||
if (use_kw) {
|
||||
Printv(f->locals,tab4, "char *_kwnames[] = ", kwargs, ";\n", 0);
|
||||
Printv(f->locals,tab4, "char *kwnames[] = ", kwargs, ";\n", 0);
|
||||
}
|
||||
|
||||
Printf(parse_args,":%s\"", iname);
|
||||
|
|
@ -873,10 +873,10 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
emit_func_call(call_name,d,l,f);
|
||||
|
||||
// Now emit code to return the functions return value (if any).
|
||||
// If there was a result, it was saved in _result.
|
||||
// If there was a result, it was saved in result.
|
||||
// If the function is a void type, don't do anything.
|
||||
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"python",d,iname,(char*)"_result",(char*)"_resultobj"))) {
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"python",d,iname,(char*)"result",(char*)"resultobj"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
} else {
|
||||
|
|
@ -893,42 +893,42 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Return an integer type
|
||||
|
||||
case T_INT: case T_SINT: case T_UINT: case T_BOOL:
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"i\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"i\",result);\n");
|
||||
break;
|
||||
case T_SHORT: case T_SSHORT: case T_USHORT:
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"h\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"h\",result);\n");
|
||||
break;
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"l\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"l\",result);\n");
|
||||
break;
|
||||
case T_SCHAR: case T_UCHAR :
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"b\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"b\",result);\n");
|
||||
break;
|
||||
|
||||
// Return a floating point value
|
||||
|
||||
case T_DOUBLE :
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"d\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"d\",result);\n");
|
||||
break;
|
||||
case T_FLOAT :
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"f\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"f\",result);\n");
|
||||
break;
|
||||
|
||||
// Return a single ASCII value. Usually we need to convert
|
||||
// it to a NULL-terminate string and return that instead.
|
||||
|
||||
case T_CHAR :
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"c\",_result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"c\",result);\n");
|
||||
break;
|
||||
|
||||
case T_USER :
|
||||
d->is_pointer++;
|
||||
DataType_remember(d);
|
||||
Printv(f->code,tab4, "_resultobj = SWIG_NewPointerObj((void *)_result, SWIGTYPE", DataType_print_mangle(d), ");\n",0);
|
||||
Printv(f->code,tab4, "resultobj = SWIG_NewPointerObj((void *)result, SWIGTYPE", DataType_manglestr(d), ");\n",0);
|
||||
d->is_pointer--;
|
||||
break;
|
||||
default :
|
||||
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, DataType_print_type(d), name);
|
||||
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, DataType_str(d,0), name);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -940,19 +940,19 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||
|
||||
// Return a character string
|
||||
Printf(f->code," _resultobj = Py_BuildValue(\"s\", _result);\n");
|
||||
Printf(f->code," resultobj = Py_BuildValue(\"s\", result);\n");
|
||||
|
||||
// If declared as a new object, free the result
|
||||
|
||||
} else {
|
||||
// Build a SWIG pointer.
|
||||
DataType_remember(d);
|
||||
Printv(f->code, tab4, "_resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE", DataType_print_mangle(d), ");\n", 0);
|
||||
Printv(f->code, tab4, "resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE", DataType_manglestr(d), ");\n", 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Printf(f->code," Py_INCREF(Py_None);\n");
|
||||
Printf(f->code," _resultobj = Py_None;\n");
|
||||
Printf(f->code," resultobj = Py_None;\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -968,19 +968,19 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Look to see if there is any newfree cleanup code
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"python",d,iname,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"python",d,iname,(char*)"result",(char*)""))) {
|
||||
Printf(f->code,"%s\n",tm);
|
||||
}
|
||||
}
|
||||
|
||||
// See if there is any argument cleanup code
|
||||
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"python",d,iname,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"python",d,iname,(char*)"result",(char*)""))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n",tm);
|
||||
}
|
||||
|
||||
Printf(f->code," return _resultobj;\n}\n");
|
||||
Printf(f->code," return resultobj;\n}\n");
|
||||
|
||||
// Substitute the cleanup code
|
||||
Replace(f->code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
|
|
@ -1121,12 +1121,12 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
case T_SINT: case T_SSHORT: case T_SLONG:
|
||||
case T_SCHAR: case T_UCHAR: case T_BOOL:
|
||||
// Get an integer value
|
||||
Wrapper_add_localv(setf,"tval",DataType_print_type(t),"tval",0);
|
||||
Wrapper_add_localv(setf,"tval",DataType_lstr(t,0),"tval",0);
|
||||
Printv(setf->code,
|
||||
tab4, "tval = ", DataType_print_cast(t), "PyInt_AsLong(val);\n",
|
||||
tab4, "tval = (", DataType_lstr(t,0), ") PyInt_AsLong(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
||||
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||
tab8, "return 1; \n",
|
||||
tab4, "}\n",
|
||||
tab4, name, " = tval;\n",
|
||||
|
|
@ -1135,12 +1135,12 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
|
||||
case T_FLOAT: case T_DOUBLE:
|
||||
// Get a floating point value
|
||||
Wrapper_add_localv(setf,"tval",DataType_print_type(t), "tval",0);
|
||||
Wrapper_add_localv(setf,"tval",DataType_lstr(t,0), "tval",0);
|
||||
Printv(setf->code,
|
||||
tab4, "tval = ", DataType_print_cast(t), "PyFloat_AsDouble(val);\n",
|
||||
tab4, "tval = (", DataType_lstr(t,0), ") PyFloat_AsDouble(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
||||
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||
tab8, "return 1; \n",
|
||||
tab4, "}\n",
|
||||
tab4, name, " = tval;\n",
|
||||
|
|
@ -1155,7 +1155,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
tab4, "tval = (char *) PyString_AsString(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
||||
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||
tab8, "return 1; \n",
|
||||
tab4, "}\n",
|
||||
tab4, name, " = *tval;\n",
|
||||
|
|
@ -1163,13 +1163,13 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
break;
|
||||
case T_USER:
|
||||
t->is_pointer++;
|
||||
Wrapper_add_localv(setf,"temp",DataType_print_type(t),"temp",0);
|
||||
Wrapper_add_localv(setf,"temp",DataType_lstr(t,0),"temp",0);
|
||||
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1");
|
||||
Printv(setf->code, tab4, name, " = *temp;\n", 0);
|
||||
t->is_pointer--;
|
||||
break;
|
||||
default:
|
||||
Printf(stderr,"%s : Line %d. Unable to link with type %s.\n", input_file, line_number, DataType_print_type(t));
|
||||
Printf(stderr,"%s : Line %d. Unable to link with type %s.\n", input_file, line_number, DataType_str(t,0));
|
||||
}
|
||||
} else {
|
||||
|
||||
|
|
@ -1181,7 +1181,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
tab4, "tval = (char *) PyString_AsString(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
||||
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||
tab8, "return 1; \n",
|
||||
tab4, "}\n",
|
||||
0);
|
||||
|
|
@ -1203,7 +1203,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
|
||||
// Is a generic pointer value.
|
||||
|
||||
Wrapper_add_localv(setf,"temp", DataType_print_type(t), "temp",0);
|
||||
Wrapper_add_localv(setf,"temp", DataType_lstr(t,0), "temp",0);
|
||||
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1");
|
||||
Printv(setf->code,tab4, name, " = temp;\n", 0);
|
||||
}
|
||||
|
|
@ -1267,12 +1267,12 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
DataType_remember(t);
|
||||
Printv(getf->code,
|
||||
tab4, "pyobj = SWIG_NewPointerObj((void *) &", name ,
|
||||
", SWIGTYPE", DataType_print_mangle(t), ");\n",
|
||||
", SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||
0);
|
||||
t->is_pointer--;
|
||||
break;
|
||||
default:
|
||||
Printf(stderr,"Unable to link with type %s\n", DataType_print_type(t));
|
||||
Printf(stderr,"Unable to link with type %s\n", DataType_str(t,0));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1288,7 +1288,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
DataType_remember(t);
|
||||
Printv(getf->code,
|
||||
tab4, "pyobj = SWIG_NewPointerObj((void *)", name,
|
||||
", SWIGTYPE", DataType_print_mangle(t), ");\n",
|
||||
", SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1367,7 +1367,7 @@ void PYTHON::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
} else {
|
||||
// A funky user-defined type. We're going to munge it into a string pointer value
|
||||
DataType_remember(type);
|
||||
Printv(const_code, tab4, "{ SWIG_PY_POINTER, \"", name, "\", 0, 0, (void *) ", value, ", &SWIGTYPE", DataType_print_mangle(type), "}, \n", 0);
|
||||
Printv(const_code, tab4, "{ SWIG_PY_POINTER, \"", name, "\", 0, 0, (void *) ", value, ", &SWIGTYPE", DataType_manglestr(type), "}, \n", 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1432,7 +1432,7 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
|
|||
if (strlen(pn) > 0) {
|
||||
Printf(temp,"%s",pn);
|
||||
} else {
|
||||
Printf(temp,"%s", DataType_print_type(pt));
|
||||
Printf(temp,"%s", DataType_str(pt,0));
|
||||
}
|
||||
}
|
||||
p = ParmList_next(l);
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
else
|
||||
sprintf(source,"varg%d",i);
|
||||
|
||||
sprintf(target,"_arg%d",i);
|
||||
sprintf(target,"%s", Parm_Getlname(p));
|
||||
|
||||
if (!p->ignore) {
|
||||
char *tab = (char*)tab4;
|
||||
|
|
@ -540,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(pt));
|
||||
input_file,line_number, DataType_str(pt,0));
|
||||
}
|
||||
if (j >= (pcount-numopt))
|
||||
Printv(f->code, tab4, "} \n");
|
||||
|
|
@ -580,12 +580,13 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
// Now write code to make the function call
|
||||
emit_func_call(name,t,l,f);
|
||||
|
||||
|
||||
// Return value if necessary
|
||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||
if (predicate) {
|
||||
Printv(f->code, tab4, "vresult = (_result ? Qtrue : Qfalse);\n", 0);
|
||||
Printv(f->code, tab4, "vresult = (result ? Qtrue : Qfalse);\n", 0);
|
||||
} else {
|
||||
tm = ruby_typemap_lookup((char*)"out",t,name,(char*)"_result",(char*)"vresult");
|
||||
tm = ruby_typemap_lookup((char*)"out",t,name,(char*)"result",(char*)"vresult");
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
|
|
@ -593,7 +594,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
Delete(s);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. No return typemap for datatype %s\n",
|
||||
input_file,line_number,DataType_print_type(t));
|
||||
input_file,line_number,DataType_str(t,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -606,7 +607,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
// Look for any remaining cleanup. This processes the %new directive
|
||||
if (NewObject) {
|
||||
tm = ruby_typemap_lookup((char*)"newfree",t,name,(char*)"_result",(char*)"");
|
||||
tm = ruby_typemap_lookup((char*)"newfree",t,name,(char*)"result",(char*)"");
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
|
|
@ -621,7 +622,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Special processing on return value.
|
||||
tm = ruby_typemap_lookup((char*)"ret",t,name,(char*)"_result",(char*)"");
|
||||
tm = ruby_typemap_lookup((char*)"ret",t,name,(char*)"result",(char*)"");
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
|
|
@ -686,11 +687,11 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
t->is_pointer++;
|
||||
DataType_remember(t);
|
||||
Printv(getf->code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
||||
", \"", DataType_print_mangle(t), "\");\n", 0);
|
||||
", \"", DataType_manglestr(t), "\");\n", 0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
||||
input_file,line_number,DataType_print_type(t));
|
||||
input_file,line_number,DataType_str(t,0));
|
||||
}
|
||||
Printv(getf->code, tab4, "return _val;\n}\n", 0);
|
||||
Wrapper_print(getf,f_wrappers);
|
||||
|
|
@ -716,15 +717,15 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
Delete(s);
|
||||
} else if (!t->is_pointer && t->type == T_USER) {
|
||||
t->is_pointer++;
|
||||
Wrapper_add_localv(setf,"temp",DataType_print_type(t), "temp",0);
|
||||
Printv(setf->code, tab4, "temp = (", DataType_print_type(t), ")",
|
||||
"SWIG_ConvertPtr(_val, \"", DataType_print_mangle(t), "\");\n",
|
||||
Wrapper_add_localv(setf,"temp",DataType_lstr(t,0), "temp",0);
|
||||
Printv(setf->code, tab4, "temp = (", DataType_lstr(t,0), ")",
|
||||
"SWIG_ConvertPtr(_val, \"", DataType_manglestr(t), "\");\n",
|
||||
0);
|
||||
Printv(setf->code, tab4, name, " = *temp;\n",0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
||||
input_file,line_number,DataType_print_type(t));
|
||||
input_file,line_number,DataType_str(t,0));
|
||||
}
|
||||
if (mod_attr)
|
||||
Printv(setf->code, tab4, "return _val;\n",0);
|
||||
|
|
@ -846,7 +847,7 @@ void RUBY::declare_const(char *name, char *iname, DataType *type, char *value) {
|
|||
Delete(str);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. Unable to create constant %s = %s\n",
|
||||
input_file, line_number, DataType_print_type(type), value);
|
||||
input_file, line_number, DataType_str(type,0), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -916,7 +917,7 @@ char *RUBY::ruby_typemap_lookup(char *op, DataType *type, char *pname, char *sou
|
|||
Replace(s,"$source",source, DOH_REPLACE_ANY);
|
||||
if (target && strlen(target) > 0)
|
||||
Replace(s,"$target",target, DOH_REPLACE_ANY);
|
||||
Replace(s,"$type", DataType_print_type(type), DOH_REPLACE_ANY);
|
||||
Replace(s,"$type", DataType_str(type,0), DOH_REPLACE_ANY);
|
||||
return Char(s);
|
||||
}
|
||||
|
||||
|
|
@ -964,7 +965,7 @@ int RUBY::to_VALUE(DataType *type, char *value, DOHString *str, int raw) {
|
|||
else
|
||||
Printv(str, "rb_str_new2(", value, ")", 0);
|
||||
} else {
|
||||
Printv(str, "SWIG_NewPointerObj((void *)", value, ", \"", DataType_print_mangle(type), "\")", 0);
|
||||
Printv(str, "SWIG_NewPointerObj((void *)", value, ", \"", DataType_manglestr(type), "\")", 0);
|
||||
}
|
||||
|
||||
if (Len(str) == 0)
|
||||
|
|
@ -1018,7 +1019,7 @@ int RUBY::from_VALUE(DataType *type, char *value, DOHString *str) {
|
|||
} else if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||
Printv(str, "STR2CSTR(", value, ")", 0);
|
||||
} else {
|
||||
Printv(str, "SWIG_ConvertPtr(", value, ", \"", DataType_print_mangle(type), "\")", 0);
|
||||
Printv(str, "SWIG_ConvertPtr(", value, ", \"", DataType_manglestr(type), "\")", 0);
|
||||
}
|
||||
|
||||
if (Len(str) == 0) return 0;
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ void TCL8::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
|
||||
if (t->type == T_VOID) Printf(f, "0)) == TCL_ERROR) { return TCL_ERROR; }\n");
|
||||
else
|
||||
Printv(f, "SWIGTYPE", DataType_print_mangle(t), ")) == TCL_ERROR) { return TCL_ERROR; }\n", 0);
|
||||
Printv(f, "SWIGTYPE", DataType_manglestr(t), ")) == TCL_ERROR) { return TCL_ERROR; }\n", 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -487,7 +487,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
Printv(f->def,
|
||||
"static int ", wname, "(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {",
|
||||
"static int\n ", wname, "(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {",
|
||||
0);
|
||||
|
||||
// Print out variables for storing arguments.
|
||||
|
|
@ -513,7 +513,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
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);
|
||||
sprintf(target,"%s", Parm_Getlname(p));
|
||||
sprintf(argnum,"%d",j+1);
|
||||
|
||||
// See if this argument is being ignored
|
||||
|
|
@ -602,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(pt));
|
||||
input_file, line_number, DataType_str(pt,0));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -616,7 +616,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
} else {
|
||||
DataType_remember(pt);
|
||||
Putc('p',argstr);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", DataType_print_mangle(pt), 0);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", DataType_manglestr(pt), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Return value if necessary
|
||||
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"tcl8",d,name,(char*)"_result",(char*)"tcl_result"))) {
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"tcl8",d,name,(char*)"result",(char*)"tcl_result"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
} else if ((d->type != T_VOID) || (d->is_pointer)) {
|
||||
|
|
@ -682,18 +682,18 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) _result));\n",0);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) result));\n",0);
|
||||
break;
|
||||
|
||||
// Is a single character. Assume we return it as a string
|
||||
case T_CHAR :
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(&_result,1));\n",0);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(&result,1));\n",0);
|
||||
break;
|
||||
|
||||
// Floating point number
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) _result));\n",0);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) result));\n",0);
|
||||
break;
|
||||
|
||||
// User defined type
|
||||
|
|
@ -704,8 +704,8 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
d->is_pointer++;
|
||||
DataType_remember(d);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
||||
DataType_print_mangle(d), "));\n", 0);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE",
|
||||
DataType_manglestr(d), "));\n", 0);
|
||||
|
||||
d->is_pointer--;
|
||||
break;
|
||||
|
|
@ -713,7 +713,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unknown type
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d: Unable to use return type %s in function %s.\n",
|
||||
input_file, line_number, DataType_print_type(d), name);
|
||||
input_file, line_number, DataType_str(d,0), name);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -722,11 +722,11 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||
// Return a character string
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(_result,-1));\n",0);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(result,-1));\n",0);
|
||||
} else {
|
||||
DataType_remember(d);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
||||
DataType_print_mangle(d), "));\n",
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE",
|
||||
DataType_manglestr(d), "));\n",
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
|
@ -741,12 +741,12 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"tcl8",d,iname,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"tcl8",d,iname,(char*)"result",(char*)""))) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"tcl8",d,name,(char*)"_result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"tcl8",d,name,(char*)"result",(char*)""))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
|
|
@ -792,19 +792,19 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
}
|
||||
|
||||
// Dump a collection of set/get functions suitable for variable tracing
|
||||
if (!Getattr(setget,DataType_print_type(t))) {
|
||||
Setattr(setget,DataType_print_type(t),"1");
|
||||
if (!Getattr(setget,DataType_str(t,0))) {
|
||||
Setattr(setget,DataType_str(t,0),"1");
|
||||
Wrapper *get, *set;
|
||||
get = NewWrapper();
|
||||
set = NewWrapper();
|
||||
Printv(set->def, "static char *_swig_", DataType_print_mangle(t), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
Printv(set->def, "static char *_swig_", DataType_manglestr(t), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
|
||||
Printv(get->def, "static char *_swig_", DataType_print_mangle(t), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
Printv(get->def, "static char *_swig_", DataType_manglestr(t), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
t->is_pointer++;
|
||||
Wrapper_add_localv(get,"addr",DataType_print_type(t),"addr",0);
|
||||
Wrapper_add_localv(set,"addr",DataType_print_type(t),"addr",0);
|
||||
Printv(set->code, tab4, "addr = ", DataType_print_cast(t), " clientData;\n", 0);
|
||||
Printv(get->code, tab4, "addr = ", DataType_print_cast(t), " clientData;\n", 0);
|
||||
Wrapper_add_localv(get,"addr",DataType_str(t,0),"addr",0);
|
||||
Wrapper_add_localv(set,"addr",DataType_str(t,0),"addr",0);
|
||||
Printv(set->code, tab4, "addr = (", DataType_lstr(t,0), ") clientData;\n", 0);
|
||||
Printv(get->code, tab4, "addr = (", DataType_lstr(t,0), ") clientData;\n", 0);
|
||||
t->is_pointer--;
|
||||
Wrapper_add_local(set, "value", "char *value");
|
||||
Wrapper_add_local(get, "value", "Tcl_Obj *value");
|
||||
|
|
@ -824,15 +824,15 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_UCHAR:
|
||||
case T_SCHAR:
|
||||
case T_BOOL:
|
||||
Printv(set->code, tab4, "*(addr) = ", DataType_print_cast(t), "atol(value);\n", 0);
|
||||
Printv(set->code, tab4, "*(addr) = (", DataType_str(t,0), ") atol(value);\n", 0);
|
||||
break;
|
||||
case T_UINT:
|
||||
case T_ULONG:
|
||||
Printv(set->code, tab4, "*(addr) = ", DataType_print_cast(t), "strtoul(value,0,0);\n",0);
|
||||
Printv(set->code, tab4, "*(addr) = (", DataType_str(t,0), ") strtoul(value,0,0);\n",0);
|
||||
break;
|
||||
case T_FLOAT:
|
||||
case T_DOUBLE:
|
||||
Printv(set->code, tab4, "*(addr) = ", DataType_print_cast(t), "atof(value);\n",0);
|
||||
Printv(set->code, tab4, "*(addr) = (", DataType_str(t,0), ") atof(value);\n",0);
|
||||
break;
|
||||
case T_CHAR: /* Single character. */
|
||||
Printv(set->code, tab4, "*(addr) = *value;\n",0);
|
||||
|
|
@ -843,10 +843,10 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
DataType_remember(t);
|
||||
Printv(set->code, tab4, "{\n",
|
||||
tab8, "void *ptr;\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_print_mangle(t), ") != TCL_OK) {\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_manglestr(t), ") != TCL_OK) {\n",
|
||||
tab8, tab4, "return \"Type Error\";\n",
|
||||
tab8, "}\n",
|
||||
tab8, "*(addr) = *(", DataType_print_cast(t), " ptr);\n",
|
||||
tab8, "*(addr) = *((", DataType_lstr(t,0), ") ptr);\n",
|
||||
tab4, "}\n",
|
||||
0);
|
||||
|
||||
|
|
@ -867,10 +867,10 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
DataType_remember(t);
|
||||
Printv(set->code, tab4, "{\n",
|
||||
tab8, "void *ptr;\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_print_mangle(t), ") != TCL_OK) {\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_manglestr(t), ") != TCL_OK) {\n",
|
||||
tab8, tab4, "return \"Type Error\";\n",
|
||||
tab8, "}\n",
|
||||
tab8, "*(addr) = ", DataType_print_cast(t), " ptr;\n",
|
||||
tab8, "*(addr) = (", DataType_lstr(t,0), ") ptr;\n",
|
||||
tab4, "}\n",
|
||||
0);
|
||||
|
||||
|
|
@ -921,7 +921,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
Wrapper_add_local(get,"value", "Tcl_Obj *value");
|
||||
t->is_pointer++;
|
||||
DataType_remember(t);
|
||||
Printv(get->code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", DataType_print_mangle(t), ");\n",
|
||||
Printv(get->code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",0);
|
||||
t->is_pointer--;
|
||||
|
|
@ -937,7 +937,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
Wrapper_add_local(get,"value","Tcl_Obj *value");
|
||||
DataType_remember(t);
|
||||
Printv(get->code,
|
||||
tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", DataType_print_mangle(t), ");\n",
|
||||
tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",
|
||||
0);
|
||||
|
|
@ -950,7 +950,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
DelWrapper(get);
|
||||
DelWrapper(set);
|
||||
}
|
||||
Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) &", name, ", _swig_", DataType_print_mangle(t), "_get,", 0);
|
||||
Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) &", name, ", _swig_", DataType_manglestr(t), "_get,", 0);
|
||||
|
||||
if (Status & STAT_READONLY) {
|
||||
static int readonly = 0;
|
||||
|
|
@ -964,7 +964,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
}
|
||||
Printf(var_info, "_swig_readonly},\n");
|
||||
} else {
|
||||
Printv(var_info, "_swig_", DataType_print_mangle(t), "_set},\n",0);
|
||||
Printv(var_info, "_swig_", DataType_manglestr(t), "_set},\n",0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1007,7 +1007,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
if (type->is_pointer == 0) {
|
||||
switch(type->type) {
|
||||
case T_BOOL: case T_INT: case T_SINT: case T_DOUBLE:
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_str(type,0), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
case T_SHORT:
|
||||
|
|
@ -1015,7 +1015,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
case T_SSHORT:
|
||||
case T_SCHAR:
|
||||
case T_SLONG:
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
|
|
@ -1033,7 +1033,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
|
|
@ -1050,13 +1050,13 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
case T_FLOAT:
|
||||
type->type = T_DOUBLE;
|
||||
strcpy(type->name,"double");
|
||||
Printf(f_header,"static %s %s = %s (%s);\n", DataType_print_type(type), var_name, DataType_print_cast(type), value);
|
||||
Printf(f_header,"static %s %s = (%s) (%s);\n", DataType_lstr(type,0), var_name, DataType_lstr(type,0), value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
|
||||
case T_CHAR:
|
||||
type->is_pointer++;
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", DataType_print_type(type), var_name, value);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", DataType_lstr(type,0), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
type->is_pointer--;
|
||||
break;
|
||||
|
|
@ -1068,22 +1068,22 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
// Have some sort of pointer value here
|
||||
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||
// Character string
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", DataType_print_type(type), var_name, value);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", DataType_lstr(type,0), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
} else {
|
||||
// Something else. Some sort of pointer value
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_lstr(type,0), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(DataType_print_mangle(type))+ 20);
|
||||
Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(DataType_manglestr(type))+ 20);
|
||||
else
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(DataType_print_mangle(type))+ 20);
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(DataType_manglestr(type))+ 20);
|
||||
|
||||
t = NewDataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
DataType_remember(type);
|
||||
Printf(f_init,"\t SWIG_MakePtr(%s_char, (void *) %s, SWIGTYPE%s);\n",
|
||||
var_name, var_name, DataType_print_mangle(type));
|
||||
var_name, var_name, DataType_manglestr(type));
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
link_variable(var_name,name,t);
|
||||
DelDataType(t);
|
||||
|
|
@ -1161,7 +1161,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
|||
Printf(temp,pn);
|
||||
}
|
||||
else {
|
||||
Printf(temp,"{ %s }", DataType_print_type(pt));
|
||||
Printf(temp,"{ %s }", DataType_str(pt,0));
|
||||
}
|
||||
}
|
||||
if (i >= (pcount-numopt))
|
||||
|
|
@ -1296,7 +1296,7 @@ void TCL8::cpp_close_class() {
|
|||
|
||||
if (have_destructor) {
|
||||
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n",
|
||||
tab4, Swig_name_destroy(real_classname), "((", DataType_print_type(t), ") obj);\n",
|
||||
tab4, Swig_name_destroy(real_classname), "((", DataType_str(t,0), ") obj);\n",
|
||||
"}\n",0);
|
||||
}
|
||||
|
||||
|
|
@ -1307,7 +1307,7 @@ void TCL8::cpp_close_class() {
|
|||
Printv(code,attributes,0);
|
||||
|
||||
Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name,
|
||||
"\", &SWIGTYPE", DataType_print_mangle(t), ",",0);
|
||||
"\", &SWIGTYPE", DataType_manglestr(t), ",",0);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(code, Swig_name_wrapper(Swig_name_construct(class_name)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue