C++ String class and all operator overloading removed.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@551 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f5d582988f
commit
d9535328a1
14 changed files with 556 additions and 723 deletions
|
|
@ -2,7 +2,7 @@
|
|||
/* SWIG version information */
|
||||
|
||||
#ifndef SWIG_VERSION
|
||||
#define SWIG_VERSION "1.3u-20000619-0141"
|
||||
#define SWIG_VERSION "1.3u-20000705-2008"
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_SPIN
|
||||
|
|
|
|||
|
|
@ -350,18 +350,18 @@ GUILE::get_pointer (char *iname, int parm, DataType *t,
|
|||
int num_scheme_parm)
|
||||
{
|
||||
/* Pointers are smobs */
|
||||
Printf(f._code, " if (SWIG_Guile_GetPtr_Str(s_%d,(void **) &_arg%d", parm, parm);
|
||||
Printf(f.code, " if (SWIG_Guile_GetPtr_Str(s_%d,(void **) &_arg%d", parm, parm);
|
||||
if (t->type == T_VOID)
|
||||
Printf(f._code, ", (char *) 0)) {\n");
|
||||
Printf(f.code, ", (char *) 0)) {\n");
|
||||
else
|
||||
Printv(f._code, ", \"", t->print_mangle(), "\")) {\n", 0);
|
||||
Printv(f.code, ", \"", t->print_mangle(), "\")) {\n", 0);
|
||||
/* Raise exception */
|
||||
Printv(f._code,
|
||||
Printv(f.code,
|
||||
tab8,
|
||||
"scm_wrong_type_arg(\"",proc_name, "\", ",
|
||||
0);
|
||||
Printf(f._code,"%d, s_%d);\n", num_scheme_parm, parm);
|
||||
Printv(f._code, tab4, "}\n", 0);
|
||||
Printf(f.code,"%d, s_%d);\n", num_scheme_parm, parm);
|
||||
Printv(f.code, tab4, "}\n", 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -422,7 +422,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
Printv(f._def, "static SCM\n", wname," (", 0);
|
||||
Printv(f.def, "static SCM\n", wname," (", 0);
|
||||
|
||||
int i = 0;
|
||||
int first_arg = 1;
|
||||
|
|
@ -431,17 +431,17 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
continue;
|
||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
||||
if (!first_arg)
|
||||
Printf(f._def,", ");
|
||||
Printf(f._def,"SCM s_%d", i);
|
||||
Printf(f.def,", ");
|
||||
Printf(f.def,"SCM s_%d", i);
|
||||
first_arg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Printf(f._def, ")\n{\n");
|
||||
Printf(f.def, ")\n{\n");
|
||||
|
||||
// Define the scheme name in C
|
||||
|
||||
Printv(f._def, "#define SCHEME_NAME \"", proc_name, "\"\n", 0);
|
||||
Printv(f.def, "#define SCHEME_NAME \"", proc_name, "\"\n", 0);
|
||||
|
||||
// Declare return variable and arguments
|
||||
|
||||
|
|
@ -467,13 +467,13 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Handle parameter types.
|
||||
|
||||
if (p.ignore)
|
||||
Printv(f._code, "/* ", p.name, " ignored... */\n", 0);
|
||||
Printv(f.code, "/* ", p.name, " ignored... */\n", 0);
|
||||
else {
|
||||
++numargs;
|
||||
if ((tm = typemap_lookup ((char*)"in", typemap_lang,
|
||||
p.t, p.name, source, target, &f))) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
else if (p.t->is_pointer)
|
||||
get_pointer (iname, i, p.t, f, proc_name, numargs);
|
||||
|
|
@ -487,8 +487,8 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((tm = typemap_lookup ((char*)"check", typemap_lang,
|
||||
p.t, p.name, source, target, &f))) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
|
||||
// Pass output arguments back to the caller.
|
||||
|
|
@ -509,23 +509,23 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Now write code to make the function call
|
||||
Printv(f._code, tab4, "gh_defer_ints();\n", 0);
|
||||
Printv(f.code, tab4, "gh_defer_ints();\n", 0);
|
||||
emit_func_call (name, d, l, f);
|
||||
Printv(f._code, tab4, "gh_allow_ints();\n", 0);
|
||||
Printv(f.code, tab4, "gh_allow_ints();\n", 0);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
|
||||
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,
|
||||
d, name, (char*)"_result", (char*)"gswig_result", &f))) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
else if (d->is_pointer) {
|
||||
/* MK: I would like to use SWIG_Guile_MakePtr here to save one type
|
||||
look-up. */
|
||||
Printv(f._code, tab4,
|
||||
Printv(f.code, tab4,
|
||||
"gswig_result = SWIG_Guile_MakePtr_Str (",
|
||||
"_result, ",
|
||||
"\"", d->print_mangle(), "\", ",
|
||||
|
|
@ -538,18 +538,18 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Dump the argument output code
|
||||
Printv(f._code,outarg,0);
|
||||
Printv(f.code,outarg,0);
|
||||
|
||||
// Dump the argument cleanup code
|
||||
Printv(f._code,cleanup,0);
|
||||
Printv(f.code,cleanup,0);
|
||||
|
||||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup ((char*)"newfree", typemap_lang,
|
||||
d, iname, (char*)"_result", (char*)"", &f))) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -557,18 +557,18 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((tm = typemap_lookup ((char*)"ret", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"", &f))) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
||||
Printv(f._code, tab4, "return gswig_result;\n", 0);
|
||||
Printv(f.code, tab4, "return gswig_result;\n", 0);
|
||||
|
||||
// Undefine the scheme name
|
||||
|
||||
Printf(f._code, "#undef SCHEME_NAME\n");
|
||||
Printf(f._code, "}\n");
|
||||
Printf(f.code, "#undef SCHEME_NAME\n");
|
||||
Printf(f.code, "}\n");
|
||||
|
||||
f.print (f_wrappers);
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ char *JAVA::SwigTcToJniType(DataType *t, int ret) {
|
|||
case T_USER: return (char*)"jlong";
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "SwigTcToJniType: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
Printf(stderr, "SwigTcToJniType: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ char *JAVA::SwigTcToJavaType(DataType *t, int ret, int inShadow) {
|
|||
case T_USER: return (char*)"long";
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "SwigTcToJavaType: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
Printf(stderr, "SwigTcToJavaType: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ char *JAVA::SwigTcToJniScalarType(DataType *t) {
|
|||
return (char*)"Long";
|
||||
}
|
||||
|
||||
fprintf(stderr, "SwigTcToJniScalarType: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
Printf(stderr, "SwigTcToJniScalarType: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ char *JAVA::JavaMethodSignature(DataType *t, int ret, int inShadow) {
|
|||
case T_USER: return (char*)"J";
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "JavaMethodSignature: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
Printf(stderr, "JavaMethodSignature: unhandled SWIG type %d, %s\n", t->type, (char *) t->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ void JAVA::parse_args(int argc, char *argv[]) {
|
|||
Swig_mark_arg(i);
|
||||
jnic = 0;
|
||||
} else if (strcmp(argv[i],"-help") == 0) {
|
||||
fprintf(stderr,"%s\n", usage);
|
||||
Printf(stderr,"%s\n", usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -380,7 +380,7 @@ void JAVA::parse_args(int argc, char *argv[]) {
|
|||
|
||||
void JAVA::parse() {
|
||||
|
||||
fprintf(stderr,"Generating wrappers for Java\n");
|
||||
Printf(stderr,"Generating wrappers for Java\n");
|
||||
|
||||
shadow_classes = NewHash();
|
||||
shadow_classdef = NewString("");
|
||||
|
|
@ -415,12 +415,12 @@ void JAVA::set_module(char *mod_name, char **mod_list) {
|
|||
void JAVA::headers(void)
|
||||
{
|
||||
Swig_banner(f_header); // Print the SWIG banner message
|
||||
fprintf(f_header,"/* Implementation : Java */\n\n");
|
||||
Printf(f_header,"/* Implementation : Java */\n\n");
|
||||
|
||||
// Include header file code fragment into the output
|
||||
// if (file::include("java.swg",f_header) == -1) {
|
||||
if (Swig_insert_file("java.swg",f_header) == -1) {
|
||||
fprintf(stderr,"Fatal Error. Unable to locate 'java.swg'.\n");
|
||||
Printf(stderr,"Fatal Error. Unable to locate 'java.swg'.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -435,7 +435,7 @@ void JAVA::headers(void)
|
|||
void JAVA::initialize()
|
||||
{
|
||||
if (!module) {
|
||||
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||
Printf(stderr,"*** Error. No module name specified.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -443,22 +443,22 @@ void JAVA::initialize()
|
|||
DOHString *s = NewString(package);
|
||||
Replace(s,".","_", DOH_REPLACE_ANY);
|
||||
Append(s,"_");
|
||||
c_pkgstr = copy_string(Char(s));
|
||||
c_pkgstr = Swig_copy_string(Char(s));
|
||||
Delete(s);
|
||||
|
||||
DOHString *s2 = NewString(package);
|
||||
Replace(s2,".","/", DOH_REPLACE_ANY);
|
||||
Append(s2,"/");
|
||||
jni_pkgstr = copy_string(Char(s2));
|
||||
jni_pkgstr = Swig_copy_string(Char(s2));
|
||||
Delete(s2);
|
||||
} else {
|
||||
package = c_pkgstr = jni_pkgstr = (char*)"";
|
||||
}
|
||||
|
||||
sprintf(bigbuf, "Java_%s%s", c_pkgstr, module);
|
||||
c_pkgstr = copy_string(bigbuf);
|
||||
c_pkgstr = Swig_copy_string(bigbuf);
|
||||
sprintf(bigbuf, "%s_%%f", c_pkgstr);
|
||||
Swig_name_register((char*)"wrapper", copy_string(bigbuf));
|
||||
Swig_name_register((char*)"wrapper", Swig_copy_string(bigbuf));
|
||||
Swig_name_register((char*)"set", (char*)"set_%v");
|
||||
Swig_name_register((char*)"get", (char*)"get_%v");
|
||||
Swig_name_register((char*)"member", (char*)"%c_%m");
|
||||
|
|
@ -466,22 +466,22 @@ void JAVA::initialize()
|
|||
// Generate the java class
|
||||
sprintf(bigbuf, "%s.java", module);
|
||||
if((f_java = fopen(bigbuf, "w")) == 0) {
|
||||
fprintf(stderr,"Unable to open %s\n", bigbuf);
|
||||
Printf(stderr,"Unable to open %s\n", bigbuf);
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
fprintf(f_header, "#define J_CLASSNAME %s\n", module);
|
||||
Printf(f_header, "#define J_CLASSNAME %s\n", module);
|
||||
if(package && *package) {
|
||||
fprintf(f_java, "package %s;\n\n", package);
|
||||
fprintf(f_header, "#define J_PACKAGE %s\n", package);
|
||||
Printf(f_java, "package %s;\n\n", package);
|
||||
Printf(f_header, "#define J_PACKAGE %s\n", package);
|
||||
} else {
|
||||
fprintf(f_header, "#define J_PACKAGE\n");
|
||||
Printf(f_header, "#define J_PACKAGE\n");
|
||||
}
|
||||
}
|
||||
|
||||
void JAVA::emit_classdef() {
|
||||
if(!classdef_emitted)
|
||||
fprintf(f_java, "public class %s {\n", module);
|
||||
Printf(f_java, "public class %s {\n", module);
|
||||
classdef_emitted = 1;
|
||||
}
|
||||
|
||||
|
|
@ -496,7 +496,7 @@ void JAVA::close(void)
|
|||
if(!classdef_emitted) emit_classdef();
|
||||
|
||||
// Finish off the java class
|
||||
fprintf(f_java, "}\n");
|
||||
Printf(f_java, "}\n");
|
||||
fclose(f_java);
|
||||
|
||||
if(useRegisterNatives)
|
||||
|
|
@ -563,8 +563,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
f.add_local(jnirettype, (char*)"_jresult", (char*)"0");
|
||||
}
|
||||
|
||||
fprintf(f_java, " %s ", method_modifiers);
|
||||
fprintf(f_java, "native %s %s(", javarettype, iname);
|
||||
Printf(f_java, " %s ", method_modifiers);
|
||||
Printf(f_java, "native %s %s(", javarettype, iname);
|
||||
if(shadow && member_func) {
|
||||
DOHString *member_name = NewString("");
|
||||
if(strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, shadow_name))) == 0)
|
||||
|
|
@ -577,8 +577,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
Delete(member_name);
|
||||
}
|
||||
|
||||
if(!jnic) Printf(f._def,"extern \"C\"\n");
|
||||
Printv(f._def, "JNIEXPORT ", jnirettype, " JNICALL ", wname, "(JNIEnv *jenv, jclass jcls", 0);
|
||||
if(!jnic) Printf(f.def,"extern \"C\"\n");
|
||||
Printv(f.def, "JNIEXPORT ", jnirettype, " JNICALL ", wname, "(JNIEnv *jenv, jclass jcls", 0);
|
||||
|
||||
// Emit all of the local variables for holding arguments.
|
||||
int pcount = emit_args(t,l,f);
|
||||
|
|
@ -609,36 +609,36 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// Add to java function header
|
||||
if(shadow && member_func) {
|
||||
if(i > 0) {
|
||||
if(i>1) fprintf(f_shadow, ", ");
|
||||
fprintf(f_shadow, "%s %s", jtype, source);
|
||||
if(i>1) Printf(f_shadow, ", ");
|
||||
Printf(f_shadow, "%s %s", jtype, source);
|
||||
Printv(body,", ", source, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(gencomma) fprintf(f_java, ", ");
|
||||
fprintf(f_java, "%s %s", jtype, source);
|
||||
if(gencomma) Printf(f_java, ", ");
|
||||
Printf(f_java, "%s %s", jtype, source);
|
||||
|
||||
gencomma = 1;
|
||||
|
||||
// Add to Jni function header
|
||||
Printv(f._def, ", ", jnitype, " ", source, 0);
|
||||
Printv(f.def, ", ", jnitype, " ", source, 0);
|
||||
|
||||
// Get typemap for this argument
|
||||
tm = typemap_lookup((char*)"in",typemap_lang,p->t,p->name,source,target,&f);
|
||||
if (tm) {
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Replace(f._code,"$arg",source, DOH_REPLACE_ANY);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
Replace(f.code,"$arg",source, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
if(!p->t->is_pointer)
|
||||
Printv(f._code, tab4, target, " = ", p->t->print_cast(), source, ";\n", 0);
|
||||
Printv(f.code, tab4, target, " = ", p->t->print_cast(), source, ";\n", 0);
|
||||
else if((p->t->type == T_VOID && p->t->is_pointer == 1) ||
|
||||
(p->t->type == T_USER && p->t->is_pointer == 1)) {
|
||||
p->t->is_pointer++;
|
||||
Printv(f._code, tab4, target, " = *", p->t->print_cast(), "&", source, ";\n", 0);
|
||||
Printv(f.code, tab4, target, " = *", p->t->print_cast(), "&", source, ";\n", 0);
|
||||
p->t->is_pointer--;
|
||||
} else {
|
||||
if(p->t->type == T_CHAR && p->t->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 {
|
||||
char *scalarType = SwigTcToJniScalarType(p->t);
|
||||
char *cptrtype = p->t->print_type();
|
||||
|
|
@ -646,7 +646,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0);
|
||||
char *ctype = p->t->print_type();
|
||||
if(scalarType == NULL || basic_jnitype == NULL) {
|
||||
fprintf(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);
|
||||
};
|
||||
p->t->is_pointer++;
|
||||
|
|
@ -654,20 +654,20 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
DOHString *basic_jniptrtype = NewStringf("%s*",basic_jnitype);
|
||||
DOHString *source_length = NewStringf("%s%s)", JNICALL((char*)"GetArrayLength"), source);
|
||||
|
||||
target_copy = copy_string(f.new_local(Char(basic_jniptrtype), target, NULL));
|
||||
target_length = copy_string(f.new_local((char*)"jsize", target, Char(source_length)));
|
||||
if(local_i == NULL) local_i = copy_string(f.new_local((char*)"int", (char*)"i", NULL));
|
||||
target_copy = Swig_copy_string(f.new_local(Char(basic_jniptrtype), target, NULL));
|
||||
target_length = Swig_copy_string(f.new_local((char*)"jsize", target, Char(source_length)));
|
||||
if(local_i == NULL) local_i = Swig_copy_string(f.new_local((char*)"int", (char*)"i", NULL));
|
||||
|
||||
DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType);
|
||||
|
||||
Printv(f._code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0);
|
||||
Printv(f._code, tab4, target, " = ", p->t->print_cast(), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
|
||||
Printv(f._code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
|
||||
Printv(f.code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0);
|
||||
Printv(f.code, tab4, target, " = ", p->t->print_cast(), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
|
||||
Printv(f.code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
|
||||
if(p->t->is_pointer > 1) {
|
||||
Printv(f._code, tab8, target, "[i] = *", p->t->print_cast(), "&", target_copy, "[i];\n", 0);
|
||||
Printv(f.code, tab8, target, "[i] = *", p->t->print_cast(), "&", target_copy, "[i];\n", 0);
|
||||
} else {
|
||||
p->t->is_pointer--;
|
||||
Printv(f._code, tab8, target, "[i] = ", p->t->print_cast(), target_copy, "[i];\n", 0);
|
||||
Printv(f.code, tab8, target, "[i] = ", p->t->print_cast(), target_copy, "[i];\n", 0);
|
||||
p->t->is_pointer++;
|
||||
}
|
||||
Delete(scalarFunc);
|
||||
|
|
@ -680,8 +680,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// Check to see if there was any sort of a constaint typemap
|
||||
if ((tm = typemap_lookup((char*)"check",typemap_lang,p->t,p->name,source,target))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Replace(f._code,"$arg",source, DOH_REPLACE_ANY);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
Replace(f.code,"$arg",source, DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
// Check if there was any cleanup code (save it for later)
|
||||
|
|
@ -710,7 +710,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0);
|
||||
char *ctype = p->t->print_type();
|
||||
if(scalarType == NULL || basic_jnitype == NULL) {
|
||||
fprintf(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);
|
||||
};
|
||||
p->t->is_pointer++;
|
||||
|
|
@ -732,13 +732,13 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(f_java, ");\n");
|
||||
Printf(f_java, ");\n");
|
||||
if(shadow && member_func) {
|
||||
fprintf(f_shadow, ") {\n");
|
||||
Printf(f_shadow, ") {\n");
|
||||
Printf(body,")");
|
||||
Printf(f_shadow, "%s;\n }\n\n",body);
|
||||
}
|
||||
Printf(f._def,") {");
|
||||
Printf(f.def,") {");
|
||||
|
||||
// Now write code to make the function call
|
||||
|
||||
|
|
@ -749,27 +749,27 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
|
||||
if((t->type != T_VOID || t->is_pointer) && !native_func) {
|
||||
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 {
|
||||
if(t->is_pointer == 0 && t->type == T_USER) { /* return by value */
|
||||
t->is_pointer=2;
|
||||
Printv(f._code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0);
|
||||
Printv(f.code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0);
|
||||
t->is_pointer=0;
|
||||
} else if(t->is_pointer == 0 && t->type != T_USER) {
|
||||
Printv(f._code, tab4, "_jresult = (", jnirettype, ") _result;\n", 0);
|
||||
Printv(f.code, tab4, "_jresult = (", jnirettype, ") _result;\n", 0);
|
||||
} else if((t->type == T_VOID && t->is_pointer == 1) ||
|
||||
(t->type == T_USER && t->is_pointer == 1)) {
|
||||
t->is_pointer++;
|
||||
Printv(f._code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0);
|
||||
Printv(f.code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
if(t->type == T_CHAR && t->is_pointer == 1) {
|
||||
Printv(f._code, tab4, "if(_result != NULL)\n", 0);
|
||||
Printv(f._code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "_result);\n", 0);
|
||||
Printv(f.code, tab4, "if(_result != NULL)\n", 0);
|
||||
Printv(f.code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "_result);\n", 0);
|
||||
} else {
|
||||
fprintf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,t->print_type());
|
||||
Printf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,t->print_type());
|
||||
t->is_pointer++;
|
||||
Printv(f._code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0);
|
||||
Printv(f.code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0);
|
||||
t->is_pointer--;
|
||||
}
|
||||
}
|
||||
|
|
@ -777,32 +777,32 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
}
|
||||
|
||||
// Dump argument output code;
|
||||
Printv(f._code, outarg, 0);
|
||||
Printv(f.code, outarg, 0);
|
||||
|
||||
// Dump the argument cleanup code
|
||||
Printv(f._code,cleanup, 0);
|
||||
Printv(f.code,cleanup, 0);
|
||||
|
||||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
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 ((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);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap things up (in a manner of speaking)
|
||||
if(t->type != T_VOID || t->is_pointer)
|
||||
Printv(f._code, tab4, "return _jresult;\n", 0);
|
||||
Printf(f._code, "}\n");
|
||||
Printv(f.code, tab4, "return _jresult;\n", 0);
|
||||
Printf(f.code, "}\n");
|
||||
|
||||
// Substitute the cleanup code (some exception handlers like to have this)
|
||||
Replace(f._code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
|
||||
// Emit the function
|
||||
|
||||
|
|
@ -861,12 +861,12 @@ void JAVA::declare_const(char *name, char *iname, DataType *type, char *value) {
|
|||
char *jtype = typemap_lookup((char*)"jtype", typemap_lang, type, name, name, iname);
|
||||
if(!jtype) jtype = SwigTcToJavaType(type, 0, 0);
|
||||
if(strcmp(jname, value) == 0 || strstr(value,"::") != NULL) {
|
||||
fprintf(stderr, "ignoring enum constant: %s\n", jname);
|
||||
Printf(stderr, "ignoring enum constant: %s\n", jname);
|
||||
} else
|
||||
fprintf(jfile, " public final static %s %s = %s;\n\n", jtype, jname, value);
|
||||
Printf(jfile, " public final static %s %s = %s;\n\n", jtype, jname, value);
|
||||
} else {
|
||||
if(type->type == T_CHAR && type->is_pointer == 1) {
|
||||
fprintf(jfile, " public final static String %s = \"%s\";\n\n", jname, value);
|
||||
Printf(jfile, " public final static String %s = \"%s\";\n\n", jname, value);
|
||||
} else {
|
||||
emit_set_get(name,iname, type);
|
||||
}
|
||||
|
|
@ -875,23 +875,23 @@ void JAVA::declare_const(char *name, char *iname, DataType *type, char *value) {
|
|||
}
|
||||
|
||||
void emit_shadow_banner(FILE *f) {
|
||||
fprintf(f, "/*\n");
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " * This file was automatically generated by :\n");
|
||||
fprintf(f, " * Simplified Wrapper and Interface Generator (SWIG)\n");
|
||||
fprintf(f, " * Version 1.1 (Final)\n");
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " * Portions Copyright (c) 1995-1997\n");
|
||||
fprintf(f, " * The University of Utah and The Regents of the University of California.\n");
|
||||
fprintf(f, " * Permission is granted to distribute this file in any manner provided\n");
|
||||
fprintf(f, " * this notice remains intact.\n");
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " * Portions Copyright (c) 1997-1999\n");
|
||||
fprintf(f, " * Harco de Hilster, Harco.de.Hilster@ATConsultancy.nl\n");
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " * Do not make changes to this file--changes will be lost!\n");
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " */\n\n\n");
|
||||
Printf(f, "/*\n");
|
||||
Printf(f, " *\n");
|
||||
Printf(f, " * This file was automatically generated by :\n");
|
||||
Printf(f, " * Simplified Wrapper and Interface Generator (SWIG)\n");
|
||||
Printf(f, " * Version 1.1 (Final)\n");
|
||||
Printf(f, " *\n");
|
||||
Printf(f, " * Portions Copyright (c) 1995-1997\n");
|
||||
Printf(f, " * The University of Utah and The Regents of the University of California.\n");
|
||||
Printf(f, " * Permission is granted to distribute this file in any manner provided\n");
|
||||
Printf(f, " * this notice remains intact.\n");
|
||||
Printf(f, " *\n");
|
||||
Printf(f, " * Portions Copyright (c) 1997-1999\n");
|
||||
Printf(f, " * Harco de Hilster, Harco.de.Hilster@ATConsultancy.nl\n");
|
||||
Printf(f, " *\n");
|
||||
Printf(f, " * Do not make changes to this file--changes will be lost!\n");
|
||||
Printf(f, " *\n");
|
||||
Printf(f, " */\n\n\n");
|
||||
}
|
||||
|
||||
void JAVA::pragma(char *lang, char *code, char *value) {
|
||||
|
|
@ -900,7 +900,7 @@ void JAVA::pragma(char *lang, char *code, char *value) {
|
|||
DOHString *s = NewString(value);
|
||||
Replace(s,"\\\"", "\"", DOH_REPLACE_ANY);
|
||||
if(strcmp(code, "import") == 0) {
|
||||
jimport = copy_string(Char(s));
|
||||
jimport = Swig_copy_string(Char(s));
|
||||
Printf(f_java, "// pragma\nimport %s;\n\n", jimport);
|
||||
} else if(strcmp(code, "module") == 0) {
|
||||
if(!classdef_emitted) emit_classdef();
|
||||
|
|
@ -914,9 +914,9 @@ void JAVA::pragma(char *lang, char *code, char *value) {
|
|||
Printf(f_shadow, "\n\n");
|
||||
}
|
||||
} else if(strcmp(code, "modifiers") == 0) {
|
||||
method_modifiers = copy_string(value);
|
||||
method_modifiers = Swig_copy_string(value);
|
||||
} else {
|
||||
fprintf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file,line_number);
|
||||
Printf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file,line_number);
|
||||
}
|
||||
Delete(s);
|
||||
}
|
||||
|
|
@ -954,11 +954,11 @@ void JAVA::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
|||
if(!shadow) return;
|
||||
|
||||
if(rename)
|
||||
shadow_classname = copy_string(rename);
|
||||
else shadow_classname = copy_string(classname);
|
||||
shadow_classname = Swig_copy_string(rename);
|
||||
else shadow_classname = Swig_copy_string(classname);
|
||||
|
||||
if (strcmp(shadow_classname, module) == 0) {
|
||||
fprintf(stderr, "class name cannot be equal to module name: %s\n", shadow_classname);
|
||||
Printf(stderr, "class name cannot be equal to module name: %s\n", shadow_classname);
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -970,16 +970,16 @@ void JAVA::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
|||
|
||||
sprintf(bigbuf, "%s.java", shadow_classname);
|
||||
if(!(f_shadow = fopen(bigbuf, "w"))) {
|
||||
fprintf(stderr, "Unable to create shadow class file: %s\n", bigbuf);
|
||||
Printf(stderr, "Unable to create shadow class file: %s\n", bigbuf);
|
||||
}
|
||||
|
||||
emit_shadow_banner(f_shadow);
|
||||
|
||||
if(*package)
|
||||
fprintf(f_shadow, "package %s;\n\n", package);
|
||||
else fprintf(f_shadow, "import %s;\n\n", module);
|
||||
Printf(f_shadow, "package %s;\n\n", package);
|
||||
else Printf(f_shadow, "import %s;\n\n", module);
|
||||
if(jimport != NULL)
|
||||
fprintf(f_shadow, "import %s;\n\n", jimport);
|
||||
Printf(f_shadow, "import %s;\n\n", jimport);
|
||||
|
||||
Clear(shadow_classdef);
|
||||
Printv(shadow_classdef, "public class ", shadow_classname, " %BASECLASS% ", "{\n", 0);
|
||||
|
|
@ -1020,10 +1020,10 @@ void JAVA::cpp_close_class() {
|
|||
if(!shadow_classdef_emitted) emit_shadow_classdef();
|
||||
|
||||
if(have_default_constructor == 0) {
|
||||
fprintf(f_shadow, " public %s() {}\n\n", shadow_classname);
|
||||
Printf(f_shadow, " public %s() {}\n\n", shadow_classname);
|
||||
}
|
||||
|
||||
fprintf(f_shadow, "}\n");
|
||||
Printf(f_shadow, "}\n");
|
||||
fclose(f_shadow);
|
||||
f_shadow = NULL;
|
||||
|
||||
|
|
@ -1049,7 +1049,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
shadowrettype = GetChar(shadow_classes,t->name);
|
||||
}
|
||||
|
||||
fprintf(f_shadow, " public %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
||||
Printf(f_shadow, " public %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
||||
|
||||
if((t->type != T_VOID || t->is_pointer)) {
|
||||
Printf(nativecall,"return ");
|
||||
|
|
@ -1083,9 +1083,9 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Add to java function header
|
||||
fprintf(f_shadow, "%s %s", (jstype) ? jstype : jtype, arg);
|
||||
Printf(f_shadow, "%s %s", (jstype) ? jstype : jtype, arg);
|
||||
if(i != pcount-1) {
|
||||
fprintf(f_shadow, ", ");
|
||||
Printf(f_shadow, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1118,7 +1118,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
shadowrettype = GetChar(shadow_classes,t->name);
|
||||
}
|
||||
|
||||
fprintf(f_shadow, " public static %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
||||
Printf(f_shadow, " public static %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
||||
|
||||
if((t->type != T_VOID || t->is_pointer)) {
|
||||
Printf(nativecall, "return ");
|
||||
|
|
@ -1184,7 +1184,7 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
DOHString *nativecall = NewString("");
|
||||
char arg[256];
|
||||
|
||||
fprintf(f_shadow, " public %s(", shadow_classname);
|
||||
Printf(f_shadow, " public %s(", shadow_classname);
|
||||
|
||||
Printv(nativecall, " if(_self == 0 && ", shadow_classname, ".class == _selfClass()) {\n", 0);
|
||||
if (iname != NULL)
|
||||
|
|
@ -1246,19 +1246,19 @@ void JAVA::cpp_destructor(char *name, char *newname) {
|
|||
char *realname = (newname) ? newname : name;
|
||||
|
||||
if(finalize) {
|
||||
fprintf(f_shadow, " protected void finalize() {\n");
|
||||
fprintf(f_shadow, " if(_selfown) {\n");
|
||||
fprintf(f_shadow, " _delete();\n");
|
||||
fprintf(f_shadow, " }\n");
|
||||
fprintf(f_shadow, " };\n\n");
|
||||
Printf(f_shadow, " protected void finalize() {\n");
|
||||
Printf(f_shadow, " if(_selfown) {\n");
|
||||
Printf(f_shadow, " _delete();\n");
|
||||
Printf(f_shadow, " }\n");
|
||||
Printf(f_shadow, " };\n\n");
|
||||
}
|
||||
|
||||
fprintf(f_shadow, " public void _delete() {\n");
|
||||
fprintf(f_shadow, " if(_self != 0 && %s.class == _selfClass()) {\n", shadow_classname);
|
||||
fprintf(f_shadow, "\t%s.%s(_self);\n", module, Swig_name_destroy(realname));
|
||||
fprintf(f_shadow, "\t_self = 0;\n");
|
||||
fprintf(f_shadow, " }\n");
|
||||
fprintf(f_shadow, " }\n\n");
|
||||
Printf(f_shadow, " public void _delete() {\n");
|
||||
Printf(f_shadow, " if(_self != 0 && %s.class == _selfClass()) {\n", shadow_classname);
|
||||
Printf(f_shadow, "\t%s.%s(_self);\n", module, Swig_name_destroy(realname));
|
||||
Printf(f_shadow, "\t_self = 0;\n");
|
||||
Printf(f_shadow, " }\n");
|
||||
Printf(f_shadow, " }\n\n");
|
||||
}
|
||||
|
||||
void JAVA::cpp_class_decl(char *name, char *rename, char *type) {
|
||||
|
|
@ -1285,23 +1285,23 @@ void JAVA::cpp_inherit(char **baseclass, int) {
|
|||
while(*bc++) cnt++;
|
||||
|
||||
if(cnt > 1)
|
||||
fprintf(stderr, "Warning: %s inherits from multiple base classes. Multiple inheritance is not supported.\n", shadow_classname);
|
||||
Printf(stderr, "Warning: %s inherits from multiple base classes. Multiple inheritance is not supported.\n", shadow_classname);
|
||||
|
||||
shadow_baseclass = copy_string(*baseclass);
|
||||
shadow_baseclass = Swig_copy_string(*baseclass);
|
||||
}
|
||||
|
||||
void JAVA::cpp_variable(char *name, char *iname, DataType *t) {
|
||||
if(shadow && !shadow_classdef_emitted) emit_shadow_classdef();
|
||||
|
||||
if(shadow) member_func = 1;
|
||||
shadow_name = copy_string((iname) ? iname : name);
|
||||
shadow_name = Swig_copy_string((iname) ? iname : name);
|
||||
this->Language::cpp_variable(name, iname, t);
|
||||
member_func = 0;
|
||||
}
|
||||
|
||||
void JAVA::cpp_static_var(char *name, char *iname, DataType *t) {
|
||||
if(shadow) member_func = 1;
|
||||
shadow_name = copy_string((iname) ? iname : name);
|
||||
shadow_name = Swig_copy_string((iname) ? iname : name);
|
||||
this->Language::cpp_static_var(name, iname, t);
|
||||
member_func = 0;
|
||||
}
|
||||
|
|
@ -1310,7 +1310,7 @@ void JAVA::cpp_declare_const(char *name, char *iname, DataType *type, char *valu
|
|||
if(shadow && !shadow_classdef_emitted) emit_shadow_classdef();
|
||||
|
||||
if(shadow) member_func = 1;
|
||||
shadow_name = copy_string((iname) ? iname : name);
|
||||
shadow_name = Swig_copy_string((iname) ? iname : name);
|
||||
this->Language::cpp_declare_const(name, iname, type, value);
|
||||
member_func = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,8 +248,8 @@ void
|
|||
MZSCHEME::get_pointer (DOHString_or_char *name, int parm, DataType *t,
|
||||
WrapperFunction &f)
|
||||
{
|
||||
Printf(f._code," if (!swig_get_c_pointer(argv[%d],\"%s\", (void **) &_arg%d))\n", parm, t->print_mangle(), parm);
|
||||
Printf(f._code," scheme_wrong_type(\"%s\", \"%s\", %d, argc, argv);\n", name, t->print_mangle(), parm);
|
||||
Printf(f.code," if (!swig_get_c_pointer(argv[%d],\"%s\", (void **) &_arg%d))\n", parm, t->print_mangle(), parm);
|
||||
Printf(f.code," scheme_wrong_type(\"%s\", \"%s\", %d, argc, argv);\n", name, t->print_mangle(), parm);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -312,7 +312,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
Replace(proc_name,"_","-",DOH_REPLACE_ANY);
|
||||
|
||||
// writing the function wrapper function
|
||||
Printv(f._def,
|
||||
Printv(f.def,
|
||||
"static Scheme_Object *", wname, " (",
|
||||
"int argc, Scheme_Object **argv",
|
||||
")\n{",
|
||||
|
|
@ -348,13 +348,13 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Handle parameter types.
|
||||
|
||||
if (p.ignore)
|
||||
Printv(f._code, "/* ", p.name, " ignored... */\n", 0);
|
||||
Printv(f.code, "/* ", p.name, " ignored... */\n", 0);
|
||||
else {
|
||||
++numargs;
|
||||
if ((tm = typemap_lookup ((char*)"in", typemap_lang,
|
||||
p.t, p.name, source, target, &f))) {
|
||||
Printv(f._code, tm, "\n", 0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code, tm, "\n", 0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
// no typemap found
|
||||
// assume it's a Scheme_Object containing the C pointer
|
||||
|
|
@ -370,8 +370,8 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
if ((tm = typemap_lookup ((char*)"check", typemap_lang,
|
||||
p.t, p.name, source, target, &f))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printv(f._code,tm,"\n", 0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n", 0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
|
||||
// Pass output arguments back to the caller.
|
||||
|
|
@ -401,18 +401,18 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if (d->type == T_VOID) {
|
||||
if(!argout_set)
|
||||
Printv(f._code, tab4, "swig_result = scheme_void;\n", 0);
|
||||
Printv(f.code, tab4, "swig_result = scheme_void;\n", 0);
|
||||
}
|
||||
|
||||
else if ((tm = typemap_lookup ((char*)"out", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"swig_result", &f))) {
|
||||
Printv(f._code, tm, "\n", 0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code, tm, "\n", 0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
// no typemap found and not void then create a Scheme_Object holding
|
||||
// the C pointer and return it
|
||||
else if (d->is_pointer) {
|
||||
Printv(f._code,
|
||||
Printv(f.code,
|
||||
tab4,
|
||||
"swig_result = swig_make_c_pointer(",
|
||||
"_result, \"",
|
||||
|
|
@ -425,18 +425,18 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Dump the argument output code
|
||||
Printv(f._code, outarg,0);
|
||||
Printv(f.code, outarg,0);
|
||||
|
||||
// Dump the argument cleanup code
|
||||
Printv(f._code, cleanup, 0);
|
||||
Printv(f.code, cleanup, 0);
|
||||
|
||||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup ((char*)"newfree", typemap_lang,
|
||||
d, iname, (char*)"_result", (char*)"", &f))) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -445,8 +445,8 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
if ((tm = typemap_lookup ((char*)"ret", typemap_lang,
|
||||
d, name, (char*)"_result", (char*)"", &f))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printv(f._code,tm,"\n",0);
|
||||
mreplace (f._code, argnum, arg, proc_name);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
mreplace (f.code, argnum, arg, proc_name);
|
||||
}
|
||||
|
||||
// returning multiple values
|
||||
|
|
@ -454,19 +454,19 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
if(d->type == T_VOID) {
|
||||
f.add_local((char*)"int", (char*)"_lenv", (char*)"0");
|
||||
f.add_local((char*)"Scheme_Object *", (char*)"_values[MAXVALUES]");
|
||||
Printv(f._code, tab4, "swig_result = scheme_values(_lenv, _values);\n", 0);
|
||||
Printv(f.code, tab4, "swig_result = scheme_values(_lenv, _values);\n", 0);
|
||||
}
|
||||
else {
|
||||
f.add_local((char*)"int", (char*)"_lenv", (char*)"1");
|
||||
f.add_local((char*)"Scheme_Object *",(char*) "_values[MAXVALUES]");
|
||||
Printv(f._code, tab4, "_values[0] = swig_result;\n", 0);
|
||||
Printv(f._code, tab4, "swig_result = scheme_values(_lenv, _values);\n", 0);
|
||||
Printv(f.code, tab4, "_values[0] = swig_result;\n", 0);
|
||||
Printv(f.code, tab4, "swig_result = scheme_values(_lenv, _values);\n", 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
||||
Printv(f._code, tab4, "return swig_result;\n", "}\n", 0);
|
||||
Printv(f.code, tab4, "return swig_result;\n", "}\n", 0);
|
||||
|
||||
f.print (f_wrappers);
|
||||
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ PERL5::parse_args(int argc, char *argv[]) {
|
|||
}
|
||||
} else if (strcmp(argv[i],"-alt-header") == 0) {
|
||||
if (argv[i+1]) {
|
||||
alt_header = copy_string(argv[i+1]);
|
||||
alt_header = Swig_copy_string(argv[i+1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i+1);
|
||||
i++;
|
||||
|
|
@ -283,9 +283,9 @@ void PERL5::set_module(char *mod_name, char **mod_list) {
|
|||
if (import_file) {
|
||||
if (!(strcmp(import_file,input_file+strlen(input_file)-strlen(import_file)))) {
|
||||
if (blessed) {
|
||||
fprintf(f_pm,"require %s;\n", mod_name);
|
||||
Printf(f_pm,"require %s;\n", mod_name);
|
||||
}
|
||||
delete [] import_file;
|
||||
free(import_file);
|
||||
import_file = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -350,29 +350,29 @@ void PERL5::headers(void)
|
|||
|
||||
if (!alt_header) {
|
||||
if (Swig_insert_file("headers.swg", f_header) == -1) {
|
||||
fprintf(stderr,"Perl5 : Fatal error. Unable to locate headers.swg. Possible installation problem.\n");
|
||||
Printf(stderr,"Perl5 : Fatal error. Unable to locate headers.swg. Possible installation problem.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
} else {
|
||||
if (Swig_insert_file(alt_header, f_header) == -1) {
|
||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate %s.\n",alt_header);
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate %s.\n",alt_header);
|
||||
SWIG_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (NoInclude) {
|
||||
fprintf(f_header,"#define SWIG_NOINCLUDE\n");
|
||||
Printf(f_header,"#define SWIG_NOINCLUDE\n");
|
||||
}
|
||||
|
||||
// Get special SWIG related declarations
|
||||
if (Swig_insert_file("perl5.swg", f_header) == -1) {
|
||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5.swg' in SWIG library.\n");
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate 'perl5.swg' in SWIG library.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
// Get special SWIG related declarations
|
||||
if (Swig_insert_file("perl5mg.swg", f_header) == -1) {
|
||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5mg.swg' in SWIG library.\n");
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate 'perl5mg.swg' in SWIG library.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ void PERL5::initialize()
|
|||
char filen[256];
|
||||
|
||||
if (!module){
|
||||
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||
Printf(stderr,"*** Error. No module name specified.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -426,7 +426,7 @@ void PERL5::initialize()
|
|||
}
|
||||
sprintf(filen,"%s%s.pm", output_dir,m);
|
||||
if ((f_pm = fopen(filen,"w")) == 0) {
|
||||
fprintf(stderr,"Unable to open %s\n", filen);
|
||||
Printf(stderr,"Unable to open %s\n", filen);
|
||||
SWIG_exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -536,8 +536,8 @@ void PERL5::initialize()
|
|||
// ---------------------------------------------------------------------
|
||||
|
||||
void PERL5::import(char *filename) {
|
||||
if (import_file) delete [] import_file;
|
||||
import_file = copy_string(filename);
|
||||
if (import_file) free(import_file);
|
||||
import_file = Swig_copy_string(filename);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -563,17 +563,17 @@ void PERL5::close(void)
|
|||
|
||||
emit_ptr_equivalence(f_init);
|
||||
|
||||
fprintf(f_init,"\t ST(0) = &PL_sv_yes;\n");
|
||||
fprintf(f_init,"\t XSRETURN(1);\n");
|
||||
fprintf(f_init,"}\n");
|
||||
Printf(f_init,"\t ST(0) = &PL_sv_yes;\n");
|
||||
Printf(f_init,"\t XSRETURN(1);\n");
|
||||
Printf(f_init,"}\n");
|
||||
|
||||
Printv(vinit,tab4, "XSRETURN(1);\n", "}\n", 0);
|
||||
Printf(f_wrappers,"%s", vinit);
|
||||
|
||||
fprintf(f_pm,"package %s;\n", package);
|
||||
Printf(f_pm,"package %s;\n", package);
|
||||
|
||||
if (!is_static) {
|
||||
fprintf(f_pm,"bootstrap %s;\n", realpackage);
|
||||
Printf(f_pm,"bootstrap %s;\n", realpackage);
|
||||
} else {
|
||||
DOHString *tmp = NewString(realpackage);
|
||||
Replace(tmp,":","_",DOH_REPLACE_ANY);
|
||||
|
|
@ -724,7 +724,7 @@ void PERL5::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
void PERL5::create_command(char *cname, char *iname) {
|
||||
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(cname));
|
||||
Printf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(cname));
|
||||
if (export_all) {
|
||||
Printf(exported,"%s ",iname);
|
||||
}
|
||||
|
|
@ -759,8 +759,8 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
Printv(f._def, "XS(", wname, ") {\n", 0);
|
||||
Printv(f._code, tab4, "cv = cv;\n", 0);
|
||||
Printv(f.def, "XS(", wname, ") {\n", 0);
|
||||
Printv(f.code, tab4, "cv = cv;\n", 0);
|
||||
|
||||
pcount = emit_args(d, l, f);
|
||||
numopt = l->numopt();
|
||||
|
|
@ -770,8 +770,8 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Check the number of arguments
|
||||
|
||||
usage = usage_func(iname,d,l);
|
||||
Printf(f._code," if ((items < %d) || (items > %d)) \n", pcount-numopt, l->numarg());
|
||||
Printf(f._code," croak(\"Usage: %s\");\n", usage);
|
||||
Printf(f.code," if ((items < %d) || (items > %d)) \n", pcount-numopt, l->numarg());
|
||||
Printf(f.code," croak(\"Usage: %s\");\n", usage);
|
||||
|
||||
// Write code to extract parameters.
|
||||
// This section should be able to extract virtually any kind
|
||||
|
|
@ -793,13 +793,13 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// If there are optional arguments, check for this
|
||||
|
||||
if (j>= (pcount-numopt))
|
||||
Printf(f._code," if (items > %d) {\n", j);
|
||||
Printf(f.code," if (items > %d) {\n", j);
|
||||
|
||||
// See if there is a type-map
|
||||
if ((tm = typemap_lookup((char*)"in",(char*)"perl5",p->t,p->name,source,target,&f))) {
|
||||
Printf(f._code,"%s\n",tm);
|
||||
Replace(f._code,"$argnum",argnum,DOH_REPLACE_ANY);
|
||||
Replace(f._code,"$arg",source,DOH_REPLACE_ANY);
|
||||
Printf(f.code,"%s\n",tm);
|
||||
Replace(f.code,"$argnum",argnum,DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$arg",source,DOH_REPLACE_ANY);
|
||||
} else {
|
||||
|
||||
if (!p->t->is_pointer) {
|
||||
|
|
@ -822,19 +822,19 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
Printf(f._code," _arg%d = %sSvIV(ST(%d));\n", i, p->t->print_cast(),j);
|
||||
Printf(f.code," _arg%d = %sSvIV(ST(%d));\n", i, p->t->print_cast(),j);
|
||||
break;
|
||||
case T_CHAR :
|
||||
|
||||
|
||||
Printf(f._code," _arg%d = (char) *SvPV(ST(%d),PL_na);\n", i, j);
|
||||
Printf(f.code," _arg%d = (char) *SvPV(ST(%d),PL_na);\n", i, j);
|
||||
break;
|
||||
|
||||
// Doubles
|
||||
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printf(f._code," _arg%d = %s SvNV(ST(%d));\n", i, p->t->print_cast(), j);
|
||||
Printf(f.code," _arg%d = %s SvNV(ST(%d));\n", i, p->t->print_cast(), j);
|
||||
break;
|
||||
|
||||
// Void.. Do nothing.
|
||||
|
|
@ -850,7 +850,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unsupported data type
|
||||
|
||||
default :
|
||||
fprintf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, p->t->print_type());
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, p->t->print_type());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -859,15 +859,15 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// since that is usually a string.
|
||||
|
||||
if ((p->t->type == T_CHAR) && (p->t->is_pointer == 1)) {
|
||||
Printf(f._code," if (! SvOK((SV*) ST(%d))) { _arg%d = 0; }\n", j, i);
|
||||
Printf(f._code," else { _arg%d = (char *) SvPV(ST(%d),PL_na); }\n", i,j);
|
||||
Printf(f.code," if (! SvOK((SV*) ST(%d))) { _arg%d = 0; }\n", j, i);
|
||||
Printf(f.code," else { _arg%d = (char *) SvPV(ST(%d),PL_na); }\n", i,j);
|
||||
} else {
|
||||
|
||||
// Have a generic pointer type here. Read it in as a swig
|
||||
// typed pointer.
|
||||
|
||||
sprintf(temp,"argument %d", i+1);
|
||||
get_pointer(iname,temp,source,target, p->t, f._code, (char*)"XSRETURN(1)");
|
||||
get_pointer(iname,temp,source,target, p->t, f.code, (char*)"XSRETURN(1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -875,7 +875,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
sprintf(temp,"_saved[%d]",num_saved);
|
||||
if (j>= (pcount-numopt))
|
||||
Printf(f._code," } \n");
|
||||
Printf(f.code," } \n");
|
||||
j++;
|
||||
} else {
|
||||
temp[0] = 0;
|
||||
|
|
@ -883,8 +883,8 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Check if there is any constraint code
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"perl5",p->t,p->name,source,target))) {
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Replace(f._code,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
Replace(f.code,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
}
|
||||
need_save = 0;
|
||||
|
||||
|
|
@ -905,7 +905,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// If we needed a saved variable, we need to emit to emit some code for that
|
||||
// This only applies if the argument actually existed (not ignore)
|
||||
if ((need_save) && (!p->ignore)) {
|
||||
Printv(f._code, tab4, temp, " = ", source, ";\n", 0);
|
||||
Printv(f.code, tab4, temp, " = ", source, ";\n", 0);
|
||||
num_saved++;
|
||||
}
|
||||
p = l->get_next();
|
||||
|
|
@ -926,26 +926,26 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// See if there was a typemap
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"perl5",d,iname,(char*)"_result",(char*)"ST(argvi)"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code, "%s\n", tm);
|
||||
Printf(f.code, "%s\n", tm);
|
||||
} else if ((d->type != T_VOID) || (d->is_pointer)) {
|
||||
if (!d->is_pointer) {
|
||||
|
||||
// Function returns a "value"
|
||||
Printf(f._code," ST(argvi) = sv_newmortal();\n");
|
||||
Printf(f.code," ST(argvi) = sv_newmortal();\n");
|
||||
switch(d->type) {
|
||||
case T_INT: case T_BOOL: case T_SINT: case T_UINT:
|
||||
case T_SHORT: case T_SSHORT: case T_USHORT:
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
case T_SCHAR: case T_UCHAR :
|
||||
Printf(f._code," sv_setiv(ST(argvi++),(IV) _result);\n");
|
||||
Printf(f.code," sv_setiv(ST(argvi++),(IV) _result);\n");
|
||||
break;
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printf(f._code," sv_setnv(ST(argvi++), (double) _result);\n");
|
||||
Printf(f.code," sv_setnv(ST(argvi++), (double) _result);\n");
|
||||
break;
|
||||
case T_CHAR :
|
||||
f.add_local((char*)"char", (char*)"_ctemp[2]");
|
||||
Printv(f._code,
|
||||
Printv(f.code,
|
||||
tab4, "_ctemp[0] = _result;\n",
|
||||
tab4, "_ctemp[1] = 0;\n",
|
||||
tab4, "sv_setpv((SV*)ST(argvi++),_ctemp);\n",
|
||||
|
|
@ -956,28 +956,28 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
case T_USER:
|
||||
d->is_pointer++;
|
||||
Printv(f._code,
|
||||
Printv(f.code,
|
||||
tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), d->print_mangle(),
|
||||
"\", (void *) _result);\n", 0);
|
||||
d->is_pointer--;
|
||||
break;
|
||||
|
||||
default :
|
||||
fprintf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, d->print_type(), name);
|
||||
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, d->print_type(), name);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Is a pointer return type
|
||||
Printf(f._code," ST(argvi) = sv_newmortal();\n");
|
||||
Printf(f.code," ST(argvi) = sv_newmortal();\n");
|
||||
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||
|
||||
// Return a character string
|
||||
Printf(f._code," sv_setpv((SV*)ST(argvi++),(char *) _result);\n");
|
||||
Printf(f.code," sv_setpv((SV*)ST(argvi++),(char *) _result);\n");
|
||||
|
||||
} else {
|
||||
// Is an ordinary pointer type.
|
||||
Printv(f._code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), d->print_mangle(),
|
||||
Printv(f.code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), d->print_mangle(),
|
||||
"\", (void *) _result);\n", 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -985,34 +985,34 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// If there were any output args, take care of them.
|
||||
|
||||
Printv(f._code,outarg,0);
|
||||
Printv(f.code,outarg,0);
|
||||
|
||||
// If there was any cleanup, do that.
|
||||
|
||||
Printv(f._code,cleanup,0);
|
||||
Printv(f.code,cleanup,0);
|
||||
|
||||
if (NewObject) {
|
||||
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*)""))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
}
|
||||
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
||||
Printf(f._code," XSRETURN(argvi);\n}\n");
|
||||
Printf(f.code," XSRETURN(argvi);\n}\n");
|
||||
|
||||
// Add the dXSARGS last
|
||||
|
||||
f.add_local((char*)"dXSARGS",(char*)"");
|
||||
|
||||
// Substitute the cleanup code
|
||||
Replace(f._code,"$cleanup",cleanup,DOH_REPLACE_ANY);
|
||||
Replace(f._code,"$name",iname,DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$cleanup",cleanup,DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$name",iname,DOH_REPLACE_ANY);
|
||||
|
||||
// Dump this function out
|
||||
|
||||
|
|
@ -1020,7 +1020,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Now register the function
|
||||
|
||||
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, wname);
|
||||
Printf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, wname);
|
||||
|
||||
if (export_all) {
|
||||
Printf(exported,"%s ", iname);
|
||||
|
|
@ -1157,17 +1157,17 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
// Create a Perl function for setting the variable value
|
||||
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
Printf(setf._def,"SWIGCLASS_STATIC int %s(SV* sv, MAGIC *mg) {\n", set_name);
|
||||
Printv(setf._code,
|
||||
Printf(setf.def,"SWIGCLASS_STATIC int %s(SV* sv, MAGIC *mg) {\n", set_name);
|
||||
Printv(setf.code,
|
||||
tab4, "MAGIC_PPERL\n",
|
||||
tab4, "mg = mg;\n",
|
||||
0);
|
||||
|
||||
/* Check for a few typemaps */
|
||||
if ((tm = typemap_lookup((char*)"varin",(char*)"perl5",t,(char*)"",(char*)"sv",name))) {
|
||||
Printf(setf._code,"%s\n", tm);
|
||||
Printf(setf.code,"%s\n", tm);
|
||||
} else if ((tm = typemap_lookup((char*)"in",(char*)"perl5",t,(char*)"",(char*)"sv",name))) {
|
||||
Printf(setf._code,"%s\n", tm);
|
||||
Printf(setf.code,"%s\n", tm);
|
||||
} else {
|
||||
if (!t->is_pointer) {
|
||||
|
||||
|
|
@ -1178,14 +1178,14 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_SHORT : case T_SSHORT : case T_USHORT:
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
case T_UCHAR: case T_SCHAR:
|
||||
Printv(setf._code,tab4, name, " = ", t->print_cast(), " SvIV(sv);\n", 0);
|
||||
Printv(setf.code,tab4, name, " = ", t->print_cast(), " SvIV(sv);\n", 0);
|
||||
break;
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printv(setf._code, tab4, name, " = ", t->print_cast(), " SvNV(sv);\n", 0);
|
||||
Printv(setf.code, tab4, name, " = ", t->print_cast(), " SvNV(sv);\n", 0);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
|
||||
case T_USER:
|
||||
|
|
@ -1195,51 +1195,51 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
|
||||
t->is_pointer++;
|
||||
setf.add_local((char*)"void",(char*)"*_temp");
|
||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf._code, (char*)"return(1)");
|
||||
Printv(setf._code, tab4, name, " = *(", t->print_cast(), " _temp);\n", 0);
|
||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf.code, (char*)"return(1)");
|
||||
Printv(setf.code, tab4, name, " = *(", t->print_cast(), " _temp);\n", 0);
|
||||
t->is_pointer--;
|
||||
break;
|
||||
|
||||
default :
|
||||
fprintf(stderr,"%s : Line %d. Unable to link with datatype %s (ignored).\n", input_file, line_number, t->print_type());
|
||||
Printf(stderr,"%s : Line %d. Unable to link with datatype %s (ignored).\n", input_file, line_number, t->print_type());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Have some sort of pointer type here, Process it differently
|
||||
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
||||
setf.add_local((char*)"char",(char*)"*_a");
|
||||
Printf(setf._code," _a = (char *) SvPV(sv,PL_na);\n");
|
||||
Printf(setf.code," _a = (char *) SvPV(sv,PL_na);\n");
|
||||
|
||||
if (CPlusPlus)
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "if (", name, ") delete [] ", name, ";\n",
|
||||
tab4, name, " = new char[strlen(_a)+1];\n",
|
||||
0);
|
||||
else
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "if (", name, ") free(", name, ");\n",
|
||||
tab4, name, " = (char *) malloc(strlen(_a)+1);\n",
|
||||
0);
|
||||
Printv(setf._code,"strcpy(", name, ",_a);\n", 0);
|
||||
Printv(setf.code,"strcpy(", name, ",_a);\n", 0);
|
||||
} else {
|
||||
// Set the value of a pointer
|
||||
|
||||
setf.add_local((char*)"void",(char*)"*_temp");
|
||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf._code, (char*)"return(1)");
|
||||
Printv(setf._code,tab4, name, " = ", t->print_cast(), " _temp;\n", 0);
|
||||
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf.code, (char*)"return(1)");
|
||||
Printv(setf.code,tab4, name, " = ", t->print_cast(), " _temp;\n", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Printf(setf._code," return 1;\n}\n");
|
||||
Replace(setf._code,"$name",iname, DOH_REPLACE_ANY);
|
||||
Printf(setf.code," return 1;\n}\n");
|
||||
Replace(setf.code,"$name",iname, DOH_REPLACE_ANY);
|
||||
setf.print(magic);
|
||||
|
||||
}
|
||||
|
||||
// Now write a function to evaluate the variable
|
||||
|
||||
Printf(getf._def,"SWIGCLASS_STATIC int %s(SV *sv, MAGIC *mg) {\n", val_name);
|
||||
Printv(getf._code,
|
||||
Printf(getf.def,"SWIGCLASS_STATIC int %s(SV *sv, MAGIC *mg) {\n", val_name);
|
||||
Printv(getf.code,
|
||||
tab4, "MAGIC_PPERL\n",
|
||||
tab4, "mg = mg;\n",
|
||||
0);
|
||||
|
|
@ -1247,9 +1247,9 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
// Check for a typemap
|
||||
|
||||
if ((tm = typemap_lookup((char*)"varout",(char*)"perl5",t,(char*)"",name, (char*)"sv"))) {
|
||||
Printf(getf._code,"%s\n", tm);
|
||||
Printf(getf.code,"%s\n", tm);
|
||||
} else if ((tm = typemap_lookup((char*)"out",(char*)"perl5",t,(char*)"",name,(char*)"sv"))) {
|
||||
Printf(getf._code,"%s\n", tm);
|
||||
Printf(getf.code,"%s\n", tm);
|
||||
} else {
|
||||
if (!t->is_pointer) {
|
||||
switch(t->type) {
|
||||
|
|
@ -1257,17 +1257,17 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_SHORT : case T_SSHORT: case T_USHORT:
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
case T_UCHAR: case T_SCHAR:
|
||||
Printv(getf._code,tab4, "sv_setiv(sv, (IV) ", name, ");\n", 0);
|
||||
Printv(getf.code,tab4, "sv_setiv(sv, (IV) ", name, ");\n", 0);
|
||||
Printv(vinit, tab4, "sv_setiv(sv,(IV)", name, ");\n",0);
|
||||
break;
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printv(getf._code, tab4,"sv_setnv(sv, (double) ", name, ");\n", 0);
|
||||
Printv(getf.code, tab4,"sv_setnv(sv, (double) ", name, ");\n", 0);
|
||||
Printv(vinit, tab4, "sv_setnv(sv,(double)", name, ");\n",0);
|
||||
break;
|
||||
case T_CHAR :
|
||||
getf.add_local((char*)"char",(char*)"_ptemp[2]");
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "_ptemp[0] = ", name, ";\n",
|
||||
tab4, "_ptemp[1] = 0;\n",
|
||||
tab4, "sv_setpv((SV*) sv, _ptemp);\n",
|
||||
|
|
@ -1275,7 +1275,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
break;
|
||||
case T_USER:
|
||||
t->is_pointer++;
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "rsv = SvRV(sv);\n",
|
||||
tab4, "sv_setiv(rsv,(IV) &", name, ");\n",
|
||||
0);
|
||||
|
|
@ -1293,9 +1293,9 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
// Have some sort of arbitrary pointer type. Return it as a string
|
||||
|
||||
if ((t->type == T_CHAR) && (t->is_pointer == 1))
|
||||
Printv(getf._code, tab4, "sv_setpv((SV*) sv, ", name, ");\n", 0);
|
||||
Printv(getf.code, tab4, "sv_setpv((SV*) sv, ", name, ");\n", 0);
|
||||
else {
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "rsv = SvRV(sv);\n",
|
||||
tab4, "sv_setiv(rsv,(IV) ", name, ");\n",
|
||||
0);
|
||||
|
|
@ -1305,9 +1305,9 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
|||
}
|
||||
}
|
||||
}
|
||||
Printf(getf._code," return 1;\n}\n");
|
||||
Printf(getf.code," return 1;\n}\n");
|
||||
|
||||
Replace(getf._code,"$name",iname, DOH_REPLACE_ANY);
|
||||
Replace(getf.code,"$name",iname, DOH_REPLACE_ANY);
|
||||
getf.print(magic);
|
||||
|
||||
// Now add symbol to the PERL interpreter
|
||||
|
|
@ -1411,10 +1411,10 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
|
|||
static int have_ref_func = 0;
|
||||
|
||||
if ((tm = typemap_lookup((char*)"const",(char*)"perl5",type,name,value,name))) {
|
||||
fprintf(f_init,"%s\n",tm);
|
||||
Printf(f_init,"%s\n",tm);
|
||||
} else {
|
||||
if ((type->type == T_USER) && (!type->is_pointer)) {
|
||||
fprintf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
Printf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
return;
|
||||
}
|
||||
// Generate a constant
|
||||
|
|
@ -1425,7 +1425,7 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
|
|||
case T_LONG: case T_SLONG: case T_ULONG:
|
||||
case T_SCHAR: case T_UCHAR:
|
||||
if (!have_int_func) {
|
||||
fprintf(f_header,"%s\n",setiv);
|
||||
Printf(f_header,"%s\n",setiv);
|
||||
have_int_func = 1;
|
||||
}
|
||||
Printv(vinit, tab4, "swig_setiv(\"", package, "::", name, "\", (long) ", value, ");\n",0);
|
||||
|
|
@ -1433,33 +1433,33 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
|
|||
case T_DOUBLE:
|
||||
case T_FLOAT:
|
||||
if (!have_double_func) {
|
||||
fprintf(f_header,"%s\n",setnv);
|
||||
Printf(f_header,"%s\n",setnv);
|
||||
have_double_func = 1;
|
||||
}
|
||||
Printv(vinit, tab4, "swig_setnv(\"", package, "::", name, "\", (double) (", value, "));\n",0);
|
||||
break;
|
||||
case T_CHAR :
|
||||
if (!have_char_func) {
|
||||
fprintf(f_header,"%s\n",setpv);
|
||||
Printf(f_header,"%s\n",setpv);
|
||||
have_char_func = 1;
|
||||
}
|
||||
Printv(vinit, tab4, "swig_setpv(\"", package, "::", name, "\", \"", value, "\");\n",0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
Printf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||
if (!have_char_func) {
|
||||
fprintf(f_header,"%s\n",setpv);
|
||||
Printf(f_header,"%s\n",setpv);
|
||||
have_char_func = 1;
|
||||
}
|
||||
Printv(vinit, tab4, "swig_setpv(\"", package, "::", name, "\", \"", value, "\");\n",0);
|
||||
} else {
|
||||
// A user-defined type. We're going to munge it into a string pointer value
|
||||
if (!have_ref_func) {
|
||||
fprintf(f_header,"%s\n",setrv);
|
||||
Printf(f_header,"%s\n",setrv);
|
||||
have_ref_func = 1;
|
||||
}
|
||||
Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"",
|
||||
|
|
@ -1573,7 +1573,7 @@ char *PERL5::usage_const(char *iname, DataType *, char *value) {
|
|||
// -----------------------------------------------------------------------
|
||||
|
||||
void PERL5::add_native(char *name, char *funcname, DataType *, ParmList *) {
|
||||
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package,name, funcname);
|
||||
Printf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package,name, funcname);
|
||||
if (export_all)
|
||||
Printf(exported,"%s ",name);
|
||||
if (blessed) {
|
||||
|
|
@ -1646,7 +1646,7 @@ void PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
|
|||
// If the class is being renamed to something else, use the renaming
|
||||
|
||||
if (rname) {
|
||||
class_name = copy_string(rname);
|
||||
class_name = Swig_copy_string(rname);
|
||||
class_renamed = 1;
|
||||
// Now things get even more hideous. Need to register an equivalence
|
||||
// between the renamed name and the new name. Yuck!
|
||||
|
|
@ -1654,11 +1654,11 @@ void PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
|
|||
typeeq_addtypedef(classname,rname,0);
|
||||
typeeq_addtypedef(rname,classname,0);
|
||||
/*
|
||||
fprintf(f_init,"\t SWIG_RegisterMapping(\"%s\",\"%s\",0);\n",classname,rname);
|
||||
fprintf(f_init,"\t SWIG_RegisterMapping(\"%s\",\"%s\",0);\n",rname,classname);
|
||||
Printf(f_init,"\t SWIG_RegisterMapping(\"%s\",\"%s\",0);\n",classname,rname);
|
||||
Printf(f_init,"\t SWIG_RegisterMapping(\"%s\",\"%s\",0);\n",rname,classname);
|
||||
*/
|
||||
} else {
|
||||
class_name = copy_string(classname);
|
||||
class_name = Swig_copy_string(classname);
|
||||
class_renamed = 0;
|
||||
}
|
||||
|
||||
|
|
@ -1675,17 +1675,17 @@ void PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
|
|||
strcpy(fullclassname, class_name);
|
||||
}
|
||||
|
||||
real_classname = copy_string(classname);
|
||||
real_classname = Swig_copy_string(classname);
|
||||
if (base_class) Delete(base_class);
|
||||
base_class = 0;
|
||||
class_type = copy_string(ctype);
|
||||
class_type = Swig_copy_string(ctype);
|
||||
pcode = NewString("");
|
||||
blessedmembers = NewString("");
|
||||
member_keys = NewString("");
|
||||
|
||||
// Add some symbols to the hash tables
|
||||
|
||||
// classes.add(real_classname,copy_string(class_name)); /* Map original classname to class */
|
||||
// classes.add(real_classname,Swig_copy_string(class_name)); /* Map original classname to class */
|
||||
Setattr(classes,real_classname,fullclassname);
|
||||
|
||||
// Add full name of datatype to the hash table just in case the user uses it
|
||||
|
|
@ -2319,7 +2319,7 @@ void PERL5::pragma(char *lang, char *code, char *value) {
|
|||
if (value) {
|
||||
FILE *f = Swig_open(value);
|
||||
if (!f) {
|
||||
fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
||||
Printf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
||||
} else {
|
||||
char buffer[4096];
|
||||
while (fgets(buffer,4095,f)) {
|
||||
|
|
@ -2328,7 +2328,7 @@ void PERL5::pragma(char *lang, char *code, char *value) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file,line_number);
|
||||
Printf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file,line_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,9 +180,9 @@ void PYTHON::set_module(char *mod_name, char **mod_list) {
|
|||
if (import_file) {
|
||||
if (!(strcmp(import_file,input_file+strlen(input_file)-strlen(import_file)))) {
|
||||
if (shadow) {
|
||||
fprintf(f_shadow,"\nfrom %s import *\n", mod_name);
|
||||
Printf(f_shadow,"\nfrom %s import *\n", mod_name);
|
||||
}
|
||||
delete import_file;
|
||||
free(import_file);
|
||||
import_file = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -236,8 +236,8 @@ void PYTHON::set_init(char *iname) {
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
void PYTHON::import(char *filename) {
|
||||
if (import_file) delete import_file;
|
||||
import_file = copy_string(filename);
|
||||
if (import_file) free(import_file);
|
||||
import_file = Swig_copy_string(filename);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -270,21 +270,21 @@ void PYTHON::print_methods() {
|
|||
|
||||
Method *n;
|
||||
|
||||
fprintf(f_wrappers,"static PyMethodDef %sMethods[] = {\n", module);
|
||||
Printf(f_wrappers,"static PyMethodDef %sMethods[] = {\n", module);
|
||||
n = head;
|
||||
while (n) {
|
||||
if (!n->kw) {
|
||||
fprintf(f_wrappers,"\t { \"%s\", %s, METH_VARARGS },\n", n->name, n->function);
|
||||
Printf(f_wrappers,"\t { \"%s\", %s, METH_VARARGS },\n", n->name, n->function);
|
||||
} else {
|
||||
fprintf(f_wrappers,"\t { \"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS },\n", n->name, n->function);
|
||||
Printf(f_wrappers,"\t { \"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS },\n", n->name, n->function);
|
||||
}
|
||||
n = n->next;
|
||||
}
|
||||
fprintf(f_wrappers,"\t { NULL, NULL }\n");
|
||||
fprintf(f_wrappers,"};\n");
|
||||
fprintf(f_wrappers,"#ifdef __cplusplus\n");
|
||||
fprintf(f_wrappers,"}\n");
|
||||
fprintf(f_wrappers,"#endif\n");
|
||||
Printf(f_wrappers,"\t { NULL, NULL }\n");
|
||||
Printf(f_wrappers,"};\n");
|
||||
Printf(f_wrappers,"#ifdef __cplusplus\n");
|
||||
Printf(f_wrappers,"}\n");
|
||||
Printf(f_wrappers,"#endif\n");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
@ -297,14 +297,14 @@ void PYTHON::headers(void)
|
|||
|
||||
Swig_banner(f_runtime);
|
||||
|
||||
fprintf(f_runtime,"/* Implementation : PYTHON */\n\n");
|
||||
fprintf(f_runtime,"#define SWIGPYTHON\n");
|
||||
Printf(f_runtime,"/* Implementation : PYTHON */\n\n");
|
||||
Printf(f_runtime,"#define SWIGPYTHON\n");
|
||||
|
||||
if (NoInclude)
|
||||
fprintf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||
Printf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||
|
||||
if (Swig_insert_file("python.swg", f_runtime) == -1) {
|
||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate python.swg. (Possible installation problem).\n");
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate python.swg. (Possible installation problem).\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ void PYTHON::initialize(void)
|
|||
char *oldmodule = 0;
|
||||
|
||||
if (!module) {
|
||||
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||
Printf(stderr,"*** Error. No module name specified.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -345,13 +345,13 @@ void PYTHON::initialize(void)
|
|||
if (shadow) {
|
||||
sprintf(filen,"%s%s.py", output_dir, oldmodule);
|
||||
if ((f_shadow = fopen(filen,"w")) == 0) {
|
||||
fprintf(stderr,"Unable to open %s\n", filen);
|
||||
Printf(stderr,"Unable to open %s\n", filen);
|
||||
SWIG_exit(0);
|
||||
}
|
||||
fprintf(f_shadow,"# This file was created automatically by SWIG.\n");
|
||||
fprintf(f_shadow,"import %s\n", module);
|
||||
Printf(f_shadow,"# This file was created automatically by SWIG.\n");
|
||||
Printf(f_shadow,"import %s\n", module);
|
||||
if (!noopt)
|
||||
fprintf(f_shadow,"import new\n");
|
||||
Printf(f_shadow,"import new\n");
|
||||
}
|
||||
|
||||
// Dump out external module declarations
|
||||
|
|
@ -362,9 +362,9 @@ void PYTHON::initialize(void)
|
|||
if (Len(modextern) > 0) {
|
||||
Printf(f_header,"%s\n",modextern);
|
||||
}
|
||||
fprintf(f_wrappers,"#ifdef __cplusplus\n");
|
||||
fprintf(f_wrappers,"extern \"C\" {\n");
|
||||
fprintf(f_wrappers,"#endif\n");
|
||||
Printf(f_wrappers,"#ifdef __cplusplus\n");
|
||||
Printf(f_wrappers,"extern \"C\" {\n");
|
||||
Printf(f_wrappers,"#endif\n");
|
||||
|
||||
Printf(const_code,"static _swig_const_info _swig_const_table[] = {\n");
|
||||
}
|
||||
|
|
@ -378,24 +378,24 @@ void PYTHON::initialize(void)
|
|||
void PYTHON::initialize_cmodule(void)
|
||||
{
|
||||
int i;
|
||||
fprintf(f_header,"#define SWIG_init init%s\n\n", module);
|
||||
fprintf(f_header,"#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header,"#define SWIG_init init%s\n\n", module);
|
||||
Printf(f_header,"#define SWIG_name \"%s\"\n", module);
|
||||
|
||||
// Output the start of the init function.
|
||||
// Modify this to use the proper return type and arguments used
|
||||
// by the target Language
|
||||
|
||||
fprintf(f_init,"static PyObject *SWIG_globals;\n");
|
||||
Printf(f_init,"static PyObject *SWIG_globals;\n");
|
||||
|
||||
fprintf(f_init,"#ifdef __cplusplus\n");
|
||||
fprintf(f_init,"extern \"C\" \n");
|
||||
fprintf(f_init,"#endif\n");
|
||||
Printf(f_init,"#ifdef __cplusplus\n");
|
||||
Printf(f_init,"extern \"C\" \n");
|
||||
Printf(f_init,"#endif\n");
|
||||
|
||||
fprintf(f_init,"SWIGEXPORT(void) init%s(void) {\n",module);
|
||||
fprintf(f_init,"\t PyObject *m, *d;\n");
|
||||
fprintf(f_init,"\t SWIG_globals = SWIG_newvarlink();\n");
|
||||
fprintf(f_init,"\t m = Py_InitModule(\"%s\", %sMethods);\n", module, module);
|
||||
fprintf(f_init,"\t d = PyModule_GetDict(m);\n");
|
||||
Printf(f_init,"SWIGEXPORT(void) init%s(void) {\n",module);
|
||||
Printf(f_init,"\t PyObject *m, *d;\n");
|
||||
Printf(f_init,"\t SWIG_globals = SWIG_newvarlink();\n");
|
||||
Printf(f_init,"\t m = Py_InitModule(\"%s\", %sMethods);\n", module, module);
|
||||
Printf(f_init,"\t d = PyModule_GetDict(m);\n");
|
||||
|
||||
Printv(f_init,
|
||||
tab4, "{\n",
|
||||
|
|
@ -540,17 +540,17 @@ PYTHON::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
void PYTHON::emit_function_header(WrapperFunction &emit_to, char *wname)
|
||||
{
|
||||
if (!use_kw) {
|
||||
Printv(emit_to._def,
|
||||
Printv(emit_to.def,
|
||||
"static PyObject *", wname,
|
||||
"(PyObject *self, PyObject *args) {",
|
||||
0);
|
||||
} else {
|
||||
Printv(emit_to._def,
|
||||
Printv(emit_to.def,
|
||||
"static PyObject *", wname,
|
||||
"(PyObject *self, PyObject *args, PyObject *kwargs) {",
|
||||
0);
|
||||
}
|
||||
Printf(emit_to._code," self = self;\n");
|
||||
Printf(emit_to.code," self = self;\n");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -786,7 +786,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unsupported data type
|
||||
|
||||
default :
|
||||
fprintf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, p->t->print_type());
|
||||
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, p->t->print_type());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -843,7 +843,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
Printf(kwargs," NULL }");
|
||||
if (use_kw) {
|
||||
Printv(f._locals,tab4, "char *_kwnames[] = ", kwargs, ";\n", 0);
|
||||
Printv(f.locals,tab4, "char *_kwnames[] = ", kwargs, ";\n", 0);
|
||||
}
|
||||
|
||||
Printf(parse_args,":%s\"", iname);
|
||||
|
|
@ -855,7 +855,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
strcpy(self_name,convert_self(f));
|
||||
|
||||
/* Now slap the whole first part of the wrapper function together */
|
||||
Printv(f._code, parse_args, get_pointers, check, 0);
|
||||
Printv(f.code, parse_args, get_pointers, check, 0);
|
||||
|
||||
// This function emits code to call the real function. Assuming you read
|
||||
// the parameters in correctly, this will work.
|
||||
|
|
@ -869,7 +869,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"python",d,iname,(char*)"_result",(char*)"_resultobj"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
} else {
|
||||
|
||||
if ((d->type != T_VOID) || (d->is_pointer)) {
|
||||
|
|
@ -884,42 +884,42 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Return an integer type
|
||||
|
||||
case T_INT: case T_SINT: case T_UINT: case T_BOOL:
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"i\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"i\",_result);\n");
|
||||
break;
|
||||
case T_SHORT: case T_SSHORT: case T_USHORT:
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"h\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"h\",_result);\n");
|
||||
break;
|
||||
case T_LONG : case T_SLONG : case T_ULONG:
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"l\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"l\",_result);\n");
|
||||
break;
|
||||
case T_SCHAR: case T_UCHAR :
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"b\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"b\",_result);\n");
|
||||
break;
|
||||
|
||||
// Return a floating point value
|
||||
|
||||
case T_DOUBLE :
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"d\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"d\",_result);\n");
|
||||
break;
|
||||
case T_FLOAT :
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"f\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"f\",_result);\n");
|
||||
break;
|
||||
|
||||
// Return a single ASCII value. Usually we need to convert
|
||||
// it to a NULL-terminate string and return that instead.
|
||||
|
||||
case T_CHAR :
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"c\",_result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"c\",_result);\n");
|
||||
break;
|
||||
|
||||
case T_USER :
|
||||
d->is_pointer++;
|
||||
d->remember();
|
||||
Printv(f._code,tab4, "_resultobj = SWIG_NewPointerObj((void *)_result, SWIGTYPE", d->print_mangle(), ");\n",0);
|
||||
Printv(f.code,tab4, "_resultobj = SWIG_NewPointerObj((void *)_result, SWIGTYPE", d->print_mangle(), ");\n",0);
|
||||
d->is_pointer--;
|
||||
break;
|
||||
default :
|
||||
fprintf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, d->print_type(), name);
|
||||
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, d->print_type(), name);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -931,36 +931,36 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||
|
||||
// Return a character string
|
||||
Printf(f._code," _resultobj = Py_BuildValue(\"s\", _result);\n");
|
||||
Printf(f.code," _resultobj = Py_BuildValue(\"s\", _result);\n");
|
||||
|
||||
// If declared as a new object, free the result
|
||||
|
||||
} else {
|
||||
// Build a SWIG pointer.
|
||||
d->remember();
|
||||
Printv(f._code, tab4, "_resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE", d->print_mangle(), ");\n", 0);
|
||||
Printv(f.code, tab4, "_resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE", d->print_mangle(), ");\n", 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Printf(f._code," Py_INCREF(Py_None);\n");
|
||||
Printf(f._code," _resultobj = Py_None;\n");
|
||||
Printf(f.code," Py_INCREF(Py_None);\n");
|
||||
Printf(f.code," _resultobj = Py_None;\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if there were any output arguments, if so we're going to
|
||||
// create a Python list object out of the current result
|
||||
|
||||
Printv(f._code,outarg,0);
|
||||
Printv(f.code,outarg,0);
|
||||
|
||||
// If there was any other cleanup needed, do that
|
||||
|
||||
Printv(f._code,cleanup,0);
|
||||
Printv(f.code,cleanup,0);
|
||||
|
||||
// Look to see if there is any newfree cleanup code
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"python",d,iname,(char*)"_result",(char*)""))) {
|
||||
Printf(f._code,"%s\n",tm);
|
||||
Printf(f.code,"%s\n",tm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -968,16 +968,16 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"python",d,iname,(char*)"_result",(char*)""))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code,"%s\n",tm);
|
||||
Printf(f.code,"%s\n",tm);
|
||||
}
|
||||
|
||||
Printf(f._code," return _resultobj;\n}\n");
|
||||
Printf(f.code," return _resultobj;\n}\n");
|
||||
|
||||
// Substitute the cleanup code
|
||||
Replace(f._code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
|
||||
// Substitute the function name
|
||||
Replace(f._code,"$name",iname, DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$name",iname, DOH_REPLACE_ANY);
|
||||
|
||||
// Dump the function out
|
||||
f.print(f_wrappers);
|
||||
|
|
@ -1076,7 +1076,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
// Python dictionary.
|
||||
|
||||
if (!have_globals) {
|
||||
fprintf(f_init,"\t PyDict_SetItemString(d,\"%s\", SWIG_globals);\n",global_name);
|
||||
Printf(f_init,"\t PyDict_SetItemString(d,\"%s\", SWIG_globals);\n",global_name);
|
||||
have_globals=1;
|
||||
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
Printv(vars, global_name, " = ", module, ".", global_name, "\n", 0);
|
||||
|
|
@ -1091,11 +1091,11 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
// Create a function for setting the value of the variable
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Printf(setf._def,"static int %s_set(PyObject *val) {", wname);
|
||||
Printf(setf.def,"static int %s_set(PyObject *val) {", wname);
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
if ((tm = typemap_lookup((char*)"varin",(char*)"python",t,name,(char*)"val",name))) {
|
||||
Printf(setf._code,"%s\n",tm);
|
||||
Replace(setf._code,"$name",iname, DOH_REPLACE_ANY);
|
||||
Printf(setf.code,"%s\n",tm);
|
||||
Replace(setf.code,"$name",iname, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||
if (!t->is_pointer) {
|
||||
|
|
@ -1109,7 +1109,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
case T_SCHAR: case T_UCHAR: case T_BOOL:
|
||||
// Get an integer value
|
||||
setf.add_local(t->print_type(), (char*)"tval");
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "tval = ", t->print_cast(), "PyInt_AsLong(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
|
|
@ -1123,7 +1123,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
case T_FLOAT: case T_DOUBLE:
|
||||
// Get a floating point value
|
||||
setf.add_local(t->print_type(), (char*)"tval");
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "tval = ", t->print_cast(), "PyFloat_AsDouble(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
|
|
@ -1138,7 +1138,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
|
||||
case T_CHAR:
|
||||
setf.add_local((char*)"char *", (char*)"tval");
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "tval = (char *) PyString_AsString(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
|
|
@ -1151,12 +1151,12 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
case T_USER:
|
||||
t->is_pointer++;
|
||||
setf.add_local(t->print_type(),(char*)"temp");
|
||||
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf._code,(char*)"1");
|
||||
Printv(setf._code, tab4, name, " = *temp;\n", 0);
|
||||
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf.code,(char*)"1");
|
||||
Printv(setf.code, tab4, name, " = *temp;\n", 0);
|
||||
t->is_pointer--;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s : Line %d. Unable to link with type %s.\n", input_file, line_number, t->print_type());
|
||||
Printf(stderr,"%s : Line %d. Unable to link with type %s.\n", input_file, line_number, t->print_type());
|
||||
}
|
||||
} else {
|
||||
|
||||
|
|
@ -1164,7 +1164,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
|
||||
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
||||
setf.add_local((char*)"char *", (char*)"tval");
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "tval = (char *) PyString_AsString(val);\n",
|
||||
tab4, "if (PyErr_Occurred()) {\n",
|
||||
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
|
||||
|
|
@ -1174,13 +1174,13 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
0);
|
||||
|
||||
if (CPlusPlus) {
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "if (", name, ") delete [] ", name, ";\n",
|
||||
tab4, name, " = new char[strlen(tval)+1];\n",
|
||||
tab4, "strcpy((char *)", name, ",tval);\n",
|
||||
0);
|
||||
} else {
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "if (", name, ") free(", name, ");\n",
|
||||
tab4, name, " = (char *) malloc(strlen(tval)+1);\n",
|
||||
tab4, "strcpy((char *)", name, ",tval);\n",
|
||||
|
|
@ -1191,23 +1191,23 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
// Is a generic pointer value.
|
||||
|
||||
setf.add_local(t->print_type(),(char*)"temp");
|
||||
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf._code,(char*)"1");
|
||||
Printv(setf._code,tab4, name, " = temp;\n", 0);
|
||||
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf.code,(char*)"1");
|
||||
Printv(setf.code,tab4, name, " = temp;\n", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Printf(setf._code," return 0;\n");
|
||||
Printf(setf.code," return 0;\n");
|
||||
} else {
|
||||
// Is a readonly variable. Issue an error
|
||||
Printv(setf._code,
|
||||
Printv(setf.code,
|
||||
tab4, "PyErr_SetString(PyExc_TypeError,\"Variable ", iname,
|
||||
" is read-only.\");\n",
|
||||
tab4, "return 1;\n",
|
||||
0);
|
||||
}
|
||||
|
||||
Printf(setf._code,"}\n");
|
||||
Printf(setf.code,"}\n");
|
||||
|
||||
// Dump out function for setting value
|
||||
|
||||
|
|
@ -1217,14 +1217,14 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
// Create a function for getting the value of a variable
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
Printf(getf._def,"static PyObject *%s_get() {", wname);
|
||||
Printf(getf.def,"static PyObject *%s_get() {", wname);
|
||||
getf.add_local((char*)"PyObject *",(char*)"pyobj");
|
||||
if ((tm = typemap_lookup((char*)"varout",(char*)"python",t,name,name,(char*)"pyobj"))) {
|
||||
Printf(getf._code,"%s\n",tm);
|
||||
Replace(getf._code,"$name",iname, DOH_REPLACE_ANY);
|
||||
Printf(getf.code,"%s\n",tm);
|
||||
Replace(getf.code,"$name",iname, DOH_REPLACE_ANY);
|
||||
} else if ((tm = typemap_lookup((char*)"out",(char*)"python",t,name,name,(char*)"pyobj"))) {
|
||||
Printf(getf._code,"%s\n",tm);
|
||||
Replace(getf._code,"$name",iname, DOH_REPLACE_ANY);
|
||||
Printf(getf.code,"%s\n",tm);
|
||||
Replace(getf.code,"$name",iname, DOH_REPLACE_ANY);
|
||||
} else {
|
||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||
if (!t->is_pointer) {
|
||||
|
|
@ -1235,14 +1235,14 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
case T_SHORT: case T_SSHORT: case T_USHORT:
|
||||
case T_LONG: case T_SLONG: case T_ULONG:
|
||||
case T_SCHAR: case T_UCHAR: case T_BOOL:
|
||||
Printv(getf._code, tab4, "pyobj = PyInt_FromLong((long) ", name, ");\n", 0);
|
||||
Printv(getf.code, tab4, "pyobj = PyInt_FromLong((long) ", name, ");\n", 0);
|
||||
break;
|
||||
case T_FLOAT: case T_DOUBLE:
|
||||
Printv(getf._code, tab4, "pyobj = PyFloat_FromDouble((double) ", name, ");\n", 0);
|
||||
Printv(getf.code, tab4, "pyobj = PyFloat_FromDouble((double) ", name, ");\n", 0);
|
||||
break;
|
||||
case T_CHAR:
|
||||
getf.add_local((char*)"char",(char*)"ptemp[2]");
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "ptemp[0] = ", name, ";\n",
|
||||
tab4, "ptemp[1] = 0;\n",
|
||||
tab4, "pyobj = PyString_FromString(ptemp);\n",
|
||||
|
|
@ -1252,28 +1252,28 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
// Hack this into a pointer
|
||||
t->is_pointer++;
|
||||
t->remember();
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "pyobj = SWIG_NewPointerObj((void *) &", name ,
|
||||
", SWIGTYPE", t->print_mangle(), ");\n",
|
||||
0);
|
||||
t->is_pointer--;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Unable to link with type %s\n", t->print_type());
|
||||
Printf(stderr,"Unable to link with type %s\n", t->print_type());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Is some sort of pointer value
|
||||
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "if (", name, ")\n",
|
||||
tab8, "pyobj = PyString_FromString(", name, ");\n",
|
||||
tab4, "else pyobj = PyString_FromString(\"(NULL)\");\n",
|
||||
0);
|
||||
} else {
|
||||
t->remember();
|
||||
Printv(getf._code,
|
||||
Printv(getf.code,
|
||||
tab4, "pyobj = SWIG_NewPointerObj((void *)", name,
|
||||
", SWIGTYPE", t->print_mangle(), ");\n",
|
||||
0);
|
||||
|
|
@ -1282,13 +1282,13 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
}
|
||||
|
||||
Printf(getf._code," return pyobj;\n}\n");
|
||||
Printf(getf.code," return pyobj;\n}\n");
|
||||
|
||||
getf.print(f_wrappers);
|
||||
|
||||
// Now add this to the variable linking mechanism
|
||||
|
||||
fprintf(f_init,"\t SWIG_addvarlink(SWIG_globals,\"%s\",%s_get, %s_set);\n", iname, wname, wname);
|
||||
Printf(f_init,"\t SWIG_addvarlink(SWIG_globals,\"%s\",%s_get, %s_set);\n", iname, wname, wname);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// Output a shadow variable. (If applicable and possible)
|
||||
|
|
@ -1323,7 +1323,7 @@ void PYTHON::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
} else {
|
||||
|
||||
if ((type->type == T_USER) && (!type->is_pointer)) {
|
||||
fprintf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
Printf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1343,7 +1343,7 @@ void PYTHON::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
Printv(const_code, tab4, "{ SWIG_PY_STRING, \"", name, "\", 0, 0, (void *) \"", value, "\", 0},\n", 0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
Printf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1493,18 +1493,18 @@ void PYTHON::pragma(char *lang, char *cmd, char *value) {
|
|||
if (strcmp(lang,(char*)"python") == 0) {
|
||||
if (strcmp(cmd,"CODE") == 0) {
|
||||
if (shadow) {
|
||||
fprintf(f_shadow,"%s\n",value);
|
||||
Printf(f_shadow,"%s\n",value);
|
||||
}
|
||||
} else if (strcmp(cmd,"code") == 0) {
|
||||
if (shadow) {
|
||||
fprintf(f_shadow,"%s\n",value);
|
||||
Printf(f_shadow,"%s\n",value);
|
||||
}
|
||||
} else if (strcmp(cmd,"include") == 0) {
|
||||
if (shadow) {
|
||||
if (value) {
|
||||
FILE *f = Swig_open(value);
|
||||
if (!f) {
|
||||
fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
||||
Printf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
||||
} else {
|
||||
char buffer[4096];
|
||||
while (fgets(buffer,4095,f)) {
|
||||
|
|
@ -1514,7 +1514,7 @@ void PYTHON::pragma(char *lang, char *cmd, char *value) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Printf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1570,7 +1570,7 @@ void PYTHON::cpp_pragma(Pragma *plist) {
|
|||
pyp2 = pragmas;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"%s : Line %d. Malformed addtomethod pragma. Should be \"methodName:text\"\n",
|
||||
Printf(stderr,"%s : Line %d. Malformed addtomethod pragma. Should be \"methodName:text\"\n",
|
||||
Char(plist->filename),plist->lineno);
|
||||
}
|
||||
Delete(temp);
|
||||
|
|
@ -1663,16 +1663,16 @@ void PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip
|
|||
have_setattr = 0;
|
||||
have_repr = 0;
|
||||
if (rname) {
|
||||
class_name = copy_string(rname);
|
||||
class_name = Swig_copy_string(rname);
|
||||
class_renamed = 1;
|
||||
} else {
|
||||
class_name = copy_string(classname);
|
||||
class_name = Swig_copy_string(classname);
|
||||
class_renamed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
real_classname = copy_string(classname);
|
||||
class_type = copy_string(ctype);
|
||||
real_classname = Swig_copy_string(classname);
|
||||
class_type = Swig_copy_string(ctype);
|
||||
|
||||
// Build up the hash table
|
||||
Setattr(hash,real_classname,class_name);
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ void RUBY::parse() {
|
|||
void RUBY::set_module(char *mod_name, char **mod_list) {
|
||||
if (import_file) {
|
||||
Printf(f_init, "%srb_f_require(Qnil, rb_str_new2(\"%s\"));\n", tab4, mod_name);
|
||||
delete [] import_file;
|
||||
free(import_file); // Note: was allocated from C
|
||||
import_file = 0;
|
||||
}
|
||||
|
||||
|
|
@ -450,18 +450,18 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
int vararg = (numoptreal != 0);
|
||||
|
||||
// Now write the wrapper function itself
|
||||
Printv(f._def, "static VALUE\n", wname, "(", 0);
|
||||
Printv(f.def, "static VALUE\n", wname, "(", 0);
|
||||
if (vararg) {
|
||||
Printv(f._def, "int argc, VALUE *argv, VALUE self",0);
|
||||
Printv(f.def, "int argc, VALUE *argv, VALUE self",0);
|
||||
} else {
|
||||
Printv(f._def, "VALUE self", 0);
|
||||
Printv(f.def, "VALUE self", 0);
|
||||
for (i = start; i < l->nparms; i++) {
|
||||
if (!l->get(i)->ignore) {
|
||||
Printf(f._def,", VALUE varg%d", i);
|
||||
Printf(f.def,", VALUE varg%d", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Printf(f._def,") {");
|
||||
Printf(f.def,") {");
|
||||
|
||||
// Emit all of the local variables for holding arguments.
|
||||
if (vararg) {
|
||||
|
|
@ -494,13 +494,13 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
#endif
|
||||
// Emit count to check the number of arguments
|
||||
if (vararg) {
|
||||
Printf(f._code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
|
||||
Printf(f.code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
|
||||
for (i = start; i < l->nparms; i++) {
|
||||
if (!l->get(i)->ignore) {
|
||||
Printf(f._code,", &varg%d", i);
|
||||
Printf(f.code,", &varg%d", i);
|
||||
}
|
||||
}
|
||||
Printf(f._code,");\n");
|
||||
Printf(f.code,");\n");
|
||||
}
|
||||
|
||||
// Now walk the function parameter list and generate code
|
||||
|
|
@ -522,7 +522,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (!p.ignore) {
|
||||
char *tab = (char*)tab4;
|
||||
if (j >= (pcount-numopt)) { // Check if parsing an optional argument
|
||||
Printf(f._code," if (argc > %d) {\n", j - start);
|
||||
Printf(f.code," if (argc > %d) {\n", j - start);
|
||||
tab = (char*)tab8;
|
||||
}
|
||||
|
||||
|
|
@ -531,15 +531,15 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s,tab);
|
||||
Printv(f._code, s, "\n", 0);
|
||||
Replace(f._code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Printv(f.code, s, "\n", 0);
|
||||
Replace(f.code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n",
|
||||
input_file,line_number, p.t->print_type());
|
||||
}
|
||||
if (j >= (pcount-numopt))
|
||||
Printv(f._code, tab4, "} \n");
|
||||
Printv(f.code, tab4, "} \n");
|
||||
j++;
|
||||
}
|
||||
|
||||
|
|
@ -548,8 +548,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code, s, "\n", 0);
|
||||
Replace(f._code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Printv(f.code, s, "\n", 0);
|
||||
Replace(f.code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Delete(s);
|
||||
}
|
||||
|
||||
|
|
@ -579,13 +579,13 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
// Return value if necessary
|
||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||
if (predicate) {
|
||||
Printv(f._code, tab4, "vresult = (_result ? Qtrue : Qfalse);\n", 0);
|
||||
Printv(f.code, tab4, "vresult = (_result ? Qtrue : Qfalse);\n", 0);
|
||||
} else {
|
||||
tm = ruby_typemap_lookup((char*)"out",t,name,(char*)"_result",(char*)"vresult");
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code, s, "\n", 0);
|
||||
Printv(f.code, s, "\n", 0);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. No return typemap for datatype %s\n",
|
||||
|
|
@ -595,10 +595,10 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Dump argument output code;
|
||||
Printv(f._code,outarg,0);
|
||||
Printv(f.code,outarg,0);
|
||||
|
||||
// Dump the argument cleanup code
|
||||
Printv(f._code,cleanup,0);
|
||||
Printv(f.code,cleanup,0);
|
||||
|
||||
// Look for any remaining cleanup. This processes the %new directive
|
||||
if (NewObject) {
|
||||
|
|
@ -606,14 +606,14 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code,s,"\n", 0);
|
||||
Printv(f.code,s,"\n", 0);
|
||||
Delete(s);
|
||||
}
|
||||
}
|
||||
|
||||
// free pragma
|
||||
if (current == MEMBER_FUNC && Getattr(klass->freemethods, mname)) {
|
||||
Printv(f._code, tab4, "DATA_PTR(self) = 0;\n", 0);
|
||||
Printv(f.code, tab4, "DATA_PTR(self) = 0;\n", 0);
|
||||
}
|
||||
|
||||
// Special processing on return value.
|
||||
|
|
@ -621,14 +621,14 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code,s,"\n", 0);
|
||||
Printv(f.code,s,"\n", 0);
|
||||
}
|
||||
|
||||
// Wrap things up (in a manner of speaking)
|
||||
Printv(f._code, tab4, "return vresult;\n}\n", 0);
|
||||
Printv(f.code, tab4, "return vresult;\n}\n", 0);
|
||||
|
||||
// Substitute the cleanup code
|
||||
Replace(f._code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
|
||||
// Emit the function
|
||||
f.print(f_wrappers);
|
||||
|
|
@ -661,9 +661,9 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
// create getter
|
||||
getfname = NewString(Swig_name_get(name));
|
||||
Replace(getfname,"::", "_", DOH_REPLACE_ANY); /* FIXME: Swig_name_get bug? */
|
||||
Printv(getf._def, "static VALUE\n", getfname, "(", 0);
|
||||
if (mod_attr) Printf(getf._def, "VALUE self");
|
||||
Printf(getf._def, ") {");
|
||||
Printv(getf.def, "static VALUE\n", getfname, "(", 0);
|
||||
if (mod_attr) Printf(getf.def, "VALUE self");
|
||||
Printf(getf.def, ") {");
|
||||
getf.add_local((char*)"VALUE", (char*)"_val");
|
||||
tm = ruby_typemap_lookup((char*)"varout",t,name,name,(char*)"_val");
|
||||
if (!tm)
|
||||
|
|
@ -671,20 +671,20 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(getf._code,s,"\n", 0);
|
||||
Printv(getf.code,s,"\n", 0);
|
||||
Delete(s);
|
||||
} else if (!t->is_pointer && t->type == T_USER) {
|
||||
// Hack this into a pointer
|
||||
t->is_pointer++;
|
||||
t->remember();
|
||||
Printv(getf._code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
||||
Printv(getf.code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
||||
", \"", t->print_mangle(), "\");\n", 0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
||||
input_file,line_number,t->print_type());
|
||||
}
|
||||
Printv(getf._code, tab4, "return _val;\n}\n", 0);
|
||||
Printv(getf.code, tab4, "return _val;\n}\n", 0);
|
||||
getf.print(f_wrappers);
|
||||
|
||||
if (Status & STAT_READONLY) {
|
||||
|
|
@ -694,33 +694,33 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
setfname = NewString(Swig_name_set(name));
|
||||
Replace(setfname,"::", "_", DOH_REPLACE_ANY); /* FIXME: Swig_name_get bug? */
|
||||
if (mod_attr)
|
||||
Printv(setf._def, "static VALUE\n", setfname, "(VALUE self, ", 0);
|
||||
Printv(setf.def, "static VALUE\n", setfname, "(VALUE self, ", 0);
|
||||
else
|
||||
Printv(setf._def, "static void\n", setfname, "(", 0);
|
||||
Printf(setf._def, "VALUE _val) {");
|
||||
Printv(setf.def, "static void\n", setfname, "(", 0);
|
||||
Printf(setf.def, "VALUE _val) {");
|
||||
tm = ruby_typemap_lookup((char*)"varin",t,name,(char*)"_val",name);
|
||||
if (!tm)
|
||||
tm = ruby_typemap_lookup((char*)"in",t,name,(char*)"_val",name);
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(setf._code,s,"\n",0);
|
||||
Printv(setf.code,s,"\n",0);
|
||||
Delete(s);
|
||||
} else if (!t->is_pointer && t->type == T_USER) {
|
||||
t->is_pointer++;
|
||||
setf.add_local(t->print_type(), (char*)"temp");
|
||||
Printv(setf._code, tab4, "temp = (", t->print_type(), ")",
|
||||
Printv(setf.code, tab4, "temp = (", t->print_type(), ")",
|
||||
"SWIG_ConvertPtr(_val, \"", t->print_mangle(), "\");\n",
|
||||
0);
|
||||
Printv(setf._code, tab4, name, " = *temp;\n",0);
|
||||
Printv(setf.code, tab4, name, " = *temp;\n",0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
||||
input_file,line_number,t->print_type());
|
||||
}
|
||||
if (mod_attr)
|
||||
Printv(setf._code, tab4, "return _val;\n",0);
|
||||
Printf(setf._code,"}\n");
|
||||
Printv(setf.code, tab4, "return _val;\n",0);
|
||||
Printf(setf.code,"}\n");
|
||||
setf.print(f_wrappers);
|
||||
}
|
||||
|
||||
|
|
@ -1382,8 +1382,8 @@ void RUBY::cpp_pragma(Pragma *plist) {
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
void RUBY::import(char *filename) {
|
||||
if (import_file) delete [] import_file;
|
||||
import_file = copy_string(filename);
|
||||
if (import_file) free(import_file);
|
||||
import_file = Swig_copy_string(filename);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ void TCL8::parse_args(int argc, char *argv[]) {
|
|||
// If a package has been specified, make sure it ends with a '_'
|
||||
|
||||
if (prefix) {
|
||||
ns_name = copy_string(prefix);
|
||||
ns_name = Swig_copy_string(prefix);
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix)+1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
|
|
@ -146,7 +146,7 @@ void TCL8::parse_args(int argc, char *argv[]) {
|
|||
|
||||
void TCL8::parse() {
|
||||
|
||||
fprintf(stderr,"Making wrappers for Tcl 8.x\n");
|
||||
Printf(stderr,"Making wrappers for Tcl 8.x\n");
|
||||
|
||||
mod_init = NewString("");
|
||||
mod_extern = NewString("");
|
||||
|
|
@ -206,7 +206,7 @@ void TCL8::set_module(char *mod_name, char **mod_list) {
|
|||
strcpy(init_name, temp);
|
||||
*init_name = toupper(*init_name);
|
||||
|
||||
if (!ns_name) ns_name = copy_string(module);
|
||||
if (!ns_name) ns_name = Swig_copy_string(module);
|
||||
|
||||
// If namespaces have been specified, set the prefix to the module name
|
||||
|
||||
|
|
@ -275,11 +275,11 @@ void TCL8::headers(void)
|
|||
// Include a Tcl configuration file for Unix,Mac,Wintel.
|
||||
|
||||
if (NoInclude) {
|
||||
fprintf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||
Printf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||
}
|
||||
|
||||
if (Swig_insert_file("swigtcl8.swg",f_runtime) == -1) {
|
||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n");
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -295,50 +295,50 @@ void TCL8::initialize()
|
|||
{
|
||||
|
||||
if ((!ns_name) && (nspace)) {
|
||||
fprintf(stderr,"Tcl error. Must specify a namespace.\n");
|
||||
Printf(stderr,"Tcl error. Must specify a namespace.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
if (!init_name) {
|
||||
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||
Printf(stderr,"*** Error. No module name specified.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
||||
fprintf(f_header,"#define SWIG_init %s\n", init_name);
|
||||
Printf(f_header,"#define SWIG_init %s\n", init_name);
|
||||
if (!module) module = (char*)"swig";
|
||||
fprintf(f_header,"#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header,"#define SWIG_name \"%s\"\n", module);
|
||||
if (nspace) {
|
||||
fprintf(f_header,"#define SWIG_prefix \"%s::\"\n", ns_name);
|
||||
fprintf(f_header,"#define SWIG_namespace \"%s\"\n\n", ns_name);
|
||||
Printf(f_header,"#define SWIG_prefix \"%s::\"\n", ns_name);
|
||||
Printf(f_header,"#define SWIG_namespace \"%s\"\n\n", ns_name);
|
||||
} else {
|
||||
fprintf(f_header,"#define SWIG_prefix \"%s\"\n", prefix);
|
||||
fprintf(f_header,"#define SWIG_namespace \"\"\n\n");
|
||||
Printf(f_header,"#define SWIG_prefix \"%s\"\n", prefix);
|
||||
Printf(f_header,"#define SWIG_namespace \"\"\n\n");
|
||||
}
|
||||
fprintf(f_header,"#ifdef __cplusplus\n");
|
||||
fprintf(f_header,"extern \"C\" {\n");
|
||||
fprintf(f_header,"#endif\n");
|
||||
fprintf(f_header,"#ifdef MAC_TCL\n");
|
||||
fprintf(f_header,"#pragma export on\n");
|
||||
fprintf(f_header,"#endif\n");
|
||||
fprintf(f_header,"SWIGEXPORT(int) %s(Tcl_Interp *);\n", init_name);
|
||||
fprintf(f_header,"#ifdef MAC_TCL\n");
|
||||
fprintf(f_header,"#pragma export off\n");
|
||||
fprintf(f_header,"#endif\n");
|
||||
fprintf(f_header,"#ifdef __cplusplus\n");
|
||||
fprintf(f_header,"}\n");
|
||||
fprintf(f_header,"#endif\n");
|
||||
Printf(f_header,"#ifdef __cplusplus\n");
|
||||
Printf(f_header,"extern \"C\" {\n");
|
||||
Printf(f_header,"#endif\n");
|
||||
Printf(f_header,"#ifdef MAC_TCL\n");
|
||||
Printf(f_header,"#pragma export on\n");
|
||||
Printf(f_header,"#endif\n");
|
||||
Printf(f_header,"SWIGEXPORT(int) %s(Tcl_Interp *);\n", init_name);
|
||||
Printf(f_header,"#ifdef MAC_TCL\n");
|
||||
Printf(f_header,"#pragma export off\n");
|
||||
Printf(f_header,"#endif\n");
|
||||
Printf(f_header,"#ifdef __cplusplus\n");
|
||||
Printf(f_header,"}\n");
|
||||
Printf(f_header,"#endif\n");
|
||||
|
||||
|
||||
fprintf(f_init,"SWIGEXPORT(int) %s(Tcl_Interp *%s) {\n", init_name, interp_name);
|
||||
fprintf(f_init,"\t int i;\n");
|
||||
Printf(f_init,"SWIGEXPORT(int) %s(Tcl_Interp *%s) {\n", init_name, interp_name);
|
||||
Printf(f_init,"\t int i;\n");
|
||||
if (nspace) {
|
||||
fprintf(f_init,"#ifdef ITCL_NAMESPACES\n");
|
||||
fprintf(f_init,"\t Itcl_Namespace spaceId;\n");
|
||||
fprintf(f_init,"#endif\n");
|
||||
Printf(f_init,"#ifdef ITCL_NAMESPACES\n");
|
||||
Printf(f_init,"\t Itcl_Namespace spaceId;\n");
|
||||
Printf(f_init,"#endif\n");
|
||||
}
|
||||
|
||||
fprintf(f_init,"\t if (%s == 0) \n", interp_name);
|
||||
fprintf(f_init,"\t\t return TCL_ERROR;\n");
|
||||
Printf(f_init,"\t if (%s == 0) \n", interp_name);
|
||||
Printf(f_init,"\t\t return TCL_ERROR;\n");
|
||||
|
||||
/* Check to see if other initializations need to be performed */
|
||||
|
||||
|
|
@ -355,9 +355,9 @@ void TCL8::initialize()
|
|||
|
||||
/* Check to see if we're adding support for Tcl8 nspaces */
|
||||
if (nspace) {
|
||||
fprintf(f_init,"#if (TCL_MAJOR_VERSION >= 8)\n");
|
||||
fprintf(f_init,"\t Tcl_Eval(%s,\"namespace eval %s { }\");\n", interp_name, ns_name);
|
||||
fprintf(f_init,"#endif\n");
|
||||
Printf(f_init,"#if (TCL_MAJOR_VERSION >= 8)\n");
|
||||
Printf(f_init,"\t Tcl_Eval(%s,\"namespace eval %s { }\");\n", interp_name, ns_name);
|
||||
Printf(f_init,"#endif\n");
|
||||
}
|
||||
|
||||
Printf(cmd_info, "\nstatic _swig_command_info _swig_commands[] = {\n");
|
||||
|
|
@ -388,15 +388,15 @@ void TCL8::close(void)
|
|||
Printf(f_wrappers,"%s", cmd_info);
|
||||
Printf(f_wrappers,"%s", var_info);
|
||||
|
||||
fprintf(f_init,"\tfor (i = 0; _swig_commands[i].name; i++) {\n");
|
||||
fprintf(f_init,"\t Tcl_CreateObjCommand(interp, (char *) _swig_commands[i].name, _swig_commands[i].wrapper, _swig_commands[i].clientdata, NULL);\n");
|
||||
fprintf(f_init,"\t}\n");
|
||||
Printf(f_init,"\tfor (i = 0; _swig_commands[i].name; i++) {\n");
|
||||
Printf(f_init,"\t Tcl_CreateObjCommand(interp, (char *) _swig_commands[i].name, _swig_commands[i].wrapper, _swig_commands[i].clientdata, NULL);\n");
|
||||
Printf(f_init,"\t}\n");
|
||||
|
||||
fprintf(f_init,"\tfor (i = 0; _swig_variables[i].name; i++) {\n");
|
||||
fprintf(f_init,"\t Tcl_SetVar(interp, (char *) _swig_variables[i].name, \"\", TCL_GLOBAL_ONLY);\n");
|
||||
fprintf(f_init,"\t Tcl_TraceVar(interp, (char *) _swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, _swig_variables[i].get, (ClientData) _swig_variables[i].addr);\n");
|
||||
fprintf(f_init,"\t Tcl_TraceVar(interp, (char *) _swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, _swig_variables[i].set, (ClientData) _swig_variables[i].addr);\n");
|
||||
fprintf(f_init,"\t}\n");
|
||||
Printf(f_init,"\tfor (i = 0; _swig_variables[i].name; i++) {\n");
|
||||
Printf(f_init,"\t Tcl_SetVar(interp, (char *) _swig_variables[i].name, \"\", TCL_GLOBAL_ONLY);\n");
|
||||
Printf(f_init,"\t Tcl_TraceVar(interp, (char *) _swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, _swig_variables[i].get, (ClientData) _swig_variables[i].addr);\n");
|
||||
Printf(f_init,"\t Tcl_TraceVar(interp, (char *) _swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, _swig_variables[i].set, (ClientData) _swig_variables[i].addr);\n");
|
||||
Printf(f_init,"\t}\n");
|
||||
|
||||
// Dump the pointer equivalency table
|
||||
|
||||
|
|
@ -406,8 +406,8 @@ void TCL8::close(void)
|
|||
|
||||
// Close the init file and quit
|
||||
|
||||
fprintf(f_init,"\t return TCL_OK;\n");
|
||||
fprintf(f_init,"}\n");
|
||||
Printf(f_init,"\t return TCL_OK;\n");
|
||||
Printf(f_init,"}\n");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
Printv(f._def,
|
||||
Printv(f.def,
|
||||
"static int ", wname, "(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {",
|
||||
0);
|
||||
|
||||
|
|
@ -599,7 +599,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unsupported data type
|
||||
|
||||
default :
|
||||
fprintf(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, p->t->print_type());
|
||||
break;
|
||||
}
|
||||
|
|
@ -646,11 +646,11 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
p = l->get_next(); // Get next parameter and continue
|
||||
}
|
||||
Printf(argstr,":%s\"",usage);
|
||||
Printv(f._code,
|
||||
Printv(f.code,
|
||||
tab4, "if (SWIG_GetArgs(interp, objc, objv,", argstr, args, ") == TCL_ERROR) return TCL_ERROR;\n",
|
||||
0);
|
||||
|
||||
Printv(f._code,incode,0);
|
||||
Printv(f.code,incode,0);
|
||||
|
||||
// Now write code to make the function call
|
||||
|
||||
|
|
@ -660,7 +660,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"tcl8",d,name,(char*)"_result",(char*)"tcl_result"))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
} else if ((d->type != T_VOID) || (d->is_pointer)) {
|
||||
if (!d->is_pointer) {
|
||||
|
||||
|
|
@ -680,18 +680,18 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
Printv(f._code, tab4, "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) _result));\n",0);
|
||||
Printv(f.code, tab4, "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) _result));\n",0);
|
||||
break;
|
||||
|
||||
// Is a single character. Assume we return it as a string
|
||||
case T_CHAR :
|
||||
Printv(f._code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(&_result,1));\n",0);
|
||||
Printv(f.code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(&_result,1));\n",0);
|
||||
break;
|
||||
|
||||
// Floating point number
|
||||
case T_DOUBLE :
|
||||
case T_FLOAT :
|
||||
Printv(f._code, tab4, "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) _result));\n",0);
|
||||
Printv(f.code, tab4, "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) _result));\n",0);
|
||||
break;
|
||||
|
||||
// User defined type
|
||||
|
|
@ -702,7 +702,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
d->is_pointer++;
|
||||
d->remember();
|
||||
Printv(f._code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
||||
Printv(f.code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
||||
d->print_mangle(), "));\n", 0);
|
||||
|
||||
d->is_pointer--;
|
||||
|
|
@ -710,7 +710,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Unknown type
|
||||
default :
|
||||
fprintf(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, d->print_type(), name);
|
||||
break;
|
||||
}
|
||||
|
|
@ -720,10 +720,10 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
if ((d->type == T_CHAR) && (d->is_pointer == 1)) {
|
||||
// Return a character string
|
||||
Printv(f._code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(_result,-1));\n",0);
|
||||
Printv(f.code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(_result,-1));\n",0);
|
||||
} else {
|
||||
d->remember();
|
||||
Printv(f._code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
||||
Printv(f.code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
|
||||
d->print_mangle(), "));\n",
|
||||
0);
|
||||
}
|
||||
|
|
@ -731,28 +731,28 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Dump output argument code
|
||||
Printv(f._code,outarg,0);
|
||||
Printv(f.code,outarg,0);
|
||||
|
||||
// Dump the argument cleanup code
|
||||
Printv(f._code,cleanup,0);
|
||||
Printv(f.code,cleanup,0);
|
||||
|
||||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
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*)""))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f._code,"%s\n", tm);
|
||||
Printf(f.code,"%s\n", tm);
|
||||
}
|
||||
Printv(f._code,tab4, "return TCL_OK;\n}", 0);
|
||||
Printv(f.code,tab4, "return TCL_OK;\n}", 0);
|
||||
|
||||
// Substitute the cleanup code
|
||||
Replace(f._code,"$cleanup",cleanup,DOH_REPLACE_ANY);
|
||||
Replace(f._code,"$name", iname, DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$cleanup",cleanup,DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$name", iname, DOH_REPLACE_ANY);
|
||||
|
||||
// Dump out the function
|
||||
|
||||
|
|
@ -785,7 +785,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
tm = typemap_lookup((char*)"varin",(char*)"tcl8",t,name,(char*)"",(char*)"");
|
||||
tm1 = typemap_lookup((char*)"varout",(char*)"tcl8",t,name,(char*)"",(char*)"");
|
||||
if (tm || tm1) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. varin/varout typemap methods not supported.",
|
||||
Printf(stderr,"%s : Line %d. Warning. varin/varout typemap methods not supported.",
|
||||
input_file, line_number);
|
||||
}
|
||||
|
||||
|
|
@ -794,19 +794,19 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
Setattr(setget,t->print_type(),"1");
|
||||
WrapperFunction get;
|
||||
WrapperFunction set;
|
||||
Printv(set._def, "static char *_swig_", t->print_mangle(), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
Printv(set.def, "static char *_swig_", t->print_mangle(), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
|
||||
Printv(get._def, "static char *_swig_", t->print_mangle(), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
Printv(get.def, "static char *_swig_", t->print_mangle(), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
t->is_pointer++;
|
||||
get.add_local(t->print_type(),(char*)"addr");
|
||||
set.add_local(t->print_type(),(char*)"addr");
|
||||
Printv(set._code, tab4, "addr = ", t->print_cast(), " clientData;\n", 0);
|
||||
Printv(get._code, tab4, "addr = ", t->print_cast(), " clientData;\n", 0);
|
||||
Printv(set.code, tab4, "addr = ", t->print_cast(), " clientData;\n", 0);
|
||||
Printv(get.code, tab4, "addr = ", t->print_cast(), " clientData;\n", 0);
|
||||
t->is_pointer--;
|
||||
set.add_local((char*)"char *",(char*)"value");
|
||||
get.add_local((char*)"Tcl_Obj *",(char*)"value");
|
||||
|
||||
Printv(set._code, tab4, "value = Tcl_GetVar2(interp, name1, name2, flags);\n",
|
||||
Printv(set.code, tab4, "value = Tcl_GetVar2(interp, name1, name2, flags);\n",
|
||||
tab4, "if (!value) return NULL;\n", 0);
|
||||
|
||||
if (!t->is_pointer) {
|
||||
|
|
@ -821,24 +821,24 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_UCHAR:
|
||||
case T_SCHAR:
|
||||
case T_BOOL:
|
||||
Printv(set._code, tab4, "*(addr) = ", t->print_cast(), "atol(value);\n", 0);
|
||||
Printv(set.code, tab4, "*(addr) = ", t->print_cast(), "atol(value);\n", 0);
|
||||
break;
|
||||
case T_UINT:
|
||||
case T_ULONG:
|
||||
Printv(set._code, tab4, "*(addr) = ", t->print_cast(), "strtoul(value,0,0);\n",0);
|
||||
Printv(set.code, tab4, "*(addr) = ", t->print_cast(), "strtoul(value,0,0);\n",0);
|
||||
break;
|
||||
case T_FLOAT:
|
||||
case T_DOUBLE:
|
||||
Printv(set._code, tab4, "*(addr) = ", t->print_cast(), "atof(value);\n",0);
|
||||
Printv(set.code, tab4, "*(addr) = ", t->print_cast(), "atof(value);\n",0);
|
||||
break;
|
||||
case T_CHAR: /* Single character. */
|
||||
Printv(set._code, tab4, "*(addr) = *value;\n",0);
|
||||
Printv(set.code, tab4, "*(addr) = *value;\n",0);
|
||||
break;
|
||||
case T_USER:
|
||||
// User defined type. We return it as a pointer
|
||||
t->is_pointer++;
|
||||
t->remember();
|
||||
Printv(set._code, tab4, "{\n",
|
||||
Printv(set.code, tab4, "{\n",
|
||||
tab8, "void *ptr;\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", t->print_mangle(), ") != TCL_OK) {\n",
|
||||
tab8, tab4, "return \"Type Error\";\n",
|
||||
|
|
@ -850,19 +850,19 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
t->is_pointer--;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Unknown type %d!\n", t->type);
|
||||
Printf(stderr,"Unknown type %d!\n", t->type);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((t->is_pointer == 1) && (t->type == T_CHAR)) {
|
||||
Printv(set._code, tab4, "if (*addr) free(*addr);\n",
|
||||
Printv(set.code, tab4, "if (*addr) free(*addr);\n",
|
||||
tab4, "*addr = (char *) malloc(strlen(value)+1);\n",
|
||||
tab4, "strcpy(*addr,value);\n",
|
||||
0);
|
||||
} else {
|
||||
// User defined type. We return it as a pointer
|
||||
t->remember();
|
||||
Printv(set._code, tab4, "{\n",
|
||||
Printv(set.code, tab4, "{\n",
|
||||
tab8, "void *ptr;\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", t->print_mangle(), ") != TCL_OK) {\n",
|
||||
tab8, tab4, "return \"Type Error\";\n",
|
||||
|
|
@ -874,7 +874,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
/* A Pointer */
|
||||
}
|
||||
}
|
||||
Printv(set._code, tab4, "return NULL;\n", "}\n",0);
|
||||
Printv(set.code, tab4, "return NULL;\n", "}\n",0);
|
||||
|
||||
if (!t->is_pointer) {
|
||||
switch(t->type) {
|
||||
|
|
@ -891,7 +891,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_SCHAR:
|
||||
case T_BOOL:
|
||||
get.add_local((char*)"Tcl_Obj *",(char*)"value");
|
||||
Printv(get._code,
|
||||
Printv(get.code,
|
||||
tab4, "value = Tcl_NewIntObj((int) *addr);\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",
|
||||
|
|
@ -900,7 +900,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_FLOAT:
|
||||
case T_DOUBLE:
|
||||
get.add_local((char*)"Tcl_Obj *",(char*)"value");
|
||||
Printv(get._code,
|
||||
Printv(get.code,
|
||||
tab4, "value = Tcl_NewDoubleObj((double) *addr);\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",
|
||||
|
|
@ -909,7 +909,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
|
||||
case T_CHAR:
|
||||
get.add_local((char*)"char",(char*)"temp[4]");
|
||||
Printv(get._code,tab4, "temp[0] = *addr; temp[1] = 0;\n",
|
||||
Printv(get.code,tab4, "temp[0] = *addr; temp[1] = 0;\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,temp,flags);\n",
|
||||
0);
|
||||
break;
|
||||
|
|
@ -918,7 +918,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
get.add_local((char*)"Tcl_Obj *",(char*)"value");
|
||||
t->is_pointer++;
|
||||
t->remember();
|
||||
Printv(get._code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", t->print_mangle(), ");\n",
|
||||
Printv(get.code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", t->print_mangle(), ");\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",0);
|
||||
t->is_pointer--;
|
||||
|
|
@ -929,11 +929,11 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
}
|
||||
} else {
|
||||
if ((t->is_pointer == 1) && (t->type == T_CHAR)) {
|
||||
Printv(get._code, tab4, "Tcl_SetVar2(interp,name1,name2,*addr, flags);\n",0);
|
||||
Printv(get.code, tab4, "Tcl_SetVar2(interp,name1,name2,*addr, flags);\n",0);
|
||||
} else {
|
||||
get.add_local((char*)"Tcl_Obj *",(char*)"value");
|
||||
t->remember();
|
||||
Printv(get._code,
|
||||
Printv(get.code,
|
||||
tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", t->print_mangle(), ");\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",
|
||||
|
|
@ -941,7 +941,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
}
|
||||
}
|
||||
|
||||
Printv(get._code, tab4, "return NULL;\n", "}\n",0);
|
||||
Printv(get.code, tab4, "return NULL;\n", "}\n",0);
|
||||
get.print(f_wrappers);
|
||||
set.print(f_wrappers);
|
||||
}
|
||||
|
|
@ -951,8 +951,8 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
static int readonly = 0;
|
||||
if (!readonly) {
|
||||
WrapperFunction ro;
|
||||
Printf(ro._def, "static char *_swig_readonly(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {");
|
||||
Printv(ro._code, tab4, "return \"Variable is read-only\";\n", "}\n", 0);
|
||||
Printf(ro.def, "static char *_swig_readonly(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {");
|
||||
Printv(ro.code, tab4, "return \"Variable is read-only\";\n", "}\n", 0);
|
||||
ro.print(f_wrappers);
|
||||
readonly = 1;
|
||||
}
|
||||
|
|
@ -993,7 +993,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
}
|
||||
if ((tm = typemap_lookup((char*)"const",(char*)"tcl8",type,name,Char(rvalue),name))) {
|
||||
// Yep. Use it instead of the default
|
||||
fprintf(f_init,"%s\n",tm);
|
||||
Printf(f_init,"%s\n",tm);
|
||||
} else {
|
||||
|
||||
// Create variable and assign it a value
|
||||
|
|
@ -1001,7 +1001,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
if (type->is_pointer == 0) {
|
||||
switch(type->type) {
|
||||
case T_BOOL: case T_INT: case T_SINT: case T_DOUBLE:
|
||||
fprintf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
case T_SHORT:
|
||||
|
|
@ -1009,14 +1009,14 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
case T_SSHORT:
|
||||
case T_SCHAR:
|
||||
case T_SLONG:
|
||||
fprintf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
fprintf(f_header,"static char *%s_char;\n", var_name);
|
||||
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
fprintf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
else
|
||||
fprintf(f_init,"\t %s_char = (char *) malloc(32);\n",var_name);
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(32);\n",var_name);
|
||||
|
||||
fprintf(f_init,"\t sprintf(%s_char,\"%%ld\", (long) %s);\n", var_name, var_name);
|
||||
Printf(f_init,"\t sprintf(%s_char,\"%%ld\", (long) %s);\n", var_name, var_name);
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
t = new DataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
|
|
@ -1027,14 +1027,14 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
fprintf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
fprintf(f_header,"static char *%s_char;\n", var_name);
|
||||
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
fprintf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
else
|
||||
fprintf(f_init,"\t %s_char = (char *) malloc(32);\n",var_name);
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(32);\n",var_name);
|
||||
|
||||
fprintf(f_init,"\t sprintf(%s_char,\"%%lu\", (unsigned long) %s);\n", var_name, var_name);
|
||||
Printf(f_init,"\t sprintf(%s_char,\"%%lu\", (unsigned long) %s);\n", var_name, var_name);
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
t = new DataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
|
|
@ -1044,39 +1044,39 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
case T_FLOAT:
|
||||
type->type = T_DOUBLE;
|
||||
strcpy(type->name,"double");
|
||||
fprintf(f_header,"static %s %s = %s (%s);\n", type->print_type(), var_name, type->print_cast(), value);
|
||||
Printf(f_header,"static %s %s = %s (%s);\n", type->print_type(), var_name, type->print_cast(), value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
|
||||
case T_CHAR:
|
||||
type->is_pointer++;
|
||||
fprintf(f_header,"static %s %s = \"%s\";\n", type->print_type(), var_name, value);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", type->print_type(), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
type->is_pointer--;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
Printf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Have some sort of pointer value here
|
||||
if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
|
||||
// Character string
|
||||
fprintf(f_header,"static %s %s = \"%s\";\n", type->print_type(), var_name, value);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", type->print_type(), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
} else {
|
||||
// Something else. Some sort of pointer value
|
||||
fprintf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
fprintf(f_header,"static char *%s_char;\n", var_name);
|
||||
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
fprintf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(type->print_mangle())+ 20);
|
||||
Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(type->print_mangle())+ 20);
|
||||
else
|
||||
fprintf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(type->print_mangle())+ 20);
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(type->print_mangle())+ 20);
|
||||
|
||||
t = new DataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
type->remember();
|
||||
fprintf(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, type->print_mangle());
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
link_variable(var_name,name,t);
|
||||
|
|
@ -1209,7 +1209,7 @@ char *TCL8::usage_const(char *name, DataType *, char *value) {
|
|||
|
||||
void TCL8::add_native(char *name, char *funcname, DataType *, ParmList *) {
|
||||
|
||||
fprintf(f_init,"\t Tcl_CreateObjCommand(%s, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",interp_name, name, funcname);
|
||||
Printf(f_init,"\t Tcl_CreateObjCommand(%s, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",interp_name, name, funcname);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1238,7 +1238,7 @@ void TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
|||
static int included_object = 0;
|
||||
if (!included_object) {
|
||||
if (Swig_insert_file("object.swg",f_header) == -1) {
|
||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'object.swg' in SWIG library.\n");
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate 'object.swg' in SWIG library.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
included_object = 1;
|
||||
|
|
@ -1256,9 +1256,9 @@ void TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
|||
have_destructor = 0;
|
||||
|
||||
if (rename)
|
||||
class_name = copy_string(rename);
|
||||
class_name = Swig_copy_string(rename);
|
||||
else
|
||||
class_name = copy_string(classname);
|
||||
class_name = Swig_copy_string(classname);
|
||||
|
||||
base_class = (char *) 0;
|
||||
if (!strip) {
|
||||
|
|
@ -1267,7 +1267,7 @@ void TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
|||
} else
|
||||
class_type = (char*)"";
|
||||
|
||||
real_classname = copy_string(classname);
|
||||
real_classname = Swig_copy_string(classname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -233,16 +233,16 @@ int emit_args(DataType *rt, ParmList *l, WrapperFunction &f) {
|
|||
|
||||
tm = typemap_lookup((char*)"arginit", typemap_lang, p->t,p->name,(char*)"",temp,&f);
|
||||
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,p->t,p->name,(char*)"",temp,&f);
|
||||
if (tm)
|
||||
Printv(f._code,tm,"\n",0);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
tm = typemap_lookup((char*)"ignore",typemap_lang,p->t,p->name,(char*)"",temp,&f);
|
||||
if (tm) {
|
||||
Printv(f._code,tm,"\n",0);
|
||||
Printv(f.code,tm,"\n",0);
|
||||
p->ignore = 1;
|
||||
}
|
||||
tm = typemap_check((char*)"build",typemap_lang,p->t,p->name);
|
||||
|
|
@ -353,14 +353,14 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f) {
|
|||
Printv(exc,tm);
|
||||
Replace(exc,"$function",fcall,DOH_REPLACE_ANY);
|
||||
Replace(exc,"$name",decl,DOH_REPLACE_ANY);
|
||||
Printv(f._code,exc,0);
|
||||
Printv(f.code,exc,0);
|
||||
} else if ((tm = fragment_lookup((char*)"except",typemap_lang, t->id))) {
|
||||
Printv(exc,tm);
|
||||
Replace(exc,"$function",fcall,DOH_REPLACE_ANY);
|
||||
Replace(exc,"$name",decl,DOH_REPLACE_ANY);
|
||||
Printv(f._code,exc,0);
|
||||
Printv(f.code,exc,0);
|
||||
} else {
|
||||
Printv(f._code,fcall,0);
|
||||
Printv(f.code,fcall,0);
|
||||
}
|
||||
Delete(fcall);
|
||||
Delete(exc);
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ static char *usage = (char*)"\
|
|||
-version - Print SWIG version number\n\
|
||||
-help - This output.\n\n";
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// check_suffix(char *name)
|
||||
//
|
||||
|
|
|
|||
|
|
@ -102,123 +102,5 @@ void format_string(char *str) {
|
|||
delete newstr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// $Header$
|
||||
// sstring.cxx
|
||||
//
|
||||
// SWIG String class.
|
||||
// This class is used to construct long strings when writing
|
||||
// wrapper functions. It also "mimicks" the C++ streams I/O
|
||||
// library for creating strings. For example :
|
||||
//
|
||||
// str << "hi there" << 3 << "\n";
|
||||
//
|
||||
// Will append the given strings to str.
|
||||
//
|
||||
// The idea here is to provide a mechanism for writing wrapper
|
||||
// functions as strings before writing them out to a file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
String::String() {
|
||||
str = NewString("");
|
||||
}
|
||||
|
||||
String::String(const char *s) {
|
||||
str = NewString(s);
|
||||
}
|
||||
|
||||
String::~String() {
|
||||
Delete(str);
|
||||
}
|
||||
|
||||
char *String::get() const {
|
||||
return Char(str);
|
||||
}
|
||||
|
||||
String &operator<<(String &t,const char *s) {
|
||||
Append(t.str,s);
|
||||
return t;
|
||||
}
|
||||
|
||||
String &operator<<(String &t,const char s) {
|
||||
char temp[2] = { 0, 0 };
|
||||
temp[0] = s;
|
||||
Append(t.str,temp);
|
||||
return t;
|
||||
}
|
||||
|
||||
String &operator<<(String &t,const int a) {
|
||||
char temp[64];
|
||||
sprintf(temp,"%d",a);
|
||||
Append(t.str,temp);
|
||||
return t;
|
||||
}
|
||||
|
||||
String &operator<<(String &t, const String &s) {
|
||||
Append(t.str,s.str);
|
||||
return t;
|
||||
}
|
||||
|
||||
String &String::operator=(const char *s) {
|
||||
Delete(str);
|
||||
str = NewString(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
String &operator>>(const char *s, String &t) {
|
||||
Insert(t.str,0,s);
|
||||
return t;
|
||||
}
|
||||
|
||||
String &operator>>(const String &s, String &t) {
|
||||
Insert(t.str,0,s.str);
|
||||
return t;
|
||||
}
|
||||
|
||||
void String::replace(const char *token, const char *rep) {
|
||||
Replace(str,token,rep,DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
void String::replaceid(const char *token, const char *rep) {
|
||||
Replace(str,token,rep,DOH_REPLACE_ID);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// void String::strip()
|
||||
//
|
||||
// Intelligently strips whitespace from a string. Will not strip
|
||||
// whitespace if it is between two characters that are part of a
|
||||
// legal C identifier. For example 'unsigned int'.
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
void String::strip() {
|
||||
DOH *so = str;
|
||||
char *s = Char(so);
|
||||
char *c, lastchar = 0;
|
||||
int whitespace = 0;
|
||||
|
||||
str = NewString("");
|
||||
c = s;
|
||||
while(*c) {
|
||||
if (!isspace(*c)) {
|
||||
// See if this character doesn't violate our whitespace rules
|
||||
if (whitespace) {
|
||||
if (isalnum(lastchar) || (lastchar == '_') || (lastchar == '$')) {
|
||||
if (isalnum(*c) || (*c == '_') || (*c == '$'))
|
||||
Putc(' ', str);
|
||||
}
|
||||
}
|
||||
Putc(*c,str);
|
||||
lastchar = *c;
|
||||
whitespace = 0;
|
||||
} else {
|
||||
whitespace = 1;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
Delete(so);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -62,31 +62,6 @@ extern int Verbose;
|
|||
#define STAT_READONLY 1
|
||||
#define MAXSCOPE 16
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// String class
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
class String {
|
||||
private:
|
||||
void *str; // String object
|
||||
public:
|
||||
String();
|
||||
String(const char *s);
|
||||
~String();
|
||||
char *get() const;
|
||||
void *doh() { return str; }
|
||||
friend String& operator<<(String&,const char *s);
|
||||
friend String& operator<<(String&,const int);
|
||||
friend String& operator<<(String&,const char);
|
||||
friend String& operator<<(String&,const String&);
|
||||
friend String& operator>>(const char *s, String&);
|
||||
friend String& operator>>(const String&,String&);
|
||||
String& operator=(const char *);
|
||||
void replace(const char *token, const char *rep);
|
||||
void replaceid(const char *id, const char *rep);
|
||||
void strip();
|
||||
};
|
||||
|
||||
#define tab2 " "
|
||||
#define tab4 " "
|
||||
#define tab8 " "
|
||||
|
|
@ -434,6 +409,7 @@ extern "C" {
|
|||
extern void *Preprocessor_define(void *, int);
|
||||
extern int Swig_insert_file(const void *filename, void *outfile);
|
||||
extern FILE *Swig_open(const void *filename);
|
||||
extern char *Swig_copy_string(const char *s);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
@ -447,16 +423,10 @@ private:
|
|||
public:
|
||||
WrapperFunction();
|
||||
~WrapperFunction();
|
||||
String def;
|
||||
String locals;
|
||||
String code;
|
||||
String init;
|
||||
void *_def; /* Migration code */
|
||||
void *_locals;
|
||||
void *_code;
|
||||
void *_init;
|
||||
void *def; /* Migration code */
|
||||
void *locals;
|
||||
void *code;
|
||||
void print(void *f);
|
||||
void print(String &f);
|
||||
void add_local(char *type, char *name, char *defvalue = 0);
|
||||
char *new_local(char *type, char *name, char *defvalue = 0);
|
||||
static void del_type(void *obj);
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
|||
char temp[10];
|
||||
for (int i = 0; i < t->array_dimensions(); i++) {
|
||||
sprintf(temp,"$dim%d",i);
|
||||
Replace(f._locals,temp,t->get_dimension(i), DOH_REPLACE_ANY);
|
||||
Replace(f.locals,temp,t->get_dimension(i), DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,9 @@ extern "C" {
|
|||
WrapperFunction::WrapperFunction() {
|
||||
h = NewHash();
|
||||
localh = NewHash();
|
||||
_def = def.doh();
|
||||
_locals = locals.doh();
|
||||
_code = code.doh();
|
||||
_init = init.doh();
|
||||
def = NewString("");
|
||||
locals = NewString("");
|
||||
code = NewString("");
|
||||
}
|
||||
|
||||
WrapperFunction::~WrapperFunction() {
|
||||
|
|
@ -77,32 +76,12 @@ void WrapperFunction::print(DOHFile *f) {
|
|||
while (key) {
|
||||
s = Getattr(localh,key);
|
||||
Delitem(s,DOH_END);
|
||||
Printv(_locals,tab4,s,";\n",0);
|
||||
Printv(locals,tab4,s,";\n",0);
|
||||
key = Nextkey(localh);
|
||||
}
|
||||
Printf(f,"%s\n",_def);
|
||||
Printf(f,"%s",_locals);
|
||||
Printf(f,"%s\n",_code);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Print out a wrapper function.
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
void WrapperFunction::print(String &f) {
|
||||
DOHString *s;
|
||||
DOH *key;
|
||||
key = Firstkey(localh);
|
||||
while (key) {
|
||||
s = Getattr(localh,key);
|
||||
Delitem(s,DOH_END);
|
||||
Printv(_locals,tab4,s,";\n",0);
|
||||
key = Nextkey(localh);
|
||||
}
|
||||
|
||||
f << def << "\n"
|
||||
<< locals << "\n"
|
||||
<< code << "\n";
|
||||
Printf(f,"%s\n",def);
|
||||
Printf(f,"%s",locals);
|
||||
Printf(f,"%s\n",code);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -206,9 +185,9 @@ char *WrapperFunction::new_local(char *type, char *name, char *defarg) {
|
|||
Printf(new_name,"%s",c);
|
||||
// Successful, write some wrapper code
|
||||
if (!defarg)
|
||||
Printv(_locals,tab4,type, " ", new_name, ";\n");
|
||||
Printv(locals,tab4,type, " ", new_name, ";\n");
|
||||
else
|
||||
Printv(_locals,tab4,type, " ", new_name, " = ", defarg, ";\n");
|
||||
Printv(locals,tab4,type, " ", new_name, " = ", defarg, ";\n");
|
||||
|
||||
// Need to strip off the array symbols now
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue