Fix a few bugs in the tcl module related to clientdata propagation.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6357 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
John Lenz 2004-10-07 02:31:14 +00:00
commit 0e57357472
16 changed files with 257 additions and 63 deletions

View file

@ -43,6 +43,7 @@ static int nspace = 0;
static String *init_name = 0;
static String *ns_name = 0;
static int have_constructor;
static String *constructor_name;
static int have_destructor;
static int have_base_classes;
static String *destructor_action = 0;
@ -747,6 +748,7 @@ public:
/* Handle inheritance */
String *base_class = NewString("");
String *base_class_names = NewString("");
if( itcl ) {
base_classes = NewString("");
@ -772,10 +774,11 @@ public:
// Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL);
// Printf(base_class,"&_wrap_class_%s",bmangle);
Printf(base_class,"0");
Printf(base_class_names,"\"%s *\",", SwigType_namestr(bname));
/* Put code to register base classes in init function */
Printf(f_init,"/* Register base : %s */\n", bmangle);
Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname));
//Printf(f_init,"/* Register base : %s */\n", bmangle);
//Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname));
b = Next(b);
index++;
Putc(',',base_class);
@ -885,13 +888,17 @@ public:
};
Printv(f_wrappers,"static swig_class *swig_",mangled_classname,"_bases[] = {", base_class,"0};\n", NIL);
Printv(f_wrappers,"static char *swig_",mangled_classname,"_base_names[] = {", base_class_names,"0};\n", NIL);
Delete(base_class);
Delete(base_class_names);
Printv(f_wrappers, "swig_class _wrap_class_", mangled_classname, " = { \"", class_name,
"\", &SWIGTYPE", SwigType_manglestr(t), ",",NIL);
if (have_constructor) {
Printf(f_wrappers,"%s", Swig_name_wrapper(Swig_name_construct(class_name)));
Printf(f_wrappers,"%s", Swig_name_wrapper(Swig_name_construct(constructor_name)));
Delete(constructor_name);
constructor_name = 0;
} else {
Printf(f_wrappers,"0");
}
@ -900,7 +907,8 @@ public:
} else {
Printf(f_wrappers,",0");
}
Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname,"_bases };\n", NIL);
Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname,"_bases,",
"swig_", mangled_classname, "_base_names };\n", NIL);
if( !itcl ) {
Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL);
@ -1141,6 +1149,7 @@ public:
}
}
constructor_name = NewString(Getattr(n, "sym:name"));
have_constructor = 1;
return SWIG_OK;
}

View file

@ -1420,44 +1420,20 @@ List *SwigType_equivalent_mangle(String *ms, Hash *checked, Hash *found) {
* ----------------------------------------------------------------------------- */
static
String *SwigType_clientdata_collect(String *ms, Hash *checked) {
Hash *ch;
String *SwigType_clientdata_collect(String *ms) {
Hash *mh;
String *clientdata = 0;
if (checked) {
ch = checked;
} else {
ch = NewHash();
}
if (Getattr(ch,ms)) goto check_exit; /* Already checked this type */
Setattr(ch, ms, "1");
mh = Getattr(r_mangled,ms);
if (mh) {
Iterator ki;
ki = First(mh);
while (ki.key) {
Hash *rh;
Setattr(ch,ki.key,"1");
clientdata = Getattr(r_clientdata,ki.key);
if (clientdata) goto check_exit;
rh = Getattr(r_resolved,ki.key);
if (rh) {
Iterator rk;
rk = First(rh);
while (rk.key) {
clientdata = SwigType_clientdata_collect(rk.key,ch);
if (clientdata) goto check_exit;
rk = Next(rk);
}
}
if (clientdata) break;
ki = Next(ki);
}
}
check_exit:
if (!checked) {
Delete(ch);
}
return clientdata;
}
@ -1671,6 +1647,9 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
Printf(stdout,"---conversions---\n");
Printf(stdout,"%s\n", conversions);
Printf(stdout,"---r_clientdata---\n");
Printf(stdout,"%s\n", r_clientdata);
#endif
table = NewString("");
types = NewString("");
@ -1691,7 +1670,7 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", ki.key, i);
Printv(types,"static swig_type_info _swigt_", ki.key, "[] = {", NIL);
cd = SwigType_clientdata_collect(ki.key,0);
cd = SwigType_clientdata_collect(ki.key);
if (!cd) cd = "0";
lt = Getattr(r_ltype,ki.key);
rt = SwigType_typedef_resolve_all(lt);