# HG changeset patch # User jwe # Date 1094619752 0 # Node ID 25c2664861bcf4a77b40d9fa20fd35dc060f4131 # Parent 52f808101130f4e70df687356664e3ce6e2c4d5d [project @ 2004-09-08 05:02:32 by jwe] diff -r 52f808101130 -r 25c2664861bc liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Sep 08 02:44:04 2004 +0000 +++ b/liboctave/ChangeLog Wed Sep 08 05:02:32 2004 +0000 @@ -1,5 +1,10 @@ 2004-09-07 John W. Eaton + * data-conv.cc (oct_data_conv::string_to_data_type): Handle dt_logical. + (oct_data_conv::data_type_as_string): Likewise. + + * data-conv.h (oct_data_conv::data_type): Add dt_logical to list. + * Range.cc (round): Delete unused function. * lo-mappers.cc (xround): Rename from round. Change all uses. diff -r 52f808101130 -r 25c2664861bc liboctave/data-conv.cc --- a/liboctave/data-conv.cc Wed Sep 08 02:44:04 2004 +0000 +++ b/liboctave/data-conv.cc Wed Sep 08 05:02:32 2004 +0000 @@ -235,6 +235,8 @@ else retval = dt_single; } + else if (s == "logical") + retval = dt_logical; else (*current_liboctave_error_handler) ("invalid data type specified"); @@ -448,6 +450,10 @@ retval = "float"; break; + case oct_data_conv::dt_logical: + retval = "logical"; + break; + case oct_data_conv::dt_unknown: default: retval = "unknown"; diff -r 52f808101130 -r 25c2664861bc liboctave/data-conv.h --- a/liboctave/data-conv.h Wed Sep 08 02:44:04 2004 +0000 +++ b/liboctave/data-conv.h Wed Sep 08 05:02:32 2004 +0000 @@ -79,16 +79,17 @@ dt_char = 10, dt_schar = 11, dt_uchar = 12, - dt_short = 13, - dt_ushort = 14, - dt_int = 15, - dt_uint = 16, - dt_long = 17, - dt_ulong = 18, - dt_longlong = 19, - dt_ulonglong = 20, - dt_float = 21, - dt_unknown = 22 // Must be last, have largest value! + dt_logical = 13, + dt_short = 14, + dt_ushort = 15, + dt_int = 16, + dt_uint = 17, + dt_long = 18, + dt_ulong = 19, + dt_longlong = 20, + dt_ulonglong = 21, + dt_float = 22, + dt_unknown = 23 // Must be last, have largest value! }; static data_type string_to_data_type (const std::string& s); diff -r 52f808101130 -r 25c2664861bc src/ChangeLog --- a/src/ChangeLog Wed Sep 08 02:44:04 2004 +0000 +++ b/src/ChangeLog Wed Sep 08 05:02:32 2004 +0000 @@ -1,5 +1,16 @@ +2004-09-08 John W. Eaton + + * ov.h: Add octave_array_type_traits specialization for + boolNDArray element type. + 2004-09-07 John W. Eaton + * oct-stream.cc: Instantiate octave_stream::write for Array. + (octave_stream::read): Expand read_fptr_table to include dt_logical. + + * ov-bool.h (octave_bool::write): New function. + * ov-bool-mat.h (octave_bool_matrix::write): New function. + * ov-fcn-inline.h (octave_fcn_inline::octave_fcn_inline): New copy constructor. (octave_fcn_inline::clone, octave_fcn_inline::empty_clone): diff -r 52f808101130 -r 25c2664861bc src/oct-stream.cc --- a/src/oct-stream.cc Wed Sep 08 02:44:04 2004 +0000 +++ b/src/oct-stream.cc Wed Sep 08 05:02:32 2004 +0000 @@ -2972,17 +2972,17 @@ DO_READ_VAL_TEMPLATE (VAL_T, signed char); \ DO_READ_VAL_TEMPLATE (VAL_T, unsigned char) -INSTANTIATE_DO_READ(int8NDArray); -INSTANTIATE_DO_READ(uint8NDArray); -INSTANTIATE_DO_READ(int16NDArray); -INSTANTIATE_DO_READ(uint16NDArray); -INSTANTIATE_DO_READ(int32NDArray); -INSTANTIATE_DO_READ(uint32NDArray); -INSTANTIATE_DO_READ(int64NDArray); -INSTANTIATE_DO_READ(uint64NDArray); -// INSTANTIATE_DO_READ(floatNDArray); -INSTANTIATE_DO_READ(NDArray); -INSTANTIATE_DO_READ(charNDArray); +INSTANTIATE_DO_READ (int8NDArray); +INSTANTIATE_DO_READ (uint8NDArray); +INSTANTIATE_DO_READ (int16NDArray); +INSTANTIATE_DO_READ (uint16NDArray); +INSTANTIATE_DO_READ (int32NDArray); +INSTANTIATE_DO_READ (uint32NDArray); +INSTANTIATE_DO_READ (int64NDArray); +INSTANTIATE_DO_READ (uint64NDArray); +// INSTANTIATE_DO_READ (floatNDArray); +INSTANTIATE_DO_READ (NDArray); +INSTANTIATE_DO_READ (charNDArray); typedef octave_value (*read_fptr) (octave_stream&, int, int, int, int, bool, oct_mach_info::float_format ffmt, int&); @@ -3003,7 +3003,8 @@ read_fptr_table(R,oct_data_conv::dt_double) = do_read; \ read_fptr_table(R,oct_data_conv::dt_char) = do_read; \ read_fptr_table(R,oct_data_conv::dt_schar) = do_read; \ - read_fptr_table(R,oct_data_conv::dt_uchar) = do_read + read_fptr_table(R,oct_data_conv::dt_uchar) = do_read; \ + read_fptr_table(R,oct_data_conv::dt_logical) = do_read octave_value octave_stream::read (const Array& size, int block_size, @@ -3016,7 +3017,7 @@ // Table function pointers for return types x read types. - static Array2 read_fptr_table (oct_data_conv::dt_unknown, 13, 0); + static Array2 read_fptr_table (oct_data_conv::dt_unknown, 14, 0); if (! initialized) { @@ -3032,6 +3033,7 @@ FILL_TABLE_ROW (oct_data_conv::dt_char, charNDArray); FILL_TABLE_ROW (oct_data_conv::dt_schar, charNDArray); FILL_TABLE_ROW (oct_data_conv::dt_uchar, charNDArray); + FILL_TABLE_ROW (oct_data_conv::dt_logical, boolNDArray); initialized = true; } @@ -3311,6 +3313,11 @@ int, oct_mach_info::float_format); template int +octave_stream::write (const Array&, int, + oct_data_conv::data_type, + int, oct_mach_info::float_format); + +template int octave_stream::write (const Array&, int, oct_data_conv::data_type, int, oct_mach_info::float_format); diff -r 52f808101130 -r 25c2664861bc src/ov-bool-mat.h --- a/src/ov-bool-mat.h Wed Sep 08 02:44:04 2004 +0000 +++ b/src/ov-bool-mat.h Wed Sep 08 05:02:32 2004 +0000 @@ -36,6 +36,7 @@ #include "oct-alloc.h" #include "error.h" +#include "oct-stream.h" #include "ov-base.h" #include "ov-base-mat.h" #include "ov-typeinfo.h" @@ -131,6 +132,11 @@ bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); #endif + int write (octave_stream& os, int block_size, + oct_data_conv::data_type output_type, int skip, + oct_mach_info::float_format flt_fmt) const + { return os.write (matrix, block_size, output_type, skip, flt_fmt); } + protected: DECLARE_OCTAVE_ALLOCATOR diff -r 52f808101130 -r 25c2664861bc src/ov-bool.h --- a/src/ov-bool.h Wed Sep 08 02:44:04 2004 +0000 +++ b/src/ov-bool.h Wed Sep 08 05:02:32 2004 +0000 @@ -37,6 +37,7 @@ #include "oct-alloc.h" #include "str-vec.h" +#include "oct-stream.h" #include "ov-base.h" #include "ov-base-scalar.h" #include "ov-typeinfo.h" @@ -132,6 +133,14 @@ bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); #endif + int write (octave_stream& os, int block_size, + oct_data_conv::data_type output_type, int skip, + oct_mach_info::float_format flt_fmt) const + { + return os.write (bool_array_value (), block_size, output_type, + skip, flt_fmt); + } + private: DECLARE_OCTAVE_ALLOCATOR diff -r 52f808101130 -r 25c2664861bc src/ov.cc --- a/src/ov.cc Wed Sep 08 02:44:04 2004 +0000 +++ b/src/ov.cc Wed Sep 08 05:02:32 2004 +0000 @@ -29,8 +29,9 @@ #endif #include "Array-flags.h" +#include "data-conv.h" +#include "quit.h" #include "str-vec.h" -#include "quit.h" #include "oct-obj.h" #include "oct-stream.h" @@ -2158,6 +2159,25 @@ octave_streamoff::register_type (); } +#if 0 +DEFUN (cast, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} cast (@var{val}, @var{type})\n\ +Convert @var{val} to the new data type @var{type}.\n\ +@end deftypefn\n\ +@seealso{class, typeinfo}") +{ + octave_value retval; + + if (args.length () == 2) + error ("cast: not implemented"); + else + print_usage ("cast"); + + return retval; +} +#endif + DEFUN (sizeof, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} sizeof (@var{val})\n\ diff -r 52f808101130 -r 25c2664861bc src/ov.h --- a/src/ov.h Wed Sep 08 02:44:04 2004 +0000 +++ b/src/ov.h Wed Sep 08 05:02:32 2004 +0000 @@ -1000,6 +1000,7 @@ } OCTAVE_ARRAY_TYPE_TRAIT (charNDArray, char); +OCTAVE_ARRAY_TYPE_TRAIT (boolNDArray, bool); OCTAVE_ARRAY_TYPE_TRAIT (int8NDArray, octave_int8); OCTAVE_ARRAY_TYPE_TRAIT (uint8NDArray, octave_uint8); OCTAVE_ARRAY_TYPE_TRAIT (int16NDArray, octave_int16);