[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Changeset] make symbol_table:; find_function also find class specific f
From: |
David Bateman |
Subject: |
[Changeset] make symbol_table:; find_function also find class specific functions |
Date: |
Sun, 28 Sep 2008 00:19:45 +0200 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080725) |
Matlab allows thing like
help @myclass/myfunc
type @myclass/myfunc
dbstop @myclas/myfunc
to work and give the help, text and set the breakpoints in the class
specific version of a function. The obvious change to allow this is tho
change the symbol_table::find_function methods such that if the first
character of the function name being looked for is "@" then it is
assumed to be a class specific method that is requested and return that
regardless of the arguments passed to the function.
This works for the help, type etc command and sets the breakpoints
correctly, as dbstatus returns the positions of the newly set
breakpoints. However the code doesn't break correctly yet in the class
specific method, and I'm not sure why. Any ideas?
D.
# HG changeset patch
# User David Bateman <address@hidden>
# Date 1222552324 -7200
# Node ID e8bc3196000384adcd9b6449f7223d2bd9752ca0
# Parent 3f579d67400e6f90f96decf8271dc9dccbde1118
Check for class specific methods in symbol_table::find_function
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@ 2008-09-26 John W. Eaton <address@hidden
+2008-09-27 David Bateman <address@hidden>
+
+ * 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 <address@hidden>
* symtab.cc (out_of_date_check_internal):
diff --git a/src/symtab.cc b/src/symtab.cc
--- a/src/symtab.cc
+++ b/src/symtab.cc
@@ -940,28 +940,45 @@ symbol_table::find_function (const std::
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 ())
- {
- octave_function *parent_fcn = parent.function_value ();
- if (parent_fcn)
+ 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
+ {
+ 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;
- [Changeset] make symbol_table:; find_function also find class specific functions,
David Bateman <=