Mercurial > hg > octave-nkf
changeset 4612:d44675070f1a
[project @ 2003-11-14 19:49:56 by jwe]
author | jwe |
---|---|
date | Fri, 14 Nov 2003 19:50:38 +0000 |
parents | c76a32c6f90c |
children | d1786f2d8a3c |
files | src/ChangeLog src/lex.l src/ov-base.cc src/ov-base.h src/ov-bool-mat.cc src/ov-bool.cc src/ov-bool.h src/ov-builtin.cc src/ov-builtin.h src/ov-cell.cc src/ov-cell.h src/ov-ch-mat.cc src/ov-colon.cc src/ov-complex.cc src/ov-complex.h src/ov-cs-list.cc src/ov-cs-list.h src/ov-cx-mat.cc src/ov-dld-fcn.cc src/ov-dld-fcn.h src/ov-fcn-handle.cc src/ov-fcn-handle.h src/ov-file.cc src/ov-file.h src/ov-list.cc src/ov-list.h src/ov-mapper.cc src/ov-mapper.h src/ov-range.cc src/ov-range.h src/ov-re-mat.cc src/ov-scalar.cc src/ov-scalar.h src/ov-str-mat.cc src/ov-struct.cc src/ov-typeinfo.cc src/ov-typeinfo.h src/ov-usr-fcn.cc src/ov-usr-fcn.h src/ov-va-args.cc src/ov.h |
diffstat | 41 files changed, 119 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,22 @@ +2003-11-14 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov-typeinfo.cc (octave_value_typeinfo::register_type, + octave_value_typeinfo::do_register_type): + New arg, c_name for class name. + * ov-base.cc, ov-bool-mat.cc, ov-bool.cc, ov-builtin.cc, + ov-cell.cc, ov-ch-mat.cc, ov-colon.cc, ov-complex.cc, + ov-cs-list.cc, ov-cx-mat.cc, ov-dld-fcn.cc, ov-fcn-handle.cc, + ov-file.cc, ov-list.cc, ov-mapper.cc, ov-range.cc, ov-re-mat.cc, + ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.cc, + ov-va-args.cc: Pass class name to DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA. + * ov.h (octave_value::class_name): New virtual function. + (DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA): Define c_name, for class name. + Pass c_name to octave_value_typeinfo::register_type. + (DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA): Declare static member + c_name for class name. Provide class_name member function. + + * ov-typeinfo.cc (Fclass): New function. + 2003-11-13 John W. Eaton <jwe@bevo.che.wisc.edu> * utils.cc (Fisvarname): Pass correct name to make_argv. @@ -11,7 +30,7 @@ * lex.l (bracket_brace_paren_nesting_level::is_bracket_or_brace): New function. (handle_close_bracket): New arg, bracket_type. Change all uses. - Return bool, not int. First arg is now bool. + First arg is now bool. (<MATRIX_START>{SNLCMT}*\}{S}*): New pattern. (maybe_unput_comma): Handle brace nesting level the same as brackets. (handle_close_brace): Likewise.
--- a/src/lex.l +++ b/src/lex.l @@ -171,7 +171,7 @@ static std::string strip_trailing_whitespace (char *s); static void handle_number (void); static int handle_string (char delim, int text_style = 0); -static char handle_close_bracket (bool spc_gobbled, char bracket_type); +static int handle_close_bracket (bool spc_gobbled, int bracket_type); static int handle_identifier (void); static bool have_continuation (bool trailing_comments_ok = true); static bool have_ellipsis_continuation (bool trailing_comments_ok = true); @@ -2226,10 +2226,10 @@ return retval; } -static char -handle_close_bracket (bool spc_gobbled, char bracket_type) +static int +handle_close_bracket (bool spc_gobbled, int bracket_type) { - char retval = bracket_type; + int retval = bracket_type; if (! nesting_level.none ()) {
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -53,7 +53,8 @@ #include "ov-fcn-handle.h" #include "variables.h" -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, "<unknown type>"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, + "<unknown type>", "unknown"); octave_value octave_base_value::squeeze (void) const
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -246,7 +246,7 @@ private: - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; }; #endif
--- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -48,7 +48,8 @@ DEFINE_OCTAVE_ALLOCATOR (octave_bool_matrix); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool_matrix, "bool matrix"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool_matrix, + "bool matrix", "logical"); static octave_value * default_numeric_conversion_function (const octave_value& a)
--- a/src/ov-bool.cc +++ b/src/ov-bool.cc @@ -47,7 +47,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_bool); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool, "bool"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool, "bool", "logical"); static octave_value * default_numeric_conversion_function (const octave_value& a)
--- a/src/ov-bool.h +++ b/src/ov-bool.h @@ -106,9 +106,9 @@ private: - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-builtin.cc +++ b/src/ov-builtin.cc @@ -35,7 +35,9 @@ DEFINE_OCTAVE_ALLOCATOR (octave_builtin); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_builtin, "built-in function"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_builtin, + "built-in function", + "built-in function"); // Are any of the arguments `:'?
--- a/src/ov-builtin.h +++ b/src/ov-builtin.h @@ -79,9 +79,9 @@ octave_builtin (const octave_builtin& m); - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -49,7 +49,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_cell); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell"); octave_value octave_cell::subsref (const std::string& type,
--- a/src/ov-cell.h +++ b/src/ov-cell.h @@ -110,6 +110,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; private: + DECLARE_OCTAVE_ALLOCATOR DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
--- a/src/ov-ch-mat.cc +++ b/src/ov-ch-mat.cc @@ -44,7 +44,8 @@ DEFINE_OCTAVE_ALLOCATOR (octave_char_matrix); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix, "char matrix"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix, + "char matrix", "int8"); bool octave_char_matrix::valid_as_scalar_index (void) const
--- a/src/ov-colon.cc +++ b/src/ov-colon.cc @@ -35,7 +35,8 @@ #include "oct-obj.h" #include "ov-colon.h" -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_magic_colon, "magic-colon"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_magic_colon, + "magic-colon", "magic-colon"); void octave_magic_colon::print (std::ostream& os, bool) const
--- a/src/ov-complex.cc +++ b/src/ov-complex.cc @@ -47,7 +47,8 @@ DEFINE_OCTAVE_ALLOCATOR (octave_complex); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex, "complex scalar"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex, + "complex scalar", "double"); octave_value * octave_complex::try_narrowing_conversion (void)
--- a/src/ov-complex.h +++ b/src/ov-complex.h @@ -100,9 +100,9 @@ private: - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-cs-list.cc +++ b/src/ov-cs-list.cc @@ -40,7 +40,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_cs_list); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cs_list, "cs-list"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cs_list, "cs-list", "cs-list"); octave_cs_list::octave_cs_list (const Cell& c) {
--- a/src/ov-cs-list.h +++ b/src/ov-cs-list.h @@ -86,9 +86,9 @@ // The list of Octave values. octave_value_list lst; - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -49,7 +49,8 @@ DEFINE_OCTAVE_ALLOCATOR (octave_complex_matrix); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_matrix, "complex matrix"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_matrix, + "complex matrix", "double"); octave_value * octave_complex_matrix::try_narrowing_conversion (void)
--- a/src/ov-dld-fcn.cc +++ b/src/ov-dld-fcn.cc @@ -40,6 +40,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_dld_function); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_dld_function, + "dynamically-linked function", "dynamically-linked function");
--- a/src/ov-dld-fcn.h +++ b/src/ov-dld-fcn.h @@ -84,9 +84,9 @@ // on the file to see if it has changed. bool system_fcn_file; - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -39,7 +39,9 @@ DEFINE_OCTAVE_ALLOCATOR (octave_fcn_handle); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle, "function handle"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle, + "function handle", + "function handle"); void octave_fcn_handle::print (std::ostream& os, bool pr_as_read_syntax) const
--- a/src/ov-fcn-handle.h +++ b/src/ov-fcn-handle.h @@ -84,9 +84,9 @@ // The name of the handle. std::string nm; - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; extern octave_value make_fcn_handle (const std::string& nm);
--- a/src/ov-file.cc +++ b/src/ov-file.cc @@ -39,7 +39,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_file); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_file, "file"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_file, "file", "file"); static octave_value * default_numeric_conversion_function (const octave_value& a)
--- a/src/ov-file.h +++ b/src/ov-file.h @@ -107,9 +107,9 @@ // The number of the beast. int number; - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-list.cc +++ b/src/ov-list.cc @@ -41,7 +41,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_list); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_list, "list"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_list, "list", "list"); octave_list::octave_list (const Cell& c) : octave_base_value (), data ()
--- a/src/ov-list.h +++ b/src/ov-list.h @@ -108,9 +108,9 @@ private: - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-mapper.cc +++ b/src/ov-mapper.cc @@ -39,6 +39,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_mapper); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_mapper, + "built-in mapper function", "built-in mapper function"); static bool
--- a/src/ov-mapper.h +++ b/src/ov-mapper.h @@ -119,9 +119,9 @@ bool can_ret_cmplx_for_real; - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -43,7 +43,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_range); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_range, "range"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_range, "range", "double"); static octave_value * default_numeric_conversion_function (const octave_value& a)
--- a/src/ov-range.h +++ b/src/ov-range.h @@ -167,9 +167,9 @@ Range range; - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -57,7 +57,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_matrix); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_matrix, "matrix"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_matrix, "matrix", "double"); octave_value * octave_matrix::try_narrowing_conversion (void)
--- a/src/ov-scalar.cc +++ b/src/ov-scalar.cc @@ -47,7 +47,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_scalar); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_scalar, "scalar"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_scalar, "scalar", "double"); octave_value octave_scalar::do_index_op (const octave_value_list& idx, int resize_ok)
--- a/src/ov-scalar.h +++ b/src/ov-scalar.h @@ -108,9 +108,9 @@ private: - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -43,7 +43,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_char_matrix_str); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix_str, "string"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix_str, "string", "char"); static octave_value * default_numeric_conversion_function (const octave_value& a)
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -42,7 +42,7 @@ DEFINE_OCTAVE_ALLOCATOR(octave_struct); -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_struct, "struct"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_struct, "struct", "struct"); Cell octave_struct::dotref (const octave_value_list& idx)
--- a/src/ov-typeinfo.cc +++ b/src/ov-typeinfo.cc @@ -81,10 +81,11 @@ } int -octave_value_typeinfo::register_type (const std::string& name) +octave_value_typeinfo::register_type (const std::string& t_name, + const std::string& c_name) { return (instance_ok ()) - ? instance->do_register_type (name) : -1; + ? instance->do_register_type (t_name, c_name) : -1; } bool @@ -147,12 +148,13 @@ } int -octave_value_typeinfo::do_register_type (const std::string& name) +octave_value_typeinfo::do_register_type (const std::string& t_name, + const std::string& c_name) { int i = 0; for (i = 0; i < num_types; i++) - if (name == types (i)) + if (t_name == types (i)) return i; int len = types.length (); @@ -184,7 +186,7 @@ widening_ops.resize (len, len, static_cast<type_conv_fcn> (0)); } - types (i) = name; + types (i) = t_name; num_types++; @@ -401,6 +403,25 @@ return retval; } +DEFUN (class, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} class (@var{expr})\n\ +\n\ +Return the class of the expression @var{expr}, as a string.\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin == 1) + retval = args(0).class_name (); + else + print_usage ("class"); + + return retval; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/src/ov-typeinfo.h +++ b/src/ov-typeinfo.h @@ -44,7 +44,7 @@ static bool instance_ok (void); - static int register_type (const std::string&); + static int register_type (const std::string&, const std::string&); static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn); @@ -152,7 +152,7 @@ Array2<type_conv_fcn> widening_ops; - int do_register_type (const std::string&); + int do_register_type (const std::string&, const std::string&); bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn);
--- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -59,6 +59,7 @@ DEFINE_OCTAVE_ALLOCATOR (octave_user_function); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_user_function, + "user-defined function", "user-defined function"); // Ugh. This really needs to be simplified (code/data?
--- a/src/ov-usr-fcn.h +++ b/src/ov-usr-fcn.h @@ -258,9 +258,9 @@ void bind_automatic_vars (const string_vector& arg_names, int nargin, int nargout, const octave_value_list& va_args); - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + DECLARE_OCTAVE_ALLOCATOR - DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif
--- a/src/ov-va-args.cc +++ b/src/ov-va-args.cc @@ -35,7 +35,7 @@ #include "oct-obj.h" #include "ov-va-args.h" -DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_all_va_args, "va-arg"); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_all_va_args, "va-arg", "va-arg"); void octave_all_va_args::print (std::ostream& os, bool) const
--- a/src/ov.h +++ b/src/ov.h @@ -604,6 +604,8 @@ virtual std::string type_name (void) const { return rep->type_name (); } + virtual std::string class_name (void) const { return rep->class_name (); } + // Unary and binary operations. friend octave_value do_unary_op (unary_op op, @@ -752,17 +754,20 @@ public: \ int type_id (void) const { return t_id; } \ std::string type_name (void) const { return t_name; } \ + std::string class_name (void) const { return c_name; } \ static int static_type_id (void) { return t_id; } \ static void register_type (void) \ - { t_id = octave_value_typeinfo::register_type (t_name); } \ + { t_id = octave_value_typeinfo::register_type (t_name, c_name); } \ \ private: \ static int t_id; \ - static const std::string t_name; + static const std::string t_name; \ + static const std::string c_name; -#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n) \ +#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \ int t::t_id (-1); \ - const std::string t::t_name (n) + const std::string t::t_name (n); \ + const std::string t::c_name (c) // If TRUE, print a warning for assignments like //