# HG changeset patch # User jwe # Date 1069574873 0 # Node ID bd2067547b40cd8f89c0b91806819593845ad82f # Parent 3b74f1a867504a36ca822c40615aa685c484e1a1 [project @ 2003-11-23 08:07:52 by jwe] diff -r 3b74f1a86750 -r bd2067547b40 ChangeLog --- a/ChangeLog Sat Nov 22 12:58:40 2003 +0000 +++ b/ChangeLog Sun Nov 23 08:07:53 2003 +0000 @@ -1,3 +1,7 @@ +2003-11-20 John W. Eaton + + * configure.in: Also maybe add -W to WARN_CFLAGS and WARN_CXXFLAGS. + 2003-11-15 John W. Eaton * Makeconf.in (SHLLIB_VER): Fix typo. diff -r 3b74f1a86750 -r bd2067547b40 configure.in --- a/configure.in Sat Nov 22 12:58:40 2003 +0000 +++ b/configure.in Sun Nov 23 08:07:53 2003 +0000 @@ -29,7 +29,7 @@ EXTERN_CXXFLAGS="$CXXFLAGS" AC_INIT -AC_REVISION($Revision: 1.440 $) +AC_REVISION($Revision: 1.441 $) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1282,13 +1282,16 @@ AC_MSG_RESULT([defining UGLY_DEFS to be $UGLY_DEFS]) AC_SUBST(UGLY_DEFS) -### Maybe add -Wall and -Wshadow to compiler flags now that we're +### Maybe add -Wall, -W, and -Wshadow to compiler flags now that we're ### done feature testing. if test -z "$EXTERN_CFLAGS"; then OCTAVE_CC_FLAG(-Wall, [ WARN_CFLAGS="$WARN_CFLAGS -Wall"; AC_MSG_RESULT([adding -Wall to WARN_CFLAGS])]) + OCTAVE_CC_FLAG(-W, [ + WARN_CFLAGS="$WARN_CFLAGS -W"; + AC_MSG_RESULT([adding -W to WARN_CFLAGS])]) OCTAVE_CC_FLAG(-Wshadow, [ WARN_CFLAGS="$WARN_CFLAGS -Wshadow"; AC_MSG_RESULT([adding -Wshadow to WARN_CFLAGS])]) @@ -1298,6 +1301,9 @@ OCTAVE_CXX_FLAG(-Wall, [ WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall"; AC_MSG_RESULT([adding -Wall to WARN_CXXFLAGS])]) + OCTAVE_CXX_FLAG(-W, [ + WARN_CXXFLAGS="$WARN_CXXFLAGS -W"; + AC_MSG_RESULT([adding -W to WARN_CXXFLAGS])]) OCTAVE_CXX_FLAG(-Wshadow, [ WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow"; AC_MSG_RESULT([adding -Wshadow to WARN_CXXFLAGS])]) diff -r 3b74f1a86750 -r bd2067547b40 liboctave/Array2.h --- a/liboctave/Array2.h Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/Array2.h Sun Nov 23 08:07:53 2003 +0000 @@ -69,18 +69,15 @@ Array2& operator = (const Array2& a) { if (this != &a) - { - Array::operator = (a); - - dimensions = a.dimensions; - } + Array::operator = (a); return *this; } - void resize (int r, int c) { resize_no_fill (r, c); } + void resize (int r, int c) { this->resize_no_fill (r, c); } - void resize (int r, int c, const T& val) { resize_and_fill (r, c, val); } + void resize (int r, int c, const T& val) + { this->resize_and_fill (r, c, val); } Array2& insert (const Array2& a, int r, int c) { diff -r 3b74f1a86750 -r bd2067547b40 liboctave/Array3.h --- a/liboctave/Array3.h Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/Array3.h Sun Nov 23 08:07:53 2003 +0000 @@ -69,19 +69,15 @@ Array3& operator = (const Array3& a) { if (this != &a) - { - Array::operator = (a); - - dimensions = a.dimensions; - } + Array::operator = (a); return *this; } - void resize (int r, int c, int p) { resize_no_fill (r, c, p); } + void resize (int r, int c, int p) { this->resize_no_fill (r, c, p); } void resize (int r, int c, int p, const T& val) - { resize_and_fill (r, c, p, val); } + { this->resize_and_fill (r, c, p, val); } }; #endif diff -r 3b74f1a86750 -r bd2067547b40 liboctave/ArrayN.h --- a/liboctave/ArrayN.h Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/ArrayN.h Sun Nov 23 08:07:53 2003 +0000 @@ -83,7 +83,7 @@ } void resize (const dim_vector& dv) - { Array::resize_no_fill (dv); } + { this->resize_no_fill (dv); } void resize (const dim_vector& dv, const T& val) { Array::resize (dv, val); } diff -r 3b74f1a86750 -r bd2067547b40 liboctave/ChangeLog --- a/liboctave/ChangeLog Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/ChangeLog Sun Nov 23 08:07:53 2003 +0000 @@ -1,3 +1,19 @@ +2003-11-20 John W. Eaton + + * MArrayN.cc (operator -=, operator +=): Check dimensions, not + just length. + + * Array2.h, Array3.h, DiagArray2.h, DiagArray2.cc, MDiagArray2.h, + ArrayN.h: Add this-> or Base:: qualifiers for references to + non-dependent member functions and data as needed. + + * DiagArray2.h, DiagArray2.cc: Delete unused code. + + * Array2.h (Array2::operator =): Don't copy dimensions here. + * Array3.h (Array3::operator =): Likewise. + * DiagArray2.h (DiagArray2::operator =): Likewise. + Include Array.h, not Array2.h. + 2003-11-19 John W. Eaton * str-vec.cc (list_in_columns): Fix previous change. diff -r 3b74f1a86750 -r bd2067547b40 liboctave/DiagArray2.cc --- a/liboctave/DiagArray2.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/DiagArray2.cc Sun Nov 23 08:07:53 2003 +0000 @@ -39,42 +39,6 @@ // A two-dimensional array with diagonal elements only. -#if 0 -template -T& -DiagArray2::elem (int r, int c) -{ - static T foo (0); - return (r == c) ? Array::xelem (r) : foo; -} - -template -T& -DiagArray2::checkelem (int r, int c) -{ - static T foo (0); - if (r < 0 || c < 0 || r >= dim1 () || c >= dim2 ()) - { - (*current_liboctave_error_handler) ("range error in DiagArray2"); - return foo; - } - return (r == c) ? Array::xelem (r) : foo; -} - -template -T& -DiagArray2::operator () (int r, int c) -{ - static T foo (0); - if (r < 0 || c < 0 || r >= dim1 () || c >= dim2 ()) - { - (*current_liboctave_error_handler) ("range error in DiagArray2"); - return foo; - } - return (r == c) ? Array::xelem (r) : foo; -} -#endif - template T DiagArray2::elem (int r, int c) const @@ -86,7 +50,7 @@ T DiagArray2::checkelem (int r, int c) const { - if (r < 0 || c < 0 || r >= dim1 () || c >= dim2 ()) + if (r < 0 || c < 0 || r >= this->dim1 () || c >= this->dim2 ()) { (*current_liboctave_error_handler) ("range error in DiagArray2"); return T (); @@ -98,7 +62,7 @@ T DiagArray2::operator () (int r, int c) const { - if (r < 0 || c < 0 || r >= dim1 () || c >= dim2 ()) + if (r < 0 || c < 0 || r >= this->dim1 () || c >= this->dim2 ()) { (*current_liboctave_error_handler) ("range error in DiagArray2"); return T (); @@ -131,18 +95,18 @@ return; } - if (r == dim1 () && c == dim2 ()) + if (r == this->dim1 () && c == this->dim2 ()) return; typename Array::ArrayRep *old_rep = Array::rep; - const T *old_data = data (); - int old_len = length (); + const T *old_data = this->data (); + int old_len = this->length (); int new_len = r < c ? r : c; Array::rep = new typename Array::ArrayRep (new_len); - dimensions = dim_vector (r, c); + this->dimensions = dim_vector (r, c); if (old_data && old_len > 0) { @@ -166,18 +130,18 @@ return; } - if (r == dim1 () && c == dim2 ()) + if (r == this->dim1 () && c == this->dim2 ()) return; typename Array::ArrayRep *old_rep = Array::rep; - const T *old_data = data (); - int old_len = length (); + const T *old_data = this->data (); + int old_len = this->length (); int new_len = r < c ? r : c; Array::rep = new typename Array::ArrayRep (new_len); - dimensions = dim_vector (r, c); + this->dimensions = dim_vector (r, c); int min_len = old_len < new_len ? old_len : new_len; diff -r 3b74f1a86750 -r bd2067547b40 liboctave/DiagArray2.h --- a/liboctave/DiagArray2.h Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/DiagArray2.h Sun Nov 23 08:07:53 2003 +0000 @@ -31,7 +31,7 @@ #include #include -#include "Array2.h" +#include "Array.h" #include "lo-error.h" class idx_vector; @@ -111,59 +111,38 @@ protected: DiagArray2 (T *d, int r, int c) : Array (d, r < c ? r : c) - { dimensions = dim_vector (r, c); } + { Array::dimensions = dim_vector (r, c); } public: DiagArray2 (void) : Array (dim_vector (0, 0)) { } DiagArray2 (int r, int c) : Array (r < c ? r : c) - { dimensions = dim_vector (r, c); } + { this->dimensions = dim_vector (r, c); } DiagArray2 (int r, int c, const T& val) : Array (r < c ? r : c) { - dimensions = dim_vector (r, c); + this->dimensions = dim_vector (r, c); fill (val); } DiagArray2 (const Array& a) : Array (a) - { dimensions = dim_vector (a.length (), a.length ()); } + { this->dimensions = dim_vector (a.length (), a.length ()); } DiagArray2 (const DiagArray2& a) : Array (a) - { dimensions = a.dims (); } + { this->dimensions = a.dims (); } ~DiagArray2 (void) { } DiagArray2& operator = (const DiagArray2& a) { if (this != &a) - { - Array::operator = (a); - dimensions = a.dims (); - } + Array::operator = (a); return *this; } -#if 0 - operator Array2 () const - { - int nr = dim1 (); - int nc = dim2 (); - - Array2 retval (nr, nc, T (0)); - - int len = nr < nc ? nr : nc; - - for (int i = 0; i < len; i++) - retval.xelem (i, i) = xelem (i, i); - - return retval; - } -#endif - -#if 1 Proxy elem (int r, int c) { return Proxy (this, r, c); @@ -171,7 +150,7 @@ Proxy checkelem (int r, int c) { - if (r < 0 || c < 0 || r >= dim1 () || c >= dim2 ()) + if (r < 0 || c < 0 || r >= this->dim1 () || c >= this->dim2 ()) { (*current_liboctave_error_handler) ("range error in DiagArray2"); return Proxy (0, r, c); @@ -182,7 +161,7 @@ Proxy operator () (int r, int c) { - if (r < 0 || c < 0 || r >= dim1 () || c >= dim2 ()) + if (r < 0 || c < 0 || r >= this->dim1 () || c >= this->dim2 ()) { (*current_liboctave_error_handler) ("range error in DiagArray2"); return Proxy (0, r, c); @@ -190,11 +169,6 @@ else return Proxy (this, r, c); } -#else - T& elem (int r, int c); - T& checkelem (int r, int c); - T& operator () (int r, int c); -#endif T elem (int r, int c) const; T checkelem (int r, int c) const; diff -r 3b74f1a86750 -r bd2067547b40 liboctave/MArrayN.cc --- a/liboctave/MArrayN.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/MArrayN.cc Sun Nov 23 08:07:53 2003 +0000 @@ -61,14 +61,18 @@ operator += (MArrayN& a, const MArrayN& b) { int l = a.length (); + if (l > 0) { - int bl = b.length (); - if (l != bl) - gripe_nonconformant ("operator +=", l, bl); + dim_vector a_dims = a.dims (); + dim_vector b_dims = b.dims (); + + if (a_dims != b_dims) + gripe_nonconformant ("operator +=", a_dims, b_dims); else DO_VV_OP2 (+=); } + return a; } @@ -77,11 +81,14 @@ operator -= (MArrayN& a, const MArrayN& b) { int l = a.length (); + if (l > 0) { - int bl = b.length (); - if (l != bl) - gripe_nonconformant ("operator -=", l, bl); + dim_vector a_dims = a.dims (); + dim_vector b_dims = b.dims (); + + if (a_dims != b_dims) + gripe_nonconformant ("operator -=", a_dims, b_dims); else DO_VV_OP2 (-=); } diff -r 3b74f1a86750 -r bd2067547b40 liboctave/MDiagArray2.h --- a/liboctave/MDiagArray2.h Sat Nov 22 12:58:40 2003 +0000 +++ b/liboctave/MDiagArray2.h Sun Nov 23 08:07:53 2003 +0000 @@ -79,7 +79,7 @@ int len = nr < nc ? nr : nc; for (int i = 0; i < len; i++) - retval.xelem (i, i) = xelem (i, i); + retval.xelem (i, i) = this->xelem (i, i); return retval; } diff -r 3b74f1a86750 -r bd2067547b40 src/ChangeLog --- a/src/ChangeLog Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ChangeLog Sun Nov 23 08:07:53 2003 +0000 @@ -1,22 +1,61 @@ +2003-11-23 John W. Eaton + + * oct-stream.cc (octave_stream::seek): Extract std::streamoff from + tc_offset instead of int. + + * ov-re-mat.cc (octave_matrix::double_value): Use numel, not length. + + * ov-re-mat.cc (octave_matrix::streamoff_array_value): New function. + * ov-re-mat.h: Provide decl. + + * ov-scalar.cc (octave_scalar::streamoff_value): New function. + * ov-scalar.h: Provide decl. + + * ov.cc (octave_value::streamoff_array_value, + octave_value::streamoff_value): New functions. + * ov.h: Provide decls. + + * ov-base.cc (octave_base_value::streamoff_array_value, + octave_base_value::streamoff_value): New functions. + * ov-base.h: Provide decls. + + * ov-usr-fcn.cc (install_automatic_vars): Don't do anything unless + sym_tab is defined. + + * ov-streamoff.h, ov-streamoff.cc, OPERATORS/op-streamoff.cc: + New files. + + * ov-cell.h (octave_value_cell::is_matrix_type): New function. + + * ov-mapper.h (octave_mapper::octave_mapper): No copying. + * ov-fcn.h (octave_function::octave_function): Likewise. + * ov-usr-fcn.h (octave_function::octave_function): Likewise. + * ov-builtin.h (octave_builtin::octave_builtin): Likewise. + * ov-dld-fcn.h (octave_dld_function::octave_dld_function): Likewise. + 2003-11-22 John W. Eaton - * ov-dld-fcn.h (octave_dld_function::octave_dld_function): - Make public, but abort if called. + * ov-mapper.h (octave_mapper::octave_mapper): Make public. + Provide copy constructor and assignment operator. + * ov-fcn.h (octave_function::octave_function): Likewise. * ov-builtin.h (octave_builtin::octave_builtin): Likewise. - * ov-fcn.h (octave_function::octave_function): Likewise. + * ov-dld-fcn.h (octave_dld_function::octave_dld_function): Likewise. * ov-typeinfo.cc (octave_value_typeinfo::register_type, octave_value_typeinfo::do_register_type): New arg, val. + Save it in vals array. (octave_value_typeinfo::lookup_type, octave_value_typeinfo::do_lookup_type): New functions. * ov-typeinfo.h: Provide decl. + (octave_value_typeinfo::vals): New data member. + (octave_value_typeinfo::octave_value_typeinfo): Initialize it. * ov.h (DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA): Pass * ov.h (DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA): Define register_type here. Also pass an empty object of the to-be-registered type to register_type. - (DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA): Declare register type + (DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA): Declare register_type here, but don't define it. 2003-11-21 John W. Eaton diff -r 3b74f1a86750 -r bd2067547b40 src/OPERATORS/op-streamoff.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/OPERATORS/op-streamoff.cc Sun Nov 23 08:07:53 2003 +0000 @@ -0,0 +1,159 @@ +/* + +Copyright (C) 2003 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gripes.h" +#include "ov.h" +#include "ov-re-mat.h" +#include "ov-scalar.h" +#include "ov-streamoff.h" +#include "ov-typeinfo.h" +#include "ops.h" + +// streamoff unary ops. + +DEFUNOP (transpose, streamoff) +{ + CAST_UNOP_ARG (const octave_streamoff&); + + return octave_value (streamoff_array (v.streamoff_array_value().transpose ())); +} + +// DEFNCUNOP_METHOD (incr, streamoff, increment) +// DEFNCUNOP_METHOD (decr, streamoff, decrement) + +// streamoff by streamoff ops. + +DEFNDBINOP_OP (add, streamoff, streamoff, streamoff_array, streamoff_array, +) +DEFNDBINOP_OP (sub, streamoff, streamoff, streamoff_array, streamoff_array, -) + +DEFNDBINOP_OP (add_so_m, streamoff, matrix, streamoff_array, streamoff_array, +) +DEFNDBINOP_OP (sub_so_m, streamoff, matrix, streamoff_array, streamoff_array, -) + +DEFNDBINOP_OP (add_m_so, matrix, streamoff, streamoff_array, streamoff_array, +) +DEFNDBINOP_OP (sub_m_so, matrix, streamoff, streamoff_array, streamoff_array, +) +DEFNDBINOP_OP (add_so_s, streamoff, scalar, streamoff_array, streamoff, +) +DEFNDBINOP_OP (sub_so_s, streamoff, scalar, streamoff_array, streamoff, -) + +DEFNDBINOP_OP (add_s_so, scalar, streamoff, streamoff, streamoff_array, +) +DEFNDBINOP_OP (sub_s_so, scalar, streamoff, streamoff, streamoff_array, +) + +DEFBINOP (eq, streamoff, streamoff) +{ + CAST_BINOP_ARGS (const octave_streamoff&, + const octave_streamoff&); + + streamoff_array cm1 = v1.streamoff_array_value (); + streamoff_array cm2 = v2.streamoff_array_value (); + + if (cm1.rows () == 1 && cm1.columns () == 1) + { + if (cm2.rows () == 1 && cm2.columns () == 1) + return octave_value (cm1 (0, 0) == cm2 (0, 0)); + else + SC_MX_BOOL_OP (std::streamoff, c, cm1 (0, 0), streamoff_array, m, cm2, + c == m (i, j), 0.0); + } + else + { + int cm2_nr = cm2.rows (); + int cm2_nc = cm2.cols (); + + if (cm2_nr == 1 && cm2_nc == 1) + MX_SC_BOOL_OP (streamoff_array, m, cm1, std::streamoff, c, cm2 (0, 0), + c == m (i, j), 0.0); + else + MX_MX_BOOL_OP (streamoff_array, m1, cm1, streamoff_array, m2, cm2, + m1 (i, j) == m2 (i, j), "==", 0.0, 1.0); + } +} + +DEFBINOP (ne, streamoff, streamoff) +{ + CAST_BINOP_ARGS (const octave_streamoff&, + const octave_streamoff&); + + streamoff_array cm1 = v1.streamoff_array_value (); + streamoff_array cm2 = v2.streamoff_array_value (); + + if (cm1.rows () == 1 && cm1.columns () == 1) + { + if (cm2.rows () == 1 && cm2.columns () == 1) + return octave_value (cm1 (0, 0) != cm2 (0, 0)); + else + SC_MX_BOOL_OP (std::streamoff, c, cm1 (0, 0), streamoff_array, m, cm2, + c != m (i, j), 1.0); + } + else + { + if (cm2.rows () == 1 && cm2.columns () == 1) + MX_SC_BOOL_OP (streamoff_array, m, cm1, std::streamoff, c, cm2 (0, 0), + c != m (i, j), 1.0); + else + MX_MX_BOOL_OP (streamoff_array, m1, cm1, streamoff_array, m2, cm2, + m1 (i, j) != m2 (i, j), "!=", 1.0, 0.0); + } +} + +DEFASSIGNOP (assign, streamoff, streamoff) +{ + CAST_BINOP_ARGS (octave_streamoff&, const octave_streamoff&); + + v1.assign (idx, v2.streamoff_array_value ()); + return octave_value (); +} + +void +install_streamoff_ops (void) +{ + INSTALL_UNOP (op_transpose, octave_streamoff, transpose); + INSTALL_UNOP (op_hermitian, octave_streamoff, transpose); + + INSTALL_BINOP (op_eq, octave_streamoff, octave_streamoff, eq); + INSTALL_BINOP (op_ne, octave_streamoff, octave_streamoff, ne); + + INSTALL_BINOP (op_add, octave_streamoff, octave_streamoff, add); + INSTALL_BINOP (op_sub, octave_streamoff, octave_streamoff, sub); + + INSTALL_BINOP (op_add, octave_streamoff, octave_matrix, add_so_m); + INSTALL_BINOP (op_sub, octave_streamoff, octave_matrix, sub_so_m); + + INSTALL_BINOP (op_add, octave_matrix, octave_streamoff, add_m_so); + INSTALL_BINOP (op_sub, octave_matrix, octave_streamoff, sub_m_so); + + INSTALL_BINOP (op_add, octave_streamoff, octave_scalar, add_so_s); + INSTALL_BINOP (op_sub, octave_streamoff, octave_scalar, sub_so_s); + + INSTALL_BINOP (op_add, octave_scalar, octave_streamoff, add_s_so); + INSTALL_BINOP (op_sub, octave_scalar, octave_streamoff, sub_s_so); + + INSTALL_ASSIGNOP (op_asn_eq, octave_streamoff, octave_streamoff, assign); +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 3b74f1a86750 -r bd2067547b40 src/oct-stream.cc --- a/src/oct-stream.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/src/oct-stream.cc Sun Nov 23 08:07:53 2003 +0000 @@ -43,6 +43,7 @@ #include "oct-stdstrm.h" #include "oct-stream.h" #include "oct-obj.h" +#include "ov-streamoff.h" #include "utils.h" // Possible values for conv_err: @@ -2697,12 +2698,12 @@ { int retval = -1; - int conv_err = 0; - - int xoffset = convert_to_valid_int (tc_offset, conv_err); - - if (! conv_err) + std::streamoff xoffset = tc_offset.streamoff_value (); + + if (! error_state) { + int conv_err = 0; + std::ios::seekdir origin = std::ios::beg; if (tc_origin.is_string ()) diff -r 3b74f1a86750 -r bd2067547b40 src/ov-base.cc --- a/src/ov-base.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-base.cc Sun Nov 23 08:07:53 2003 +0000 @@ -466,11 +466,20 @@ return retval; } -streamoff_array +std::streamoff octave_base_value::streamoff_value (void) const { + std::streamoff retval; + gripe_wrong_type_arg ("octave_base_value::streamoff_value()", type_name ()); + return retval; +} + +streamoff_array +octave_base_value::streamoff_array_value (void) const +{ streamoff_array retval; - gripe_wrong_type_arg ("octave_base_value::streamoff_value()", type_name ()); + gripe_wrong_type_arg ("octave_base_value::streamoff_array_value()", + type_name ()); return retval; } diff -r 3b74f1a86750 -r bd2067547b40 src/ov-base.h --- a/src/ov-base.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-base.h Sun Nov 23 08:07:53 2003 +0000 @@ -226,7 +226,9 @@ int stream_number (void) const; - streamoff_array streamoff_value (void) const; + std::streamoff streamoff_value (void) const; + + streamoff_array streamoff_array_value (void) const; octave_function *function_value (bool silent); diff -r 3b74f1a86750 -r bd2067547b40 src/ov-builtin.h --- a/src/ov-builtin.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-builtin.h Sun Nov 23 08:07:53 2003 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - #include #include "ov-fcn.h" @@ -44,7 +42,7 @@ { public: - octave_builtin (void) { abort (); } + octave_builtin (void) { } typedef octave_value_list (*fcn) (const octave_value_list&, int); @@ -79,7 +77,11 @@ private: - octave_builtin (const octave_builtin& m); + // No copying! + + octave_builtin (const octave_builtin& ob); + + octave_builtin& operator = (const octave_builtin& ob); DECLARE_OCTAVE_ALLOCATOR diff -r 3b74f1a86750 -r bd2067547b40 src/ov-cell.h --- a/src/ov-cell.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-cell.h Sun Nov 23 08:07:53 2003 +0000 @@ -88,6 +88,8 @@ const std::list& idx, const octave_value& rhs); + bool is_matrix_type (void) const { return false; } + bool is_numeric_type (void) const { return false; } bool is_defined (void) const { return true; } diff -r 3b74f1a86750 -r bd2067547b40 src/ov-dld-fcn.h --- a/src/ov-dld-fcn.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-dld-fcn.h Sun Nov 23 08:07:53 2003 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - #include #include "oct-shlib.h" @@ -49,7 +47,7 @@ { public: - octave_dld_function (void) { abort (); } + octave_dld_function (void) { } octave_dld_function (octave_builtin::fcn ff, const octave_shlib& shl, const std::string& nm = std::string (), @@ -73,8 +71,6 @@ private: - octave_dld_function (const octave_dld_function& m); - octave_shlib sh_lib; // The time the file was last checked to see if it needs to be @@ -86,6 +82,12 @@ // on the file to see if it has changed. bool system_fcn_file; + // No copying! + + octave_dld_function (const octave_dld_function& fn); + + octave_dld_function& operator = (const octave_dld_function& fn); + DECLARE_OCTAVE_ALLOCATOR DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA diff -r 3b74f1a86750 -r bd2067547b40 src/ov-fcn.h --- a/src/ov-fcn.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-fcn.h Sun Nov 23 08:07:53 2003 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - #include #include "oct-time.h" @@ -47,10 +45,7 @@ { public: - octave_function (void) { abort (); } - - octave_function (const octave_function& f) - : octave_base_value (), my_name (f.my_name), doc (f.doc) { } + octave_function (void) { } ~octave_function (void) { } @@ -98,6 +93,12 @@ private: + // No copying! + + octave_function (const octave_function& f); + + octave_function& operator = (const octave_function& f); + DECLARE_OCTAVE_ALLOCATOR }; diff -r 3b74f1a86750 -r bd2067547b40 src/ov-mapper.h --- a/src/ov-mapper.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-mapper.h Sun Nov 23 08:07:53 2003 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - #include #include "oct-obj.h" @@ -45,7 +43,7 @@ { public: - octave_mapper (void) { abort (); } + octave_mapper (void) { } typedef int (*ch_mapper) (int); typedef bool (*d_b_mapper) (double); @@ -86,8 +84,6 @@ private: - octave_mapper (const octave_mapper& m); - octave_value apply (const octave_value& arg) const; // ch_map_fcn is a kluge. @@ -121,6 +117,12 @@ bool can_ret_cmplx_for_real; + // No copying! + + octave_mapper (const octave_mapper& om); + + octave_mapper& operator = (const octave_mapper& om); + DECLARE_OCTAVE_ALLOCATOR DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA diff -r 3b74f1a86750 -r bd2067547b40 src/ov-re-mat.cc --- a/src/ov-re-mat.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-re-mat.cc Sun Nov 23 08:07:53 2003 +0000 @@ -82,8 +82,7 @@ { double retval = lo_ieee_nan_value (); - // XXX FIXME XXX -- maybe this should be a function, valid_as_scalar() - if (rows () > 0 && columns () > 0) + if (numel () > 0) { // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? if (Vwarn_fortran_indexing) @@ -135,6 +134,29 @@ return ComplexMatrix (matrix.matrix_value ()); } +streamoff_array +octave_matrix::streamoff_array_value (void) const +{ + streamoff_array retval (dims ()); + + int nel = numel (); + + for (int i = 0; i < nel; i++) + { + double d = matrix(i); + + if (D_NINT (d) == d) + retval(i) = std::streamoff (static_cast (d)); + else + { + error ("conversion to streamoff_array value failed"); + break; + } + } + + return retval; +} + octave_value octave_matrix::convert_to_str_internal (bool, bool) const { diff -r 3b74f1a86750 -r bd2067547b40 src/ov-re-mat.h --- a/src/ov-re-mat.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-re-mat.h Sun Nov 23 08:07:53 2003 +0000 @@ -39,6 +39,7 @@ #include "error.h" #include "ov-base.h" #include "ov-base-mat.h" +#include "ov-streamoff.h" #include "ov-typeinfo.h" class Octave_map; @@ -103,6 +104,8 @@ NDArray array_value (bool = false) const { return matrix; } + streamoff_array streamoff_array_value (void) const; + void increment (void) { matrix += 1.0; } void decrement (void) { matrix -= 1.0; } diff -r 3b74f1a86750 -r bd2067547b40 src/ov-scalar.cc --- a/src/ov-scalar.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-scalar.cc Sun Nov 23 08:07:53 2003 +0000 @@ -76,6 +76,19 @@ return retval; } +std::streamoff +octave_scalar::streamoff_value (void) const +{ + std::streamoff retval (-1); + + if (D_NINT (scalar) == scalar) + retval = std::streamoff (static_cast (scalar)); + else + error ("conversion to streamoff value failed"); + + return retval; +} + octave_value octave_scalar::convert_to_str_internal (bool, bool) const { diff -r 3b74f1a86750 -r bd2067547b40 src/ov-scalar.h --- a/src/ov-scalar.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-scalar.h Sun Nov 23 08:07:53 2003 +0000 @@ -100,6 +100,8 @@ ComplexNDArray complex_array_value (bool = false) const { return ComplexNDArray (dim_vector (1, 1), Complex (scalar)); } + std::streamoff streamoff_value (void) const; + octave_value convert_to_str_internal (bool pad, bool force) const; void increment (void) { ++scalar; } diff -r 3b74f1a86750 -r bd2067547b40 src/ov-streamoff.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ov-streamoff.cc Sun Nov 23 08:07:53 2003 +0000 @@ -0,0 +1,235 @@ +/* + +Copyright (C) 2003 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) +#pragma implementation +#endif + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Array.h" +#include "Array.cc" +#include "ArrayN.h" +#include "ArrayN.cc" + +#include "defun.h" +#include "error.h" +#include "gripes.h" +#include "ov-streamoff.h" +#include "oct-obj.h" +#include "unwind-prot.h" +#include "utils.h" +#include "ov-base-mat.h" +#include "ov-base-mat.cc" + +INSTANTIATE_ARRAY_AND_ASSIGN (std::streamoff); + +template class ArrayN; + +template class octave_base_matrix; + +DEFINE_OCTAVE_ALLOCATOR (octave_streamoff); + +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_streamoff, + "streamoff", "streamoff"); +boolNDArray +streamoff_array::all (int dim) const +{ + MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (MX_ND_ALL_EXPR), true); +} + +boolNDArray +streamoff_array::any (int dim) const +{ + MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR), false); +} + +#if 0 +streamoff_array& +streamoff_array::operator += (const streamoff_array& a) +{ + // XXX FIXME XXX + return *this; +} + +streamoff_array& +streamoff_array::operator -= (const streamoff_array& a) +{ + // XXX FIXME XXX + return *this; +} +#endif + +int +streamoff_array::compute_index (Array& ra_idx, + const dim_vector& dimensions) +{ + return ::compute_index (ra_idx, dimensions); +} + +SND_CMP_OP (mx_el_eq, ==, std::streamoff, , streamoff_array, , FBM) +SND_CMP_OP (mx_el_ne, !=, std::streamoff, , streamoff_array, , TBM) + +NDS_CMP_OP (mx_el_eq, ==, streamoff_array, , std::streamoff, , FBM) +NDS_CMP_OP (mx_el_ne, !=, streamoff_array, , std::streamoff, , TBM) + +NDND_CMP_OP (mx_el_eq, ==, streamoff_array, , streamoff_array, , FBM, TBM) +NDND_CMP_OP (mx_el_ne, !=, streamoff_array, , streamoff_array, , TBM, FBM) + +NDND_BIN_OP (streamoff_array, operator +, streamoff_array, streamoff_array, mx_inline_add) +NDND_BIN_OP (streamoff_array, operator -, streamoff_array, streamoff_array, mx_inline_subtract) + +NDS_BIN_OP (streamoff_array, operator +, streamoff_array, std::streamoff, mx_inline_add) +NDS_BIN_OP (streamoff_array, operator -, streamoff_array, std::streamoff, mx_inline_subtract) + +SND_BIN_OP (streamoff_array, operator +, std::streamoff, streamoff_array, mx_inline_add) +SND_BIN_OP (streamoff_array, operator -, std::streamoff, streamoff_array, mx_inline_subtract) + +std::streamoff +octave_streamoff::streamoff_value (void) const +{ + std::streamoff retval (-1); + + if (numel () > 0) + { + // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? + if (Vwarn_fortran_indexing) + gripe_implicit_conversion ("streamoff array", "scalar streamoff"); + + retval = matrix (0, 0); + } + else + gripe_invalid_conversion ("streamoff array", "scalar streamoff"); + + return retval; +} + +void +octave_streamoff::print (std::ostream& os, bool) const +{ + print_raw (os); + newline (os); +} + +void +octave_streamoff::print_raw (std::ostream& os, bool) const +{ + dim_vector dv = matrix.dims (); + os << "<" << dv.str () << " streamoff object>"; +} + +DEFUN (isstreamoff, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} isstreamoff (@var{x})\n\ +Return true if @var{x} is a streamoff object. Otherwise, return\n\ +false.\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 1) + retval = args(0).is_streamoff (); + else + print_usage ("isstreamoff"); + + return retval; +} + +DEFUN (streamoff, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} streamoff (@var{x})\n\ +@deftypefnx {Built-in Function} {} streamoff (@var{n}, @var{m})\n\ +Create a new streamoff array object. If invoked with a single scalar\n\ +argument, @code{streamoff} returns a square streamoff array with\n\ +the dimension specified. If you supply two scalar arguments,\n\ +@code{streamoff} takes them to be the number of rows and columns.\n\ +If given a vector with two elements, @code{streamoff} uses the values\n\ +of the elements as the number of rows and columns, respectively.\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + dim_vector dims; + + switch (nargin) + { + case 0: + dims = dim_vector (0, 0); + break; + + case 1: + get_dimensions (args(0), "streamoff", dims); + break; + + default: + { + dims.resize (nargin); + + for (int i = 0; i < nargin; i++) + { + dims(i) = args(i).is_empty () ? 0 : args(i).nint_value (); + + if (error_state) + { + error ("streamoff: expecting scalar arguments"); + break; + } + } + } + break; + } + + if (! error_state) + { + int ndim = dims.length (); + + check_dimensions (dims, "streamoff"); + + if (! error_state) + { + switch (ndim) + { + case 1: + retval = Cell (dims(0), dims(0), Matrix ()); + break; + + default: + retval = Cell (dims, Matrix ()); + break; + } + } + } + + return retval; +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 3b74f1a86750 -r bd2067547b40 src/ov-streamoff.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ov-streamoff.h Sun Nov 23 08:07:53 2003 +0000 @@ -0,0 +1,160 @@ +/* + +Copyright (C) 2003 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if !defined (octave_streamoff_h) +#define octave_streamoff_h 1 + +#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) +#pragma interface +#endif + +#include +#include + +#include "mx-base.h" +#include "mx-op-defs.h" +#include "oct-alloc.h" +#include "str-vec.h" + +#include "error.h" +#include "oct-obj.h" +#include "ov-base-mat.h" +#include "ov-typeinfo.h" + +class tree_walker; + +// Stream offsets. + +class streamoff_array : public ArrayN +{ +public: + + streamoff_array (void) : ArrayN () { } + + streamoff_array (const dim_vector& dv, + const std::streamoff& val = resize_fill_value ()) + : ArrayN (dv, val) { } + + streamoff_array (const ArrayN& sa) + : ArrayN (sa) { } + + streamoff_array (const streamoff_array& sa) + : ArrayN (sa) { } + + ~streamoff_array (void) { } + + streamoff_array& operator = (const streamoff_array& a) + { + if (this != &a) + ArrayN::operator = (a); + + return *this; + } + + streamoff_array squeeze (void) const + { return ArrayN::squeeze (); } + + boolNDArray all (int dim = -1) const; + boolNDArray any (int dim = -1) const; + + // streamoff_array& operator += (const streamoff_array& a); + // streamoff_array& operator -= (const streamoff_array& a); + + static int compute_index (Array& ra_idx, + const dim_vector& dimensions); + + static std::streamoff resize_fill_value (void) { return 0; } +}; + +NDCMP_OP_DECL (mx_el_eq, std::streamoff, streamoff_array); +NDCMP_OP_DECL (mx_el_ne, std::streamoff, streamoff_array); + +NDCMP_OP_DECL (mx_el_eq, streamoff_array, std::streamoff); +NDCMP_OP_DECL (mx_el_ne, streamoff_array, std::streamoff); + +NDCMP_OP_DECL (mx_el_eq, streamoff_array, streamoff_array); +NDCMP_OP_DECL (mx_el_ne, streamoff_array, streamoff_array); + +BIN_OP_DECL (streamoff_array, operator +, streamoff_array, streamoff_array); +BIN_OP_DECL (streamoff_array, operator -, streamoff_array, streamoff_array); + +BIN_OP_DECL (streamoff_array, operator +, streamoff_array, std::streamoff); +BIN_OP_DECL (streamoff_array, operator -, streamoff_array, std::streamoff); + +BIN_OP_DECL (streamoff_array, operator +, std::streamoff, streamoff_array); +BIN_OP_DECL (streamoff_array, operator -, std::streamoff, streamoff_array); + +class +octave_streamoff : public octave_base_matrix +{ +public: + + octave_streamoff (void) + : octave_base_matrix () { } + + octave_streamoff (const std::streamoff& off) + : octave_base_matrix + (streamoff_array (dim_vector (1, 1), off)) { } + + octave_streamoff (const streamoff_array& off) + : octave_base_matrix (off) { } + + octave_streamoff (const octave_streamoff& off) + : octave_base_matrix (off) { } + + ~octave_streamoff (void) { } + + octave_value *clone (void) const { return new octave_streamoff (*this); } + octave_value *empty_clone (void) const { return new octave_streamoff (); } + + bool is_defined (void) const { return true; } + + bool is_streamoff (void) const { return true; } + + std::streamoff streamoff_value (void) const; + + streamoff_array streamoff_array_value (void) const { return matrix; } + + // void increment (void) { matrix += 1; } + + // void decrement (void) { matrix -= 1; } + + bool print_as_scalar (void) const { return true; } + + void print (std::ostream& os, bool pr_as_read_syntax = false) const; + + void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; + +private: + + DECLARE_OCTAVE_ALLOCATOR + + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 3b74f1a86750 -r bd2067547b40 src/ov-typeinfo.h --- a/src/ov-typeinfo.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-typeinfo.h Sun Nov 23 08:07:53 2003 +0000 @@ -122,6 +122,7 @@ octave_value_typeinfo (void) : num_types (0), types (init_tab_sz, std::string ()), + vals (init_tab_sz), unary_ops (octave_value::num_unary_ops, init_tab_sz, (unary_op_fcn) 0), non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, diff -r 3b74f1a86750 -r bd2067547b40 src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-usr-fcn.cc Sun Nov 23 08:07:53 2003 +0000 @@ -558,12 +558,15 @@ void octave_user_function::install_automatic_vars (void) { - argn_sr = sym_tab->lookup ("argn", true); - nargin_sr = sym_tab->lookup ("nargin", true); - nargout_sr = sym_tab->lookup ("nargout", true); + if (sym_tab) + { + argn_sr = sym_tab->lookup ("argn", true); + nargin_sr = sym_tab->lookup ("nargin", true); + nargout_sr = sym_tab->lookup ("nargout", true); - if (takes_varargs ()) - varargin_sr = sym_tab->lookup ("varargin", true); + if (takes_varargs ()) + varargin_sr = sym_tab->lookup ("varargin", true); + } } void diff -r 3b74f1a86750 -r bd2067547b40 src/ov-usr-fcn.h --- a/src/ov-usr-fcn.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov-usr-fcn.h Sun Nov 23 08:07:53 2003 +0000 @@ -168,8 +168,6 @@ private: - octave_user_function (const octave_user_function& m); - // List of arguments for this function. These are local variables. tree_parameter_list *param_list; @@ -256,6 +254,13 @@ void bind_automatic_vars (const string_vector& arg_names, int nargin, int nargout, const octave_value_list& va_args); + + // No copying! + + octave_user_function (const octave_user_function& fn); + + octave_user_function& operator = (const octave_user_function& fn); + DECLARE_OCTAVE_ALLOCATOR DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA diff -r 3b74f1a86750 -r bd2067547b40 src/ov.cc --- a/src/ov.cc Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov.cc Sun Nov 23 08:07:53 2003 +0000 @@ -930,12 +930,18 @@ return rep->stream_number (); } -streamoff_array +std::streamoff octave_value::streamoff_value (void) const { return rep->streamoff_value (); } +streamoff_array +octave_value::streamoff_array_value (void) const +{ + return rep->streamoff_array_value (); +} + octave_function * octave_value::function_value (bool silent) { diff -r 3b74f1a86750 -r bd2067547b40 src/ov.h --- a/src/ov.h Sat Nov 22 12:58:40 2003 +0000 +++ b/src/ov.h Sun Nov 23 08:07:53 2003 +0000 @@ -548,7 +548,9 @@ virtual int stream_number (void) const; - virtual streamoff_array streamoff_value (void) const; + virtual std::streamoff streamoff_value (void) const; + + virtual streamoff_array streamoff_array_value (void) const; virtual octave_function *function_value (bool silent = false); @@ -779,7 +781,7 @@ { \ t_id = octave_value_typeinfo::register_type (t::t_name, \ t::c_name, \ - octave_value (new t)); \ + octave_value (new t ())); \ } // If TRUE, print a warning for assignments like