small fixes to make octave module compatible with octave 3.2

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11388 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Xavier Delacour 2009-07-12 20:23:19 +00:00
commit cdc9de8210
4 changed files with 60 additions and 1 deletions

View file

@ -72,11 +72,32 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
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
%}