Mercurial > hg > octave-nkf
changeset 8160:436438954797
Check for class specific methods in symbol_table::find_function
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 29 Sep 2008 16:48:04 -0400 |
parents | ccf38fc1057f |
children | 64f1cd525656 |
files | src/ChangeLog src/symtab.cc |
diffstat | 2 files changed, 39 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2008-09-29 David Bateman <dbateman@free.fr> + + * symtab.cc (octave_value symbol_table::find_function + (const std::string&, tree_argument_list *, const string_vector&, + octave_value_list&, bool&)): If first character of function name + is "@" then look for class specific method. + 2008-09-26 John W. Eaton <jwe@octave.org> * symtab.cc (out_of_date_check_internal):
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -940,28 +940,45 @@ bool& args_evaluated) { octave_value retval; - size_t pos = name.find_first_of (Vfilemarker); - if (pos == std::string::npos) - retval = find (name, args, arg_names, evaluated_args, args_evaluated, true); + if (name.at(0) == '@') + { + // Looking for a class specific function + std::string dispatch_type = + name.substr(1, name.find_first_of(file_ops::dir_sep_str ()) - 1); + std::string method = + name.substr (name.find_last_of(file_ops::dir_sep_str ()) + 1, + std::string::npos); + + retval = find_method (method, dispatch_type); + } else { - std::string fcn_scope = name.substr(0, pos); - scope_id stored_scope = xcurrent_scope; - xcurrent_scope = xtop_scope; - octave_value parent = find_function (name.substr(0, pos)); - if (parent.is_defined ()) + size_t pos = name.find_first_of (Vfilemarker); + + if (pos == std::string::npos) + retval = + find (name, args, arg_names, evaluated_args, args_evaluated, true); + else { - octave_function *parent_fcn = parent.function_value (); - if (parent_fcn) + std::string fcn_scope = name.substr(0, pos); + scope_id stored_scope = xcurrent_scope; + xcurrent_scope = xtop_scope; + octave_value parent = find_function (name.substr(0, pos)); + if (parent.is_defined ()) { - xcurrent_scope = parent_fcn->scope (); - if (xcurrent_scope > 1) - retval = find_function (name.substr (pos + 1), args, arg_names, - evaluated_args, args_evaluated); + octave_function *parent_fcn = parent.function_value (); + if (parent_fcn) + { + xcurrent_scope = parent_fcn->scope (); + if (xcurrent_scope > 1) + retval = find_function (name.substr (pos + 1), args, + arg_names, evaluated_args, + args_evaluated); + } } + xcurrent_scope = stored_scope; } - xcurrent_scope = stored_scope; } return retval;