changeset 4346:d39de791ef9c

[project @ 2003-02-20 21:38:39 by jwe]
author jwe
date Thu, 20 Feb 2003 21:38:39 +0000
parents 4e23bfdd6172
children 024ef171aec3
files src/ChangeLog src/debug.cc src/ov-base.cc src/ov-base.h src/ov-fcn-handle.cc src/ov-fcn-handle.h src/ov-usr-fcn.cc src/ov-usr-fcn.h src/ov.cc src/ov.h
diffstat 10 files changed, 34 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ChangeLog	Thu Feb 20 21:38:39 2003 +0000
@@ -1,6 +1,15 @@
 2003-02-20  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* debug.cc (get_user_function): Use dynamic_cast, not static_cast.
+
+	* ov-usr-fcn.cc (octave_user_function::traceback_error): Now const.
+
 	* ov.cc (octave_value (const octave_fcn_handle&)): New constructor.
+	(octave_value::fcn_handle_value): New virtual function.
+	* ov-base.cc (octave_value::fcn_handle_value): Provide default.
+	* ov-usr-fcn.cc (octave_user_function::stash_fcn_file_name): New
+	arg, nm.  Change all callers.
+	* ov-fcn.h (octave_function::is_nested_function): New virtual function.
 	* parse.y (get_feval_args): New function.
 	(feval (octave_function *, const octave_value_list&, int)): Likewise.
 	(feval (const octave_value_list&, int)): Allow the first arg to be
--- a/src/debug.cc	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/debug.cc	Thu Feb 20 21:38:39 2003 +0000
@@ -60,7 +60,7 @@
       if (ptr && ptr->is_user_function ())
 	{
 	  octave_value tmp = ptr->def ();
-	  dbg_fcn = static_cast<octave_user_function *> (tmp.function_value ());
+	  dbg_fcn = dynamic_cast<octave_user_function *> (tmp.function_value ());
 	}
       else
 	{
@@ -69,7 +69,7 @@
 	  if (ptr && ptr->is_user_function ())
 	    {
 	      octave_value tmp = ptr->def ();
-	      dbg_fcn = static_cast<octave_user_function *> (tmp.function_value ());
+	      dbg_fcn = dynamic_cast<octave_user_function *> (tmp.function_value ());
 	    }
 	}
     }
--- a/src/ov-base.cc	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov-base.cc	Thu Feb 20 21:38:39 2003 +0000
@@ -403,10 +403,10 @@
   return retval;
 }
 
