diff src/mex.cc @ 7336:745a8299c2b5

[project @ 2007-12-28 20:56:55 by jwe]
author jwe
date Fri, 28 Dec 2007 20:56:58 +0000
parents 32abf21b21e9
children 3a1e5a965815
line wrap: on
line diff
--- a/src/mex.cc	Fri Feb 01 23:56:51 2008 -0500
+++ b/src/mex.cc	Fri Dec 28 20:56:58 2007 +0000
@@ -3242,31 +3242,26 @@
 {
   mxArray *retval = 0;
 
-  // FIXME -- this should be in variable.cc, but the correct
-  // functionality is not exported.  Particularly, get_global_value()
-  // generates an error if the symbol is undefined.
-
-  symbol_record *sr = 0;
+  // FIXME -- should this be in variables.cc?
+
+  symbol_table::scope_id scope = -1;
 
   if (! strcmp (space, "global"))
-    sr = global_sym_tab->lookup (name);
+    scope = symbol_table::global_scope ();
   else if (! strcmp (space, "caller"))
-    sr = curr_sym_tab->lookup (name);
+    scope = symbol_table::current_caller_scope ();
   else if (! strcmp (space, "base"))
-    sr = top_level_sym_tab->lookup (name);
+    scope = symbol_table::top_scope ();
   else
     mexErrMsgTxt ("mexGetVariable: symbol table does not exist");
 
-  if (sr)
+  octave_value val = symbol_table::varval (name, scope);
+
+  if (val.is_defined ())
     {
-      octave_value sr_def = sr->def ();
-
-      if (sr_def.is_defined ())
-	{
-	  retval = mex_context->make_value (sr_def);
-
-	  retval->set_name (name);
-	}
+      retval = mex_context->make_value (val);
+
+      retval->set_name (name);
     }
 
   return retval;
@@ -3297,21 +3292,20 @@
     set_global_value (name, mxArray::as_octave_value (ptr));
   else
     {
-      // FIXME -- this belongs in variables.cc.
-
-      symbol_record *sr = 0;
-
-      if (! strcmp (space, "caller"))
-	sr = curr_sym_tab->lookup (name, true);
+      // FIXME -- should this be in variables.cc?
+
+      symbol_table::scope_id scope = -1;
+
+      if (! strcmp (space, "global"))
+	scope = symbol_table::global_scope ();
+      else if (! strcmp (space, "caller"))
+	scope = symbol_table::current_caller_scope ();
       else if (! strcmp (space, "base"))
-	sr = top_level_sym_tab->lookup (name, true);
+	scope = symbol_table::top_scope ();
       else
 	mexErrMsgTxt ("mexPutVariable: symbol table does not exist");
 
-      if (sr)
-	sr->define (mxArray::as_octave_value (ptr));
-      else
-	panic_impossible ();
+      symbol_table::varref (name, scope) = mxArray::as_octave_value (ptr);
     }
 
   return 0;
@@ -3390,7 +3384,7 @@
       else
 	mex_lock_count[fname]++;
 
-      mlock (fname);
+      mlock ();
     }
 }