Sophie

Sophie

distrib > Mandriva > current > i586 > by-pkgid > 54478070873cb3561313a8ca8515b5f9 > files > 1

octave-forge-20090607-5mdv2010.1.src.rpm

--- main/ann-1.0.2/src/ann/bindings/ann_wrap.cpp	2009/01/10 01:02:37	5518
+++ main/ann-1.0.2/src/ann/bindings/ann_wrap.cpp	2009/07/12 21:16:23	6006
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.37
+ * Version 1.3.40
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -11,6 +11,7 @@
 #define SWIGOCTAVE
 #define SWIG_name_d      "ann"
 #define SWIG_name        ann
+#define USE_OCTAVE_API_VERSION 37
 
 
 #ifdef __cplusplus
@@ -860,27 +861,35 @@
 
   typedef std::map < void *, Director * > rtdir_map;
 
-  SWIGINTERN rtdir_map &get_rtdir_map() {
+  SWIGINTERN rtdir_map* get_rtdir_map() {
     static swig_module_info *module = 0;
     if (!module)
       module = SWIG_GetModule(0);
-    assert(module);
+    if (!module)
+      return 0;
     if (!module->clientdata)
       module->clientdata = new rtdir_map;
-    return *(rtdir_map *) module->clientdata;
+    return (rtdir_map *) module->clientdata;
   }
 
   SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
-    get_rtdir_map()[vptr] = d;
+    rtdir_map* rm = get_rtdir_map();
+    if (rm)
+      (*rm)[vptr] = d;
   }
 
   SWIGINTERNINLINE void erase_rtdir(void *vptr) {
-    get_rtdir_map().erase(vptr);
+    rtdir_map* rm = get_rtdir_map();
+    if (rm)
+      (*rm).erase(vptr);
   }
 
   SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
-    rtdir_map::const_iterator pos = get_rtdir_map().find(vptr);
-    Director *rtdir = (pos != get_rtdir_map().end())? pos->second : 0;
+    rtdir_map* rm = get_rtdir_map();
+    if (!rm)
+      return 0;
+    rtdir_map::const_iterator pos = rm->find(vptr);
+    Director *rtdir = (pos != rm->end())? pos->second : 0;
     return rtdir;
   }
 }
@@ -1194,9 +1203,15 @@
 	  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::varref(it->first);
+	  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();
@@ -1205,6 +1220,7 @@
 	      sr->document(h);
 	    }
 	  }
+#endif
 	}
       }
     }
@@ -2107,7 +2123,12 @@
 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::varref(module_var);
+  symbol_table::mark_global(module_var);
+#endif
   set_global_value(module_var, ov);
 }
 
@@ -2146,7 +2167,7 @@
 /* -------- TYPES TABLE (END) -------- */
 
 
-#define SWIGVERSION 0x010337 
+#define SWIGVERSION 0x010340 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -9614,12 +9635,34 @@
     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::varref(SWIG_name_d);
+  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
+
 
 static void SWIG_init_user(octave_swig_type* module_ns)
 {