# HG changeset patch # User jwe # Date 1146767925 0 # Node ID 70215aff5ccf54eae14a906366c1f380dcd2627a # Parent 60659f01c75b2a6d5971bc11015e59507ed2935e [project @ 2006-05-04 18:38:45 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2006-05-04 John W. Eaton + * variables.cc (set_internal_variable): Move here from + DLD-FUNCTIONS/__gnuplot_raw__.l. + * variables.h (SET_INTERNAL_VARIABLE): Likewise. + (set_internal_variable): Provide decls. + + * DLD-FUNCTIONS/__gnuplot_raw__.l: Convert all DEFVARs to DEFUN_DLDs. + (gnuplot::init): Delete. + (gnuplot::gnuplot): Don't call init here. + (set_internal_variable): New functions. + (SET_INTERNAL_VARIABLE): New macro. + * Makefile.in: Undo changes of 2006-03-16. * DLD-FUNCTINS/__gnuplot_raw__.l: Move here from __gnuplot_raw__.l. Undo changes of 2006-03-16. diff --git a/src/DLD-FUNCTIONS/__gnuplot_raw__.l b/src/DLD-FUNCTIONS/__gnuplot_raw__.l --- a/src/DLD-FUNCTIONS/__gnuplot_raw__.l +++ b/src/DLD-FUNCTIONS/__gnuplot_raw__.l @@ -1460,54 +1460,6 @@ static gnuplot_X X; -static octave_value -set_internal_variable (bool& var, const octave_value_list& args, - const char *nm) -{ - octave_value retval = var; - - int nargin = args.length (); - - if (nargin == 1) - { - bool bval = args(0).bool_value (); - - if (! error_state) - var = bval; - else - error ("%s: expecting arg to be a logical value", nm); - } - else if (nargin > 1) - print_usage ("automatic_replot"); - - return retval; -} - -static octave_value -set_internal_variable (std::string& var, const octave_value_list& args, - const char *nm) -{ - octave_value retval = var; - - int nargin = args.length (); - - if (nargin == 1) - { - std::string sval = args(0).string_value (); - - if (! error_state) - var = sval; - else - error ("%s: expecting arg to be a character string", nm); - } - else if (nargin > 1) - print_usage ("automatic_replot"); - - return retval; -} - -#define SET_INTERNAL_VARIABLE(NM) set_internal_variable (V ## NM, args, #NM) - // ----------------------- // User-callable functions // ----------------------- diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -1256,6 +1256,52 @@ // Variable values. +octave_value +set_internal_variable (bool& var, const octave_value_list& args, + const char *nm) +{ + octave_value retval = var; + + int nargin = args.length (); + + if (nargin == 1) + { + bool bval = args(0).bool_value (); + + if (! error_state) + var = bval; + else + error ("%s: expecting arg to be a logical value", nm); + } + else if (nargin > 1) + print_usage ("automatic_replot"); + + return retval; +} + +octave_value +set_internal_variable (std::string& var, const octave_value_list& args, + const char *nm) +{ + octave_value retval = var; + + int nargin = args.length (); + + if (nargin == 1) + { + std::string sval = args(0).string_value (); + + if (! error_state) + var = sval; + else + error ("%s: expecting arg to be a character string", nm); + } + else if (nargin > 1) + print_usage ("automatic_replot"); + + return retval; +} + // Look for the given name in the global symbol table. If it refers // to a string, return a new copy. If not, return 0; diff --git a/src/variables.h b/src/variables.h --- a/src/variables.h +++ b/src/variables.h @@ -107,6 +107,16 @@ extern void set_global_value (const std::string& nm, const octave_value& val); +extern octave_value +set_internal_variable (bool& var, const octave_value_list& args, + const char *nm); + +extern octave_value +set_internal_variable (std::string& var, const octave_value_list& args, + const char *nm); + +#define SET_INTERNAL_VARIABLE(NM) set_internal_variable (V ## NM, args, #NM) + extern std::string builtin_string_variable (const std::string&); extern int builtin_real_scalar_variable (const std::string&, double&); extern octave_value builtin_any_variable (const std::string&);