Mercurial > hg > octave-shane
changeset 9728:70925b11ba46
again allow the obsolete syntax for cellfun
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 15 Oct 2009 13:07:44 +0200 |
parents | 04386b72d3df |
children | 3b7e644bb46d |
files | src/ChangeLog src/DLD-FUNCTIONS/cellfun.cc src/ov.cc src/ov.h |
diffstat | 4 files changed, 25 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-10-15 Jaroslav Hajek <highegg@gmail.com> + + * ov.h (octave_value::octave_value (octave_base_value *, bool)) : New constructor. + (octave_value::octave_value (octave_base_value *, int)): Deprecate. + * DLD-FUNCTIONS/cellfun.cc (Fcellfun): Allow the obsolete func body syntax. + 2009-10-15 Jaroslav Hajek <highegg@gmail.com> * variables.cc (extract_function): Pass 0 to eval_string to avoid
--- a/src/DLD-FUNCTIONS/cellfun.cc +++ b/src/DLD-FUNCTIONS/cellfun.cc @@ -41,6 +41,7 @@ #include "ov-colon.h" #include "unwind-prot.h" #include "gripes.h" +#include "utils.h" // Rationale: // The octave_base_value::subsasgn method carries too much overhead for @@ -296,9 +297,6 @@ octave_idx_type k = f_args.numel (); std::string name = func.string_value (); - if (name.find_first_of ("(x)") != std::string::npos) - warning ("cellfun: passing function body as string is no longer supported." - " Use @ or `inline'."); if (name == "isempty") { @@ -384,6 +382,19 @@ } else { + if (! valid_identifier (name)) + { + + std::string fcn_name = unique_symbol_name ("__cellfun_fcn_"); + std::string fname = "function y = "; + fname.append (fcn_name); + fname.append ("(x) y = "); + octave_function *ptr_func = extract_function (args(0), "cellfun", + fcn_name, fname, "; endfunction"); + if (ptr_func && ! error_state) + func = octave_value (ptr_func, true); + } + func = symbol_table::find_function (name); if (func.is_undefined ()) error ("cellfun: invalid function name: %s", name.c_str ());
--- a/src/ov.cc +++ b/src/ov.cc @@ -1118,9 +1118,11 @@ { } -octave_value::octave_value (octave_base_value *new_rep) +octave_value::octave_value (octave_base_value *new_rep, bool borrow) : rep (new_rep) { + if (borrow) + rep->count++; } octave_value::octave_value (octave_base_value *new_rep, int xcount)
--- a/src/ov.h +++ b/src/ov.h @@ -279,8 +279,8 @@ octave_value (const octave_value_list& m, bool is_cs_list = false); octave_value (octave_value::magic_colon); - octave_value (octave_base_value *new_rep); - octave_value (octave_base_value *new_rep, int xcount); + octave_value (octave_base_value *new_rep, bool borrow = false); + octave_value (octave_base_value *new_rep, int xcount) GCC_ATTR_DEPRECATED; // Copy constructor.