Mercurial > hg > octave-lojdl
changeset 11999:49affc56fac2 release-3-2-x
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 18 Jun 2009 07:09:17 +0200 |
parents | abe4d6657872 |
children | a9d20c890190 |
files | src/ChangeLog src/mex.cc src/ov-base-diag.cc src/ov-base-mat.h src/ov-bool-mat.h src/ov-flt-re-mat.h src/ov-intx.h src/ov-re-mat.h |
diffstat | 8 files changed, 34 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2009-06-17 John W. Eaton <jwe@octave.org> + + * 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 <highegg@gmail.com> * symtab.h (symbol_table::set_scope_and_context): Avoid checking
--- a/src/mex.cc +++ b/src/mex.cc @@ -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 ();
--- a/src/ov-base-diag.cc +++ b/src/ov-base-diag.cc @@ -500,7 +500,7 @@ octave_base_diag<DMT, MT>::to_dense (void) const { if (! dense_cache.is_defined ()) - dense_cache = MT (matrix); + dense_cache = MT (matrix); return dense_cache; }
--- a/src/ov-base-mat.h +++ b/src/ov-base-mat.h @@ -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;
--- a/src/ov-bool-mat.h +++ b/src/ov-bool-mat.h @@ -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
--- a/src/ov-flt-re-mat.h +++ b/src/ov-flt-re-mat.h @@ -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;
--- a/src/ov-intx.h +++ b/src/ov-intx.h @@ -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);
--- a/src/ov-re-mat.h +++ b/src/ov-re-mat.h @@ -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;