More work on smoothing out the type system. Needs more work however.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@592 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9ccd0daa88
commit
cc46a46b6d
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)
|
if (t->type == T_VOID)
|
||||||
Printf(f->code, ", (char *) 0)) {\n");
|
Printf(f->code, ", (char *) 0)) {\n");
|
||||||
else
|
else
|
||||||
Printv(f->code, ", \"", DataType_print_mangle(t), "\")) {\n", 0);
|
Printv(f->code, ", \"", DataType_manglestr(t), "\")) {\n", 0);
|
||||||
/* Raise exception */
|
/* Raise exception */
|
||||||
Printv(f->code,
|
Printv(f->code,
|
||||||
tab8,
|
tab8,
|
||||||
|
|
@ -474,7 +474,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
// Produce names of source and target
|
// Produce names of source and target
|
||||||
sprintf(source,"s_%d",i);
|
sprintf(source,"s_%d",i);
|
||||||
sprintf(target,"_arg%d",i);
|
sprintf(target,"%s",Parm_Getlname(p));
|
||||||
sprintf(argnum,"%d",i);
|
sprintf(argnum,"%d",i);
|
||||||
strcpy(arg,pn);
|
strcpy(arg,pn);
|
||||||
|
|
||||||
|
|
@ -532,7 +532,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
||||||
if (d->type == T_VOID)
|
if (d->type == T_VOID)
|
||||||
Printv(f->code, tab4, "gswig_result = GH_UNSPECIFIED;\n", 0);
|
Printv(f->code, tab4, "gswig_result = GH_UNSPECIFIED;\n", 0);
|
||||||
else if ((tm = typemap_lookup ((char*)"out", typemap_lang,
|
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);
|
Printv(f->code,tm,"\n",0);
|
||||||
mreplace (f->code, argnum, arg, proc_name);
|
mreplace (f->code, argnum, arg, proc_name);
|
||||||
}
|
}
|
||||||
|
|
@ -541,9 +541,9 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
||||||
look-up. */
|
look-up. */
|
||||||
Printv(f->code, tab4,
|
Printv(f->code, tab4,
|
||||||
"gswig_result = SWIG_Guile_MakePtr_Str (",
|
"gswig_result = SWIG_Guile_MakePtr_Str (",
|
||||||
"_result, ",
|
"result, ",
|
||||||
"\"", DataType_print_mangle(d), "\", ",
|
"\"", DataType_manglestr(d), "\", ",
|
||||||
"\"", DataType_print_type(d), "\"",
|
"\"", DataType_str(d,0), "\"",
|
||||||
");\n",
|
");\n",
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
@ -561,7 +561,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
if (NewObject) {
|
if (NewObject) {
|
||||||
if ((tm = typemap_lookup ((char*)"newfree", typemap_lang,
|
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);
|
Printv(f->code,tm,"\n",0);
|
||||||
mreplace (f->code, argnum, arg, proc_name);
|
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..
|
// Free any memory allocated by the function being wrapped..
|
||||||
|
|
||||||
if ((tm = typemap_lookup ((char*)"ret", typemap_lang,
|
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);
|
Printv(f->code,tm,"\n",0);
|
||||||
mreplace (f->code, argnum, arg, proc_name);
|
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)
|
if (t->type == T_VOID)
|
||||||
Printf (f_wrappers, "(char *) 0)) {\n");
|
Printf (f_wrappers, "(char *) 0)) {\n");
|
||||||
else
|
else
|
||||||
Printf (f_wrappers, "\"%s\")) {\n", DataType_print_mangle(t));
|
Printf (f_wrappers, "\"%s\")) {\n", DataType_manglestr(t));
|
||||||
/* Raise exception */
|
/* Raise exception */
|
||||||
Printf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", "
|
Printf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", "
|
||||||
"%d, s_0);\n", proc_name, 1);
|
"%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
|
/* MK: I would like to use SWIG_Guile_MakePtr here to save one type
|
||||||
look-up. */
|
look-up. */
|
||||||
Printf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str ("
|
Printf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str ("
|
||||||
"%s, \"%s\", \"%s\");\n", name, DataType_print_mangle(t),
|
"%s, \"%s\", \"%s\");\n", name, DataType_manglestr(t),
|
||||||
DataType_print_type(t));
|
DataType_str(t,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -717,7 +717,7 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
|
||||||
} else {
|
} else {
|
||||||
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
|
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
|
||||||
" type %s (ignored).\n",
|
" type %s (ignored).\n",
|
||||||
input_file, line_number, DataType_print_type(t));
|
input_file, line_number, DataType_str(t,0));
|
||||||
}
|
}
|
||||||
Delete(proc_name);
|
Delete(proc_name);
|
||||||
}
|
}
|
||||||
|
|
@ -769,7 +769,7 @@ GUILE::declare_const (char *name, char *, DataType *type, char *value)
|
||||||
} else {
|
} else {
|
||||||
// Create variable and assign it a value
|
// 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)) {
|
if ((type->type == T_CHAR) && (type->is_pointer <= 1)) {
|
||||||
Printf (f_header, "\"%s\";\n", value);
|
Printf (f_header, "\"%s\";\n", value);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -898,7 +898,7 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
|
||||||
Insert(param,0," unspecified ");
|
Insert(param,0," unspecified ");
|
||||||
else {
|
else {
|
||||||
Insert(param,0,"# ");
|
Insert(param,0,"# ");
|
||||||
Insert(param,0, DataType_print_type(d));
|
Insert(param,0, DataType_str(d,0));
|
||||||
Insert(param,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
|
// Produce string representation of source and target arguments
|
||||||
sprintf(source,"jarg%d",i);
|
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);
|
char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
|
||||||
if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
|
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);
|
Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
|
||||||
} else {
|
} else {
|
||||||
if(!pt->is_pointer)
|
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) ||
|
else if((pt->type == T_VOID && pt->is_pointer == 1) ||
|
||||||
(pt->type == T_USER && pt->is_pointer == 1)) {
|
(pt->type == T_USER && pt->is_pointer == 1)) {
|
||||||
pt->is_pointer++;
|
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--;
|
pt->is_pointer--;
|
||||||
} else {
|
} else {
|
||||||
if(pt->type == T_CHAR && pt->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);
|
Printv(f->code, tab4, target, " = (", source, ") ? (char *)", JNICALL((char*)"GetStringUTFChars"), source, ", 0) : NULL;\n", 0);
|
||||||
} else {
|
} else {
|
||||||
char *scalarType = SwigTcToJniScalarType(pt);
|
char *scalarType = SwigTcToJniScalarType(pt);
|
||||||
char *cptrtype = DataType_print_type(pt);
|
char *cptrtype = DataType_lstr(pt,0);
|
||||||
pt->is_pointer--;
|
pt->is_pointer--;
|
||||||
const char *basic_jnitype = (pt->is_pointer > 0) ? "jlong" : SwigTcToJniType(pt, 0);
|
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) {
|
if(scalarType == NULL || basic_jnitype == NULL) {
|
||||||
Printf(stderr, "\'%s\' does not have a in/jni typemap, and is not a basic type.\n", ctype);
|
Printf(stderr, "\'%s\' does not have a in/jni typemap, and is not a basic type.\n", ctype);
|
||||||
SWIG_exit(1);
|
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);
|
DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType);
|
||||||
|
|
||||||
Printv(f->code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0);
|
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);
|
Printv(f->code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
|
||||||
if(pt->is_pointer > 1) {
|
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 {
|
} else {
|
||||||
pt->is_pointer--;
|
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++;
|
pt->is_pointer++;
|
||||||
}
|
}
|
||||||
Delete(scalarFunc);
|
Delete(scalarFunc);
|
||||||
|
|
@ -707,10 +707,10 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
// nothing to do
|
// nothing to do
|
||||||
} else {
|
} else {
|
||||||
char *scalarType = SwigTcToJniScalarType(pt);
|
char *scalarType = SwigTcToJniScalarType(pt);
|
||||||
char *cptrtype = DataType_print_type(pt);
|
char *cptrtype = DataType_lstr(pt,0);
|
||||||
pt->is_pointer--;
|
pt->is_pointer--;
|
||||||
const char *basic_jnitype = (pt->is_pointer > 0) ? "jlong" : SwigTcToJniType(pt, 0);
|
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) {
|
if(scalarType == NULL || basic_jnitype == NULL) {
|
||||||
Printf(stderr, "\'%s\' does not have a argout/jni typemap, and is not a basic type.\n", ctype);
|
Printf(stderr, "\'%s\' does not have a argout/jni typemap, and is not a basic type.\n", ctype);
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
|
|
@ -718,7 +718,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
pt->is_pointer++;
|
pt->is_pointer++;
|
||||||
Printf(outarg, " for(i=0; i< %d; i++)\n", target_length);
|
Printf(outarg, " for(i=0; i< %d; i++)\n", target_length);
|
||||||
if(pt->is_pointer > 1) {
|
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 {
|
} else {
|
||||||
Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0);
|
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
|
// Return value if necessary
|
||||||
|
|
||||||
if((t->type != T_VOID || t->is_pointer) && !native_func) {
|
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);
|
Printf(f->code,"%s\n", tm);
|
||||||
} else {
|
} else {
|
||||||
if(t->is_pointer == 0 && t->type == T_USER) { /* return by value */
|
if(t->is_pointer == 0 && t->type == T_USER) { /* return by value */
|
||||||
t->is_pointer=2;
|
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;
|
t->is_pointer=0;
|
||||||
} else if(t->is_pointer == 0 && t->type != T_USER) {
|
} 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) ||
|
} else if((t->type == T_VOID && t->is_pointer == 1) ||
|
||||||
(t->type == T_USER && t->is_pointer == 1)) {
|
(t->type == T_USER && t->is_pointer == 1)) {
|
||||||
t->is_pointer++;
|
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--;
|
t->is_pointer--;
|
||||||
} else {
|
} else {
|
||||||
if(t->type == T_CHAR && t->is_pointer == 1) {
|
if(t->type == T_CHAR && t->is_pointer == 1) {
|
||||||
Printv(f->code, tab4, "if(_result != NULL)\n", 0);
|
Printv(f->code, tab4, "if(result != NULL)\n", 0);
|
||||||
Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "_result);\n", 0);
|
Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "result);\n", 0);
|
||||||
} else {
|
} 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++;
|
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--;
|
t->is_pointer--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -787,13 +787,13 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
// Look for any remaining cleanup
|
// Look for any remaining cleanup
|
||||||
|
|
||||||
if (NewObject) {
|
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);
|
Printf(f->code,"%s\n", tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((t->type != T_VOID || t->is_pointer) && !native_func) {
|
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);
|
Printf(f->code,"%s\n", tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -248,8 +248,8 @@ void
|
||||||
MZSCHEME::get_pointer (DOHString_or_char *name, int parm, DataType *t,
|
MZSCHEME::get_pointer (DOHString_or_char *name, int parm, DataType *t,
|
||||||
Wrapper *f)
|
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," 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_print_mangle(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
|
// Produce names of source and target
|
||||||
|
|
||||||
sprintf(source,"argv[%d]",i);
|
sprintf(source,"argv[%d]",i);
|
||||||
sprintf(target,"_arg%d",i);
|
sprintf(target,"%s", Parm_Getlname(p));
|
||||||
sprintf(argnum,"%d",i);
|
sprintf(argnum,"%d",i);
|
||||||
strcpy(arg,pn);
|
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,
|
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);
|
Printv(f->code, tm, "\n", 0);
|
||||||
mreplace (f->code, argnum, arg, proc_name);
|
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,
|
Printv(f->code,
|
||||||
tab4,
|
tab4,
|
||||||
"swig_result = swig_make_c_pointer(",
|
"swig_result = swig_make_c_pointer(",
|
||||||
"_result, \"",
|
"result, \"",
|
||||||
DataType_print_mangle(d),
|
DataType_manglestr(d),
|
||||||
"\");\n",
|
"\");\n",
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
@ -436,7 +436,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
if (NewObject) {
|
if (NewObject) {
|
||||||
if ((tm = typemap_lookup ((char*)"newfree", typemap_lang,
|
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);
|
Printv(f->code,tm,"\n",0);
|
||||||
mreplace (f->code, argnum, arg, proc_name);
|
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..
|
// Free any memory allocated by the function being wrapped..
|
||||||
|
|
||||||
if ((tm = typemap_lookup ((char*)"ret", typemap_lang,
|
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
|
// Yep. Use it instead of the default
|
||||||
Printv(f->code,tm,"\n",0);
|
Printv(f->code,tm,"\n",0);
|
||||||
mreplace (f->code, argnum, arg, proc_name);
|
mreplace (f->code, argnum, arg, proc_name);
|
||||||
|
|
@ -560,9 +560,9 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
|
||||||
} else {
|
} else {
|
||||||
// Set the value of a pointer
|
// Set the value of a pointer
|
||||||
Printf(f_wrappers, "\t\tif (!swig_get_c_pointer(argv[0], \"%s\", (void **) &_arg0))\n",
|
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", \
|
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 {
|
else {
|
||||||
|
|
@ -583,7 +583,7 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
|
||||||
} else {
|
} else {
|
||||||
// Is an ordinary pointer type.
|
// Is an ordinary pointer type.
|
||||||
Printf(f_wrappers, "\tswig_result = swig_make_c_pointer(%s, \"%s\");\n",
|
Printf(f_wrappers, "\tswig_result = swig_make_c_pointer(%s, \"%s\");\n",
|
||||||
name, DataType_print_mangle(t));
|
name, DataType_manglestr(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -603,7 +603,7 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
|
||||||
} else {
|
} else {
|
||||||
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
|
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
|
||||||
" type %s (ignored).\n",
|
" type %s (ignored).\n",
|
||||||
input_file, line_number, DataType_print_type(t));
|
input_file, line_number, DataType_str(t,0));
|
||||||
}
|
}
|
||||||
Delete(proc_name);
|
Delete(proc_name);
|
||||||
}
|
}
|
||||||
|
|
@ -656,7 +656,7 @@ MZSCHEME::declare_const (char *name, char *, DataType *type, char *value)
|
||||||
} else {
|
} else {
|
||||||
// Create variable and assign it a value
|
// 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)) {
|
if ((type->type == T_CHAR) && (type->is_pointer <= 1)) {
|
||||||
Printf (f_header, "\"%s\";\n", value);
|
Printf (f_header, "\"%s\";\n", value);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -783,7 +783,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
|
||||||
Insert(param,0," unspecified");
|
Insert(param,0," unspecified");
|
||||||
else {
|
else {
|
||||||
Insert(param,0,"# ");
|
Insert(param,0,"# ");
|
||||||
Insert(param,0,DataType_print_type(d));
|
Insert(param,0,DataType_str(d,0));
|
||||||
Insert(param,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");
|
if (t->type == T_VOID) Printf(f, "(char *) 0 )) {\n");
|
||||||
else
|
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.
|
// Change this part to return an error.
|
||||||
Printv(f,
|
Printv(f,
|
||||||
tab8, "croak(\"Type error in ", srcname,
|
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",
|
tab8, ret, ";\n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
0);
|
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
|
// Produce string representation of source and target arguments
|
||||||
sprintf(source,"ST(%d)",j);
|
sprintf(source,"ST(%d)",j);
|
||||||
sprintf(target,"_arg%d",i);
|
sprintf(target,"%s", Parm_Getlname(p));
|
||||||
sprintf(argnum,"%d",j+1);
|
sprintf(argnum,"%d",j+1);
|
||||||
|
|
||||||
// Check to see if this argument is being ignored
|
// Check to see if this argument is being ignored
|
||||||
|
|
@ -825,19 +825,19 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
case T_USHORT:
|
case T_USHORT:
|
||||||
case T_ULONG:
|
case T_ULONG:
|
||||||
case T_UCHAR:
|
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;
|
break;
|
||||||
case T_CHAR :
|
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;
|
break;
|
||||||
|
|
||||||
// Doubles
|
// Doubles
|
||||||
|
|
||||||
case T_DOUBLE :
|
case T_DOUBLE :
|
||||||
case T_FLOAT :
|
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;
|
break;
|
||||||
|
|
||||||
// Void.. Do nothing.
|
// Void.. Do nothing.
|
||||||
|
|
@ -853,7 +853,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Unsupported data type
|
// Unsupported data type
|
||||||
|
|
||||||
default :
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -862,8 +862,8 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// since that is usually a string.
|
// since that is usually a string.
|
||||||
|
|
||||||
if ((pt->type == T_CHAR) && (pt->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," if (! SvOK((SV*) ST(%d))) { %s = 0; }\n", j, target);
|
||||||
Printf(f->code," else { _arg%d = (char *) SvPV(ST(%d),PL_na); }\n", i,j);
|
Printf(f->code," else { %s = (char *) SvPV(ST(%d),PL_na); }\n", target,j);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Have a generic pointer type here. Read it in as a swig
|
// 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);
|
emit_func_call(name,d,l,f);
|
||||||
|
|
||||||
// See if there was a typemap
|
// 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
|
// Yep. Use it instead of the default
|
||||||
Printf(f->code, "%s\n", tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
} else if ((d->type != T_VOID) || (d->is_pointer)) {
|
} 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_SHORT: case T_SSHORT: case T_USHORT:
|
||||||
case T_LONG : case T_SLONG : case T_ULONG:
|
case T_LONG : case T_SLONG : case T_ULONG:
|
||||||
case T_SCHAR: case T_UCHAR :
|
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;
|
break;
|
||||||
case T_DOUBLE :
|
case T_DOUBLE :
|
||||||
case T_FLOAT :
|
case T_FLOAT :
|
||||||
Printf(f->code," sv_setnv(ST(argvi++), (double) _result);\n");
|
Printf(f->code," sv_setnv(ST(argvi++), (double) result);\n");
|
||||||
break;
|
break;
|
||||||
case T_CHAR :
|
case T_CHAR :
|
||||||
Wrapper_add_local(f,"_ctemp", "char _ctemp[2]");
|
Wrapper_add_local(f,"_ctemp", "char ctemp[2]");
|
||||||
Printv(f->code,
|
Printv(f->code,
|
||||||
tab4, "_ctemp[0] = _result;\n",
|
tab4, "ctemp[0] = result;\n",
|
||||||
tab4, "_ctemp[1] = 0;\n",
|
tab4, "ctemp[1] = 0;\n",
|
||||||
tab4, "sv_setpv((SV*)ST(argvi++),_ctemp);\n",
|
tab4, "sv_setpv((SV*)ST(argvi++),ctemp);\n",
|
||||||
0);
|
0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -960,13 +960,13 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
case T_USER:
|
case T_USER:
|
||||||
d->is_pointer++;
|
d->is_pointer++;
|
||||||
Printv(f->code,
|
Printv(f->code,
|
||||||
tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(d),
|
tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_manglestr(d),
|
||||||
"\", (void *) _result);\n", 0);
|
"\", (void *) result);\n", 0);
|
||||||
d->is_pointer--;
|
d->is_pointer--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} 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)) {
|
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||||
|
|
||||||
// Return a character string
|
// 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 {
|
} else {
|
||||||
// Is an ordinary pointer type.
|
// Is an ordinary pointer type.
|
||||||
Printv(f->code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(d),
|
Printv(f->code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_manglestr(d),
|
||||||
"\", (void *) _result);\n", 0);
|
"\", (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);
|
Printv(f->code,cleanup,0);
|
||||||
|
|
||||||
if (NewObject) {
|
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);
|
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
|
// Yep. Use it instead of the default
|
||||||
Printf(f->code,"%s\n", tm);
|
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_SHORT : case T_SSHORT : case T_USHORT:
|
||||||
case T_LONG : case T_SLONG : case T_ULONG:
|
case T_LONG : case T_SLONG : case T_ULONG:
|
||||||
case T_UCHAR: case T_SCHAR:
|
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;
|
break;
|
||||||
case T_DOUBLE :
|
case T_DOUBLE :
|
||||||
case T_FLOAT :
|
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;
|
break;
|
||||||
case T_CHAR :
|
case T_CHAR :
|
||||||
Printv(setf->code, tab4, name, " = (char) *SvPV(sv,PL_na);\n", 0);
|
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++;
|
t->is_pointer++;
|
||||||
Wrapper_add_local(setf,"_temp", "void *_temp");
|
Wrapper_add_local(setf,"_temp", "void *_temp");
|
||||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)");
|
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--;
|
t->is_pointer--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
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;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1236,7 +1236,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
||||||
|
|
||||||
Wrapper_add_local(setf,"_temp","void *_temp");
|
Wrapper_add_local(setf,"_temp","void *_temp");
|
||||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)");
|
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);
|
0);
|
||||||
|
|
||||||
Wrapper_add_local(getf,"rsv","SV *rsv");
|
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--;
|
t->is_pointer--;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -1311,7 +1311,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
||||||
0);
|
0);
|
||||||
|
|
||||||
Wrapper_add_local(getf,"rsv","SV *rsv");
|
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;
|
have_ref_func = 1;
|
||||||
}
|
}
|
||||||
Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"",
|
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) {
|
if (strlen(pn) > 0) {
|
||||||
Printf(temp,"%s",pn);
|
Printf(temp,"%s",pn);
|
||||||
} else {
|
} else {
|
||||||
Printf(temp,"%s",DataType_print_type(pt));
|
Printf(temp,"%s",DataType_str(pt,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
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);
|
if (t->type == T_VOID) Printv(f, "0,1)) == -1) return ", ret, ";\n", 0);
|
||||||
else
|
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);
|
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
|
// 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,\"");
|
Printf(parse_args," if(!PyArg_ParseTuple(args,\"");
|
||||||
} else {
|
} else {
|
||||||
Printf(parse_args," if(!PyArg_ParseTupleAndKeywords(args,kwargs,\"");
|
Printf(parse_args," if(!PyArg_ParseTupleAndKeywords(args,kwargs,\"");
|
||||||
Printf(arglist,",_kwnames");
|
Printf(arglist,",kwnames");
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
@ -690,8 +690,8 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
char *pv = Parm_Getvalue(p);
|
char *pv = Parm_Getvalue(p);
|
||||||
|
|
||||||
// Generate source and target strings
|
// Generate source and target strings
|
||||||
sprintf(source,"_obj%d",i);
|
sprintf(source,"obj%d",i);
|
||||||
sprintf(target,"_arg%d",i);
|
sprintf(target,Parm_Getlname(p));
|
||||||
sprintf(argnum,"%d",j+1);
|
sprintf(argnum,"%d",j+1);
|
||||||
|
|
||||||
// Only consider this argument if it's not ignored
|
// Only consider this argument if it's not ignored
|
||||||
|
|
@ -770,7 +770,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
Wrapper_add_localv(f,tempb,"int",tempb,0);
|
Wrapper_add_localv(f,tempb,"int",tempb,0);
|
||||||
else
|
else
|
||||||
Wrapper_add_localv(f,tempb,"int",tempb, "=",tempval,0);
|
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);
|
Printf(arglist,"&%s",tempb);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -783,8 +783,8 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
case T_USER:
|
case T_USER:
|
||||||
|
|
||||||
Putc('O',parse_args);
|
Putc('O',parse_args);
|
||||||
sprintf(source,"_argo%d", i);
|
sprintf(source,"argo%d", i);
|
||||||
sprintf(target,"_arg%d", i);
|
sprintf(target,Parm_Getlname(p));
|
||||||
sprintf(temp,"argument %d",i+1);
|
sprintf(temp,"argument %d",i+1);
|
||||||
|
|
||||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||||
|
|
@ -796,14 +796,14 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit code for parameter list
|
// Emit code for parameter list
|
||||||
|
|
||||||
if ((pt->type != T_VOID) && (pt->type != T_BOOL) && (pt->type != T_USER))
|
if ((pt->type != T_VOID) && (pt->type != T_BOOL) && (pt->type != T_USER))
|
||||||
Printf(arglist,"&_arg%d",i);
|
Printf(arglist,"&%s",Parm_Getlname(p));
|
||||||
|
|
||||||
} else {
|
} 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)) {
|
if ((pt->type == T_CHAR) && (pt->is_pointer == 1)) {
|
||||||
Putc('s',parse_args);
|
Putc('s',parse_args);
|
||||||
Printf(arglist,"&_arg%d",i);
|
Printf(arglist,"&%s", Parm_Getlname(p));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Have some sort of pointer variable. Create a temporary local
|
// Have some sort of pointer variable. Create a temporary local
|
||||||
// variable for the string and read the pointer value into it.
|
// variable for the string and read the pointer value into it.
|
||||||
|
|
||||||
Putc('O',parse_args);
|
Putc('O',parse_args);
|
||||||
sprintf(source,"_argo%d", i);
|
sprintf(source,"argo%d", i);
|
||||||
sprintf(target,"_arg%d", i);
|
sprintf(target,"%s",Parm_Getlname(p));
|
||||||
sprintf(temp,"argument %d",i+1);
|
sprintf(temp,"argument %d",i+1);
|
||||||
|
|
||||||
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
Wrapper_add_localv(f,source,"PyObject *",source,"=0",0);
|
||||||
|
|
@ -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,"$argnum", argnum, DOH_REPLACE_ANY);
|
||||||
Replace(cleanup,"$arg",source, 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);
|
Printf(outarg,"%s\n", tm);
|
||||||
Replace(outarg,"$argnum",argnum,DOH_REPLACE_ANY);
|
Replace(outarg,"$argnum",argnum,DOH_REPLACE_ANY);
|
||||||
Replace(outarg,"$arg",source, 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 }");
|
Printf(kwargs," NULL }");
|
||||||
if (use_kw) {
|
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);
|
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);
|
emit_func_call(call_name,d,l,f);
|
||||||
|
|
||||||
// Now emit code to return the functions return value (if any).
|
// 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 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
|
// Yep. Use it instead of the default
|
||||||
Printf(f->code,"%s\n", tm);
|
Printf(f->code,"%s\n", tm);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -893,42 +893,42 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Return an integer type
|
// Return an integer type
|
||||||
|
|
||||||
case T_INT: case T_SINT: case T_UINT: case T_BOOL:
|
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;
|
break;
|
||||||
case T_SHORT: case T_SSHORT: case T_USHORT:
|
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;
|
break;
|
||||||
case T_LONG : case T_SLONG : case T_ULONG:
|
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;
|
break;
|
||||||
case T_SCHAR: case T_UCHAR :
|
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;
|
break;
|
||||||
|
|
||||||
// Return a floating point value
|
// Return a floating point value
|
||||||
|
|
||||||
case T_DOUBLE :
|
case T_DOUBLE :
|
||||||
Printf(f->code," _resultobj = Py_BuildValue(\"d\",_result);\n");
|
Printf(f->code," resultobj = Py_BuildValue(\"d\",result);\n");
|
||||||
break;
|
break;
|
||||||
case T_FLOAT :
|
case T_FLOAT :
|
||||||
Printf(f->code," _resultobj = Py_BuildValue(\"f\",_result);\n");
|
Printf(f->code," resultobj = Py_BuildValue(\"f\",result);\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Return a single ASCII value. Usually we need to convert
|
// Return a single ASCII value. Usually we need to convert
|
||||||
// it to a NULL-terminate string and return that instead.
|
// it to a NULL-terminate string and return that instead.
|
||||||
|
|
||||||
case T_CHAR :
|
case T_CHAR :
|
||||||
Printf(f->code," _resultobj = Py_BuildValue(\"c\",_result);\n");
|
Printf(f->code," resultobj = Py_BuildValue(\"c\",result);\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_USER :
|
case T_USER :
|
||||||
d->is_pointer++;
|
d->is_pointer++;
|
||||||
DataType_remember(d);
|
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--;
|
d->is_pointer--;
|
||||||
break;
|
break;
|
||||||
default :
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} 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)) {
|
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||||
|
|
||||||
// Return a character string
|
// 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
|
// If declared as a new object, free the result
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Build a SWIG pointer.
|
// Build a SWIG pointer.
|
||||||
DataType_remember(d);
|
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 {
|
} else {
|
||||||
Printf(f->code," Py_INCREF(Py_None);\n");
|
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
|
// Look to see if there is any newfree cleanup code
|
||||||
|
|
||||||
if (NewObject) {
|
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);
|
Printf(f->code,"%s\n",tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if there is any argument cleanup code
|
// 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
|
// Yep. Use it instead of the default
|
||||||
Printf(f->code,"%s\n",tm);
|
Printf(f->code,"%s\n",tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(f->code," return _resultobj;\n}\n");
|
Printf(f->code," return resultobj;\n}\n");
|
||||||
|
|
||||||
// Substitute the cleanup code
|
// Substitute the cleanup code
|
||||||
Replace(f->code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
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_SINT: case T_SSHORT: case T_SLONG:
|
||||||
case T_SCHAR: case T_UCHAR: case T_BOOL:
|
case T_SCHAR: case T_UCHAR: case T_BOOL:
|
||||||
// Get an integer value
|
// 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,
|
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",
|
tab4, "if (PyErr_Occurred()) {\n",
|
||||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||||
tab8, "return 1; \n",
|
tab8, "return 1; \n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
tab4, name, " = tval;\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:
|
case T_FLOAT: case T_DOUBLE:
|
||||||
// Get a floating point value
|
// 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,
|
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",
|
tab4, "if (PyErr_Occurred()) {\n",
|
||||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||||
tab8, "return 1; \n",
|
tab8, "return 1; \n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
tab4, name, " = tval;\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, "tval = (char *) PyString_AsString(val);\n",
|
||||||
tab4, "if (PyErr_Occurred()) {\n",
|
tab4, "if (PyErr_Occurred()) {\n",
|
||||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||||
tab8, "return 1; \n",
|
tab8, "return 1; \n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
tab4, name, " = *tval;\n",
|
tab4, name, " = *tval;\n",
|
||||||
|
|
@ -1163,13 +1163,13 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
||||||
break;
|
break;
|
||||||
case T_USER:
|
case T_USER:
|
||||||
t->is_pointer++;
|
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");
|
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1");
|
||||||
Printv(setf->code, tab4, name, " = *temp;\n", 0);
|
Printv(setf->code, tab4, name, " = *temp;\n", 0);
|
||||||
t->is_pointer--;
|
t->is_pointer--;
|
||||||
break;
|
break;
|
||||||
default:
|
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 {
|
} else {
|
||||||
|
|
||||||
|
|
@ -1181,7 +1181,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
||||||
tab4, "tval = (char *) PyString_AsString(val);\n",
|
tab4, "tval = (char *) PyString_AsString(val);\n",
|
||||||
tab4, "if (PyErr_Occurred()) {\n",
|
tab4, "if (PyErr_Occurred()) {\n",
|
||||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||||
iname, "'(", DataType_print_type(t), ")\");\n",
|
iname, "'(", DataType_str(t,0), ")\");\n",
|
||||||
tab8, "return 1; \n",
|
tab8, "return 1; \n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
0);
|
0);
|
||||||
|
|
@ -1203,7 +1203,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
||||||
|
|
||||||
// Is a generic pointer value.
|
// 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");
|
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1");
|
||||||
Printv(setf->code,tab4, name, " = temp;\n", 0);
|
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);
|
DataType_remember(t);
|
||||||
Printv(getf->code,
|
Printv(getf->code,
|
||||||
tab4, "pyobj = SWIG_NewPointerObj((void *) &", name ,
|
tab4, "pyobj = SWIG_NewPointerObj((void *) &", name ,
|
||||||
", SWIGTYPE", DataType_print_mangle(t), ");\n",
|
", SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||||
0);
|
0);
|
||||||
t->is_pointer--;
|
t->is_pointer--;
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1288,7 +1288,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
||||||
DataType_remember(t);
|
DataType_remember(t);
|
||||||
Printv(getf->code,
|
Printv(getf->code,
|
||||||
tab4, "pyobj = SWIG_NewPointerObj((void *)", name,
|
tab4, "pyobj = SWIG_NewPointerObj((void *)", name,
|
||||||
", SWIGTYPE", DataType_print_mangle(t), ");\n",
|
", SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1367,7 +1367,7 @@ void PYTHON::declare_const(char *name, char *, DataType *type, char *value) {
|
||||||
} else {
|
} else {
|
||||||
// A funky user-defined type. We're going to munge it into a string pointer value
|
// A funky user-defined type. We're going to munge it into a string pointer value
|
||||||
DataType_remember(type);
|
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) {
|
if (strlen(pn) > 0) {
|
||||||
Printf(temp,"%s",pn);
|
Printf(temp,"%s",pn);
|
||||||
} else {
|
} else {
|
||||||
Printf(temp,"%s", DataType_print_type(pt));
|
Printf(temp,"%s", DataType_str(pt,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = ParmList_next(l);
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
else
|
else
|
||||||
sprintf(source,"varg%d",i);
|
sprintf(source,"varg%d",i);
|
||||||
|
|
||||||
sprintf(target,"_arg%d",i);
|
sprintf(target,"%s", Parm_Getlname(p));
|
||||||
|
|
||||||
if (!p->ignore) {
|
if (!p->ignore) {
|
||||||
char *tab = (char*)tab4;
|
char *tab = (char*)tab4;
|
||||||
|
|
@ -540,7 +540,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
Delete(s);
|
Delete(s);
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n",
|
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))
|
if (j >= (pcount-numopt))
|
||||||
Printv(f->code, tab4, "} \n");
|
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
|
// Now write code to make the function call
|
||||||
emit_func_call(name,t,l,f);
|
emit_func_call(name,t,l,f);
|
||||||
|
|
||||||
|
|
||||||
// Return value if necessary
|
// Return value if necessary
|
||||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
if (predicate) {
|
if (predicate) {
|
||||||
Printv(f->code, tab4, "vresult = (_result ? Qtrue : Qfalse);\n", 0);
|
Printv(f->code, tab4, "vresult = (result ? Qtrue : Qfalse);\n", 0);
|
||||||
} else {
|
} 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) {
|
if (tm) {
|
||||||
DOHString *s = NewString(tm);
|
DOHString *s = NewString(tm);
|
||||||
indent(s);
|
indent(s);
|
||||||
|
|
@ -593,7 +594,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
Delete(s);
|
Delete(s);
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr,"%s : Line %d. No return typemap for datatype %s\n",
|
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
|
// Look for any remaining cleanup. This processes the %new directive
|
||||||
if (NewObject) {
|
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) {
|
if (tm) {
|
||||||
DOHString *s = NewString(tm);
|
DOHString *s = NewString(tm);
|
||||||
indent(s);
|
indent(s);
|
||||||
|
|
@ -621,7 +622,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special processing on return value.
|
// 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) {
|
if (tm) {
|
||||||
DOHString *s = NewString(tm);
|
DOHString *s = NewString(tm);
|
||||||
indent(s);
|
indent(s);
|
||||||
|
|
@ -686,11 +687,11 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
DataType_remember(t);
|
DataType_remember(t);
|
||||||
Printv(getf->code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
Printv(getf->code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
||||||
", \"", DataType_print_mangle(t), "\");\n", 0);
|
", \"", DataType_manglestr(t), "\");\n", 0);
|
||||||
t->is_pointer--;
|
t->is_pointer--;
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
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);
|
Printv(getf->code, tab4, "return _val;\n}\n", 0);
|
||||||
Wrapper_print(getf,f_wrappers);
|
Wrapper_print(getf,f_wrappers);
|
||||||
|
|
@ -716,15 +717,15 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
||||||
Delete(s);
|
Delete(s);
|
||||||
} else if (!t->is_pointer && t->type == T_USER) {
|
} else if (!t->is_pointer && t->type == T_USER) {
|
||||||
t->is_pointer++;
|
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);
|
||||||
Printv(setf->code, tab4, "temp = (", DataType_print_type(t), ")",
|
Printv(setf->code, tab4, "temp = (", DataType_lstr(t,0), ")",
|
||||||
"SWIG_ConvertPtr(_val, \"", DataType_print_mangle(t), "\");\n",
|
"SWIG_ConvertPtr(_val, \"", DataType_manglestr(t), "\");\n",
|
||||||
0);
|
0);
|
||||||
Printv(setf->code, tab4, name, " = *temp;\n",0);
|
Printv(setf->code, tab4, name, " = *temp;\n",0);
|
||||||
t->is_pointer--;
|
t->is_pointer--;
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
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)
|
if (mod_attr)
|
||||||
Printv(setf->code, tab4, "return _val;\n",0);
|
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);
|
Delete(str);
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr,"%s : Line %d. Unable to create constant %s = %s\n",
|
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);
|
Replace(s,"$source",source, DOH_REPLACE_ANY);
|
||||||
if (target && strlen(target) > 0)
|
if (target && strlen(target) > 0)
|
||||||
Replace(s,"$target",target, DOH_REPLACE_ANY);
|
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);
|
return Char(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -964,7 +965,7 @@ int RUBY::to_VALUE(DataType *type, char *value, DOHString *str, int raw) {
|
||||||
else
|
else
|
||||||
Printv(str, "rb_str_new2(", value, ")", 0);
|
Printv(str, "rb_str_new2(", value, ")", 0);
|
||||||
} else {
|
} 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)
|
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)) {
|
} else if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||||
Printv(str, "STR2CSTR(", value, ")", 0);
|
Printv(str, "STR2CSTR(", value, ")", 0);
|
||||||
} else {
|
} 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;
|
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");
|
if (t->type == T_VOID) Printf(f, "0)) == TCL_ERROR) { return TCL_ERROR; }\n");
|
||||||
else
|
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
|
// Now write the wrapper function itself....this is pretty ugly
|
||||||
|
|
||||||
Printv(f->def,
|
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);
|
0);
|
||||||
|
|
||||||
// Print out variables for storing arguments.
|
// 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);
|
char *pv = Parm_Getvalue(p);
|
||||||
// Produce string representations of the source and target arguments
|
// Produce string representations of the source and target arguments
|
||||||
sprintf(source,"objv[%d]",j+1);
|
sprintf(source,"objv[%d]",j+1);
|
||||||
sprintf(target,"_arg%d",i);
|
sprintf(target,"%s", Parm_Getlname(p));
|
||||||
sprintf(argnum,"%d",j+1);
|
sprintf(argnum,"%d",j+1);
|
||||||
|
|
||||||
// See if this argument is being ignored
|
// See if this argument is being ignored
|
||||||
|
|
@ -602,7 +602,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
default :
|
default :
|
||||||
Printf(stderr,"%s : Line %d: Unable to use type %s as a function argument.\n",
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -616,7 +616,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
} else {
|
} else {
|
||||||
DataType_remember(pt);
|
DataType_remember(pt);
|
||||||
Putc('p',argstr);
|
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
|
// 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
|
// Yep. Use it instead of the default
|
||||||
Printf(f->code,"%s\n", tm);
|
Printf(f->code,"%s\n", tm);
|
||||||
} else if ((d->type != T_VOID) || (d->is_pointer)) {
|
} 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_USHORT:
|
||||||
case T_ULONG:
|
case T_ULONG:
|
||||||
case T_UCHAR:
|
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;
|
break;
|
||||||
|
|
||||||
// Is a single character. Assume we return it as a string
|
// Is a single character. Assume we return it as a string
|
||||||
case T_CHAR :
|
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;
|
break;
|
||||||
|
|
||||||
// Floating point number
|
// Floating point number
|
||||||
case T_DOUBLE :
|
case T_DOUBLE :
|
||||||
case T_FLOAT :
|
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;
|
break;
|
||||||
|
|
||||||
// User defined type
|
// User defined type
|
||||||
|
|
@ -704,8 +704,8 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
d->is_pointer++;
|
d->is_pointer++;
|
||||||
DataType_remember(d);
|
DataType_remember(d);
|
||||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE",
|
||||||
DataType_print_mangle(d), "));\n", 0);
|
DataType_manglestr(d), "));\n", 0);
|
||||||
|
|
||||||
d->is_pointer--;
|
d->is_pointer--;
|
||||||
break;
|
break;
|
||||||
|
|
@ -713,7 +713,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Unknown type
|
// Unknown type
|
||||||
default :
|
default :
|
||||||
Printf(stderr,"%s : Line %d: Unable to use return type %s in function %s.\n",
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} 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)) {
|
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||||
// Return a character string
|
// 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 {
|
} else {
|
||||||
DataType_remember(d);
|
DataType_remember(d);
|
||||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE",
|
||||||
DataType_print_mangle(d), "));\n",
|
DataType_manglestr(d), "));\n",
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -741,12 +741,12 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Look for any remaining cleanup
|
// Look for any remaining cleanup
|
||||||
|
|
||||||
if (NewObject) {
|
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);
|
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
|
// Yep. Use it instead of the default
|
||||||
Printf(f->code,"%s\n", tm);
|
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
|
// Dump a collection of set/get functions suitable for variable tracing
|
||||||
if (!Getattr(setget,DataType_print_type(t))) {
|
if (!Getattr(setget,DataType_str(t,0))) {
|
||||||
Setattr(setget,DataType_print_type(t),"1");
|
Setattr(setget,DataType_str(t,0),"1");
|
||||||
Wrapper *get, *set;
|
Wrapper *get, *set;
|
||||||
get = NewWrapper();
|
get = NewWrapper();
|
||||||
set = 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++;
|
t->is_pointer++;
|
||||||
Wrapper_add_localv(get,"addr",DataType_print_type(t),"addr",0);
|
Wrapper_add_localv(get,"addr",DataType_str(t,0),"addr",0);
|
||||||
Wrapper_add_localv(set,"addr",DataType_print_type(t),"addr",0);
|
Wrapper_add_localv(set,"addr",DataType_str(t,0),"addr",0);
|
||||||
Printv(set->code, tab4, "addr = ", DataType_print_cast(t), " clientData;\n", 0);
|
Printv(set->code, tab4, "addr = (", DataType_lstr(t,0), ") clientData;\n", 0);
|
||||||
Printv(get->code, tab4, "addr = ", DataType_print_cast(t), " clientData;\n", 0);
|
Printv(get->code, tab4, "addr = (", DataType_lstr(t,0), ") clientData;\n", 0);
|
||||||
t->is_pointer--;
|
t->is_pointer--;
|
||||||
Wrapper_add_local(set, "value", "char *value");
|
Wrapper_add_local(set, "value", "char *value");
|
||||||
Wrapper_add_local(get, "value", "Tcl_Obj *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_UCHAR:
|
||||||
case T_SCHAR:
|
case T_SCHAR:
|
||||||
case T_BOOL:
|
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;
|
break;
|
||||||
case T_UINT:
|
case T_UINT:
|
||||||
case T_ULONG:
|
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;
|
break;
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
case T_DOUBLE:
|
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;
|
break;
|
||||||
case T_CHAR: /* Single character. */
|
case T_CHAR: /* Single character. */
|
||||||
Printv(set->code, tab4, "*(addr) = *value;\n",0);
|
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);
|
DataType_remember(t);
|
||||||
Printv(set->code, tab4, "{\n",
|
Printv(set->code, tab4, "{\n",
|
||||||
tab8, "void *ptr;\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, tab4, "return \"Type Error\";\n",
|
||||||
tab8, "}\n",
|
tab8, "}\n",
|
||||||
tab8, "*(addr) = *(", DataType_print_cast(t), " ptr);\n",
|
tab8, "*(addr) = *((", DataType_lstr(t,0), ") ptr);\n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
|
@ -867,10 +867,10 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
DataType_remember(t);
|
DataType_remember(t);
|
||||||
Printv(set->code, tab4, "{\n",
|
Printv(set->code, tab4, "{\n",
|
||||||
tab8, "void *ptr;\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, tab4, "return \"Type Error\";\n",
|
||||||
tab8, "}\n",
|
tab8, "}\n",
|
||||||
tab8, "*(addr) = ", DataType_print_cast(t), " ptr;\n",
|
tab8, "*(addr) = (", DataType_lstr(t,0), ") ptr;\n",
|
||||||
tab4, "}\n",
|
tab4, "}\n",
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
|
@ -921,7 +921,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
Wrapper_add_local(get,"value", "Tcl_Obj *value");
|
Wrapper_add_local(get,"value", "Tcl_Obj *value");
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
DataType_remember(t);
|
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_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||||
tab4, "Tcl_DecrRefCount(value);\n",0);
|
tab4, "Tcl_DecrRefCount(value);\n",0);
|
||||||
t->is_pointer--;
|
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");
|
Wrapper_add_local(get,"value","Tcl_Obj *value");
|
||||||
DataType_remember(t);
|
DataType_remember(t);
|
||||||
Printv(get->code,
|
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_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||||
tab4, "Tcl_DecrRefCount(value);\n",
|
tab4, "Tcl_DecrRefCount(value);\n",
|
||||||
0);
|
0);
|
||||||
|
|
@ -950,7 +950,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
DelWrapper(get);
|
DelWrapper(get);
|
||||||
DelWrapper(set);
|
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) {
|
if (Status & STAT_READONLY) {
|
||||||
static int readonly = 0;
|
static int readonly = 0;
|
||||||
|
|
@ -964,7 +964,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
}
|
}
|
||||||
Printf(var_info, "_swig_readonly},\n");
|
Printf(var_info, "_swig_readonly},\n");
|
||||||
} else {
|
} 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) {
|
if (type->is_pointer == 0) {
|
||||||
switch(type->type) {
|
switch(type->type) {
|
||||||
case T_BOOL: case T_INT: case T_SINT: case T_DOUBLE:
|
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);
|
link_variable(var_name,name,type);
|
||||||
break;
|
break;
|
||||||
case T_SHORT:
|
case T_SHORT:
|
||||||
|
|
@ -1015,7 +1015,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
||||||
case T_SSHORT:
|
case T_SSHORT:
|
||||||
case T_SCHAR:
|
case T_SCHAR:
|
||||||
case T_SLONG:
|
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);
|
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||||
if (CPlusPlus)
|
if (CPlusPlus)
|
||||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
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_USHORT:
|
||||||
case T_ULONG:
|
case T_ULONG:
|
||||||
case T_UCHAR:
|
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);
|
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||||
if (CPlusPlus)
|
if (CPlusPlus)
|
||||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
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:
|
case T_FLOAT:
|
||||||
type->type = T_DOUBLE;
|
type->type = T_DOUBLE;
|
||||||
strcpy(type->name,"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);
|
link_variable(var_name,name,type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_CHAR:
|
case T_CHAR:
|
||||||
type->is_pointer++;
|
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);
|
link_variable(var_name,name,type);
|
||||||
type->is_pointer--;
|
type->is_pointer--;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1068,22 +1068,22 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
||||||
// Have some sort of pointer value here
|
// Have some sort of pointer value here
|
||||||
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||||
// Character string
|
// 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);
|
link_variable(var_name,name,type);
|
||||||
} else {
|
} else {
|
||||||
// Something else. Some sort of pointer value
|
// 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);
|
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||||
if (CPlusPlus)
|
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
|
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 = NewDataType(T_CHAR);
|
||||||
t->is_pointer = 1;
|
t->is_pointer = 1;
|
||||||
DataType_remember(type);
|
DataType_remember(type);
|
||||||
Printf(f_init,"\t SWIG_MakePtr(%s_char, (void *) %s, SWIGTYPE%s);\n",
|
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);
|
sprintf(var_name,"%s_char",var_name);
|
||||||
link_variable(var_name,name,t);
|
link_variable(var_name,name,t);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
|
|
@ -1161,7 +1161,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
||||||
Printf(temp,pn);
|
Printf(temp,pn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Printf(temp,"{ %s }", DataType_print_type(pt));
|
Printf(temp,"{ %s }", DataType_str(pt,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i >= (pcount-numopt))
|
if (i >= (pcount-numopt))
|
||||||
|
|
@ -1296,7 +1296,7 @@ void TCL8::cpp_close_class() {
|
||||||
|
|
||||||
if (have_destructor) {
|
if (have_destructor) {
|
||||||
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n",
|
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n",
|
||||||
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);
|
"}\n",0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1307,7 +1307,7 @@ void TCL8::cpp_close_class() {
|
||||||
Printv(code,attributes,0);
|
Printv(code,attributes,0);
|
||||||
|
|
||||||
Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name,
|
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) {
|
if (have_constructor) {
|
||||||
Printf(code, Swig_name_wrapper(Swig_name_construct(class_name)));
|
Printf(code, Swig_name_wrapper(Swig_name_construct(class_name)));
|
||||||
|
|
|
||||||
|
|
@ -1584,11 +1584,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||||
if (type->is_reference) {
|
if (type->is_reference) {
|
||||||
type->is_pointer--;
|
type->is_pointer--;
|
||||||
}
|
}
|
||||||
Printf(wrap,"%s", DataType_print_full(type));
|
Printf(wrap,"%s", DataType_str(type,0));
|
||||||
if (type->is_reference) {
|
|
||||||
Printf(wrap,"&");
|
|
||||||
type->is_pointer++;
|
|
||||||
}
|
|
||||||
Printv(wrap, " ", cname, "(", classtype, classname, " *self", 0);
|
Printv(wrap, " ", cname, "(", classtype, classname, " *self", 0);
|
||||||
|
|
||||||
// Walk down the parameter list and Spit out arguments
|
// Walk down the parameter list and Spit out arguments
|
||||||
|
|
@ -1598,16 +1594,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Parm_Gettype(p);
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||||
Printf(wrap,",");
|
Printf(wrap,",");
|
||||||
if (pt->is_reference) {
|
Printf(wrap, DataType_str(pt, Parm_Getname(p)));
|
||||||
pt->is_pointer--;
|
|
||||||
}
|
|
||||||
Printf(wrap, DataType_print_full(pt));
|
|
||||||
if (pt->is_reference) {
|
|
||||||
pt->is_pointer++;
|
|
||||||
if (pt->is_reference)
|
|
||||||
Printf(wrap,"&");
|
|
||||||
}
|
|
||||||
Printf(wrap," %s", Parm_Getname(p));
|
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = ParmList_next(l);
|
||||||
}
|
}
|
||||||
|
|
@ -1762,22 +1749,14 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
||||||
// Otherwise, assume the function has been written already and
|
// Otherwise, assume the function has been written already and
|
||||||
// wrap it.
|
// wrap it.
|
||||||
|
|
||||||
Printv(wrap,"static ", DataType_print_full(type), " ", cname, "(", 0);
|
Printv(wrap,"static ", DataType_str(type,0), " ", cname, "(", 0);
|
||||||
|
|
||||||
// Walk down the parameter list and Spit out arguments
|
// Walk down the parameter list and Spit out arguments
|
||||||
p = ParmList_first(l);
|
p = ParmList_first(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
DataType *pt = Parm_Gettype(p);
|
DataType *pt = Parm_Gettype(p);
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
||||||
if (pt->is_reference) {
|
Printf(wrap, DataType_str(pt,Parm_Getname(p)));
|
||||||
pt->is_pointer--;
|
|
||||||
}
|
|
||||||
Printf(wrap, DataType_print_full(pt));
|
|
||||||
if (pt->is_reference) {
|
|
||||||
pt->is_pointer++;
|
|
||||||
Printf(wrap, "&");
|
|
||||||
}
|
|
||||||
Printf(wrap," %s", Parm_Getname(p));
|
|
||||||
}
|
}
|
||||||
p = ParmList_next(l);
|
p = ParmList_next(l);
|
||||||
if (p) Printf(wrap, ",");
|
if (p) Printf(wrap, ",");
|
||||||
|
|
@ -1793,14 +1772,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
||||||
|
|
||||||
if ((type->type != T_VOID) || (type->is_pointer)) {
|
if ((type->type != T_VOID) || (type->is_pointer)) {
|
||||||
// Declare the return value
|
// Declare the return value
|
||||||
|
Printv(wrap, tab4, DataType_str(type,"_result"), " = ", 0);
|
||||||
if (type->is_reference) {
|
|
||||||
type->is_pointer--;
|
|
||||||
Printv(wrap, tab4, DataType_print_full(type), "& _result = ",0);
|
|
||||||
type->is_pointer++;
|
|
||||||
} else {
|
|
||||||
Printv(wrap, tab4, DataType_print_type(type), " _result = ", DataType_print_cast(type), 0);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Printf(wrap,tab4);
|
Printf(wrap,tab4);
|
||||||
}
|
}
|
||||||
|
|
@ -1824,7 +1796,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
||||||
|
|
||||||
if ((type->type != T_VOID) || (type->is_pointer)) {
|
if ((type->type != T_VOID) || (type->is_pointer)) {
|
||||||
if (type->is_reference) {
|
if (type->is_reference) {
|
||||||
Printv(wrap, tab4, "return ", DataType_print_cast(type), " &_result;\n",0);
|
Printv(wrap, tab4, "return &_result;\n",0);
|
||||||
} else {
|
} else {
|
||||||
Printv(wrap, tab4, "return _result;\n",0);
|
Printv(wrap, tab4, "return _result;\n",0);
|
||||||
}
|
}
|
||||||
|
|
@ -2008,11 +1980,11 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
||||||
Printv(wrap, "#define ", iname, "(", 0);
|
Printv(wrap, "#define ", iname, "(", 0);
|
||||||
strcpy(cname,iname);
|
strcpy(cname,iname);
|
||||||
if (ObjCClass) {
|
if (ObjCClass) {
|
||||||
Printv(fcall, DataType_print_cast(type), "[", classname, " ", mname,0);
|
Printv(fcall, "(", DataType_lstr(type,0), ") [", classname, " ", mname,0);
|
||||||
} else if (CPlusPlus) {
|
} else if (CPlusPlus) {
|
||||||
Printv(fcall, "new ", classname, "(", 0);
|
Printv(fcall, "new ", classname, "(", 0);
|
||||||
} else {
|
} else {
|
||||||
Printv(fcall, DataType_print_cast(type), " calloc(1,sizeof(", classtype, classname, "))", 0);
|
Printv(fcall, "(", DataType_lstr(type,0), ") calloc(1,sizeof(", classtype, classname, "))", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk down the parameter list and spit out arguments
|
// Walk down the parameter list and spit out arguments
|
||||||
|
|
@ -2197,9 +2169,9 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
||||||
if ((type->type == T_USER) && (!type->is_pointer)) {
|
if ((type->type == T_USER) && (!type->is_pointer)) {
|
||||||
type->is_pointer++;
|
type->is_pointer++;
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Printv(wrap, "static ", DataType_print_type(type), " ", cname, "(",
|
Printv(wrap, "static ", DataType_str(type,0), " ", cname, "(",
|
||||||
classtype, classname, " *obj) {\n",
|
classtype, classname, " *obj) {\n",
|
||||||
tab4, DataType_print_type(type), " result;\n",
|
tab4, DataType_str(type,0), " result;\n",
|
||||||
tm, "\n",
|
tm, "\n",
|
||||||
tab4, "return result;\n",
|
tab4, "return result;\n",
|
||||||
"}\n",
|
"}\n",
|
||||||
|
|
@ -2212,16 +2184,16 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
||||||
type->is_pointer--;
|
type->is_pointer--;
|
||||||
} else {
|
} else {
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Printv(wrap, "static ", DataType_print_type(type), " ", cname, "(",
|
Printv(wrap, "static ", DataType_str(type,0), " ", cname, "(",
|
||||||
classtype, classname, " *obj) {\n",
|
classtype, classname, " *obj) {\n",
|
||||||
tab4, DataType_print_type(type), " result;\n",
|
tab4, DataType_str(type,0), " result;\n",
|
||||||
tm, "\n",
|
tm, "\n",
|
||||||
tab4, "return result;\n",
|
tab4, "return result;\n",
|
||||||
"}\n",
|
"}\n",
|
||||||
0);
|
0);
|
||||||
} else {
|
} else {
|
||||||
Printv(wrap, "#define ", cname, "(_swigobj) (",0);
|
Printv(wrap, "#define ", cname, "(_swigobj) (",0);
|
||||||
if (!type->is_reference) Printf(wrap,DataType_print_cast(type));
|
if (!type->is_reference) Printf(wrap,"(%s)", DataType_lstr(type,0));
|
||||||
else
|
else
|
||||||
Printf(wrap,"&");
|
Printf(wrap,"&");
|
||||||
Printv(wrap, " _swigobj->", mname, ")\n",0);
|
Printv(wrap, " _swigobj->", mname, ")\n",0);
|
||||||
|
|
@ -2389,7 +2361,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
||||||
is_user = 1;
|
is_user = 1;
|
||||||
}
|
}
|
||||||
Printv(wrap,
|
Printv(wrap,
|
||||||
"static ", DataType_print_type(type), " ", cname, "(",
|
"static ", DataType_str(type,0), " ", cname, "(",
|
||||||
classtype, classname, " *obj, ", DataType_str(type,(char*)"val"), ") {\n",
|
classtype, classname, " *obj, ", DataType_str(type,(char*)"val"), ") {\n",
|
||||||
0);
|
0);
|
||||||
if (is_user) {
|
if (is_user) {
|
||||||
|
|
@ -2398,7 +2370,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
||||||
Printv(wrap,tm,"\n",0);
|
Printv(wrap,tm,"\n",0);
|
||||||
// Return the member
|
// Return the member
|
||||||
if (is_user) type->is_pointer++;
|
if (is_user) type->is_pointer++;
|
||||||
Printv(wrap, tab4, "return ", DataType_print_cast(type), " val;\n",0);
|
Printv(wrap, tab4, "return val;\n",0);
|
||||||
if (is_user) type->is_pointer--;
|
if (is_user) type->is_pointer--;
|
||||||
Printf(wrap,"}\n");
|
Printf(wrap,"}\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2422,7 +2394,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
||||||
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||||
char temp[512];
|
char temp[512];
|
||||||
Printv(wrap,
|
Printv(wrap,
|
||||||
"static ", DataType_print_type(type), " ", cname, "(",
|
"static ", DataType_str(type,0), " ", cname, "(",
|
||||||
classtype, classname, " *obj, ", DataType_str(type,(char*)"val"), ") {\n",
|
classtype, classname, " *obj, ", DataType_str(type,(char*)"val"), ") {\n",
|
||||||
0);
|
0);
|
||||||
sprintf(temp,"obj->%s",mname);
|
sprintf(temp,"obj->%s",mname);
|
||||||
|
|
|
||||||
|
|
@ -37,44 +37,14 @@ static char cvsroot[] = "$Header$";
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f) {
|
void emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f) {
|
||||||
char *arr = 0;
|
|
||||||
|
|
||||||
arr = DataType_arraystr(t);
|
|
||||||
if (!arr) arr = (char*)"";
|
|
||||||
|
|
||||||
switch(extern_type) {
|
switch(extern_type) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
// No extern. Just a forward reference
|
// No extern. Just a forward reference
|
||||||
if (DataType_arraystr(t))
|
fprintf(f,"%s;\n", DataType_str(t, decl));
|
||||||
t->is_pointer--;
|
|
||||||
|
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"%s& %s%s; \n", DataType_print_full(t), decl, arr);
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
fprintf(f,"%s %s%s; \n", DataType_print_full(t), decl,arr);
|
|
||||||
}
|
|
||||||
if (DataType_arraystr(t))
|
|
||||||
t->is_pointer++;
|
|
||||||
break;
|
break;
|
||||||
case 1: case 2:
|
case 1: case 2:
|
||||||
if (DataType_arraystr(t))
|
fprintf(f,"extern %s;\n", DataType_str(t,decl));
|
||||||
t->is_pointer--;
|
break;
|
||||||
|
|
||||||
// Normal C/C++ extern
|
|
||||||
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
|
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"extern %s& %s%s; \n", DataType_print_full(t), decl,arr);
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
fprintf(f,"extern %s %s%s; \n", DataType_print_full(t), decl,arr);
|
|
||||||
}
|
|
||||||
if (DataType_arraystr(t))
|
|
||||||
t->is_pointer++;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -102,56 +72,26 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
|
||||||
|
|
||||||
switch(extern_type) {
|
switch(extern_type) {
|
||||||
case 0:
|
case 0:
|
||||||
if (t->is_reference) {
|
fprintf(f,"%s", DataType_str(t,0));
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"%s&", DataType_print_full(t));
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
fprintf(f,"%s", DataType_print_full(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(", decl);
|
||||||
ParmList_print_types(L,f);
|
ParmList_print_types(L,f);
|
||||||
fprintf(f,");\n");
|
fprintf(f,");\n");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Normal C/C++ extern
|
fprintf(f,"extern %s", DataType_str(t,0));
|
||||||
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
|
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"extern %s&", DataType_print_full(t));
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
fprintf(f,"extern %s", DataType_print_full(t));
|
|
||||||
}
|
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(", decl);
|
||||||
ParmList_print_types(L,f);
|
ParmList_print_types(L,f);
|
||||||
fprintf(f,");\n");
|
fprintf(f,");\n");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// A C++ --- > C Extern
|
// A C++ --- > C Extern
|
||||||
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
|
fprintf(f,"extern \"C\" %s", DataType_str(t,0));
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"extern \"C\" %s&", DataType_print_full(t));
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
fprintf(f,"extern \"C\" %s", DataType_print_full(t));
|
|
||||||
}
|
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(", decl);
|
||||||
ParmList_print_types(L,f);
|
ParmList_print_types(L,f);
|
||||||
fprintf(f,");\n");
|
fprintf(f,");\n");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// A function declaration (for inlining )
|
fprintf(f,"%s", DataType_str(t,0));
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"%s&", DataType_print_full(t));
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
fprintf(f,"%s", DataType_print_full(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f,"%s(", decl);
|
fprintf(f,"%s(", decl);
|
||||||
ParmList_print_args(L,f);
|
ParmList_print_args(L,f);
|
||||||
fprintf(f,")\n");
|
fprintf(f,")\n");
|
||||||
|
|
@ -161,28 +101,13 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// char *emit_local(int i)
|
|
||||||
//
|
|
||||||
// Returns the name of local variable for parameter i
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
char *emit_local(int i) {
|
|
||||||
static char arg[64];
|
|
||||||
|
|
||||||
sprintf(arg,"_arg%d", i);
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// int emit_args(char *d, DataType *rt, ParmList *l, Wrapper *f)
|
// int emit_args(char *d, DataType *rt, ParmList *l, Wrapper *f)
|
||||||
//
|
//
|
||||||
// Creates a list of variable declarations for both the return value
|
// Creates a list of variable declarations for both the return value
|
||||||
// and function parameters.
|
// and function parameters.
|
||||||
//
|
//
|
||||||
// The return value is always called _result and arguments label as
|
// The return value is always called result and arguments arg0, arg1, arg2, etc...
|
||||||
// _arg0, _arg1, _arg2, etc...
|
|
||||||
//
|
|
||||||
// Returns the number of parameters associated with a function.
|
// Returns the number of parameters associated with a function.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -192,77 +117,42 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
||||||
int i;
|
int i;
|
||||||
char *tm;
|
char *tm;
|
||||||
DataType *pt;
|
DataType *pt;
|
||||||
// Declare the return variable
|
char *pvalue;
|
||||||
|
char *pname;
|
||||||
if ((rt->type != T_VOID) || (rt->is_pointer)) {
|
char *local;
|
||||||
if ((rt->type == T_USER) && (!rt->is_pointer)) {
|
char *lname;
|
||||||
|
|
||||||
// Special case for return by "value"
|
|
||||||
rt->is_pointer++;
|
|
||||||
Wrapper_add_localv(f, "_result", DataType_print_type(rt), "_result",0);
|
|
||||||
rt->is_pointer--;
|
|
||||||
} else {
|
|
||||||
// Normal return value
|
|
||||||
Wrapper_add_localv(f, "_result", DataType_print_type(rt), "_result",0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit function arguments
|
// Emit function arguments
|
||||||
|
Swig_cargs(f, l);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
p = ParmList_first(l);
|
p = ParmList_first(l);
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
pt = Parm_Gettype(p);
|
lname = Parm_Getlname(p);
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer)) {
|
pt = Parm_Gettype(p);
|
||||||
char *temp = emit_local(i);
|
pname = Parm_Getname(p);
|
||||||
// Figure out default values
|
pvalue = Parm_Getvalue(p);
|
||||||
char *pvalue = Parm_Getvalue(p);
|
|
||||||
char *pname = Parm_Getname(p);
|
|
||||||
if (((pt->is_reference) && (pvalue)) ||
|
|
||||||
((pt->type == T_USER) && (pt->is_pointer == 0) && (pvalue))) {
|
|
||||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp," = (", DataType_print_type(pt), ") &", pvalue,0);
|
|
||||||
} else {
|
|
||||||
char deftmp[1024];
|
|
||||||
if (pvalue) {
|
|
||||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp, " = (", DataType_print_type(pt), ") ", pvalue, 0);
|
|
||||||
} else {
|
|
||||||
if ((pt->type == T_USER) && (pt->is_pointer == 0)) {
|
|
||||||
pt->is_pointer++;
|
|
||||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp, 0);
|
|
||||||
pt->is_pointer--;
|
|
||||||
} else {
|
|
||||||
Wrapper_add_localv(f,temp, DataType_print_type(pt), temp, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tm = typemap_lookup((char*)"arginit", typemap_lang, pt,pname,(char*)"",temp,f);
|
tm = typemap_lookup((char*)"arginit", typemap_lang, pt,pname,(char*)"",lname,f);
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Printv(f->code,tm,"\n",0);
|
Printv(f->code,tm,"\n",0);
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check for ignore or default typemaps
|
|
||||||
tm = typemap_lookup((char*)"default",typemap_lang,pt,pname,(char*)"",temp,f);
|
|
||||||
if (tm)
|
|
||||||
Printv(f->code,tm,"\n",0);
|
|
||||||
tm = typemap_lookup((char*)"ignore",typemap_lang,pt,pname,(char*)"",temp,f);
|
|
||||||
if (tm) {
|
|
||||||
Printv(f->code,tm,"\n",0);
|
|
||||||
p->ignore = 1;
|
|
||||||
}
|
|
||||||
tm = typemap_check((char*)"build",typemap_lang,pt,pname);
|
|
||||||
if (tm) {
|
|
||||||
p->ignore = 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
// Check for ignore or default typemaps
|
||||||
|
tm = typemap_lookup((char*)"default",typemap_lang,pt,pname,(char*)"",lname,f);
|
||||||
|
if (tm) {
|
||||||
|
Printv(f->code,tm,"\n",0);
|
||||||
|
}
|
||||||
|
tm = typemap_lookup((char*)"ignore",typemap_lang,pt,pname,(char*)"",lname,f);
|
||||||
|
if (tm) {
|
||||||
|
Printv(f->code,tm,"\n",0);
|
||||||
|
p->ignore = 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
p = ParmList_next(l);
|
p = ParmList_next(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
// i now contains number of parameters
|
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// int emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper*f)
|
// int emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper*f)
|
||||||
//
|
//
|
||||||
|
|
@ -276,96 +166,23 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
||||||
|
|
||||||
int i;
|
|
||||||
Parm *p;
|
|
||||||
DOHString *fcall;
|
|
||||||
DOHString *exc;
|
|
||||||
char *tm;
|
char *tm;
|
||||||
|
|
||||||
fcall = NewString(tab4);
|
if ((tm = typemap_lookup((char*)"except",typemap_lang,t,decl,(char*)"result",(char*)""))) {
|
||||||
exc = NewString("");
|
|
||||||
|
|
||||||
// First check if there is a return value
|
|
||||||
|
|
||||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
|
||||||
|
|
||||||
// Special case for return by "value"
|
|
||||||
// Caution : This *will* cause a memory leak if not
|
|
||||||
// used properly.
|
|
||||||
|
|
||||||
if (CPlusPlus) {
|
|
||||||
Printv(fcall, "_result = new ", DataType_print_type(t), "(", 0);
|
|
||||||
} else {
|
|
||||||
t->is_pointer++;
|
|
||||||
Printv(fcall, "_result = ", DataType_print_cast(t), " malloc(sizeof(", 0);
|
|
||||||
t->is_pointer--;
|
|
||||||
Printv(fcall, DataType_print_type(t), "));\n", 0);
|
|
||||||
Printv(fcall, tab4, "*(_result) = ", 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Check if this is a C++ reference
|
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
Printv(fcall, DataType_print_full(t), "& _result_ref = ", 0);
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Normal return value
|
|
||||||
Printv(fcall, "_result = ", DataType_print_cast(t), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now print out function call
|
|
||||||
Printv(fcall, decl, "(", 0);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
p = ParmList_first(l);
|
|
||||||
while(p != 0) {
|
|
||||||
DataType *pt = Parm_Gettype(p);
|
|
||||||
if ((pt->type != T_VOID) || (pt->is_pointer)){
|
|
||||||
Printf(fcall,DataType_print_arraycast(pt));
|
|
||||||
if ((pt->is_reference) || ((pt->is_pointer == 0) && (pt->type == T_USER)))
|
|
||||||
Printf(fcall, "*");
|
|
||||||
Printf(fcall, emit_local(i));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
p = ParmList_next(l);
|
|
||||||
if (p != 0)
|
|
||||||
Printf(fcall,",");
|
|
||||||
}
|
|
||||||
Printf(fcall,")");
|
|
||||||
|
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
|
||||||
if (CPlusPlus) {
|
|
||||||
Printf(fcall,")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Printf(fcall,";\n");
|
|
||||||
|
|
||||||
if (t->is_reference) {
|
|
||||||
Printv(fcall, tab4, "_result = ", DataType_print_cast(t), " &_result_ref;\n", 0);
|
|
||||||
}
|
|
||||||
// Check for exception handling
|
|
||||||
|
|
||||||
if ((tm = typemap_lookup((char*)"except",typemap_lang,t,decl,(char*)"_result",(char*)""))) {
|
|
||||||
// Found a type-specific mapping
|
// Found a type-specific mapping
|
||||||
Printv(exc,tm,0);
|
Printv(f->code,tm,0);
|
||||||
Replace(exc,"$function",fcall,DOH_REPLACE_ANY);
|
Replace(f->code,"$name",decl,DOH_REPLACE_ANY);
|
||||||
Replace(exc,"$name",decl,DOH_REPLACE_ANY);
|
|
||||||
Printv(f->code,exc,0);
|
|
||||||
} else if ((tm = fragment_lookup((char*)"except",typemap_lang, t->id))) {
|
} else if ((tm = fragment_lookup((char*)"except",typemap_lang, t->id))) {
|
||||||
Printv(exc,tm,0);
|
Printv(f->code,tm,0);
|
||||||
Replace(exc,"$function",fcall,DOH_REPLACE_ANY);
|
Replace(f->code,"$name",decl,DOH_REPLACE_ANY);
|
||||||
Replace(exc,"$name",decl,DOH_REPLACE_ANY);
|
|
||||||
Printv(f->code,exc,0);
|
|
||||||
} else {
|
} else {
|
||||||
Printv(f->code,fcall,0);
|
Printv(f->code,"$function",0);
|
||||||
|
}
|
||||||
|
if (CPlusPlus) {
|
||||||
|
Swig_cppresult(f, t, "result", Swig_cfunction(decl,l));
|
||||||
|
} else {
|
||||||
|
Swig_cresult(f, t, "result", Swig_cfunction(decl,l));
|
||||||
}
|
}
|
||||||
Delete(fcall);
|
|
||||||
Delete(exc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -406,121 +223,72 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
ParmList *l;
|
ParmList *l;
|
||||||
char *new_name = 0, *new_iname = 0;
|
char *new_name = 0, *new_iname = 0;
|
||||||
|
|
||||||
|
DataType *lt;
|
||||||
|
|
||||||
|
// Figure out the assignable local type for this variable
|
||||||
|
|
||||||
|
lt = Swig_clocal_type(t);
|
||||||
|
|
||||||
// First write a function to set the variable of the variable
|
// First write a function to set the variable of the variable
|
||||||
|
|
||||||
if (!(Status & STAT_READONLY)) {
|
if (!(Status & STAT_READONLY)) {
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
fprintf(f_header,"static %s %s(%s) {\n",
|
||||||
t->is_pointer++;
|
DataType_lstr(lt,0), Swig_name_set(name), DataType_lstr(lt,"val"));
|
||||||
fprintf(f_header,"static %s %s(%s val) {\n",
|
if (!t->is_pointer) {
|
||||||
DataType_print_type(t), Swig_name_set(name), DataType_print_type(t));
|
fprintf(f_header,"\t %s = %s;\n", name, Swig_clocal_deref(t,"val"));
|
||||||
t->is_pointer--;
|
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||||
} else {
|
} else {
|
||||||
fprintf(f_header,"static %s %s(%s val) {\n",
|
// Is a pointer type here. If string, we do something
|
||||||
DataType_print_type(t), Swig_name_set(name), DataType_print_type(t));
|
// special. Otherwise. No problem.
|
||||||
}
|
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
||||||
|
if (CPlusPlus) {
|
||||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
fprintf(f_header,"\t if (%s) delete %s;\n", name,name);
|
||||||
if (!t->is_pointer) {
|
fprintf(f_header,"\t %s = new char[strlen(val)+1];\n",name);
|
||||||
|
fprintf(f_header,"\t strcpy(%s,val);\n", name);
|
||||||
// Have a real value here
|
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||||
// If it's a user defined type, we'll do something special.
|
|
||||||
// Otherwise, just assign it.
|
|
||||||
|
|
||||||
if (t->type != T_USER) {
|
|
||||||
fprintf(f_header,"\t return (%s) (%s = val);\n", DataType_print_type(t), name);
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(f_header,"\t %s = *(val);\n", name);
|
fprintf(f_header,"\t if (%s) free(%s);\n", name,name);
|
||||||
t->is_pointer++;
|
fprintf(f_header,"\t %s = (char *) malloc(strlen(val)+1);\n",name);
|
||||||
fprintf(f_header,"\t return (%s) &%s;\n", DataType_print_type(t),name);
|
fprintf(f_header,"\t strcpy(%s,val);\n", name);
|
||||||
t->is_pointer--;
|
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
fprintf(f_header,"\t %s = %s;\n", name, Swig_clocal_deref(t,"val"));
|
||||||
// Is a pointer type here. If string, we do something
|
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||||
// special. Otherwise. No problem.
|
|
||||||
|
|
||||||
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
|
||||||
if (CPlusPlus) {
|
|
||||||
fprintf(f_header,"\t if (%s) delete %s;\n", name,name);
|
|
||||||
fprintf(f_header,"\t %s = new char[strlen(val)+1];\n",name);
|
|
||||||
fprintf(f_header,"\t strcpy(%s,val);\n", name);
|
|
||||||
fprintf(f_header,"\t return %s;\n", name);
|
|
||||||
} else {
|
|
||||||
fprintf(f_header,"\t if (%s) free(%s);\n", name,name);
|
|
||||||
fprintf(f_header,"\t %s = (char *) malloc(strlen(val)+1);\n",name);
|
|
||||||
fprintf(f_header,"\t strcpy(%s,val);\n", name);
|
|
||||||
fprintf(f_header,"\t return %s;\n", name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fprintf(f_header,"\t return (%s) (%s = val);\n", DataType_print_type(t), name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f_header,"}\n");
|
fprintf(f_header,"}\n");
|
||||||
|
|
||||||
// Now wrap it.
|
// Now wrap it.
|
||||||
|
|
||||||
l = NewParmList();
|
l = NewParmList();
|
||||||
p = NewParm(t,0);
|
p = NewParm(lt,0);
|
||||||
DataType *pt = Parm_Gettype(p);
|
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) pt->is_pointer++;
|
|
||||||
Parm_Setname(p,(char*)"");
|
Parm_Setname(p,(char*)"");
|
||||||
ParmList_append(l,p);
|
ParmList_append(l,p);
|
||||||
|
|
||||||
new_name = copy_string(Swig_name_set(name));
|
new_name = copy_string(Swig_name_set(name));
|
||||||
new_iname = copy_string(Swig_name_set(iname));
|
new_iname = copy_string(Swig_name_set(iname));
|
||||||
|
lang->create_function(new_name, new_iname, lt, l);
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
|
||||||
t->is_pointer++;
|
|
||||||
lang->create_function(new_name, new_iname, t, l);
|
|
||||||
t->is_pointer--;
|
|
||||||
} else {
|
|
||||||
lang->create_function(new_name, new_iname, t, l);
|
|
||||||
}
|
|
||||||
DelParmList(l);
|
DelParmList(l);
|
||||||
DelParm(p);
|
DelParm(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now write a function to get the value of the variable
|
// Now write a function to get the value of the variable
|
||||||
|
fprintf(f_header,"static %s %s() { \n",
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
DataType_lstr(lt,0), Swig_name_get(name));
|
||||||
t->is_pointer++;
|
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||||
fprintf(f_header,"static %s %s() { \n",
|
|
||||||
DataType_print_type(t), Swig_name_get(name));
|
|
||||||
fprintf(f_header,"\t return (%s) &%s;\n", DataType_print_type(t), name);
|
|
||||||
t->is_pointer--;
|
|
||||||
} else {
|
|
||||||
fprintf(f_header,"static %s %s() { \n",
|
|
||||||
DataType_print_type(t), Swig_name_get(name));
|
|
||||||
fprintf(f_header,"\t return (%s) %s;\n", DataType_print_type(t), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f_header,"}\n");
|
fprintf(f_header,"}\n");
|
||||||
|
|
||||||
// Wrap this function
|
// Wrap this function
|
||||||
|
|
||||||
l = NewParmList();
|
l = NewParmList();
|
||||||
|
|
||||||
if (new_name) delete [] new_name;
|
if (new_name) delete [] new_name;
|
||||||
if (new_iname) delete [] new_iname;
|
if (new_iname) delete [] new_iname;
|
||||||
|
|
||||||
new_name = copy_string(Swig_name_get(name));
|
new_name = copy_string(Swig_name_get(name));
|
||||||
new_iname = copy_string(Swig_name_get(iname));
|
new_iname = copy_string(Swig_name_get(iname));
|
||||||
|
lang->create_function(new_name, new_iname, lt, l);
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
|
||||||
t->is_pointer++;
|
|
||||||
lang->create_function(new_name, new_iname, t, l);
|
|
||||||
t->is_pointer--;
|
|
||||||
} else {
|
|
||||||
lang->create_function(new_name, new_iname, t, l);
|
|
||||||
}
|
|
||||||
DelParmList(l);
|
DelParmList(l);
|
||||||
|
DelDataType(lt);
|
||||||
delete [] new_name;
|
delete [] new_name;
|
||||||
delete [] new_iname;
|
delete [] new_iname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1148,7 +1148,7 @@ typedef_decl : TYPEDEF type declaration {
|
||||||
lang->add_typedef($2,$3.id);
|
lang->add_typedef($2,$3.id);
|
||||||
/* If this is %typedef, add it to the header */
|
/* If this is %typedef, add it to the header */
|
||||||
if ($1)
|
if ($1)
|
||||||
fprintf(f_header,"typedef %s %s;\n", DataType_print_full($2), $3.id);
|
fprintf(f_header,"typedef %s;\n", DataType_str($2,$3.id));
|
||||||
cplus_register_type($3.id);
|
cplus_register_type($3.id);
|
||||||
} typedeflist { };
|
} typedeflist { };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
|
||||||
|
|
||||||
// Form the application name
|
// Form the application name
|
||||||
if (!pname) pname = (char*)"";
|
if (!pname) pname = (char*)"";
|
||||||
sprintf(temp,"%s$%s",DataType_print_type(type),pname);
|
sprintf(temp,"%s$%s",DataType_str(type,0),pname);
|
||||||
|
|
||||||
// See if there is a method already defined
|
// See if there is a method already defined
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
|
||||||
void typemap_clear_apply(DataType *type, char *pname) {
|
void typemap_clear_apply(DataType *type, char *pname) {
|
||||||
char temp[512];
|
char temp[512];
|
||||||
if (!pname) pname = (char*)"";
|
if (!pname) pname = (char*)"";
|
||||||
sprintf(temp,"%s$%s", DataType_print_type(type), pname);
|
sprintf(temp,"%s$%s", DataType_str(type,0), pname);
|
||||||
if (!application_hash) application_hash = NewHash();
|
if (!application_hash) application_hash = NewHash();
|
||||||
Delattr(application_hash,temp);
|
Delattr(application_hash,temp);
|
||||||
}
|
}
|
||||||
|
|
@ -231,9 +231,9 @@ static char *typemap_string(char *lang, DataType *type, char *pname, char *ary,
|
||||||
Clear(str);
|
Clear(str);
|
||||||
|
|
||||||
if (ary)
|
if (ary)
|
||||||
Printv(str, lang, DataType_print_type(type), pname, ary, suffix, 0);
|
Printv(str, lang, DataType_str(type,0), pname, ary, suffix, 0);
|
||||||
else
|
else
|
||||||
Printv(str, lang, DataType_print_type(type), pname, suffix,0);
|
Printv(str, lang, DataType_str(type,0), pname, suffix,0);
|
||||||
|
|
||||||
type->status = old_status;
|
type->status = old_status;
|
||||||
return Char(str);
|
return Char(str);
|
||||||
|
|
@ -518,12 +518,12 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
||||||
char temp_ip1 = tt->implicit_ptr;
|
char temp_ip1 = tt->implicit_ptr;
|
||||||
tt->is_pointer = 0;
|
tt->is_pointer = 0;
|
||||||
tt->implicit_ptr = 0;
|
tt->implicit_ptr = 0;
|
||||||
new_name = Wrapper_new_localv(f,str, DataType_print_type(tt), str, 0);
|
new_name = Wrapper_new_localv(f,str, DataType_str(tt,0), str, 0);
|
||||||
tt->is_pointer = temp_ip;
|
tt->is_pointer = temp_ip;
|
||||||
tt->implicit_ptr = temp_ip1;
|
tt->implicit_ptr = temp_ip1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
new_name = Wrapper_new_localv(f,str, DataType_print_full(tt), str, 0);
|
new_name = Wrapper_new_localv(f,str, DataType_str(tt,str), 0);
|
||||||
|
|
||||||
if (DataType_arraystr(tt)) tt->is_pointer++;
|
if (DataType_arraystr(tt)) tt->is_pointer++;
|
||||||
// Substitute
|
// Substitute
|
||||||
|
|
@ -618,7 +618,7 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
|
||||||
|
|
||||||
Replace(str,"$source",source,DOH_REPLACE_ANY);
|
Replace(str,"$source",source,DOH_REPLACE_ANY);
|
||||||
Replace(str,"$target",target,DOH_REPLACE_ANY);
|
Replace(str,"$target",target,DOH_REPLACE_ANY);
|
||||||
Replace(str,"$type",DataType_print_type(realtype),DOH_REPLACE_ANY);
|
Replace(str,"$type",DataType_str(realtype,0),DOH_REPLACE_ANY);
|
||||||
if (realname) {
|
if (realname) {
|
||||||
Replace(str,"$parmname",realname,DOH_REPLACE_ANY);
|
Replace(str,"$parmname",realname,DOH_REPLACE_ANY);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -630,16 +630,16 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
|
||||||
char temp_ip1 = realtype->implicit_ptr;
|
char temp_ip1 = realtype->implicit_ptr;
|
||||||
realtype->is_pointer = 0;
|
realtype->is_pointer = 0;
|
||||||
realtype->implicit_ptr = 0;
|
realtype->implicit_ptr = 0;
|
||||||
char *bt = DataType_print_type(realtype);
|
char *bt = DataType_str(realtype,0);
|
||||||
if (bt[strlen(bt)-1] == ' ')
|
if (bt[strlen(bt)-1] == ' ')
|
||||||
bt[strlen(bt)-1] = 0;
|
bt[strlen(bt)-1] = 0;
|
||||||
Replace(str,"$basetype",bt,DOH_REPLACE_ANY);
|
Replace(str,"$basetype",bt,DOH_REPLACE_ANY);
|
||||||
Replace(str,"$basemangle",DataType_print_mangle(realtype), DOH_REPLACE_ANY);
|
Replace(str,"$basemangle",DataType_manglestr(realtype), DOH_REPLACE_ANY);
|
||||||
realtype->is_pointer = temp_ip;
|
realtype->is_pointer = temp_ip;
|
||||||
realtype->implicit_ptr = temp_ip1;
|
realtype->implicit_ptr = temp_ip1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Replace(str,"$mangle",DataType_print_mangle(realtype), DOH_REPLACE_ANY);
|
Replace(str,"$mangle",DataType_manglestr(realtype), DOH_REPLACE_ANY);
|
||||||
|
|
||||||
// If there were locals and a wrapper function, replace
|
// If there were locals and a wrapper function, replace
|
||||||
if ((tm->args) && f) {
|
if ((tm->args) && f) {
|
||||||
|
|
@ -650,7 +650,7 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
|
||||||
if ((tm->args) && !f) {
|
if ((tm->args) && !f) {
|
||||||
if (!pname) pname = (char*)"";
|
if (!pname) pname = (char*)"";
|
||||||
fprintf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n",
|
fprintf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n",
|
||||||
input_file, line_number, lang,op, DataType_print_type(type), pname);
|
input_file, line_number, lang,op, DataType_str(type,0), pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return character string
|
// Return character string
|
||||||
|
|
@ -690,7 +690,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
||||||
|
|
||||||
while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) {
|
while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) {
|
||||||
type->is_pointer -= drop_pointer;
|
type->is_pointer -= drop_pointer;
|
||||||
tstr = DataType_print_type(type);
|
tstr = DataType_str(type,0);
|
||||||
sprintf(temp,"%s$%s",tstr,ppname);
|
sprintf(temp,"%s$%s",tstr,ppname);
|
||||||
// No mapping was found. See if the name has been mapped with %apply
|
// No mapping was found. See if the name has been mapped with %apply
|
||||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||||
|
|
@ -852,7 +852,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
||||||
|
|
||||||
while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) {
|
while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) {
|
||||||
type->is_pointer -= drop_pointer;
|
type->is_pointer -= drop_pointer;
|
||||||
tstr = DataType_print_type(type);
|
tstr = DataType_str(type,0);
|
||||||
sprintf(temp,"%s$%s",tstr,ppname);
|
sprintf(temp,"%s$%s",tstr,ppname);
|
||||||
// No mapping was found. See if the name has been mapped with %apply
|
// No mapping was found. See if the name has been mapped with %apply
|
||||||
if (!application_hash) application_hash = NewHash();
|
if (!application_hash) application_hash = NewHash();
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ srcdir = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
|
|
||||||
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
|
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
|
||||||
oldtypes.c oldparms.c
|
oldtypes.c oldparms.c cwrap.c
|
||||||
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
|
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
|
||||||
oldtypes.o oldparms.o
|
oldtypes.o oldparms.o cwrap.o
|
||||||
|
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
exec_prefix = @exec_prefix@
|
exec_prefix = @exec_prefix@
|
||||||
|
|
|
||||||
405
SWIG/Source/Swig/cwrap.c
Normal file
405
SWIG/Source/Swig/cwrap.c
Normal file
|
|
@ -0,0 +1,405 @@
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* cwrap.c
|
||||||
|
*
|
||||||
|
* This file defines a variety of wrapping rules for C/C++ handling including
|
||||||
|
* the naming of local variables, calling conventions, and so forth.
|
||||||
|
*
|
||||||
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
|
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
||||||
|
* University of California.
|
||||||
|
*
|
||||||
|
* See the file LICENSE for information on usage and redistribution.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
|
#include "swig.h"
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_parm_name()
|
||||||
|
*
|
||||||
|
* Generates a name for the ith argument in an argument list
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_cparm_name(Parm *p, int i) {
|
||||||
|
static char name[256];
|
||||||
|
sprintf(name,"arg%d",i);
|
||||||
|
Parm_Setlname(p,name);
|
||||||
|
return Parm_Getlname(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_clocal()
|
||||||
|
*
|
||||||
|
* Creates a string that declares a C local variable type. Converts references
|
||||||
|
* and user defined types to pointers.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_clocal(DataType *t, DOHString_or_char *name, DOHString_or_char *value) {
|
||||||
|
static DOHString *decl = 0;
|
||||||
|
|
||||||
|
if (!decl) decl = NewString("");
|
||||||
|
Clear(decl);
|
||||||
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
t->is_pointer++;
|
||||||
|
if (value)
|
||||||
|
Printf(decl,"%s = &%s", DataType_lstr(t,name), value);
|
||||||
|
else
|
||||||
|
Printf(decl,"%s", DataType_lstr(t,name));
|
||||||
|
t->is_pointer--;
|
||||||
|
} else if (t->is_reference) {
|
||||||
|
if (value)
|
||||||
|
Printf(decl,"%s = &%s", DataType_lstr(t,name), value);
|
||||||
|
else
|
||||||
|
Printf(decl,"%s", DataType_lstr(t,name));
|
||||||
|
} else {
|
||||||
|
if (value)
|
||||||
|
Printf(decl,"%s = %s", DataType_lstr(t,name), value);
|
||||||
|
else
|
||||||
|
Printf(decl,"%s", DataType_lstr(t,name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Char(decl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_clocal_type()
|
||||||
|
*
|
||||||
|
* Creates a string that declares a C local variable type. Converts references
|
||||||
|
* and user defined types to pointers.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
DataType *
|
||||||
|
Swig_clocal_type(DataType *t) {
|
||||||
|
DataType *ty;
|
||||||
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
t->is_pointer++;
|
||||||
|
ty = DataType_ltype(t);
|
||||||
|
t->is_pointer--;
|
||||||
|
} else {
|
||||||
|
ty = DataType_ltype(t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ty = DataType_ltype(t);
|
||||||
|
}
|
||||||
|
return ty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_clocal_deref()
|
||||||
|
*
|
||||||
|
* Creates a string that can be used to deref a local variable wrapped with
|
||||||
|
* the Swig_clocal() function.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_clocal_deref(DataType *t, DOHString_or_char *name) {
|
||||||
|
static char temp[256];
|
||||||
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
sprintf(temp,"*%s",Char(name));
|
||||||
|
} else {
|
||||||
|
sprintf(temp,DataType_rcaststr(t,name));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strcpy(temp,"");
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_clocal_assign()
|
||||||
|
*
|
||||||
|
* Assigns a value to a local
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_clocal_assign(DataType *t, DOHString_or_char *name) {
|
||||||
|
static char temp[256];
|
||||||
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
sprintf(temp,"&%s",Char(name));
|
||||||
|
} else {
|
||||||
|
sprintf(temp,DataType_lcaststr(t,name));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strcpy(temp,"");
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cargs()
|
||||||
|
*
|
||||||
|
* Emit all of the local variables for a list of parameters. Returns the
|
||||||
|
* number of parameters.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int Swig_cargs(Wrapper *w, ParmList *l) {
|
||||||
|
Parm *p;
|
||||||
|
int i;
|
||||||
|
DataType *pt;
|
||||||
|
char *pvalue;
|
||||||
|
char *pname;
|
||||||
|
char *local;
|
||||||
|
char *lname;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
p = ParmList_first(l);
|
||||||
|
while (p != 0) {
|
||||||
|
lname = Swig_cparm_name(p,i);
|
||||||
|
pt = Parm_Gettype(p);
|
||||||
|
pname = Parm_Getname(p);
|
||||||
|
pvalue = Parm_Getvalue(p);
|
||||||
|
local = Swig_clocal(pt,lname,pvalue);
|
||||||
|
Wrapper_add_localv(w,lname,local,0);
|
||||||
|
i++;
|
||||||
|
p = ParmList_next(l);
|
||||||
|
}
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cresult()
|
||||||
|
*
|
||||||
|
* This function generates the C code needed to set the result of a C
|
||||||
|
* function call.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Swig_cresult(Wrapper *w, DataType *t, DOHString_or_char *name, DOHString_or_char *decl) {
|
||||||
|
int i;
|
||||||
|
Parm *p;
|
||||||
|
DOHString *fcall;
|
||||||
|
char *tm;
|
||||||
|
|
||||||
|
fcall = NewString("");
|
||||||
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
|
Wrapper_add_localv(w,name, Swig_clocal(t,name,0), 0);
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
t->is_pointer++;
|
||||||
|
Printv(fcall, name, " = (", DataType_lstr(t,0), ") malloc(sizeof(", 0);
|
||||||
|
t->is_pointer--;
|
||||||
|
Printv(fcall, DataType_str(t,0), "));\n", 0);
|
||||||
|
Printv(fcall, "*(", name, ") = ", 0);
|
||||||
|
} else {
|
||||||
|
/* Is this a reference? */
|
||||||
|
if (t->is_reference) {
|
||||||
|
Printv(fcall, DataType_str(t,"_result_ref")," = ", 0);
|
||||||
|
} else {
|
||||||
|
/* Normal return value */
|
||||||
|
if (DataType_qualifier(t)) {
|
||||||
|
Printv(fcall, name, " = (", DataType_lstr(t,0), ")", 0);
|
||||||
|
} else {
|
||||||
|
Printv(fcall, name, " = ", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now print out function call */
|
||||||
|
Printv(fcall, decl, ";\n", 0);
|
||||||
|
|
||||||
|
if (t->is_reference) {
|
||||||
|
Printv(fcall, name, " = (", DataType_lstr(t,0), ") &_result_ref;\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Replace(w->code,"$function",fcall, DOH_REPLACE_ANY) == 0) {
|
||||||
|
Printv(w->code, fcall, 0);
|
||||||
|
}
|
||||||
|
Delete(fcall);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cppresult()
|
||||||
|
*
|
||||||
|
* This function generates the C++ code needed to set the result. This uses
|
||||||
|
* the C++ default copy constructor for user defined objects.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Swig_cppresult(Wrapper *w, DataType *t, DOHString_or_char *name, DOHString_or_char *decl) {
|
||||||
|
int i;
|
||||||
|
Parm *p;
|
||||||
|
DOHString *fcall;
|
||||||
|
char *tm;
|
||||||
|
|
||||||
|
fcall = NewString("");
|
||||||
|
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||||
|
Wrapper_add_localv(w,name, Swig_clocal(t,name,0), 0);
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
Printv(fcall, name, " = new ", DataType_str(t,0), "(", 0);
|
||||||
|
} else {
|
||||||
|
/* Is this a reference? */
|
||||||
|
if (t->is_reference) {
|
||||||
|
Printv(fcall, DataType_str(t,"_result_ref")," = ", 0);
|
||||||
|
} else {
|
||||||
|
/* Normal return value */
|
||||||
|
Printv(fcall, name, " = (", DataType_lstr(t,0), ")", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now print out function call */
|
||||||
|
Printv(fcall, decl, 0);
|
||||||
|
|
||||||
|
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||||
|
Printf(fcall,")");
|
||||||
|
}
|
||||||
|
Printf(fcall,";\n");
|
||||||
|
|
||||||
|
if (t->is_reference) {
|
||||||
|
Printv(fcall, name, " = (", DataType_lstr(t,0), ") &_result_ref;\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Replace(w->code,"$function",fcall, DOH_REPLACE_ANY) == 0) {
|
||||||
|
Printv(w->code, fcall, 0);
|
||||||
|
}
|
||||||
|
Delete(fcall);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cfunction()
|
||||||
|
*
|
||||||
|
* Creates a string that calls a C function using the local variable rules
|
||||||
|
* defined above.
|
||||||
|
*
|
||||||
|
* name(arg0, arg1, arg2, ... argn)
|
||||||
|
*
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_cfunction(DOHString_or_char *name, ParmList *parms) {
|
||||||
|
static DOH *func = 0;
|
||||||
|
int i = 0;
|
||||||
|
Parm *p;
|
||||||
|
DataType *pt;
|
||||||
|
|
||||||
|
if (!func) func = NewString("");
|
||||||
|
Clear(func);
|
||||||
|
|
||||||
|
Printf(func,"%s(", name);
|
||||||
|
|
||||||
|
p = ParmList_first(parms);
|
||||||
|
while (p) {
|
||||||
|
pt = Parm_Gettype(p);
|
||||||
|
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
||||||
|
i++;
|
||||||
|
p = ParmList_next(parms);
|
||||||
|
if (p)
|
||||||
|
Printf(func,",");
|
||||||
|
}
|
||||||
|
Printf(func,")");
|
||||||
|
return Char(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cmethod()
|
||||||
|
*
|
||||||
|
* Generates a string that calls a C++ method from a list of parameters.
|
||||||
|
*
|
||||||
|
* arg0->name(arg1, arg2, arg3, ..., argn)
|
||||||
|
*
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_cmethod(DOHString_or_char *name, ParmList *parms) {
|
||||||
|
static DOH *func = 0;
|
||||||
|
int i = 0;
|
||||||
|
Parm *p;
|
||||||
|
DataType *pt;
|
||||||
|
|
||||||
|
if (!func) func = NewString("");
|
||||||
|
Clear(func);
|
||||||
|
|
||||||
|
p = ParmList_first(parms);
|
||||||
|
|
||||||
|
if (!p) return "";
|
||||||
|
Printf(func,"%s->%s(", Swig_cparm_name(p,0), name);
|
||||||
|
i++;
|
||||||
|
p = ParmList_next(parms);
|
||||||
|
while (p) {
|
||||||
|
pt = Parm_Gettype(p);
|
||||||
|
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,i)));
|
||||||
|
i++;
|
||||||
|
p = ParmList_next(parms);
|
||||||
|
if (p)
|
||||||
|
Printf(func,",");
|
||||||
|
}
|
||||||
|
Printf(func,")");
|
||||||
|
return Char(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cmember_set()
|
||||||
|
*
|
||||||
|
* Generates a string that sets the name of a member in a C++ class or C struct.
|
||||||
|
*
|
||||||
|
* arg0->name = arg1
|
||||||
|
*
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_cmember_set(DOHString_or_char *name, ParmList *parms) {
|
||||||
|
static DOH *func = 0;
|
||||||
|
Parm *p;
|
||||||
|
DataType *pt;
|
||||||
|
|
||||||
|
if (!func) func = NewString("");
|
||||||
|
Clear(func);
|
||||||
|
|
||||||
|
if (ParmList_numarg(parms) != 2) {
|
||||||
|
printf("Swig_cmember_set called with wrong # args!\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
p = ParmList_first(parms);
|
||||||
|
Printf(func,"(%s->%s = ", Swig_cparm_name(p,0), name);
|
||||||
|
p = ParmList_next(parms);
|
||||||
|
pt = Parm_Gettype(p);
|
||||||
|
Printf(func,"%s", Swig_clocal_deref(pt, Swig_cparm_name(p,1)));
|
||||||
|
Printf(func,")");
|
||||||
|
return Char(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_cmember_get()
|
||||||
|
*
|
||||||
|
* Generates a string that sets the name of a member in a C++ class or C struct.
|
||||||
|
*
|
||||||
|
* arg0->name
|
||||||
|
*
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *
|
||||||
|
Swig_cmember_get(DOHString_or_char *name, ParmList *parms) {
|
||||||
|
static DOH *func = 0;
|
||||||
|
Parm *p;
|
||||||
|
DataType *pt;
|
||||||
|
|
||||||
|
if (!func) func = NewString("");
|
||||||
|
Clear(func);
|
||||||
|
|
||||||
|
if (ParmList_numarg(parms) != 1) {
|
||||||
|
printf("Swig_cmember_get called with wrong # args!\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
p = ParmList_first(parms);
|
||||||
|
Printf(func,"(%s->%s)", Swig_cparm_name(p,0), name);
|
||||||
|
return Char(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,6 +34,7 @@ Parm *NewParm(DataType *type, char *n) {
|
||||||
p->_type = 0;
|
p->_type = 0;
|
||||||
}
|
}
|
||||||
p->_name = Swig_copy_string(n);
|
p->_name = Swig_copy_string(n);
|
||||||
|
p->_lname = 0;
|
||||||
p->_defvalue = 0;
|
p->_defvalue = 0;
|
||||||
p->ignore = 0;
|
p->ignore = 0;
|
||||||
return p;
|
return p;
|
||||||
|
|
@ -48,6 +49,7 @@ Parm *CopyParm(Parm *p) {
|
||||||
if (p->_type) np->_type = CopyDataType(p->_type);
|
if (p->_type) np->_type = CopyDataType(p->_type);
|
||||||
np->_name = Swig_copy_string(p->_name);
|
np->_name = Swig_copy_string(p->_name);
|
||||||
np->_defvalue = Swig_copy_string(p->_defvalue);
|
np->_defvalue = Swig_copy_string(p->_defvalue);
|
||||||
|
np->_lname = Swig_copy_string(p->_lname);
|
||||||
np->ignore = p->ignore;
|
np->ignore = p->ignore;
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
|
@ -60,6 +62,7 @@ void DelParm(Parm *p) {
|
||||||
if (p->_type) DelDataType(p->_type);
|
if (p->_type) DelDataType(p->_type);
|
||||||
if (p->_name) free(p->_name);
|
if (p->_name) free(p->_name);
|
||||||
if (p->_defvalue) free(p->_defvalue);
|
if (p->_defvalue) free(p->_defvalue);
|
||||||
|
if (p->_lname) free(p->_lname);
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,6 +84,15 @@ char *Parm_Getname(Parm *p) {
|
||||||
return p->_name;
|
return p->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Parm_Setlname(Parm *p, char *n) {
|
||||||
|
if (p->_lname) free(p->_lname);
|
||||||
|
p->_lname = Swig_copy_string(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *Parm_Getlname(Parm *p) {
|
||||||
|
return p->_lname;
|
||||||
|
}
|
||||||
|
|
||||||
void Parm_Setvalue(Parm *p, char *v) {
|
void Parm_Setvalue(Parm *p, char *v) {
|
||||||
if (p->_defvalue) free(p->_defvalue);
|
if (p->_defvalue) free(p->_defvalue);
|
||||||
p->_defvalue = Swig_copy_string(v);
|
p->_defvalue = Swig_copy_string(v);
|
||||||
|
|
@ -301,7 +313,6 @@ void ParmList_print_types(ParmList *l, DOHFile *f) {
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ParmList_print_args(ParmList *l, DOHFile *f) {
|
void ParmList_print_args(ParmList *l, DOHFile *f) {
|
||||||
|
|
||||||
int is_pointer;
|
int is_pointer;
|
||||||
int pn;
|
int pn;
|
||||||
DataType *t;
|
DataType *t;
|
||||||
|
|
@ -316,3 +327,4 @@ void ParmList_print_args(ParmList *l, DOHFile *f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,134 +183,14 @@ void DataType_primitive(DataType *t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
* char *print_type()
|
* char *mangle_default()
|
||||||
*
|
|
||||||
* Print the datatype, but without qualifiers (ie. const, volatile)
|
|
||||||
* Returns a string containing the result.
|
|
||||||
*
|
|
||||||
* If a datatype is marked as an implicit ptr it means that is_pointer
|
|
||||||
* is at least one, but we don't print '*'.
|
|
||||||
*
|
|
||||||
* If the type status is STAT_REPLACETYPE, it means that we can't
|
|
||||||
* use this type as a valid type. We'll substitute it's old name in.
|
|
||||||
* -------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
char *DataType_print_type(DataType *ty) {
|
|
||||||
static char result[8][256];
|
|
||||||
static int ri = 0;
|
|
||||||
int i;
|
|
||||||
DataType *t = ty;
|
|
||||||
|
|
||||||
if (ty->status & STAT_REPLACETYPE) {
|
|
||||||
t = CopyDataType(ty);
|
|
||||||
DataType_typedef_replace(t);
|
|
||||||
}
|
|
||||||
ri = ri % 8;
|
|
||||||
sprintf(result[ri],"%s ", t->name);
|
|
||||||
for (i = 0; i < (t->is_pointer-t->implicit_ptr); i++)
|
|
||||||
strcat(result[ri],"*");
|
|
||||||
|
|
||||||
if (ty->status & STAT_REPLACETYPE) {
|
|
||||||
DelDataType(t);
|
|
||||||
};
|
|
||||||
return result[ri++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
|
||||||
* char *print_full()
|
|
||||||
*
|
|
||||||
* Prints full type, with qualifiers.
|
|
||||||
* -------------------------------------------------------------------- */
|
|
||||||
char *DataType_print_full(DataType *t) {
|
|
||||||
static char result[8][256];
|
|
||||||
static int ri = 0;
|
|
||||||
|
|
||||||
ri = ri % 8;
|
|
||||||
if (t->_qualifier) {
|
|
||||||
sprintf(result[ri],"%s %s", t->_qualifier, DataType_print_type(t));
|
|
||||||
return result[ri++];
|
|
||||||
} else {
|
|
||||||
return DataType_print_type(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
|
||||||
* char *print_cast()
|
|
||||||
*
|
|
||||||
* Prints a cast. (Basically just a type but with parens added).
|
|
||||||
* -------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
char *DataType_print_cast(DataType *t) {
|
|
||||||
static char result[8][256];
|
|
||||||
static int ri = 0;
|
|
||||||
|
|
||||||
ri = ri % 8;
|
|
||||||
sprintf(result[ri],"(%s)", DataType_print_type(t));
|
|
||||||
return result[ri++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
|
||||||
* char *print_arraycast()
|
|
||||||
*
|
|
||||||
* Prints a cast, but for array datatypes. Super ugly, but necessary
|
|
||||||
* for multidimensional arrays.
|
|
||||||
* -------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
char *DataType_print_arraycast(DataType *ty) {
|
|
||||||
static char result[8][256];
|
|
||||||
static int ri = 0;
|
|
||||||
int ndim;
|
|
||||||
char *c;
|
|
||||||
DataType *t;
|
|
||||||
|
|
||||||
t = ty;
|
|
||||||
if (ty->status & STAT_REPLACETYPE) {
|
|
||||||
t = CopyDataType(ty);
|
|
||||||
DataType_typedef_replace(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
ri = ri % 8;
|
|
||||||
if (t->_arraystr) {
|
|
||||||
ndim = 0;
|
|
||||||
c = t->_arraystr;
|
|
||||||
while (*c) {
|
|
||||||
if (*c == '[') ndim++;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
if (ndim > 1) {
|
|
||||||
/* a Multidimensional array. Provide a special cast for it */
|
|
||||||
int oldstatus = ty->status;
|
|
||||||
t->status = t->status & (~STAT_REPLACETYPE);
|
|
||||||
t->is_pointer--;
|
|
||||||
sprintf(result[ri],"(%s", DataType_print_type(t));
|
|
||||||
t->is_pointer++;
|
|
||||||
t->status = oldstatus;
|
|
||||||
strcat(result[ri]," (*)");
|
|
||||||
c = t->_arraystr;
|
|
||||||
while (*c) {
|
|
||||||
if (*c == ']') break;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
if (*c) c++;
|
|
||||||
strcat(result[ri],c);
|
|
||||||
strcat(result[ri],")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ty->status & STAT_REPLACETYPE) {
|
|
||||||
DelDataType(t);
|
|
||||||
}
|
|
||||||
return result[ri++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
|
||||||
* char *print_mangle_default()
|
|
||||||
*
|
*
|
||||||
* Prints a mangled version of this datatype. Used for run-time type
|
* Prints a mangled version of this datatype. Used for run-time type
|
||||||
* checking in order to print out a "language friendly" version (ie. no
|
* checking in order to print out a "language friendly" version (ie. no
|
||||||
* spaces and no weird characters).
|
* spaces and no weird characters).
|
||||||
* -------------------------------------------------------------------- */
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *DataType_print_mangle_default(DataType *t) {
|
char *DataType_mangle_default(DataType *t) {
|
||||||
static char result[8][256];
|
static char result[8][256];
|
||||||
static int ri = 0;
|
static int ri = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -342,9 +222,9 @@ char *DataType_print_mangle_default(DataType *t) {
|
||||||
/* This is kind of ugly but needed for each language to support a
|
/* This is kind of ugly but needed for each language to support a
|
||||||
custom name mangling mechanism. (ie. Perl5). */
|
custom name mangling mechanism. (ie. Perl5). */
|
||||||
|
|
||||||
static char *(*mangler)(DataType *t) = DataType_print_mangle_default;
|
static char *(*mangler)(DataType *t) = DataType_mangle_default;
|
||||||
|
|
||||||
char *DataType_print_mangle(DataType *t) {
|
char *DataType_manglestr(DataType *t) {
|
||||||
/* Call into target language for name mangling. */
|
/* Call into target language for name mangling. */
|
||||||
return (*mangler)(t);
|
return (*mangler)(t);
|
||||||
}
|
}
|
||||||
|
|
@ -360,7 +240,7 @@ void DataType_set_mangle(char *(*m)(DataType *t)) {
|
||||||
* variable name.
|
* variable name.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *DataType_str(DataType *t, char *name) {
|
char *DataType_str(DataType *t, DOHString_or_char *name) {
|
||||||
static char result[8][256];
|
static char result[8][256];
|
||||||
static int ri = 0;
|
static int ri = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -378,7 +258,7 @@ char *DataType_str(DataType *t, char *name) {
|
||||||
strcat(result[ri],"*");
|
strcat(result[ri],"*");
|
||||||
}
|
}
|
||||||
if (t->is_reference) strcat(result[ri],"&");
|
if (t->is_reference) strcat(result[ri],"&");
|
||||||
if (name) strcat(result[ri],name);
|
if (name) strcat(result[ri],Char(name));
|
||||||
if (t->_arraystr) {
|
if (t->_arraystr) {
|
||||||
strcat(result[ri],t->_arraystr);
|
strcat(result[ri],t->_arraystr);
|
||||||
t->is_pointer++;
|
t->is_pointer++;
|
||||||
|
|
@ -387,6 +267,177 @@ char *DataType_str(DataType *t, char *name) {
|
||||||
return result[ri++];
|
return result[ri++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------
|
||||||
|
* char *DataType_lstr()
|
||||||
|
*
|
||||||
|
* Produces a type-string that is suitable as a lvalue in an expression.
|
||||||
|
* That is, a type that can be freely assigned a value without violating
|
||||||
|
* any C assignment rules.
|
||||||
|
*
|
||||||
|
* - Qualifiers such as 'const' and 'volatile' are stripped.
|
||||||
|
* - Arrays are converted into a *single* pointer (i.e.,
|
||||||
|
* double [][] becomes double *).
|
||||||
|
* - References are converted into a pointer.
|
||||||
|
* - Typedef names that refer to read-only types will be replaced
|
||||||
|
* with an equivalent assignable version.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *DataType_lstr(DataType *ty, DOHString_or_char *name) {
|
||||||
|
static char result[8][256];
|
||||||
|
static int ri = 0;
|
||||||
|
int i;
|
||||||
|
DataType *t = ty;
|
||||||
|
|
||||||
|
if (ty->status & STAT_REPLACETYPE) {
|
||||||
|
t = CopyDataType(ty);
|
||||||
|
DataType_typedef_replace(t); /* Replace the type with its typedef value */
|
||||||
|
}
|
||||||
|
ri = ri % 8;
|
||||||
|
sprintf(result[ri],"%s ", t->name);
|
||||||
|
for (i = 0; i < (t->is_pointer-t->implicit_ptr); i++)
|
||||||
|
strcat(result[ri],"*");
|
||||||
|
|
||||||
|
if (ty->status & STAT_REPLACETYPE) {
|
||||||
|
DelDataType(t);
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
strcat(result[ri],Char(name));
|
||||||
|
}
|
||||||
|
return result[ri++];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* DataType_ltype(DataType *ty)
|
||||||
|
*
|
||||||
|
* Returns a type object corresponding to the string created by lstr
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
DataType *DataType_ltype(DataType *t) {
|
||||||
|
|
||||||
|
DataType *ty = CopyDataType(t);
|
||||||
|
if (ty->status & STAT_REPLACETYPE) {
|
||||||
|
DataType_typedef_replace(ty); /* Replace the type with its typedef value */
|
||||||
|
}
|
||||||
|
if (ty->_qualifier) {
|
||||||
|
free(ty->_qualifier);
|
||||||
|
ty->_qualifier = 0;
|
||||||
|
}
|
||||||
|
if (ty->_arraystr) {
|
||||||
|
free(ty->_arraystr);
|
||||||
|
ty->_arraystr = 0;
|
||||||
|
}
|
||||||
|
ty->is_reference = 0;
|
||||||
|
return ty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* char *DataType_rcaststr(DataType *t, char *name)
|
||||||
|
*
|
||||||
|
* Produces a casting string that maps the type returned by lstr() to the real
|
||||||
|
* datatype printed by str().
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *DataType_rcaststr(DataType *ty, DOHString_or_char *name) {
|
||||||
|
static char result[8][256];
|
||||||
|
static int ri = 0;
|
||||||
|
DataType *t = 0;
|
||||||
|
ri = ri % 8;
|
||||||
|
|
||||||
|
strcpy(result[ri],"");
|
||||||
|
if (ty->_arraystr) {
|
||||||
|
t = ty;
|
||||||
|
if (ty->status & STAT_REPLACETYPE) {
|
||||||
|
t = CopyDataType(ty);
|
||||||
|
DataType_typedef_replace(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
ri = ri % 8;
|
||||||
|
if (t->_arraystr) {
|
||||||
|
int ndim;
|
||||||
|
char *c;
|
||||||
|
ndim = 0;
|
||||||
|
c = t->_arraystr;
|
||||||
|
while (*c) {
|
||||||
|
if (*c == '[') ndim++;
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
if (ndim > 1) {
|
||||||
|
/* a Multidimensional array. Provide a special cast for it */
|
||||||
|
char *oldarr = 0;
|
||||||
|
int oldstatus = ty->status;
|
||||||
|
t->status = t->status & (~STAT_REPLACETYPE);
|
||||||
|
t->is_pointer--;
|
||||||
|
oldarr = t->_arraystr;
|
||||||
|
t->_arraystr = 0;
|
||||||
|
sprintf(result[ri],"(%s", DataType_str(t,0));
|
||||||
|
t->_arraystr = oldarr;
|
||||||
|
t->is_pointer++;
|
||||||
|
t->status = oldstatus;
|
||||||
|
strcat(result[ri]," (*)");
|
||||||
|
c = t->_arraystr;
|
||||||
|
while (*c) {
|
||||||
|
if (*c == ']') break;
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
if (*c) c++;
|
||||||
|
strcat(result[ri],c);
|
||||||
|
strcat(result[ri],")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ty->status & STAT_REPLACETYPE) {
|
||||||
|
DelDataType(t);
|
||||||
|
}
|
||||||
|
} else if (ty->_qualifier) {
|
||||||
|
/* Make a cast to restore const/volatile */
|
||||||
|
sprintf(result[ri],"(%s)", DataType_str(ty,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
if (ty->is_reference) {
|
||||||
|
strcat(result[ri],"*");
|
||||||
|
}
|
||||||
|
strcat(result[ri],Char(name));
|
||||||
|
}
|
||||||
|
return result[ri++];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* DataType_lcaststr()
|
||||||
|
*
|
||||||
|
* Casts a variable from the real type to the local datatype.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *DataType_lcaststr(DataType *ty, DOHString_or_char *name) {
|
||||||
|
static char result[8][256];
|
||||||
|
static int ri = 0;
|
||||||
|
DataType *t = 0;
|
||||||
|
ri = ri % 8;
|
||||||
|
|
||||||
|
strcpy(result[ri],"");
|
||||||
|
|
||||||
|
if (ty->_arraystr) {
|
||||||
|
sprintf(result[ri],"(%s)", DataType_lstr(ty,0));
|
||||||
|
if (name)
|
||||||
|
strcat(result[ri], Char(name));
|
||||||
|
} else if (ty->is_reference) {
|
||||||
|
sprintf(result[ri],"(%s)", DataType_lstr(ty,0));
|
||||||
|
if (name) {
|
||||||
|
strcat(result[ri], "&");
|
||||||
|
strcat(result[ri], Char(name));
|
||||||
|
}
|
||||||
|
} else if (ty->_qualifier) {
|
||||||
|
sprintf(result[ri],"(%s)", DataType_lstr(ty,0));
|
||||||
|
if (name) {
|
||||||
|
strcat(result[ri], Char(name));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (name) {
|
||||||
|
strcat(result[ri], Char(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result[ri++];
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
* int DataType_array_dimensions()
|
* int DataType_array_dimensions()
|
||||||
*
|
*
|
||||||
|
|
@ -507,8 +558,8 @@ int DataType_typedef_add(DataType *t,char *tname, int mode) {
|
||||||
if ((t->type != T_VOID) && (strcmp(t->name,tname) != 0)) {
|
if ((t->type != T_VOID) && (strcmp(t->name,tname) != 0)) {
|
||||||
t1 = NewDataType(0);
|
t1 = NewDataType(0);
|
||||||
strcpy(t1->name,tname);
|
strcpy(t1->name,tname);
|
||||||
name2 = DataType_print_mangle(t1);
|
name2 = DataType_manglestr(t1);
|
||||||
name1 = DataType_print_mangle(t);
|
name1 = DataType_manglestr(t);
|
||||||
typeeq_addtypedef(name1,name2,t1);
|
typeeq_addtypedef(name1,name2,t1);
|
||||||
typeeq_addtypedef(name2,name1,t);
|
typeeq_addtypedef(name2,name1,t);
|
||||||
DelDataType(t1);
|
DelDataType(t1);
|
||||||
|
|
@ -933,8 +984,8 @@ void typeeq_derived(char *n1, char *n2, char *cast) {
|
||||||
t1->type = T_USER;
|
t1->type = T_USER;
|
||||||
strcpy(t->name,n1);
|
strcpy(t->name,n1);
|
||||||
strcpy(t1->name,n2);
|
strcpy(t1->name,n2);
|
||||||
name = DataType_print_mangle(t);
|
name = DataType_manglestr(t);
|
||||||
name2 = DataType_print_mangle(t1);
|
name2 = DataType_manglestr(t1);
|
||||||
typeeq_add(name,name2, cast, t1);
|
typeeq_add(name,name2, cast, t1);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
DelDataType(t1);
|
DelDataType(t1);
|
||||||
|
|
@ -956,8 +1007,8 @@ void typeeq_mangle(char *n1, char *n2, char *cast) {
|
||||||
|
|
||||||
strcpy(t->name,n1);
|
strcpy(t->name,n1);
|
||||||
strcpy(t1->name,n2);
|
strcpy(t1->name,n2);
|
||||||
name = DataType_print_mangle(t);
|
name = DataType_manglestr(t);
|
||||||
name2 = DataType_print_mangle(t1);
|
name2 = DataType_manglestr(t1);
|
||||||
typeeq_add(name,name2,cast,0);
|
typeeq_add(name,name2,cast,0);
|
||||||
DelDataType(t);
|
DelDataType(t);
|
||||||
DelDataType(t1);
|
DelDataType(t1);
|
||||||
|
|
@ -1007,7 +1058,7 @@ check_equivalent(DataType *t) {
|
||||||
Clear(out);
|
Clear(out);
|
||||||
|
|
||||||
while (t->is_pointer >= t->implicit_ptr) {
|
while (t->is_pointer >= t->implicit_ptr) {
|
||||||
m = Swig_copy_string(DataType_print_mangle(t));
|
m = Swig_copy_string(DataType_manglestr(t));
|
||||||
|
|
||||||
if (!te_init) typeeq_init();
|
if (!te_init) typeeq_init();
|
||||||
|
|
||||||
|
|
@ -1019,7 +1070,7 @@ check_equivalent(DataType *t) {
|
||||||
while (e2) {
|
while (e2) {
|
||||||
if (e2->type) {
|
if (e2->type) {
|
||||||
e2->type->is_pointer += (npointer - t->is_pointer);
|
e2->type->is_pointer += (npointer - t->is_pointer);
|
||||||
Printf(out,"{ \"%s\",", DataType_print_mangle(e2->type));
|
Printf(out,"{ \"%s\",", DataType_manglestr(e2->type));
|
||||||
e2->type->is_pointer -= (npointer - t->is_pointer);
|
e2->type->is_pointer -= (npointer - t->is_pointer);
|
||||||
if (e2->cast)
|
if (e2->cast)
|
||||||
Printf(out,"%s}, ", e2->cast);
|
Printf(out,"%s}, ", e2->cast);
|
||||||
|
|
@ -1076,7 +1127,7 @@ void DataType_remember(DataType *ty) {
|
||||||
DataType *t = CopyDataType(ty);
|
DataType *t = CopyDataType(ty);
|
||||||
|
|
||||||
if (!remembered) remembered = NewHash();
|
if (!remembered) remembered = NewHash();
|
||||||
SetVoid(remembered, DataType_print_mangle(t), t);
|
SetVoid(remembered, DataType_manglestr(t), t);
|
||||||
|
|
||||||
if (!bases) bases = NewHash();
|
if (!bases) bases = NewHash();
|
||||||
/* Now, do the base-class hack */
|
/* Now, do the base-class hack */
|
||||||
|
|
@ -1087,7 +1138,7 @@ void DataType_remember(DataType *ty) {
|
||||||
while (key) {
|
while (key) {
|
||||||
DataType *nt = CopyDataType(t);
|
DataType *nt = CopyDataType(t);
|
||||||
strcpy(nt->name,Char(key));
|
strcpy(nt->name,Char(key));
|
||||||
if (!Getattr(remembered,DataType_print_mangle(nt)))
|
if (!Getattr(remembered,DataType_manglestr(nt)))
|
||||||
DataType_remember(nt);
|
DataType_remember(nt);
|
||||||
DelDataType(nt);
|
DelDataType(nt);
|
||||||
key = Nextkey(h);
|
key = Nextkey(h);
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,12 @@ extern void DelDataType(DataType *type);
|
||||||
|
|
||||||
/* -- New type interface -- */
|
/* -- New type interface -- */
|
||||||
|
|
||||||
extern char *DataType_str(DataType *, char *name); /* Exact datatype */
|
extern char *DataType_str(DataType *, DOHString_or_char *name); /* Exact datatype */
|
||||||
|
extern char *DataType_lstr(DataType *, DOHString_or_char *name); /* Assignable datatype */
|
||||||
|
extern char *DataType_rcaststr(DataType *, DOHString_or_char *name); /* Cast from lstr to str */
|
||||||
|
extern char *DataType_lcaststr(DataType *, DOHString_or_char *name); /* Cast from str to lstr */
|
||||||
|
extern char *DataType_manglestr(DataType *t); /* Mangled type name */
|
||||||
|
extern DataType *DataType_ltype(DataType *); /* Create local type object */
|
||||||
|
|
||||||
/* -- Old type interface -- */
|
/* -- Old type interface -- */
|
||||||
|
|
||||||
|
|
@ -258,14 +263,8 @@ extern char *DataType_qualifier(DataType *);
|
||||||
extern void DataType_set_qualifier(DataType *, char *q);
|
extern void DataType_set_qualifier(DataType *, char *q);
|
||||||
extern char *DataType_arraystr(DataType *);
|
extern char *DataType_arraystr(DataType *);
|
||||||
extern void DataType_set_arraystr(DataType *, char *a);
|
extern void DataType_set_arraystr(DataType *, char *a);
|
||||||
|
extern char *DataType_mangle_default(DataType *t); /* Default name mangler */
|
||||||
extern void DataType_primitive(DataType *);
|
extern void DataType_primitive(DataType *);
|
||||||
extern char *DataType_print_type(DataType *);
|
|
||||||
extern char *DataType_print_full(DataType *);
|
|
||||||
extern char *DataType_print_cast(DataType *);
|
|
||||||
extern char *DataType_print_mangle(DataType *);
|
|
||||||
extern char *DataType_print_arraycast(DataType *);
|
|
||||||
extern char *DataType_print_mangle_default(DataType *);
|
|
||||||
extern void DataType_set_mangle(char *(*m)(DataType *));
|
extern void DataType_set_mangle(char *(*m)(DataType *));
|
||||||
extern int DataType_array_dimensions(DataType *);
|
extern int DataType_array_dimensions(DataType *);
|
||||||
extern char *DataType_get_dimension(DataType *, int);
|
extern char *DataType_get_dimension(DataType *, int);
|
||||||
|
|
@ -294,10 +293,11 @@ extern void typeeq_addtypedef(char *name, char *eqname, DataType *t);
|
||||||
/* --- Deprecated parameter list structure */
|
/* --- Deprecated parameter list structure */
|
||||||
|
|
||||||
typedef struct Parm {
|
typedef struct Parm {
|
||||||
DataType *_type; /* Datatype of this parameter */
|
DataType *_type; /* Datatype of this parameter */
|
||||||
char *_name; /* Name of parameter (optional) */
|
char *_name; /* Name of parameter (optional) */
|
||||||
char *_defvalue; /* Default value (as a string) */
|
char *_defvalue; /* Default value (as a string) */
|
||||||
int ignore; /* Ignore flag */
|
char *_lname; /* Local name */
|
||||||
|
int ignore; /* Ignore flag */
|
||||||
} Parm;
|
} Parm;
|
||||||
|
|
||||||
extern Parm *NewParm(DataType *type, char *n);
|
extern Parm *NewParm(DataType *type, char *n);
|
||||||
|
|
@ -307,6 +307,8 @@ extern void Parm_Settype(Parm *p, DataType *t);
|
||||||
extern DataType *Parm_Gettype(Parm *p);
|
extern DataType *Parm_Gettype(Parm *p);
|
||||||
extern void Parm_Setname(Parm *p, char *name);
|
extern void Parm_Setname(Parm *p, char *name);
|
||||||
extern char *Parm_Getname(Parm *p);
|
extern char *Parm_Getname(Parm *p);
|
||||||
|
extern void Parm_Setlname(Parm *p, char *lname);
|
||||||
|
extern char *Parm_Getlname(Parm *p);
|
||||||
extern void Parm_Setvalue(Parm *p, char *value);
|
extern void Parm_Setvalue(Parm *p, char *value);
|
||||||
extern char *Parm_Getvalue(Parm *p);
|
extern char *Parm_Getvalue(Parm *p);
|
||||||
|
|
||||||
|
|
@ -330,6 +332,24 @@ extern Parm *ParmList_next(ParmList *);
|
||||||
extern void ParmList_print_types(ParmList*,DOHFile *f);
|
extern void ParmList_print_types(ParmList*,DOHFile *f);
|
||||||
extern void ParmList_print_args(ParmList *, DOHFile *f);
|
extern void ParmList_print_args(ParmList *, DOHFile *f);
|
||||||
|
|
||||||
|
|
||||||
|
extern void Wrapper_local(Wrapper *w, DataType *t, DOHString_or_char *name, DOHString_or_char *value);
|
||||||
|
extern char *Wrapper_local_deref(DataType *t, DOHString_or_char *name);
|
||||||
|
|
||||||
|
/* --- C Wrappers --- */
|
||||||
|
extern char *Swig_clocal(DataType *t, DOHString_or_char *name, DOHString_or_char *value);
|
||||||
|
extern DataType *Swig_clocal_type(DataType *t);
|
||||||
|
extern char *Swig_clocal_deref(DataType *t, DOHString_or_char *name);
|
||||||
|
extern char *Swig_clocal_assign(DataType *t, DOHString_or_char *name);
|
||||||
|
extern char *Swig_cparm_name(Parm *p, int i);
|
||||||
|
extern int Swig_cargs(Wrapper *w, ParmList *l);
|
||||||
|
extern void Swig_cresult(Wrapper *w, DataType *t, DOHString_or_char *name, DOHString_or_char *decl);
|
||||||
|
extern void Swig_cppresult(Wrapper *w, DataType *t, DOHString_or_char *name, DOHString_or_char *decl);
|
||||||
|
extern char *Swig_cfunction(DOHString_or_char *name, ParmList *parms);
|
||||||
|
extern char *Swig_cmethod(DOHString_or_char *name, ParmList *parms);
|
||||||
|
extern char *Swig_cmember_set(DOHString_or_char *name, ParmList *parms);
|
||||||
|
extern char *Swig_cmember_get(DOHString_or_char *name, ParmList *parms);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* This file defines a object for creating wrapper functions. Primarily
|
* This file defines a object for creating wrapper functions. Primarily
|
||||||
* this is used for convenience since it allows pieces of a wrapper function
|
* this is used for convenience since it allows pieces of a wrapper function
|
||||||
* to be created in a non-linear manner.
|
* to be created in a piecemeal manner.
|
||||||
*
|
*
|
||||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
*
|
*
|
||||||
|
|
@ -249,23 +249,3 @@ Wrapper_new_localv(Wrapper *w, const DOHString_or_char *name, ...) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
|
||||||
int main() {
|
|
||||||
Wrapper *w;
|
|
||||||
w = NewWrapper();
|
|
||||||
Printf(w->def,"int foo_wrap(ClientData clientdata, Tcl_Interp *interp, int argc, char *argv[]) {");
|
|
||||||
Wrapper_add_local(w,"int a", "a");
|
|
||||||
Wrapper_add_local(w,"int a", "a");
|
|
||||||
Wrapper_add_local(w,"int b", "b");
|
|
||||||
Wrapper_add_local(w,"char temp[256]","temp");
|
|
||||||
|
|
||||||
Printf(w->code,"for (i = 0; i < 10; i++) { printf(\"%%d\", i); }\n");
|
|
||||||
|
|
||||||
Printf(w->code,"if (1) { foo;\n} else { bar; \n}\n");
|
|
||||||
|
|
||||||
Printf(w->code,"}\n");
|
|
||||||
Wrapper_print(w,stdout);
|
|
||||||
DelWrapper(w);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue