# HG changeset patch # User jwe # Date 1045777119 0 # Node ID d39de791ef9c8c62db8430a324cf047dca5b100a # Parent 4e23bfdd61726468962a8d6db1b865856c86ebf2 [project @ 2003-02-20 21:38:39 by jwe] diff -r 4e23bfdd6172 -r d39de791ef9c src/ChangeLog --- 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 + * 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 diff -r 4e23bfdd6172 -r d39de791ef9c src/debug.cc --- 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 (tmp.function_value ()); + dbg_fcn = dynamic_cast (tmp.function_value ()); } else { @@ -69,7 +69,7 @@ if (ptr && ptr->is_user_function ()) { octave_value tmp = ptr->def (); - dbg_fcn = static_cast (tmp.function_value ()); + dbg_fcn = dynamic_cast (tmp.function_value ()); } } } diff -r 4e23bfdd6172 -r d39de791ef9c src/ov-base.cc --- 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()", diff -r 4e23bfdd6172 -r d39de791ef9c src/ov-base.h --- 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; diff -r 4e23bfdd6172 -r d39de791ef9c src/ov-fcn-handle.cc --- 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"); diff -r 4e23bfdd6172 -r d39de791ef9c src/ov-fcn-handle.h --- 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; } diff -r 4e23bfdd6172 -r d39de791ef9c src/ov-usr-fcn.cc --- 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; diff -r 4e23bfdd6172 -r d39de791ef9c src/ov-usr-fcn.h --- 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; } diff -r 4e23bfdd6172 -r d39de791ef9c src/ov.cc --- 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); diff -r 4e23bfdd6172 -r d39de791ef9c src/ov.h --- 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;