# HG changeset patch # User John W. Eaton # Date 1222192154 14400 # Node ID 2b2ca62f8ab6616307125175b81a18e25bc9dce0 # Parent 170ff7258b31f28c791e105a36aaab3775d5948f dispatch to user-defined end function for classes if one is defined diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-09-23 John W. Eaton + + * 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 * variables.cc (static octave_value do_who (int, const string_vector&, diff --git a/src/lex.l b/src/lex.l --- 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 { diff --git a/src/pt-arg-list.cc b/src/pt-arg-list.cc --- 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 ();