changeset 2953:ca7d3625ee01

[project @ 1997-05-09 14:56:52 by jwe]
author jwe
date Fri, 09 May 1997 14:57:34 +0000
parents c4bc40161199
children ac3368dba5d3
files src/symtab.cc src/symtab.h src/variables.cc src/variables.h
diffstat 4 files changed, 15 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/src/symtab.cc
+++ b/src/symtab.cc
@@ -34,8 +34,9 @@
 #include "str-vec.h"
 
 #include "error.h"
+#include "oct-fcn.h"
 #include "oct-sym.h"
-#include "oct-fcn.h"
+#include "oct-var-ref.h"
 #include "symtab.h"
 #include "utils.h"
 #include "variables.h"
@@ -344,7 +345,7 @@
 }
 
 void
-symbol_record::set_sv_function (sv_Function f)
+symbol_record::set_sv_function (sv_function f)
 {
   sv_fcn = f;
 }
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -33,8 +33,6 @@
 
 #include "str-vec.h"
 
-#include "variables.h"
-
 // Must be multiple of 2.
 #define HASH_TABLE_SIZE 1024
 #define HASH_MASK (HASH_TABLE_SIZE - 1)
@@ -122,6 +120,9 @@
   friend class symbol_record_info;
 
 public:
+
+  typedef int (*sv_function) (void);
+
   symbol_record (void);
   symbol_record (const string& n, symbol_record *nxt = 0);
 
@@ -153,7 +154,7 @@
   void unprotect (void);
   void make_eternal (void);
 
-  void set_sv_function (sv_Function f);
+  void set_sv_function (sv_function f);
 
   int define (const octave_value& v,
 	      unsigned int sym_type = symbol_def::USER_VARIABLE);
@@ -196,7 +197,7 @@
   unsigned int tagged_static : 1;
 
   string nm;
-  sv_Function sv_fcn;
+  sv_function sv_fcn;
   symbol_def *definition;
   symbol_record *next_elem;
 
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -109,43 +109,6 @@
 // Symbol table for global symbols.
 symbol_table *global_sym_tab = 0;
 
-void
-octave_variable_reference::assign (octave_value::assign_op op,
-				   const octave_value& rhs)
-{
-  octave_value saved_val;
-
-  if (chg_fcn)
-    octave_value saved_val = *val;
-
-  if (struct_elt_name.empty ())
-    val->assign (op, rhs);
-  else
-    val->assign_struct_elt (op, struct_elt_name, rhs);
-
-  if (chg_fcn && chg_fcn () < 0)
-    *val = saved_val;
-}
-
-void
-octave_variable_reference::assign (octave_value::assign_op op,
-				   const octave_value_list& idx,
-				   const octave_value& rhs)
-{
-  octave_value saved_val;
-
-  if (chg_fcn)
-    octave_value saved_val = *val;
-
-  if (struct_elt_name.empty ())
-    val->assign (op, idx, rhs);
-  else
-    val->assign_struct_elt (op, struct_elt_name, idx, rhs);
-
-  if (chg_fcn && chg_fcn () < 0)
-    *val = saved_val;
-}
-
 // Initialization.
 
 // Create the initial symbol tables and set the current scope at the
@@ -1577,7 +1540,7 @@
 					  v.eternal, v.help_string);
   else
     bind_builtin_variable (v.name, v.value, v.protect, v.eternal,
-			   v.sv_function, v.help_string);
+			   v.sv_fcn, v.help_string);
 }
 
 void
@@ -1665,7 +1628,8 @@
 
 void
 bind_builtin_variable (const string& varname, const octave_value& val,
-		       bool protect, bool eternal, sv_Function sv_fcn,
+		       bool protect, bool eternal,
+		       symbol_record::sv_function sv_fcn,
 		       const string& help)
 {
   symbol_record *sr = global_sym_tab->lookup (varname, true);
--- a/src/variables.h
+++ b/src/variables.h
@@ -38,86 +38,24 @@
 #include <string>
 
 #include "ov.h"
-
-typedef int (*sv_Function)(void);
+#include "symtab.h"
 
 struct builtin_variable
 {
   builtin_variable (const string& n, const octave_value& v, bool iaf,
 		    bool p, bool e, sv_Function svf, const string& h)
     : name (n), value (v), install_as_function (iaf), protect (p),
-      eternal (e), sv_function (svf), help_string (h) { }
+      eternal (e), sv_fcn (svf), help_string (h) { }
 
   string name;
   octave_value value;
   bool install_as_function;
   bool protect;
   bool eternal;
-  sv_Function sv_function;
+  symbol_record::sv_function sv_fcn;
   string help_string;
 };
 
-class
-octave_variable_reference
-{
-public:
-
-  octave_variable_reference (octave_value *v = 0, sv_Function f = 0)
-    : val (v), chg_fcn (f), struct_elt_name () { }
-
-  octave_variable_reference (octave_value *v, const string& nm,
-			     sv_Function f = 0)
-    : val (v), chg_fcn (f), struct_elt_name (nm) { }
-
-  octave_variable_reference (const octave_variable_reference& vr)
-    : val (vr.val), chg_fcn (vr.chg_fcn),
-      struct_elt_name (vr.struct_elt_name) { }
-
-  octave_variable_reference& operator = (const octave_variable_reference& vr)
-    {
-      if (this != &vr)
-	{
-	  val = vr.val;
-	  chg_fcn = vr.chg_fcn;
-	  struct_elt_name = vr.struct_elt_name;
-	}
-
-      return *this;
-    }
-
-  ~octave_variable_reference (void) { }
-
-  bool is_undefined (void) { return val->is_undefined (); }
-
-  void define (const octave_value& v) { *val = v; }
-
-  void assign (octave_value::assign_op, const octave_value&);
-
-  void assign (octave_value::assign_op, const octave_value_list&,
-	       const octave_value&);
-
-  octave_variable_reference struct_elt_ref (const string& nm)
-    { return val->struct_elt_ref (nm); }
-
-  void increment (void) { val->increment (); }
-
-  void decrement (void) { val->decrement (); }
-
-  octave_value value (void)
-    {
-      return struct_elt_name.empty ()
-	? *val : val->struct_elt_val (struct_elt_name);
-    }
-
-private:
-
-  octave_value *val;
-
-  sv_Function chg_fcn;
-
-  string struct_elt_name;
-};
-
 typedef octave_value_list (*Octave_builtin_fcn)(const octave_value_list&, int);
 
 extern void initialize_symbol_tables (void);
@@ -196,7 +134,7 @@
 extern void
 bind_builtin_variable (const string&, const octave_value&,
 		       bool protect = false, bool eternal = false,
-		       sv_Function f = (sv_Function) 0,
+		       symbol_record::sv_function f = 0,
 		       const string& help = string ());
 
 // Symbol table for symbols at the top level.