# HG changeset patch # User John W. Eaton # Date 1245301757 -7200 # Node ID 49affc56fac2c53e7c8766ddc8543ad12d1a52a8 # Parent abe4d6657872c027e5baebb8a4948bddae4f36b3 mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign diff -r abe4d6657872 -r 49affc56fac2 src/ChangeLog --- a/src/ChangeLog Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ChangeLog Thu Jun 18 07:09:17 2009 +0200 @@ -1,3 +1,16 @@ +2009-06-17 John W. Eaton + + * mex.cc (mxArray_octave_value::get_data): + If octave_value::mex_get_data returns a valid pointer, mark it as + foreign and return it instead of enumerating the types that can be + handled directly. + + * ov-re-mat.h (octave_matrix::mex_get_data): New function. + * ov-bool-mat.h (octave_bool_matrix::mex_get_data): Ditto. + * ov-flt-re-mat.h (octave_float_matrix::mex_get_data): Ditto. + * ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::mex_get_data): Ditto. + * ov-base-mat.h (octave_base_matrix::mex_get_data): Delete. + 2009-06-16 Jaroslav Hajek * symtab.h (symbol_table::set_scope_and_context): Avoid checking diff -r abe4d6657872 -r 49affc56fac2 src/mex.cc --- a/src/mex.cc Thu Jun 18 07:09:17 2009 +0200 +++ b/src/mex.cc Thu Jun 18 07:09:17 2009 +0200 @@ -498,11 +498,10 @@ void *get_data (void) const { - void *retval = 0; - - if (is_char () - || (is_numeric () && is_real_type () && ! is_range ())) - retval = maybe_mark_foreign (val.mex_get_data ()); + void *retval = val.mex_get_data (); + + if (retval) + maybe_mark_foreign (retval); else request_mutation (); diff -r abe4d6657872 -r 49affc56fac2 src/ov-base-diag.cc --- a/src/ov-base-diag.cc Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ov-base-diag.cc Thu Jun 18 07:09:17 2009 +0200 @@ -500,7 +500,7 @@ octave_base_diag::to_dense (void) const { if (! dense_cache.is_defined ()) - dense_cache = MT (matrix); + dense_cache = MT (matrix); return dense_cache; } diff -r abe4d6657872 -r 49affc56fac2 src/ov-base-mat.h --- a/src/ov-base-mat.h Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ov-base-mat.h Thu Jun 18 07:09:17 2009 +0200 @@ -151,10 +151,6 @@ void print_info (std::ostream& os, const std::string& prefix) const; - // Unsafe. This function exists to support the MEX interface. - // You should not use it anywhere else. - void *mex_get_data (void) const { return matrix.mex_get_data (); } - protected: MT matrix; diff -r abe4d6657872 -r 49affc56fac2 src/ov-bool-mat.h --- a/src/ov-bool-mat.h Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ov-bool-mat.h Thu Jun 18 07:09:17 2009 +0200 @@ -196,6 +196,10 @@ oct_mach_info::float_format flt_fmt) const { return os.write (matrix, block_size, output_type, skip, flt_fmt); } + // Unsafe. This function exists to support the MEX interface. + // You should not use it anywhere else. + void *mex_get_data (void) const { return matrix.mex_get_data (); } + mxArray *as_mxArray (void) const; // Mapper functions are converted to double for treatment diff -r abe4d6657872 -r 49affc56fac2 src/ov-flt-re-mat.h --- a/src/ov-flt-re-mat.h Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ov-flt-re-mat.h Thu Jun 18 07:09:17 2009 +0200 @@ -190,6 +190,10 @@ oct_mach_info::float_format flt_fmt) const { return os.write (matrix, block_size, output_type, skip, flt_fmt); } + // Unsafe. This function exists to support the MEX interface. + // You should not use it anywhere else. + void *mex_get_data (void) const { return matrix.mex_get_data (); } + mxArray *as_mxArray (void) const; octave_value erf (void) const; diff -r abe4d6657872 -r 49affc56fac2 src/ov-intx.h --- a/src/ov-intx.h Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ov-intx.h Thu Jun 18 07:09:17 2009 +0200 @@ -323,6 +323,10 @@ oct_mach_info::float_format flt_fmt) const { return os.write (matrix, block_size, output_type, skip, flt_fmt); } + // Unsafe. This function exists to support the MEX interface. + // You should not use it anywhere else. + void *mex_get_data (void) const { return matrix.mex_get_data (); } + mxArray *as_mxArray (void) const { mxArray *retval = new mxArray (OCTAVE_INT_MX_CLASS, dims (), mxREAL); diff -r abe4d6657872 -r 49affc56fac2 src/ov-re-mat.h --- a/src/ov-re-mat.h Thu Jun 18 07:09:17 2009 +0200 +++ b/src/ov-re-mat.h Thu Jun 18 07:09:17 2009 +0200 @@ -189,6 +189,10 @@ oct_mach_info::float_format flt_fmt) const { return os.write (matrix, block_size, output_type, skip, flt_fmt); } + // Unsafe. This function exists to support the MEX interface. + // You should not use it anywhere else. + void *mex_get_data (void) const { return matrix.mex_get_data (); } + mxArray *as_mxArray (void) const; octave_value erf (void) const;