From: <xav...@us...> - 2009-07-12 20:53:21
|
Revision: 11388 http://swig.svn.sourceforge.net/swig/?rev=11388&view=rev Author: xavier98 Date: 2009-07-12 20:23:19 +0000 (Sun, 12 Jul 2009) Log Message: ----------- small fixes to make octave module compatible with octave 3.2 Modified Paths: -------------- trunk/Examples/test-suite/octave/empty_runme.m trunk/Lib/octave/octrun.swg trunk/Lib/octave/octruntime.swg trunk/Source/Modules/octave.cxx Modified: trunk/Examples/test-suite/octave/empty_runme.m =================================================================== --- trunk/Examples/test-suite/octave/empty_runme.m 2009-07-12 00:47:34 UTC (rev 11387) +++ trunk/Examples/test-suite/octave/empty_runme.m 2009-07-12 20:23:19 UTC (rev 11388) @@ -1 +1,15 @@ +printf("begin\n"); +who global empty +printf("after load\n"); +who global + +#clear -g +printf("after clear\n"); +who global + +#clear empty +printf("after clear specific\n"); +who global + +printf("before shutdown\n"); Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2009-07-12 00:47:34 UTC (rev 11387) +++ trunk/Lib/octave/octrun.swg 2009-07-12 20:23:19 UTC (rev 11388) @@ -439,9 +439,14 @@ install_builtin_function(it->second.first->method, it->first, it->second.first->doc?it->second.first->doc:std::string()); else if (it->second.second.is_defined()) { +#if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(it->first, true)); +#else + symbol_table::mark_global(it->first); +#endif set_global_value(it->first, it->second.second); +#if USE_OCTAVE_API_VERSION<37 octave_swig_type *ost = Swig::swig_value_deref(it->second.second); if (ost) { const char* h = ost->help_text(); @@ -450,6 +455,7 @@ sr->document(h); } } +#endif } } } @@ -1352,6 +1358,10 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) { octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *)); const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION; +#if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(module_var, true)); +#else + symbol_table::mark_global(module_var); +#endif set_global_value(module_var, ov); } Modified: trunk/Lib/octave/octruntime.swg =================================================================== --- trunk/Lib/octave/octruntime.swg 2009-07-12 00:47:34 UTC (rev 11387) +++ trunk/Lib/octave/octruntime.swg 2009-07-12 20:23:19 UTC (rev 11388) @@ -72,11 +72,32 @@ module_ns->install_global(); module_ns->decref(); +#if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true)); +#else + symbol_table::mark_global(SWIG_name_d); +#endif set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns)); +#if USE_OCTAVE_API_VERSION>=37 + mlock(); +#endif + return octave_value_list(); } +// workaround bug in octave where installing global variable of custom type and then +// exiting without explicitly clearing the variable causes octave to segfault. +#if USE_OCTAVE_API_VERSION>=37 +struct oct_file_unload { + ~oct_file_unload() { + string_vector vars = symbol_table::global_variable_names(); + for (int i = 0; i < vars.length(); i++) + symbol_table::clear_global(vars[i]); + } +}; +static oct_file_unload __unload; +#endif + %} Modified: trunk/Source/Modules/octave.cxx =================================================================== --- trunk/Source/Modules/octave.cxx 2009-07-12 00:47:34 UTC (rev 11387) +++ trunk/Source/Modules/octave.cxx 2009-07-12 20:23:19 UTC (rev 11388) @@ -13,7 +13,8 @@ static const char *usage = (char *) "\ Octave Options (available with -octave)\n\ - (none yet)\n\n"; + -api <N> - Generate code that assume octave API N [default: 37]\n\ + \n"; class OCTAVE:public Language { @@ -35,6 +36,8 @@ int have_destructor; String *constructor_name; + int api_version; + Hash *docs; public: @@ -53,6 +56,7 @@ director_multiple_inheritance = 1; director_language = 1; docs = NewHash(); + api_version = 37; } virtual void main(int argc, char *argv[]) { @@ -60,6 +64,15 @@ if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stderr); + } else if (strcmp(argv[i], "-api") == 0) { + if (argv[i + 1]) { + api_version = atoi(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } } } } @@ -125,6 +138,7 @@ Printf(f_runtime, "#define SWIGOCTAVE\n"); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); + Printf(f_runtime, "#define USE_OCTAVE_API_VERSION %i\n", api_version); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |