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:
parent
0576ffcde7
commit
cdc9de8210
4 changed files with 60 additions and 1 deletions
|
|
@ -439,9 +439,14 @@ namespace Swig {
|
|||
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 @@ namespace Swig {
|
|||
sr->document(h);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1352,6 +1358,10 @@ SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) {
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue