Mercurial > hg > octave-terminal
changeset 8136:2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 23 Sep 2008 13:49:14 -0400 |
parents | 170ff7258b31 |
children | 177117c7e375 |
files | src/ChangeLog src/lex.l src/pt-arg-list.cc |
diffstat | 3 files changed, 27 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-09-23 John W. Eaton <jwe@octave.org> + + * pt-arg-list.cc (F__end__): Dispatch to user-defined end + function for classes if one is defined. + * lex.l (is_keyword_token): Allow "end" as a functon name. + 2008-09-23 David Bateman <dbateman@free.fr> * variables.cc (static octave_value do_who (int, const string_vector&,
--- a/src/lex.l +++ b/src/lex.l @@ -1057,7 +1057,10 @@ break; case end_kw: - if (lexer_flags.looking_at_object_index) + if (lexer_flags.looking_at_object_index + || (lexer_flags.defining_func + && ! (lexer_flags.looking_at_return_list + || lexer_flags.parsed_function_name))) return 0; else {
--- a/src/pt-arg-list.cc +++ b/src/pt-arg-list.cc @@ -36,6 +36,7 @@ #include "oct-obj.h" #include "ov.h" #include "ov-usr-fcn.h" +#include "parse.h" #include "pt-arg-list.h" #include "pt-exp.h" #include "pt-pr-code.h" @@ -103,6 +104,22 @@ if (indexed_object) { + if (indexed_object->is_object ()) + { + octave_value_list args; + + args(2) = num_indices; + args(1) = index_position; + args(0) = *indexed_object; + + std::string class_name = indexed_object->class_name (); + + octave_value meth = symbol_table::find_method ("end", class_name); + + if (meth.is_defined ()) + return feval (meth.function_value (), args, 1); + } + dim_vector dv = indexed_object->dims (); int ndims = dv.length ();