- Improve the runtime type sytesm
- Update all languages to new type system - Add DohSortList function - Fix mzscheme Examples/Makefile git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6930 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
58cd593dae
commit
f6964f285f
48 changed files with 1383 additions and 1021 deletions
|
|
@ -292,6 +292,7 @@ extern int DohCopyto(DOHFile *input, DOHFile *output);
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
extern DOHList *DohNewList();
|
||||
extern void DohSortList(DOH *lo, int (*cmp)(DOH *, DOH *));
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Hash
|
||||
|
|
@ -388,6 +389,7 @@ extern void DohMemoryDebug(void);
|
|||
#define First DohFirst
|
||||
#define Next DohNext
|
||||
#define Iterator DohIterator
|
||||
#define SortList DohSortList
|
||||
#endif
|
||||
|
||||
#ifdef NIL
|
||||
|
|
|
|||
|
|
@ -361,3 +361,18 @@ DohNewList() {
|
|||
return DohObjMalloc(&DohListType,l);
|
||||
}
|
||||
|
||||
static int (*List_sort_compare_func)(DOH *, DOH *);
|
||||
static int List_qsort_compare(const void *a, const void *b) {
|
||||
return List_sort_compare_func(*((DOH **)a), *((DOH **)b));
|
||||
}
|
||||
|
||||
/* Sort a list */
|
||||
void DohSortList(DOH *lo, int (*cmp)(DOH *, DOH *)) {
|
||||
List *l = (List *) ObjData(lo);
|
||||
if (cmp) {
|
||||
List_sort_compare_func = cmp;
|
||||
} else {
|
||||
List_sort_compare_func = DohCmp;
|
||||
}
|
||||
qsort(l->items, l->nitems, sizeof(DOH *), List_qsort_compare);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,12 +377,12 @@ public:
|
|||
/* Simple linkage; we have to export the SWIG_init function. The user can
|
||||
rename the function by a #define. */
|
||||
Printf (f_runtime, "extern void\nSWIG_init (void)\n;\n");
|
||||
Printf (f_init, "extern void\nSWIG_init (void)\n{\n");
|
||||
Printf (f_init, "#define SWIG_GUILE_INIT_STATIC static\n");
|
||||
break;
|
||||
default:
|
||||
/* Other linkage; we make the SWIG_init function static */
|
||||
Printf (f_runtime, "static void\nSWIG_init (void)\n;\n");
|
||||
Printf (f_init, "static void\nSWIG_init (void)\n{\n");
|
||||
Printf (f_init, "#define SWIG_GUILE_INIT_STATIC extern\n");
|
||||
break;
|
||||
}
|
||||
if (CPlusPlus) {
|
||||
|
|
|
|||
|
|
@ -155,30 +155,28 @@ public:
|
|||
|
||||
SwigType_emit_type_table (f_runtime, f_wrappers);
|
||||
if (!noinit) {
|
||||
Printf(f_init, "Scheme_Object *scheme_reload(Scheme_Env *env) {\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "\tScheme_Env *menv = scheme_primitive_module(scheme_intern_symbol(\"%s\"), env);\n", module);
|
||||
}
|
||||
else {
|
||||
Printf(f_init, "\tScheme_Env *menv = env;\n");
|
||||
}
|
||||
Printf(f_init, "%s\n", Char(init_func_def));
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "\tscheme_finish_primitive_module(menv);\n");
|
||||
}
|
||||
Printf (f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf (f_init, "}\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "#define SWIG_MZSCHEME_CREATE_MENV(env) scheme_primitive_module(scheme_intern_symbol(\"%s\"), env)\n", module);
|
||||
}
|
||||
else {
|
||||
Printf(f_init,"#define SWIG_MZSCHEME_CREATE_MENV(env) (env)\n");
|
||||
}
|
||||
Printf(f_init, "%s\n", Char(init_func_def));
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "\tscheme_finish_primitive_module(menv);\n");
|
||||
}
|
||||
Printf (f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf (f_init, "}\n");
|
||||
|
||||
Printf(f_init,"Scheme_Object *scheme_module_name(void) {\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, " return scheme_intern_symbol((char*)\"%s\");\n", module);
|
||||
}
|
||||
else {
|
||||
Printf(f_init," return scheme_make_symbol((char*)\"%s\");\n", module);
|
||||
}
|
||||
Printf(f_init,"}\n");
|
||||
Printf(f_init,"Scheme_Object *scheme_module_name(void) {\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, " return scheme_intern_symbol((char*)\"%s\");\n", module);
|
||||
} else {
|
||||
Printf(f_init," return scheme_make_symbol((char*)\"%s\");\n", module);
|
||||
}
|
||||
Printf(f_init,"}\n");
|
||||
}
|
||||
|
||||
/* Close all of the files */
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ public:
|
|||
Printf( f_mlibody,
|
||||
"val int_to_enum : c_enum_type -> int -> c_obj\n" );
|
||||
Printf( f_init,
|
||||
"SWIGEXT void f_%s_init() {\n"
|
||||
"#define SWIG_init f_%s_init\n"
|
||||
"%s"
|
||||
"}\n",
|
||||
module, init_func_def );
|
||||
|
|
|
|||
|
|
@ -733,12 +733,8 @@ public:
|
|||
* things are being called in the wrong order
|
||||
*/
|
||||
|
||||
Printf(s_init,"PHP_MINIT_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init,
|
||||
" int i;\n"
|
||||
" for (i = 0; swig_types_initial[i]; i++) {\n"
|
||||
" swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);\n"
|
||||
" }\n");
|
||||
Printf(s_init,"#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module);
|
||||
|
||||
/* Emit all of the code */
|
||||
Language::top(n);
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ private:
|
|||
File *f_header;
|
||||
File *f_wrappers;
|
||||
File *f_init;
|
||||
File *f_initbeforefunc;
|
||||
|
||||
bool useGlobalModule;
|
||||
bool multipleInheritance;
|
||||
|
|
@ -185,6 +186,7 @@ public:
|
|||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
f_initbeforefunc = 0;
|
||||
useGlobalModule = false;
|
||||
multipleInheritance = false;
|
||||
director_prot_ctor_code = NewString("");
|
||||
|
|
@ -391,6 +393,7 @@ public:
|
|||
f_wrappers = NewString("");
|
||||
f_directors_h = NewString("");
|
||||
f_directors = NewString("");
|
||||
f_initbeforefunc = NewString("");
|
||||
|
||||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header",f_header);
|
||||
|
|
@ -399,6 +402,7 @@ public:
|
|||
Swig_register_filebyname("init",f_init);
|
||||
Swig_register_filebyname("director",f_directors);
|
||||
Swig_register_filebyname("director_h",f_directors_h);
|
||||
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
|
||||
|
||||
modvar = 0;
|
||||
current = NO_CPP;
|
||||
|
|
@ -457,9 +461,9 @@ public:
|
|||
|
||||
Printv(f_init,
|
||||
"\n",
|
||||
"for (i = 0; swig_types_initial[i]; i++) {\n",
|
||||
"swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);\n",
|
||||
"SWIG_define_class(swig_types[i]);\n",
|
||||
"SWIG_InitializeModule(0);\n",
|
||||
"for (i = 0; i < swig_module.size; i++) {\n",
|
||||
"SWIG_define_class(swig_module.types[i]);\n",
|
||||
"}\n",
|
||||
NIL);
|
||||
Printf(f_init,"\n");
|
||||
|
|
@ -482,11 +486,13 @@ public:
|
|||
}
|
||||
|
||||
Dump(f_wrappers,f_runtime);
|
||||
Dump(f_initbeforefunc, f_runtime);
|
||||
Wrapper_pretty_print(f_init,f_runtime);
|
||||
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
Close(f_runtime);
|
||||
Delete(f_runtime);
|
||||
|
||||
|
|
|
|||
|
|
@ -896,7 +896,7 @@ public:
|
|||
Delete(base_class);
|
||||
Delete(base_class_names);
|
||||
|
||||
Printv(f_wrappers, "swig_class _wrap_class_", mangled_classname, " = { \"", class_name,
|
||||
Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name,
|
||||
"\", &SWIGTYPE", SwigType_manglestr(t), ",",NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
|
|
@ -912,7 +912,7 @@ public:
|
|||
Printf(f_wrappers,",0");
|
||||
}
|
||||
Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname,"_bases,",
|
||||
"swig_", mangled_classname, "_base_names };\n", NIL);
|
||||
"swig_", mangled_classname, "_base_names, &swig_module };\n", NIL);
|
||||
|
||||
if( !itcl ) {
|
||||
Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL);
|
||||
|
|
|
|||
|
|
@ -1745,6 +1745,24 @@ void SwigType_inherit_equiv(File *out) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Helper function to sort the mangled list */
|
||||
static int SwigType_compare_mangled(DOH *a, DOH *b) {
|
||||
return strcmp(DohData(a), DohData(b));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_get_sorted_mangled_list()
|
||||
*
|
||||
* Returns the sorted list of mangled type names that should be exported into the
|
||||
* wrapper file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
List *SwigType_get_sorted_mangled_list() {
|
||||
List *l = Keys(r_mangled);
|
||||
SortList(l, SwigType_compare_mangled);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_type_table()
|
||||
*
|
||||
|
|
@ -1754,7 +1772,9 @@ void SwigType_inherit_equiv(File *out) {
|
|||
void
|
||||
SwigType_emit_type_table(File *f_forward, File *f_table) {
|
||||
Iterator ki;
|
||||
String *types, *table;
|
||||
String *types, *table, *cast, *cast_init, *cast_temp;
|
||||
Hash *imported_types;
|
||||
List *mangled_list;
|
||||
int i = 0;
|
||||
|
||||
if (!r_mangled) {
|
||||
|
|
@ -1789,11 +1809,17 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
#endif
|
||||
table = NewString("");
|
||||
types = NewString("");
|
||||
Printf(table,"static swig_type_info *swig_types_initial[] = {\n");
|
||||
|
||||
ki = First(r_mangled);
|
||||
cast = NewString("");
|
||||
cast_init = NewString("");
|
||||
imported_types = NewHash("");
|
||||
|
||||
Printf(table,"static swig_type_info *swig_type_initial[] = {\n");
|
||||
Printf(cast_init, "static swig_cast_info *swig_cast_initial[] = {\n");
|
||||
|
||||
Printf(f_forward,"\n/* -------- TYPES TABLE (BEGIN) -------- */\n\n");
|
||||
while (ki.key) {
|
||||
|
||||
mangled_list = SwigType_get_sorted_mangled_list();
|
||||
for (ki = First(mangled_list); ki.item; ki = Next(ki)) {
|
||||
List *el;
|
||||
Iterator ei;
|
||||
SwigType *lt;
|
||||
|
|
@ -1803,12 +1829,19 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
String *rn;
|
||||
const String *cd;
|
||||
|
||||
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", ki.key, i);
|
||||
Printv(types,"static swig_type_info _swigt_", ki.key, "[] = {", NIL);
|
||||
cast_temp = NewString("");
|
||||
|
||||
cd = SwigType_clientdata_collect(ki.key);
|
||||
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d]\n", ki.item, i);
|
||||
Printv(types,"static swig_type_info _swigt_", ki.item, " = {", NIL);
|
||||
Printf(table, " &_swigt_%s,\n", ki.item);
|
||||
Printf(cast_temp, "static swig_cast_info _swigc_%s[] = {", ki.item);
|
||||
Printf(cast_init, " _swigc_%s,\n", ki.item);
|
||||
i++;
|
||||
|
||||
cd = SwigType_clientdata_collect(ki.item);
|
||||
if (!cd) cd = "0";
|
||||
lt = Getattr(r_ltype,ki.key);
|
||||
|
||||
lt = Getattr(r_ltype,ki.item);
|
||||
rt = SwigType_typedef_resolve_all(lt);
|
||||
/* we save the original type and the fully resolved version */
|
||||
ln = SwigType_lstr(lt,0);
|
||||
|
|
@ -1818,35 +1851,58 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
} else {
|
||||
nt = NewStringf("%s|%s", rn, ln);
|
||||
}
|
||||
Printv(types,"{\"", ki.key, "\", 0, \"",nt,"\", ", cd, ", 0, 0, 0},", NIL);
|
||||
el = SwigType_equivalent_mangle(ki.key,0,0);
|
||||
Printf(types, "\"%s\", \"%s\", 0, 0, %s};\n", ki.item, nt, cd);
|
||||
|
||||
el = SwigType_equivalent_mangle(ki.item,0,0);
|
||||
for (ei = First(el); ei.item; ei = Next(ei)) {
|
||||
String *ckey;
|
||||
String *conv;
|
||||
ckey = NewStringf("%s+%s", ei.item, ki.key);
|
||||
ckey = NewStringf("%s+%s", ei.item, ki.item);
|
||||
conv = Getattr(conversions,ckey);
|
||||
if (conv) {
|
||||
Printf(types,"{\"%s\", %s, 0, 0, 0, 0, 0},", ei.item, conv);
|
||||
Printf(cast_temp," {&_swigt_%s, %s, 0, 0},", ei.item, conv);
|
||||
} else {
|
||||
Printf(types,"{\"%s\", 0, 0, 0, 0, 0, 0},", ei.item);
|
||||
Printf(cast_temp," {&_swigt_%s, 0, 0, 0},", ei.item);
|
||||
}
|
||||
Delete(ckey);
|
||||
|
||||
if (!Getattr(r_mangled, ei.item) && !Getattr(imported_types, ei.item)) {
|
||||
Printf(f_forward, "#define SWIGTYPE%s swig_types[%i]\n", ei.item, i);
|
||||
Printf(types, "static swig_type_info _swigt_%s = {\"%s\", 0, 0, 0, 0};\n", ei.item, ei.item);
|
||||
Printf(table, " &_swigt_%s,\n", ei.item);
|
||||
Printf(cast, "static swig_cast_info _swigc_%s[] = {{&_swigt_%s, 0, 0, 0},{0, 0, 0, 0}};\n",
|
||||
ei.item, ei.item);
|
||||
Printf(cast_init, " _swigc_%s,\n", ei.item);
|
||||
i++;
|
||||
|
||||
Setattr(imported_types, ei.item, "1");
|
||||
}
|
||||
}
|
||||
Delete(el);
|
||||
Printf(cast,"%s{0, 0, 0, 0}};\n", cast_temp);
|
||||
Delete(cast_temp);
|
||||
Delete(nt);
|
||||
Delete(rt);
|
||||
Printf(types,"{0, 0, 0, 0, 0, 0, 0}};\n");
|
||||
Printv(table, "_swigt_", ki.key, ", \n", NIL);
|
||||
ki = Next(ki);
|
||||
i++;
|
||||
}
|
||||
Delete(mangled_list);
|
||||
|
||||
Printf(table, "0\n};\n");
|
||||
Printf(f_forward,"static swig_type_info *swig_types[%d];\n", i+1);
|
||||
Printf(f_forward,"\n/* -------- TYPES TABLE (END) -------- */\n\n");
|
||||
Printf(table, "};\n");
|
||||
Printf(cast_init, "};\n");
|
||||
Printf(f_table,"%s\n", types);
|
||||
Printf(f_table,"%s\n", table);
|
||||
Printf(f_table,"%s\n", cast);
|
||||
Printf(f_table,"%s\n", cast_init);
|
||||
Printf(f_table,"\n/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */\n\n");
|
||||
|
||||
Printf(f_forward,"static swig_type_info *swig_types[%d];\n", i);
|
||||
Printf(f_forward,"static swig_module_info swig_module = {swig_types, %d, 0, 0, 0, 0};\n", i);
|
||||
Printf(f_forward,"#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)\n");
|
||||
Printf(f_forward,"#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)\n");
|
||||
Printf(f_forward,"\n/* -------- TYPES TABLE (END) -------- */\n\n");
|
||||
|
||||
Delete(types);
|
||||
Delete(table);
|
||||
Delete(cast);
|
||||
Delete(cast_init);
|
||||
Delete(imported_types);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue