massive typemap unification

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-18 13:24:15 +00:00
commit 7e5e4fd1f9
144 changed files with 6378 additions and 7248 deletions

View file

@ -156,11 +156,9 @@ public:
apply = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-cppcast") == 0) {
/* Turn on new value wrapper mpde */
cppcast = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nocppcast") == 0) {
/* Turn on new value wrapper mpde */
cppcast = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nortti") == 0) {
@ -187,7 +185,6 @@ public:
}
if (cppcast) {
/* Turn on new value wrapper mpde */
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
}
@ -1352,7 +1349,7 @@ public:
/* Insert cleanup code */
for (p = l; p;) {
if ((tm = Getattr(p,"tmap:freearg"))) {
if (!checkAttribute(p,"tmap:in:numinputs","0") && (tm = Getattr(p,"tmap:freearg"))) {
Replaceall(tm,"$source",Getattr(p,"lname"));
Printv(cleanup,tm,"\n",NIL);
p = Getattr(p,"tmap:freearg:next");

View file

@ -118,6 +118,8 @@ usage = "\
Ruby Options (available with -ruby)\n\
-globalmodule - Wrap everything into the global module\n\
-minherit - Attempt to support multiple inheritance\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-cppcast - Enable C++ casting operators\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-feature <name> - Set feature name to <name> (used by `require')\n";
@ -205,6 +207,7 @@ public:
* --------------------------------------------------------------------- */
virtual void main(int argc, char *argv[]) {
int cppcast = 1;
/* Set location of SWIG library */
SWIG_library_directory("ruby");
@ -229,6 +232,12 @@ public:
multipleInheritance = true;
director_multiple_inheritance = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-cppcast") == 0) {
cppcast = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nocppcast") == 0) {
cppcast = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-prefix") == 0) {
if (argv[i+1]) {
char *name = argv[i+1];
@ -245,6 +254,11 @@ public:
}
}
if (cppcast) {
/* Turn on new value wrapper mpde */
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
}
/* Add a symbol to the parser for conditional compilation */
Preprocessor_define("SWIGRUBY 1", 0);
@ -889,7 +903,7 @@ public:
void insertCleanupCode(ParmList *l, String *cleanup) {
String *tm;
for (Parm *p = l; p; ) {
if ((tm = Getattr(p,"tmap:freearg"))) {
if (!checkAttribute(p,"tmap:in:numinputs","0") && (tm = Getattr(p,"tmap:freearg"))) {
Replaceall(tm,"$source",Getattr(p,"lname"));
Printv(cleanup,tm,"\n",NIL);
p = Getattr(p,"tmap:freearg:next");
@ -1132,12 +1146,12 @@ public:
/* Now write the wrapper function itself */
if (current == CONSTRUCTOR_ALLOCATE) {
Printf(f->def, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n");
Printv(f->def, "static VALUE\n", wname, "(VALUE self) {", NIL);
Printv(f->def, "SWIGINTERN VALUE\n", wname, "(VALUE self) {", NIL);
Printf(f->def, "#else\n");
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
Printf(f->def, "#endif\n");
} else if (current == CONSTRUCTOR_INITIALIZE) {
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
if (!varargs) {
Printf(f->code,"if ((argc < %d) || (argc > %d))\n", numreq-start, numarg-start);
} else {
@ -1145,7 +1159,7 @@ public:
}
Printf(f->code,"rb_raise(rb_eArgError, \"wrong # of arguments(%%d for %d)\",argc);\n",numreq-start);
} else {
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
if (!varargs) {
Printf(f->code,"if ((argc < %d) || (argc > %d))\n", numreq-start, numarg-start);
} else {
@ -1379,7 +1393,7 @@ public:
String *wname = Swig_name_wrapper(symname);
Printv(f->def,
"static VALUE ", wname,
"SWIGINTERN VALUE ", wname,
"(int nargs, VALUE *args, VALUE self) {",
NIL);
@ -1438,7 +1452,7 @@ public:
/* create getter */
getfname = NewString(Swig_name_get(iname));
Printv(getf->def, "static VALUE\n", getfname, "(", NIL);
Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL);
Printf(getf->def, "VALUE self");
Printf(getf->def, ") {");
Wrapper_add_local(getf,"_val","VALUE _val");
@ -1461,7 +1475,7 @@ public:
} else {
/* create setter */
setfname = NewString(Swig_name_set(iname));
Printv(setf->def, "static VALUE\n", setfname, "(VALUE self, ", NIL);
Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL);
Printf(setf->def, "VALUE _val) {");
tm = Swig_typemap_lookup_new("varin",n,name,0);
@ -1594,6 +1608,7 @@ public:
value = Char(wname);
}
String *tm = Swig_typemap_lookup_new("constant", n, value, 0);
if (!tm) tm = Swig_typemap_lookup_new("constcode", n, value, 0);
if (tm) {
Replaceall(tm, "$source", value);
Replaceall(tm, "$target", iname);
@ -1962,7 +1977,7 @@ public:
String *freebody = NewString("");
Printv(freefunc, "free_", klass->mname, NIL);
Printv(freebody, "static void\n",
Printv(freebody, "SWIGINTERN void\n",
freefunc, "(", klass->type, " *", Swig_cparm_name(0,0), ") {\n",
tab4, NIL);

View file

@ -85,6 +85,7 @@ public:
* ------------------------------------------------------------ */
virtual void main(int argc, char *argv[]) {
int cppcast = 1;
SWIG_library_directory("tcl");
@ -113,11 +114,22 @@ public:
} else if (strcmp(argv[i],"-nosafe") == 0) {
nosafe = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-cppcast") == 0) {
cppcast = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nocppcast") == 0) {
cppcast = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stdout);
}
}
}
if (cppcast) {
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
}
Preprocessor_define("SWIGTCL 1",0);
Preprocessor_define("SWIGTCL8 1", 0);
SWIG_typemap_lang("tcl8");
@ -283,8 +295,11 @@ public:
outarg = NewString("");
argstr = NewString("\"");
args = NewString("");
f = NewWrapper();
Wrapper_add_local(f,"resultobj", "Tcl_Obj *resultobj = NULL");
String *wname = Swig_name_wrapper(iname);
if (overname) {
Append(wname, overname);
@ -292,7 +307,7 @@ public:
Setattr(n,"wrap:name",wname);
Printv(f->def,
"static int\n ", wname, "(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {",
"SWIGINTERN int\n ", wname, "(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {",
NIL);
/* Print out variables for storing arguments. */
@ -404,7 +419,7 @@ public:
/* Insert cleanup code */
for (i = 0, p = parms; p; i++) {
if ((tm = Getattr(p,"tmap:freearg"))) {
if (!checkAttribute(p,"tmap:in:numinputs","0") && (tm = Getattr(p,"tmap:freearg"))) {
Replaceall(tm,"$source",Getattr(p,"lname"));
Printv(cleanup,tm,"\n",NIL);
p = Getattr(p,"tmap:freearg:next");
@ -417,8 +432,8 @@ public:
for (i=0,p = parms; p;i++) {
if ((tm = Getattr(p,"tmap:argout"))) {
Replaceall(tm,"$source",Getattr(p,"lname"));
Replaceall(tm,"$target","(Tcl_GetObjResult(interp))");
Replaceall(tm,"$result","(Tcl_GetObjResult(interp))");
Replaceall(tm,"$target","resultobj");
Replaceall(tm,"$result","resultobj");
Replaceall(tm,"$arg",Getattr(p,"emit:input"));
Replaceall(tm,"$input",Getattr(p,"emit:input"));
Printv(outarg,tm,"\n",NIL);
@ -436,8 +451,8 @@ public:
/* Return value if necessary */
if ((tm = Swig_typemap_lookup_new("out",n,"result",0))) {
Replaceall(tm,"$source", "result");
Replaceall(tm,"$target", "Tcl_GetObjResult(interp)");
Replaceall(tm,"$result", "Tcl_GetObjResult(interp)");
Replaceall(tm,"$target", "resultobj");
Replaceall(tm,"$result", "resultobj");
if(GetFlag(n,"feature:new")) {
Replaceall(tm,"$owner","1");
} else {
@ -467,6 +482,7 @@ public:
Replaceall(tm,"$source","result");
Printf(f->code,"%s\n", tm);
}
Printv(f->code, "if (resultobj) Tcl_SetObjResult(interp, resultobj);\n", NIL);
Printv(f->code, "return TCL_OK;\n", NIL);
Printv(f->code, "fail:\n", cleanup, "return TCL_ERROR;\n", NIL);
Printv(f->code,"}\n", NIL);
@ -494,7 +510,7 @@ public:
String *dname = Swig_name_wrapper(iname);
Printv(df->def,
"static int\n", dname,
"SWIGINTERN int\n", dname,
"(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {",
NIL);
Printf(df->code,"Tcl_Obj *CONST *argv = objv+1;\n");
@ -541,7 +557,7 @@ public:
/* Create a function for getting a variable */
getf = NewWrapper();
getname = Swig_name_wrapper(Swig_name_get(iname));
Printv(getf->def,"static char *",getname,"(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
Printv(getf->def,"SWIGINTERN char *",getname,"(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
Wrapper_add_local(getf,"value", "Tcl_Obj *value = 0");
if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) {
@ -568,7 +584,7 @@ public:
if (!GetFlag(n,"feature:immutable")) {
setf = NewWrapper();
setname = Swig_name_wrapper(Swig_name_set(iname));
Printv(setf->def,"static char *",setname, "(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
Printv(setf->def,"SWIGINTERN char *",setname, "(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
Wrapper_add_local(setf,"value", "Tcl_Obj *value = 0");
Wrapper_add_local(setf,"name1o", "Tcl_Obj *name1o = 0");
@ -597,7 +613,7 @@ public:
static int readonlywrap = 0;
if (!readonlywrap) {
Wrapper *ro = NewWrapper();
Printf(ro->def, "static const char *swig_readonly(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {");
Printf(ro->def, "SWIGINTERN const char *swig_readonly(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {");
Printv(ro->code, "return (char*) \"Variable is read-only\";\n", "}\n", NIL);
Wrapper_print(ro,f_wrappers);
readonlywrap = 1;
@ -621,7 +637,8 @@ public:
String *iname = Getattr(n,"sym:name");
String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s",ns_name,iname);
SwigType *type = Getattr(n,"type");
String *value = Getattr(n,"value");
String *rawval = Getattr(n,"rawval");
String *value = rawval ? rawval : Getattr(n,"value");
String *tm;
if (!addSymbol(iname,n)) return SWIG_ERROR;
@ -734,7 +751,7 @@ public:
// Register the class structure with the type checker
/* Printf(f_init,"SWIG_TypeClientData(SWIGTYPE%s, (void *) &_wrap_class_%s);\n", SwigType_manglestr(t), mangled_classname); */
if (have_destructor) {
Printv(f_wrappers, "static void swig_delete_", class_name, "(void *obj) {\n", NIL);
Printv(f_wrappers, "SWIGINTERN void swig_delete_", class_name, "(void *obj) {\n", NIL);
if (destructor_action) {
Printv(f_wrappers, SwigType_str(rt,"arg1"), " = (", SwigType_str(rt,0), ") obj;\n", NIL);
Printv(f_wrappers, destructor_action, NIL);