Mercurial > hg > octave-nkf
changeset 4319:05973ead74eb
[project @ 2003-02-13 21:03:04 by jwe]
author | jwe |
---|---|
date | Thu, 13 Feb 2003 21:03:04 +0000 |
parents | 115bffcecfd3 |
children | cc3a9c2608bd |
files | src/ChangeLog src/symtab.h src/variables.cc src/variables.h |
diffstat | 4 files changed, 142 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2003-02-13 Paul Kienzle <pkienzle@users.sf.net> + + * variables.cc (Fmlock, Fmunlock, Fmislocked): New functions. + + * variables.cc (mlock, munlock, mislocked): New functions. + * variables.h: Provide decls. + + * symtab.h (symbol_record::unmark_static): New function. + 2003-02-12 John W. Eaton <jwe@bevo.che.wisc.edu> * error.cc (reset_error_handler): New function.
--- a/src/symtab.h +++ b/src/symtab.h @@ -323,6 +323,7 @@ void mark_as_static (void); bool is_static (void) const { return tagged_static; } + void unmark_static (void) { tagged_static = false; } int rows (void) const { return definition->rows (); } int columns (void) const { return definition->columns (); }
--- a/src/variables.cc +++ b/src/variables.cc @@ -1290,6 +1290,131 @@ sr->document (help); } +void +mlock (const std::string& nm) +{ + symbol_record *sr = fbi_sym_tab->lookup (nm, true); + + if (sr) + sr->mark_as_static (); +} + +void +munlock (const std::string& nm) +{ + symbol_record *sr = fbi_sym_tab->lookup (nm); + + if (sr && sr->is_static ()) + sr->unmark_static (); + else + error ("munlock: %s is not locked", nm.c_str ()); +} + +bool +mislocked (const std::string& nm) +{ + symbol_record *sr = fbi_sym_tab->lookup (nm); + + return (sr && sr->is_static ()); +} + +DEFCMD (mlock, args, , + "-*- texinfo -*-\n\ +@deftypefnx {Built-in Function} {} mlock (@var{name})\n\ +Lock the named function into memory. If no function is named\n\ +then lock in the current function.\n\ +@end deftypefn\n\ +@seealso{munlock, mislocked, and persistent}") +{ + octave_value_list retval; + + if (args.length () == 1) + { + std::string name = args(0).string_value (); + + if (! error_state) + mlock (name); + else + error ("mlock: expecting argument to be a function name"); + } + else if (args.length () == 0) + { + if (curr_function) + mlock (curr_function->function_name ()); + else + error ("mlock: invalid use outside a function"); + } + else + print_usage ("mlock"); + + return retval; +} + +DEFCMD (munlock, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} munlock (@var{fcn})\n\ +Unlock the named function. If no function is named\n\ +then unlock the current function.\n\ +@end deftypefn\n\ +@seealso{mlock, mislocked, and persistent}") +{ + octave_value_list retval; + + if (args.length() == 1) + { + std::string name = args(0).string_value (); + + if (! error_state) + munlock (name); + else + error ("munlock: expecting argument to be a function name"); + } + else if (args.length () == 0) + { + if (curr_function) + mlock (curr_function->function_name ()); + else + error ("munlock: invalid use outside a function"); + } + else + print_usage ("munlock"); + + return retval; +} + + +DEFCMD (mislocked, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} mislocked (@var{fcn})\n\ +Return true if the named function is locked. If no function is named\n\ +then return true if the current function is locked.\n\ +@end deftypefn\n\ +@seealso{mlock, munlock, and persistent}") +{ + octave_value retval; + + if (args.length() == 1) + { + std::string name = args(0).string_value (); + + if (! error_state) + retval = mislocked (name); + else + error ("mislocked: expecting argument to be a function name"); + } + else if (args.length () == 0) + { + if (curr_function) + retval = mislocked (curr_function->function_name ()); + else + error ("mislocked: invalid use outside a function"); + } + else + print_usage ("mislocked"); + + return retval; +} + // Deleting names from the symbol tables. static inline bool
--- a/src/variables.h +++ b/src/variables.h @@ -71,6 +71,10 @@ extern bool looks_like_struct (const std::string& text); +extern int +symbol_exist (const std::string& name, + const std::string& type = std::string ()); + extern bool lookup (symbol_record *s, bool exec_script = true); extern symbol_record * @@ -106,9 +110,9 @@ symbol_record::change_function f = 0, const std::string& help = std::string ()); -extern int -symbol_exist (const std::string& name, - const std::string& type = std::string ()); +extern void mlock (const std::string&); +extern void munlock (const std::string&); +extern bool mislocked (const std::string&); // Symbol table for symbols at the top level. extern symbol_table *top_level_sym_tab;