-octave_fcn_handle
+octave_fcn_handle *
 octave_base_value::fcn_handle_value (bool silent)
 {
-  octave_fcn_handle retval;
+  octave_fcn_handle *retval = 0;
 
   if (! silent)
     gripe_wrong_type_arg ("octave_base_value::fcn_handle_value()",
--- a/src/ov-base.h	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov-base.h	Thu Feb 20 21:38:39 2003 +0000
@@ -211,7 +211,7 @@
 
   octave_function *function_value (bool silent);
 
-  octave_fcn_handle fcn_handle_value (bool silent);
+  octave_fcn_handle *fcn_handle_value (bool silent);
 
   octave_value_list list_value (void) const;
 
--- a/src/ov-fcn-handle.cc	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov-fcn-handle.cc	Thu Feb 20 21:38:39 2003 +0000
@@ -85,17 +85,17 @@
 
   if (args.length () == 1)
     {
-      octave_fcn_handle fh = args(0).fcn_handle_value ();
+      octave_fcn_handle *fh = args(0).fcn_handle_value ();
 
       if (! error_state)
 	{
-	  octave_function *fcn = fh.function_value (true);
+	  octave_function *fcn = fh ? fh->function_value (true) : 0;
 
 	  if (fcn)
 	    {
 	      Octave_map m;
 
-	      m ["function"](0) = fh.name ();
+	      m ["function"](0) = fh->name ();
 
 	      if (fcn->is_nested_function ())
 		m ["type"](0) = "subfunction";
@@ -134,12 +134,12 @@
 
   if (args.length () == 1)
     {
-      octave_fcn_handle fh = args(0).fcn_handle_value ();
+      octave_fcn_handle *fh = args(0).fcn_handle_value ();
 
-      if (! error_state)
-	retval = fh.name ();
+      if (! error_state && fh)
+	retval = fh->name ();
       else
-	error ("func2str: expecting function handle as first argument");
+	error ("func2str: expecting valid function handle as first argument");
     }
   else
     print_usage ("func2str");
--- a/src/ov-fcn-handle.h	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov-fcn-handle.h	Thu Feb 20 21:38:39 2003 +0000
@@ -43,8 +43,7 @@
 {
 public:
 
-  octave_fcn_handle (octave_function *f = 0,
-		     const std::string& n = std::string ())
+  octave_fcn_handle (octave_function *f, const std::string& n)
     : fcn (f), nm (n) { }
 
   octave_fcn_handle (const octave_fcn_handle& fh)
@@ -67,7 +66,7 @@
 
   octave_function *function_value (bool) { return fcn; }
 
-  octave_fcn_handle fcn_handle_value (bool) { return *this; }
+  octave_fcn_handle *fcn_handle_value (bool) { return this; }
 
   bool print_as_scalar (void) const { return true; }
 
--- a/src/ov-usr-fcn.cc	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov-usr-fcn.cc	Thu Feb 20 21:38:39 2003 +0000
@@ -516,7 +516,7 @@
 }
 
 void
-octave_user_function::traceback_error (void)
+octave_user_function::traceback_error (void) const
 {
   if (error_state >= 0)
     error_state = -1;
--- a/src/ov-usr-fcn.h	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov-usr-fcn.h	Thu Feb 20 21:38:39 2003 +0000
@@ -81,27 +81,21 @@
       mark_fcn_file_up_to_date (t);
     }
 
-  void stash_symtab_ptr (symbol_record *sr)
-    { symtab_entry = sr; }
+  void stash_symtab_ptr (symbol_record *sr) { symtab_entry = sr; }
 
-  std::string fcn_file_name (void) const
-    { return file_name; }
+  std::string fcn_file_name (void) const { return file_name; }
 
-  octave_time time_parsed (void) const
-    { return t_parsed; }
+  octave_time time_parsed (void) const { return t_parsed; }
 
-  octave_time time_checked (void) const
-    { return t_checked; }
+  octave_time time_checked (void) const { return t_checked; }
 
   void mark_as_system_fcn_file (void);
 
-  bool is_system_fcn_file (void) const
-    { return system_fcn_file; }
+  bool is_system_fcn_file (void) const { return system_fcn_file; }
 
   bool takes_varargs (void) const;
 
-  void octave_va_start (void)
-    { curr_va_arg_number = num_named_args; }
+  void octave_va_start (void) { curr_va_arg_number = num_named_args; }
 
   octave_value octave_va_arg (void);
 
@@ -117,8 +111,7 @@
 
   void stash_function_name (const std::string& s);
 
-  std::string function_name (void)
-    { return fcn_name; }
+  std::string function_name (void) const { return fcn_name; }
 
   void mark_as_nested_function (void) { nested_function = true; }
 
@@ -157,7 +150,7 @@
   octave_value_list
   do_multi_index_op (int nargout, const octave_value_list& args);
 
-  void traceback_error (void);
+  void traceback_error (void) const;
 
   tree_parameter_list *parameter_list (void) { return param_list; }
 
--- a/src/ov.cc	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov.cc	Thu Feb 20 21:38:39 2003 +0000
@@ -801,7 +801,7 @@
   return rep->function_value (silent);
 }
 
-octave_fcn_handle
+octave_fcn_handle *
 octave_value::fcn_handle_value (bool silent)
 {
   return rep->fcn_handle_value (silent);
--- a/src/ov.h	Thu Feb 20 20:45:49 2003 +0000
+++ b/src/ov.h	Thu Feb 20 21:38:39 2003 +0000
@@ -484,7 +484,7 @@
 
   virtual octave_function *function_value (bool silent = false);
 
-  virtual octave_fcn_handle fcn_handle_value (bool silent = false);
+  virtual octave_fcn_handle *fcn_handle_value (bool silent = false);
 
   virtual octave_value_list list_value (void) const;