Mercurial > octave
annotate libinterp/corefcn/mex.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | fa025af77216 |
children | aac27ad79be6 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30501
diff
changeset
|
3 // Copyright (C) 2006-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
7016 | 25 |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
27 # include "config.h" |
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
28 #endif |
5864 | 29 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
30 // #define DEBUG 1 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
31 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
32 #if defined (DEBUG) |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
33 # include <iostream> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
34 #endif |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
35 |
5900 | 36 #include <cstdarg> |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
37 #include <cstdlib> |
5900 | 38 #include <cstring> |
39 #include <cctype> | |
40 | |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
41 #include <limits> |
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
42 #include <map> |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
43 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30494
ba5370c670d5
make use of <memory_resource> conditional on HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR
John W. Eaton <jwe@octave.org>
parents:
30488
diff
changeset
|
44 # include <memory_resource> |
ba5370c670d5
make use of <memory_resource> conditional on HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR
John W. Eaton <jwe@octave.org>
parents:
30488
diff
changeset
|
45 #endif |
5864 | 46 #include <set> |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
47 #include <string> |
5900 | 48 |
49 #include "f77-fcn.h" | |
50 #include "lo-ieee.h" | |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
7901
diff
changeset
|
51 #include "oct-locbuf.h" |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
52 #include "quit.h" |
5900 | 53 |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15096
diff
changeset
|
54 #include "Cell.h" |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
55 #include "error.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23499
diff
changeset
|
56 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
57 #include "interpreter.h" |
5900 | 58 // mxArray must be declared as a class before including mexproto.h. |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15096
diff
changeset
|
59 #include "mxarray.h" |
5900 | 60 #include "mexproto.h" |
61 #include "oct-map.h" | |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20771
diff
changeset
|
62 #include "ovl.h" |
5900 | 63 #include "ov.h" |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
64 #include "ov-classdef.h" |
6068 | 65 #include "ov-mex-fcn.h" |
5900 | 66 #include "ov-usr-fcn.h" |
5864 | 67 #include "pager.h" |
68 #include "parse.h" | |
5900 | 69 #include "unwind-prot.h" |
70 #include "utils.h" | |
5864 | 71 #include "variables.h" |
6595 | 72 #include "graphics.h" |
5900 | 73 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
74 // These must be declared extern "C" but may be omitted from the set of |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
75 // symbols declared in mexproto.h, so we declare them here as well. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
76 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
77 extern "C" |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
78 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
79 extern OCTINTERP_API const mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
80 mexGet_interleaved (double handle, const char *property); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
81 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
82 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
83 mxCreateCellArray (mwSize ndims, const mwSize *dims); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
84 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
85 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
86 mxCreateCellMatrix (mwSize m, mwSize n); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
87 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
88 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
89 mxCreateCharArray (mwSize ndims, const mwSize *dims); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
90 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
91 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
92 mxCreateCharMatrixFromStrings (mwSize m, const char **str); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
93 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
94 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
95 mxCreateDoubleMatrix (mwSize nr, mwSize nc, mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
96 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
97 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
98 mxCreateDoubleScalar (double val); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
99 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
100 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
101 mxCreateLogicalArray (mwSize ndims, const mwSize *dims); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
102 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
103 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
104 mxCreateLogicalMatrix (mwSize m, mwSize n); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
105 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
106 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
107 mxCreateLogicalScalar (mxLogical val); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
108 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
109 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
110 mxCreateNumericArray (mwSize ndims, const mwSize *dims, mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
111 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
112 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
113 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
114 mxCreateNumericMatrix (mwSize m, mwSize n, mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
115 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
116 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
117 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
118 mxCreateUninitNumericArray (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
119 mxClassID class_id, mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
120 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
121 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
122 mxCreateUninitNumericMatrix (mwSize m, mwSize n, mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
123 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
124 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
125 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
126 mxCreateSparse (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
127 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
128 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
129 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
130 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
131 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
132 mxCreateString (const char *str); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
133 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
134 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
135 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
136 const char **keys); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
137 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
138 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
139 mxCreateStructMatrix (mwSize rows, mwSize cols, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
140 const char **keys); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
141 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
142 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
143 mxCreateCellArray_interleaved (mwSize ndims, const mwSize *dims); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
144 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
145 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
146 mxCreateCellMatrix_interleaved (mwSize m, mwSize n); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
147 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
148 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
149 mxCreateCharArray_interleaved (mwSize ndims, const mwSize *dims); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
150 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
151 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
152 mxCreateCharMatrixFromStrings_interleaved (mwSize m, const char **str); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
153 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
154 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
155 mxCreateDoubleMatrix_interleaved (mwSize nr, mwSize nc, mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
156 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
157 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
158 mxCreateDoubleScalar_interleaved (double val); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
159 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
160 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
161 mxCreateLogicalArray_interleaved (mwSize ndims, const mwSize *dims); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
162 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
163 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
164 mxCreateLogicalMatrix_interleaved (mwSize m, mwSize n); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
165 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
166 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
167 mxCreateLogicalScalar_interleaved (mxLogical val); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
168 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
169 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
170 mxCreateNumericArray_interleaved (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
171 mxClassID class_id, mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
172 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
173 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
174 mxCreateNumericMatrix_interleaved (mwSize m, mwSize n, mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
175 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
176 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
177 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
178 mxCreateUninitNumericArray_interleaved (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
179 mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
180 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
181 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
182 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
183 mxCreateUninitNumericMatrix_interleaved (mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
184 mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
185 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
186 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
187 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
188 mxCreateSparse_interleaved (mwSize m, mwSize n, mwSize nzmax, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
189 mxComplexity flag); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
190 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
191 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
192 mxCreateSparseLogicalMatrix_interleaved (mwSize m, mwSize n, mwSize nzmax); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
193 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
194 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
195 mxCreateString_interleaved (const char *str); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
196 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
197 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
198 mxCreateStructArray_interleaved (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
199 int num_keys, const char **keys); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
200 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
201 extern OCTINTERP_API mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
202 mxCreateStructMatrix_interleaved (mwSize rows, mwSize cols, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
203 const char **keys); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
204 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
205 extern OCTINTERP_API int mxMakeArrayReal (mxArray *ptr); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
206 extern OCTINTERP_API int mxMakeArrayComplex (mxArray *ptr); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
207 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
208 extern OCTINTERP_API mxDouble * mxGetDoubles (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
209 extern OCTINTERP_API mxSingle * mxGetSingles (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
210 extern OCTINTERP_API mxInt8 * mxGetInt8s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
211 extern OCTINTERP_API mxInt16 * mxGetInt16s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
212 extern OCTINTERP_API mxInt32 * mxGetInt32s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
213 extern OCTINTERP_API mxInt64 * mxGetInt64s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
214 extern OCTINTERP_API mxUint8 * mxGetUint8s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
215 extern OCTINTERP_API mxUint16 * mxGetUint16s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
216 extern OCTINTERP_API mxUint32 * mxGetUint32s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
217 extern OCTINTERP_API mxUint64 * mxGetUint64s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
218 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
219 extern OCTINTERP_API mxComplexDouble * mxGetComplexDoubles (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
220 extern OCTINTERP_API mxComplexSingle * mxGetComplexSingles (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
221 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
222 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
223 extern OCTINTERP_API mxComplexInt8 * mxGetComplexInt8s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
224 extern OCTINTERP_API mxComplexInt16 * mxGetComplexInt16s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
225 extern OCTINTERP_API mxComplexInt32 * mxGetComplexInt32s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
226 extern OCTINTERP_API mxComplexInt64 * mxGetComplexInt64s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
227 extern OCTINTERP_API mxComplexUint8 * mxGetComplexUint8s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
228 extern OCTINTERP_API mxComplexUint16 * mxGetComplexUint16s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
229 extern OCTINTERP_API mxComplexUint32 * mxGetComplexUint32s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
230 extern OCTINTERP_API mxComplexUint64 * mxGetComplexUint64s (const mxArray *p); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
231 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
232 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
233 extern OCTINTERP_API double * mxGetPi (const mxArray *ptr); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
234 extern OCTINTERP_API void * mxGetImagData (const mxArray *ptr); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
235 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
236 extern OCTINTERP_API int mxSetDoubles (mxArray *p, mxDouble *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
237 extern OCTINTERP_API int mxSetSingles (mxArray *p, mxSingle *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
238 extern OCTINTERP_API int mxSetInt8s (mxArray *p, mxInt8 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
239 extern OCTINTERP_API int mxSetInt16s (mxArray *p, mxInt16 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
240 extern OCTINTERP_API int mxSetInt32s (mxArray *p, mxInt32 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
241 extern OCTINTERP_API int mxSetInt64s (mxArray *p, mxInt64 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
242 extern OCTINTERP_API int mxSetUint8s (mxArray *p, mxUint8 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
243 extern OCTINTERP_API int mxSetUint16s (mxArray *p, mxUint16 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
244 extern OCTINTERP_API int mxSetUint32s (mxArray *p, mxUint32 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
245 extern OCTINTERP_API int mxSetUint64s (mxArray *p, mxUint64 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
246 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
247 extern OCTINTERP_API int mxSetComplexDoubles (mxArray *p, mxComplexDouble *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
248 extern OCTINTERP_API int mxSetComplexSingles (mxArray *p, mxComplexSingle *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
249 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
250 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
251 extern OCTINTERP_API int mxSetComplexInt8s (mxArray *p, mxComplexInt8 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
252 extern OCTINTERP_API int mxSetComplexInt16s (mxArray *p, mxComplexInt16 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
253 extern OCTINTERP_API int mxSetComplexInt32s (mxArray *p, mxComplexInt32 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
254 extern OCTINTERP_API int mxSetComplexInt64s (mxArray *p, mxComplexInt64 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
255 extern OCTINTERP_API int mxSetComplexUint8s (mxArray *p, mxComplexUint8 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
256 extern OCTINTERP_API int mxSetComplexUint16s (mxArray *p, mxComplexUint16 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
257 extern OCTINTERP_API int mxSetComplexUint32s (mxArray *p, mxComplexUint32 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
258 extern OCTINTERP_API int mxSetComplexUint64s (mxArray *p, mxComplexUint64 *d); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
259 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
260 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
261 extern OCTINTERP_API void mxSetPi (mxArray *ptr, double *pi); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
262 extern OCTINTERP_API void mxSetImagData (mxArray *ptr, void *pi); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
263 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
264 |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
265 static void * |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
266 xmalloc (size_t n) |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
267 { |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
268 void *ptr = std::malloc (n); |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
269 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
270 #if defined (DEBUG) |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
271 std::cerr << "xmalloc (" << n << ") = " << ptr << std::endl; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
272 #endif |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
273 |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
274 return ptr; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
275 } |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
276 |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
277 static void * |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
278 xrealloc (void *ptr, size_t n) |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
279 { |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
280 void *newptr = std::realloc (ptr, n); |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
281 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
282 #if defined (DEBUG) |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
283 std::cerr << "xrealloc (" << ptr << ", " << n << ") = " << newptr |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
284 << std::endl; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
285 #endif |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
286 |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
287 return newptr; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
288 } |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
289 |
5905 | 290 static void |
291 xfree (void *ptr) | |
292 { | |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
293 #if defined (DEBUG) |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
294 std::cerr << "xfree (" << ptr << ")" << std::endl; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
295 #endif |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
296 |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
297 std::free (ptr); |
5905 | 298 } |
299 | |
6806 | 300 static mwSize |
301 max_str_len (mwSize m, const char **str) | |
5900 | 302 { |
303 int max_len = 0; | |
304 | |
6806 | 305 for (mwSize i = 0; i < m; i++) |
5900 | 306 { |
6806 | 307 mwSize tmp = strlen (str[i]); |
5900 | 308 |
309 if (tmp > max_len) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
310 max_len = tmp; |
5900 | 311 } |
312 | |
313 return max_len; | |
314 } | |
315 | |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
316 // FIXME: Is there a better/standard way to do this job? |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
317 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
318 template <typename T> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
319 class fp_type_traits |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
320 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
321 public: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
322 static const bool is_complex = false; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
323 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
324 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
325 template <> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
326 class fp_type_traits<Complex> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
327 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
328 public: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
329 static const bool is_complex = true; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
330 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
331 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
332 template <> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
333 class fp_type_traits <FloatComplex> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
334 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
335 public: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
336 static const bool is_complex = true; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
337 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
338 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
339 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
340 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
341 class mx_deleting_memory_resource : public std::pmr::memory_resource |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
342 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
343 private: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
344 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
345 void * do_allocate (std::size_t bytes, size_t /*alignment*/) |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
346 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
347 void *ptr = xmalloc (bytes); |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
348 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
349 if (! ptr) |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
350 throw std::bad_alloc (); |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
351 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
352 return ptr; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
353 } |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
354 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
355 void do_deallocate (void* ptr, std::size_t /*bytes*/, |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
356 std::size_t /*alignment*/) |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
357 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
358 xfree (ptr); |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
359 } |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
360 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
361 bool do_is_equal (const std::pmr::memory_resource& other) const noexcept |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
362 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
363 return this == dynamic_cast<const mx_deleting_memory_resource *> (&other); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
364 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
365 }; |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
366 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
367 class mx_preserving_memory_resource : public std::pmr::memory_resource |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
368 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
369 private: |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
370 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
371 void * do_allocate (std::size_t bytes, size_t /*alignment*/) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
372 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
373 void *ptr = xmalloc (bytes); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
374 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
375 if (! ptr) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
376 throw std::bad_alloc (); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
377 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
378 return ptr; |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
379 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
380 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
381 void do_deallocate (void* /*ptr*/, std::size_t /*bytes*/, |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
382 std::size_t /*alignment*/) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
383 { } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
384 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
385 bool do_is_equal (const std::pmr::memory_resource& other) const noexcept |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
386 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
387 return this == dynamic_cast<const mx_preserving_memory_resource *> (&other); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
388 } |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
389 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
390 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
391 // FIXME: Is it OK for the memory resource object to be defined this |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
392 // way? |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
393 static mx_deleting_memory_resource the_mx_deleting_memory_resource; |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
394 static mx_preserving_memory_resource the_mx_preserving_memory_resource; |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
395 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
396 static std::pmr::memory_resource *current_mx_memory_resource = &the_mx_deleting_memory_resource; |
30494
ba5370c670d5
make use of <memory_resource> conditional on HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR
John W. Eaton <jwe@octave.org>
parents:
30488
diff
changeset
|
397 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
398 #endif |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
399 |
5900 | 400 // ------------------------------------------------------------------ |
401 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
402 mxArray_base::mxArray_base (bool interleaved) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
403 : m_interleaved (interleaved) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
404 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
405 |
7357 | 406 static mwIndex |
407 calc_single_subscript_internal (mwSize ndims, const mwSize *dims, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
408 mwSize nsubs, const mwIndex *subs) |
7357 | 409 { |
410 mwIndex retval = 0; | |
411 | |
412 switch (nsubs) | |
413 { | |
414 case 0: | |
415 break; | |
416 | |
417 case 1: | |
418 retval = subs[0]; | |
419 break; | |
420 | |
421 default: | |
422 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
423 // Both nsubs and ndims should be at least 2 here. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
424 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
425 mwSize n = (nsubs <= ndims ? nsubs : ndims); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
426 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
427 retval = subs[--n]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
428 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
429 while (--n >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
430 retval = dims[n] * retval + subs[n]; |
7357 | 431 } |
432 break; | |
433 } | |
434 | |
435 return retval; | |
436 } | |
437 | |
5900 | 438 // The object that handles values pass to MEX files from Octave. Some |
439 // methods in this class may set mutate_flag to TRUE to tell the | |
440 // mxArray class to convert to the Matlab-style representation and | |
441 // then invoke the method on that object instead (for example, getting | |
442 // a pointer to real or imaginary data from a complex object requires | |
443 // a mutation but getting a pointer to real data from a real object | |
444 // does not). Changing the representation causes a copy so we try to | |
445 // avoid it unless it is really necessary. Once the conversion | |
446 // happens, we delete this representation, so the conversion can only | |
447 // happen once per call to a MEX file. | |
448 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
449 static inline void * maybe_mark_foreign (void *ptr); |
7179 | 450 |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
451 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
452 static inline void maybe_disown_ptr (void *ptr); |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
453 #endif |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
454 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
455 #define VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
456 void FCN_NAME ARG_LIST { request_mutation (); } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
457 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
458 #define CONST_VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
459 void FCN_NAME ARG_LIST const { request_mutation (); } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
460 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
461 #define MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
462 RET_TYPE FCN_NAME ARG_LIST { request_mutation (); return RET_VAL; } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
463 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
464 #define CONST_MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
465 RET_TYPE FCN_NAME ARG_LIST const { request_mutation (); return RET_VAL; } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
466 |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
467 #define GET_DATA_METHOD(RT, FCN_NAME, ID, COMPLEXITY) \ |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
468 RT * FCN_NAME (void) const { return get_data<RT> (ID, COMPLEXITY); } |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
469 |
5900 | 470 class mxArray_octave_value : public mxArray_base |
471 { | |
472 public: | |
473 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
474 mxArray_octave_value (bool interleaved, const octave_value& ov) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
475 : mxArray_base (interleaved), m_val (ov), m_mutate_flag (false), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
476 m_id (mxUNKNOWN_CLASS), m_class_name (nullptr), m_ndims (-1), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
477 m_dims (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
478 { } |
5900 | 479 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
480 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
481 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
482 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
483 mxArray_octave_value& operator = (const mxArray_octave_value&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
484 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
485 mxArray_base * dup (void) const { return new mxArray_octave_value (*this); } |
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
486 |
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
487 mxArray * as_mxArray (void) const |
12331
f39436e14734
mex.cc (mxArray_octave_value::dup): if value can't be converted to mxArray object, create a clone of the mxArray_octave_value container
John W. Eaton <jwe@octave.org>
parents:
12123
diff
changeset
|
488 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
489 mxArray *retval = m_val.as_mxArray (m_interleaved); |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
490 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
491 // RETVAL is assumed to be an mxArray_matlab object. Should we |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
492 // error_unless that condition here? |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
493 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
494 if (retval) |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
495 { |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
496 // Preserve cached values of class name and dimensions in case |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
497 // they will be used after we mutate. |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
498 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
499 // set_class_name will handle deleting class name that comes |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
500 // from as_mxArray conversion function. |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
501 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
502 if (m_class_name) |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
503 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
504 retval->set_class_name (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
505 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
506 m_class_name = nullptr; |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
507 } |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
508 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
509 if (m_dims) |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
510 { |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
511 mwSize *xdims = retval->get_dimensions (); |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
512 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
513 mxFree (xdims); |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
514 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
515 retval->set_dimensions (m_dims, m_ndims); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
516 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
517 m_dims = nullptr; |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
518 } |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
519 } |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
520 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
521 return retval; |
12331
f39436e14734
mex.cc (mxArray_octave_value::dup): if value can't be converted to mxArray object, create a clone of the mxArray_octave_value container
John W. Eaton <jwe@octave.org>
parents:
12123
diff
changeset
|
522 } |
5900 | 523 |
524 ~mxArray_octave_value (void) | |
525 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
526 mxFree (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
527 mxFree (m_dims); |
5900 | 528 } |
529 | |
530 bool is_octave_value (void) const { return true; } | |
531 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
532 int iscell (void) const { return m_val.iscell (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
533 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
534 int is_char (void) const { return m_val.is_string (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
535 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
536 int is_complex (void) const { return m_val.iscomplex (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
537 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
538 int is_double (void) const { return m_val.is_double_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
539 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
540 int is_function_handle (void) const { return m_val.is_function_handle (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
541 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
542 int is_int16 (void) const { return m_val.is_int16_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
543 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
544 int is_int32 (void) const { return m_val.is_int32_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
545 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
546 int is_int64 (void) const { return m_val.is_int64_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
547 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
548 int is_int8 (void) const { return m_val.is_int8_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
549 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
550 int is_logical (void) const { return m_val.islogical (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
551 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
552 int is_numeric (void) const { return m_val.isnumeric (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
553 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
554 int is_single (void) const { return m_val.is_single_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
555 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
556 int is_sparse (void) const { return m_val.issparse (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
557 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
558 int is_struct (void) const { return m_val.isstruct (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
559 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
560 int is_uint16 (void) const { return m_val.is_uint16_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
561 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
562 int is_uint32 (void) const { return m_val.is_uint32_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
563 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
564 int is_uint64 (void) const { return m_val.is_uint64_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
565 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
566 int is_uint8 (void) const { return m_val.is_uint8_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
567 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
568 int is_range (void) const { return m_val.is_range (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
569 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
570 int isreal (void) const { return m_val.isreal (); } |
5900 | 571 |
572 int is_logical_scalar_true (void) const | |
573 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
574 return (is_logical_scalar () && m_val.is_true ()); |
5900 | 575 } |
576 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
577 mwSize get_m (void) const { return m_val.rows (); } |
6686 | 578 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
579 mwSize get_n (void) const |
6187 | 580 { |
6686 | 581 mwSize n = 1; |
6187 | 582 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
583 // Force m_dims and m_ndims to be cached. |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14840
diff
changeset
|
584 get_dimensions (); |
6187 | 585 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
586 for (mwIndex i = m_ndims - 1; i > 0; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
587 n *= m_dims[i]; |
6187 | 588 |
589 return n; | |
590 } | |
5900 | 591 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
592 mwSize * get_dimensions (void) const |
5900 | 593 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
594 if (! m_dims) |
5900 | 595 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
596 m_ndims = m_val.ndims (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
597 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
598 m_dims = static_cast<mwSize *> (mxArray::malloc (m_ndims |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
599 * sizeof (mwSize))); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
600 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
601 dim_vector dv = m_val.dims (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
602 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
603 for (mwIndex i = 0; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
604 m_dims[i] = dv(i); |
5900 | 605 } |
606 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
607 return m_dims; |
5900 | 608 } |
609 | |
6686 | 610 mwSize get_number_of_dimensions (void) const |
5900 | 611 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
612 // Force m_dims and m_ndims to be cached. |
6332 | 613 get_dimensions (); |
5900 | 614 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
615 return m_ndims; |
5900 | 616 } |
617 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
618 VOID_MUTATION_METHOD (set_m, (mwSize)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
619 VOID_MUTATION_METHOD (set_n, (mwSize)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
620 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
621 MUTATION_METHOD (int, set_dimensions, (mwSize *, mwSize), 0) |
5900 | 622 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
623 mwSize get_number_of_elements (void) const { return m_val.numel (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
624 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
625 int isempty (void) const { return m_val.isempty (); } |
5900 | 626 |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
627 bool is_scalar (void) const |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
628 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
629 // Force m_dims and m_ndims to be cached. |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
630 get_dimensions (); |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
631 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
632 return m_ndims == 2 && m_dims[0] == 1 && m_dims[1] == 1; |
22599
51b395d24782
maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents:
22480
diff
changeset
|
633 } |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
634 |
5900 | 635 mxClassID get_class_id (void) const |
636 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
637 m_id = mxUNKNOWN_CLASS; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
638 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
639 std::string cn = m_val.class_name (); |
5900 | 640 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
641 if (cn == "double") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
642 m_id = mxDOUBLE_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
643 else if (cn == "single") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
644 m_id = mxSINGLE_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
645 else if (cn == "char") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
646 m_id = mxCHAR_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
647 else if (cn == "logical") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
648 m_id = mxLOGICAL_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
649 else if (cn == "cell") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
650 m_id = mxCELL_CLASS; |
5900 | 651 else if (cn == "struct") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
652 m_id = mxSTRUCT_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
653 else if (cn == "function_handle") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
654 m_id = mxFUNCTION_CLASS; |
5900 | 655 else if (cn == "int8") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
656 m_id = mxINT8_CLASS; |
5900 | 657 else if (cn == "uint8") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
658 m_id = mxUINT8_CLASS; |
5900 | 659 else if (cn == "int16") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
660 m_id = mxINT16_CLASS; |
5900 | 661 else if (cn == "uint16") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
662 m_id = mxUINT16_CLASS; |
5900 | 663 else if (cn == "int32") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
664 m_id = mxINT32_CLASS; |
5900 | 665 else if (cn == "uint32") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
666 m_id = mxUINT32_CLASS; |
5900 | 667 else if (cn == "int64") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
668 m_id = mxINT64_CLASS; |
5900 | 669 else if (cn == "uint64") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
670 m_id = mxUINT64_CLASS; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
671 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
672 return m_id; |
5900 | 673 } |
674 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
675 const char * get_class_name (void) const |
5900 | 676 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
677 if (! m_class_name) |
5900 | 678 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
679 std::string s = m_val.class_name (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
680 m_class_name = mxArray::strsave (s.c_str ()); |
5900 | 681 } |
682 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
683 return m_class_name; |
5900 | 684 } |
685 | |
686 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
687 VOID_MUTATION_METHOD (set_class_name, (const char *)) |
5900 | 688 |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
689 mxArray * get_property (mwIndex idx, const char *pname) const |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
690 { |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
691 mxArray *retval = nullptr; |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
692 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
693 if (m_val.is_classdef_object ()) |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
694 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
695 octave_classdef *ov_cdef = m_val.classdef_object_value (); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
696 |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
697 if (ov_cdef) |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
698 { |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
699 octave_value pval = ov_cdef->get_property (idx, pname); |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
700 |
23898
a490e729f2f2
correctly return NULL for unknown properties in mxGetProperty (bug #51725)
John W. Eaton <jwe@octave.org>
parents:
23893
diff
changeset
|
701 if (pval.is_defined()) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
702 retval = new mxArray (m_interleaved, pval); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
703 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
704 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
705 |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
706 return retval; |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
707 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
708 |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
709 void set_property (mwIndex idx, const char *pname, const mxArray *pval) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
710 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
711 if (m_val.is_classdef_object ()) |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
712 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
713 octave_classdef *ov_cdef = m_val.classdef_object_value (); |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
714 |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
715 if (ov_cdef) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
716 ov_cdef->set_property (idx, pname, pval->as_octave_value ()); |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
717 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
718 else |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
719 err_invalid_type ("set_property"); |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
720 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
721 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
722 CONST_MUTATION_METHOD (mxArray *, get_cell, (mwIndex), nullptr) |
5900 | 723 |
724 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
725 VOID_MUTATION_METHOD (set_cell, (mwIndex, mxArray *)) |
5900 | 726 |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
727 double get_scalar (void) const |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
728 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
729 if (m_val.issparse ()) |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
730 { |
22599
51b395d24782
maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents:
22480
diff
changeset
|
731 // For sparse arrays, return the first non-zero value. |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
732 const void *m_data = m_val.mex_get_data (); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
733 if (m_data == nullptr) |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
734 return 0.0; |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
735 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
736 if (m_val.islogical ()) |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
737 return *static_cast<const bool *> (m_data); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
738 else if (m_val.isreal ()) |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
739 return *static_cast<const double *> (m_data); |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
740 else // Complex type, only return real part |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
741 return *static_cast<const double *> (m_data); |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
742 } |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
743 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
744 return m_val.scalar_value (true); |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
745 } |
6332 | 746 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
747 void * get_data (void) const |
5900 | 748 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
749 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
750 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
751 void *retval = const_cast<void *> (m_val.mex_get_data ()); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
752 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
753 if (retval && (m_val.isreal () || m_interleaved)) |
29870
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
754 { |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
755 maybe_mark_foreign (retval); |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
756 return retval; |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
757 } |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
758 |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
759 request_mutation (); |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
760 return nullptr; |
5900 | 761 } |
762 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
763 template <typename T> |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
764 T * get_data (mxClassID class_id, mxComplexity complexity) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
765 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
766 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
767 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
768 void *ptr = const_cast<void *> (m_val.mex_get_data (class_id, complexity)); |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
769 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
770 T *retval = static_cast<T *> (ptr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
771 |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
772 if (retval && (complexity == mxREAL || m_interleaved)) |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
773 { |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
774 maybe_mark_foreign (retval); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
775 return retval; |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
776 } |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
777 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
778 request_mutation (); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
779 return nullptr; |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
780 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
781 |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
782 GET_DATA_METHOD (mxDouble, get_doubles, mxDOUBLE_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
783 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
784 GET_DATA_METHOD (mxSingle, get_singles, mxSINGLE_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
785 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
786 GET_DATA_METHOD (mxInt8, get_int8s, mxINT8_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
787 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
788 GET_DATA_METHOD (mxInt16, get_int16s, mxINT16_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
789 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
790 GET_DATA_METHOD (mxInt32, get_int32s, mxINT32_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
791 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
792 GET_DATA_METHOD (mxInt64, get_int64s, mxINT64_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
793 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
794 GET_DATA_METHOD (mxUint8, get_uint8s, mxUINT8_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
795 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
796 GET_DATA_METHOD (mxUint16, get_uint16s, mxUINT16_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
797 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
798 GET_DATA_METHOD (mxUint32, get_uint32s, mxUINT32_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
799 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
800 GET_DATA_METHOD (mxUint64, get_uint64s, mxUINT64_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
801 |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
802 GET_DATA_METHOD (mxComplexDouble, get_complex_doubles, |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
803 mxDOUBLE_CLASS, mxCOMPLEX); |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
804 |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
805 GET_DATA_METHOD (mxComplexSingle, get_complex_singles, |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
806 mxDOUBLE_CLASS, mxCOMPLEX); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
807 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
808 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
809 /* We don't have these yet. */ |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
810 GET_DATA_METHOD (mxComplexInt8 *, get_complex_int8s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
811 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
812 GET_DATA_METHOD (mxComplexInt16 *, get_complex_int16s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
813 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
814 GET_DATA_METHOD (mxComplexInt32 *, get_complex_int32s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
815 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
816 GET_DATA_METHOD (mxComplexInt64 *, get_complex_int64s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
817 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
818 GET_DATA_METHOD (mxComplexUint8 *, get_complex_uint8s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
819 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
820 GET_DATA_METHOD (mxComplexUint16 *, get_complex_uint16s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
821 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
822 GET_DATA_METHOD (mxComplexUint32 *, get_complex_uint32s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
823 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
824 GET_DATA_METHOD (mxComplexUint64 *, get_complex_uint64s, (void), nullptr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
825 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
826 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
827 void * get_imag_data (void) const |
5900 | 828 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
829 void *retval = nullptr; |
5900 | 830 |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23581
diff
changeset
|
831 if (is_numeric () && isreal ()) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23703
diff
changeset
|
832 retval = nullptr; |
5900 | 833 else |
834 request_mutation (); | |
835 | |
836 return retval; | |
837 } | |
838 | |
839 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
840 VOID_MUTATION_METHOD (set_data, (void *)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
841 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
842 MUTATION_METHOD (int, set_doubles, (mxDouble *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
843 MUTATION_METHOD (int, set_singles, (mxSingle *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
844 MUTATION_METHOD (int, set_int8s, (mxInt8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
845 MUTATION_METHOD (int, set_int16s, (mxInt16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
846 MUTATION_METHOD (int, set_int32s, (mxInt32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
847 MUTATION_METHOD (int, set_int64s, (mxInt64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
848 MUTATION_METHOD (int, set_uint8s, (mxUint8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
849 MUTATION_METHOD (int, set_uint16s, (mxUint16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
850 MUTATION_METHOD (int, set_uint32s, (mxUint32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
851 MUTATION_METHOD (int, set_uint64s, (mxUint64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
852 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
853 MUTATION_METHOD (int, set_complex_doubles, (mxComplexDouble *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
854 MUTATION_METHOD (int, set_complex_singles, (mxComplexSingle *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
855 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
856 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
857 MUTATION_METHOD (int, set_complex_int8s, (mxComplexInt8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
858 MUTATION_METHOD (int, set_complex_int16s, (mxComplexInt16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
859 MUTATION_METHOD (int, set_complex_int32s, (mxComplexInt32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
860 MUTATION_METHOD (int, set_complex_int64s, (mxComplexInt64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
861 MUTATION_METHOD (int, set_complex_uint8s, (mxComplexUint8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
862 MUTATION_METHOD (int, set_complex_uint16s, (mxComplexUint16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
863 MUTATION_METHOD (int, set_complex_uint32s, (mxComplexUint32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
864 MUTATION_METHOD (int, set_complex_uint64s, (mxComplexUint64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
865 #endif |
5900 | 866 |
867 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
868 VOID_MUTATION_METHOD (set_imag_data, (void *)) |
5900 | 869 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
870 mwIndex * get_ir (void) const |
5900 | 871 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
872 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
873 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
874 octave_idx_type *ptr = const_cast<octave_idx_type *> (m_val.mex_get_ir ()); |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
875 return static_cast<mwIndex *> (maybe_mark_foreign (ptr)); |
5900 | 876 } |
877 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
878 mwIndex * get_jc (void) const |
5900 | 879 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
880 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
881 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
882 octave_idx_type *ptr = const_cast<octave_idx_type *> (m_val.mex_get_jc ()); |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
883 return static_cast<mwIndex *> (maybe_mark_foreign (ptr)); |
5900 | 884 } |
885 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
886 mwSize get_nzmax (void) const { return m_val.nzmax (); } |
5900 | 887 |
888 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
889 VOID_MUTATION_METHOD (set_ir, (mwIndex *)) |
5900 | 890 |
891 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
892 VOID_MUTATION_METHOD (set_jc, (mwIndex *)) |
5900 | 893 |
894 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
895 VOID_MUTATION_METHOD (set_nzmax, (mwSize)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
896 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
897 // Not allowed. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
898 MUTATION_METHOD (int, add_field, (const char *), 0) |
5900 | 899 |
900 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
901 VOID_MUTATION_METHOD (remove_field, (int)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
902 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
903 CONST_MUTATION_METHOD (mxArray *, get_field_by_number, (mwIndex, int), nullptr) |
5900 | 904 |
905 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
906 VOID_MUTATION_METHOD (set_field_by_number, (mwIndex, int, mxArray *)) |
5900 | 907 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
908 int get_number_of_fields (void) const { return m_val.nfields (); } |
5900 | 909 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
910 CONST_MUTATION_METHOD (const char *, get_field_name_by_number, (int), nullptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
911 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
912 CONST_MUTATION_METHOD (int, get_field_number, (const char *), 0) |
5900 | 913 |
6686 | 914 int get_string (char *buf, mwSize buflen) const |
5900 | 915 { |
916 int retval = 1; | |
917 | |
6686 | 918 mwSize nel = get_number_of_elements (); |
5900 | 919 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
920 if (m_val.is_string () && nel < buflen) |
5900 | 921 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
922 charNDArray tmp = m_val.char_array_value (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
923 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
924 const char *p = tmp.data (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
925 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
926 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
927 buf[i] = p[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
928 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
929 buf[nel] = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
930 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
931 retval = 0; |
5900 | 932 } |
933 | |
934 return retval; | |
935 } | |
936 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
937 char * array_to_string (void) const |
5900 | 938 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
939 // FIXME: this is supposed to handle multi-byte character strings. |
5900 | 940 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
941 char *buf = nullptr; |
5900 | 942 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
943 if (m_val.is_string ()) |
5900 | 944 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
945 mwSize nel = get_number_of_elements (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
946 |
15354
93dff6435fe1
tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents:
15353
diff
changeset
|
947 buf = static_cast<char *> (mxArray::malloc (nel + 1)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
948 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
949 if (buf) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
950 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
951 charNDArray tmp = m_val.char_array_value (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
952 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
953 const char *p = tmp.data (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
954 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
955 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
956 buf[i] = p[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
957 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
958 buf[nel] = '\0'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
959 } |
5900 | 960 } |
961 | |
962 return buf; | |
963 } | |
964 | |
6686 | 965 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const |
5900 | 966 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
967 // Force m_ndims, n_dims to be cached. |
5900 | 968 get_dimensions (); |
969 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
970 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs); |
5900 | 971 } |
972 | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
973 std::size_t get_element_size (void) const |
5900 | 974 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
975 // Force m_id to be cached. |
5900 | 976 get_class_id (); |
977 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
978 switch (m_id) |
5900 | 979 { |
980 case mxCELL_CLASS: return sizeof (mxArray *); | |
981 case mxSTRUCT_CLASS: return sizeof (mxArray *); | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
982 case mxLOGICAL_CLASS: return sizeof (mxLogical); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
983 case mxCHAR_CLASS: return sizeof (mxChar); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
984 case mxDOUBLE_CLASS: return get_numeric_element_size (sizeof (mxDouble)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
985 case mxSINGLE_CLASS: return get_numeric_element_size (sizeof (mxSingle)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
986 case mxINT8_CLASS: return get_numeric_element_size (sizeof (mxInt8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
987 case mxUINT8_CLASS: return get_numeric_element_size (sizeof (mxUint8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
988 case mxINT16_CLASS: return get_numeric_element_size (sizeof (mxInt16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
989 case mxUINT16_CLASS: return get_numeric_element_size (sizeof (mxUint16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
990 case mxINT32_CLASS: return get_numeric_element_size (sizeof (mxInt32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
991 case mxUINT32_CLASS: return get_numeric_element_size (sizeof (mxUint32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
992 case mxINT64_CLASS: return get_numeric_element_size (sizeof (mxInt64)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
993 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64)); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
994 case mxFUNCTION_CLASS: return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
995 // FIXME: user-defined objects need their own class ID. |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
996 // What should they return, size of pointer? |
5900 | 997 default: return 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
998 } |
5900 | 999 } |
1000 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1001 bool mutation_needed (void) const { return m_mutate_flag; } |
5900 | 1002 |
1003 void request_mutation (void) const | |
1004 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1005 if (m_mutate_flag) |
5900 | 1006 panic_impossible (); |
1007 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1008 m_mutate_flag = true; |
5900 | 1009 } |
1010 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1011 mxArray * mutate (void) const { return as_mxArray (); } |
5900 | 1012 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1013 octave_value as_octave_value (void) const { return m_val; } |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
1014 |
5900 | 1015 protected: |
1016 | |
1017 mxArray_octave_value (const mxArray_octave_value& arg) | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1018 : mxArray_base (arg), m_val (arg.m_val), m_mutate_flag (arg.m_mutate_flag), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1019 m_id (arg.m_id), m_class_name (mxArray::strsave (arg.m_class_name)), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1020 m_ndims (arg.m_ndims), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1021 m_dims (m_ndims > 0 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1022 ? static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1023 : nullptr) |
5900 | 1024 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1025 if (m_dims) |
5900 | 1026 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1027 for (mwIndex i = 0; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1028 m_dims[i] = arg.m_dims[i]; |
5900 | 1029 } |
1030 } | |
1031 | |
1032 private: | |
1033 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1034 octave_value m_val; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1035 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1036 mutable bool m_mutate_flag; |
5900 | 1037 |
1038 // Caching these does not cost much or lead to much duplicated | |
1039 // code. For other things, we just request mutation to a | |
1040 // Matlab-style mxArray object. | |
1041 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1042 mutable mxClassID m_id; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1043 mutable char *m_class_name; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1044 mutable mwSize m_ndims; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1045 mutable mwSize *m_dims; |
5900 | 1046 }; |
1047 | |
1048 // The base class for the Matlab-style representation, used to handle | |
1049 // things that are common to all Matlab-style objects. | |
1050 | |
1051 class mxArray_matlab : public mxArray_base | |
1052 { | |
1053 public: | |
1054 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1055 // No assignment! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1056 // FIXME: should this be implemented? |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1057 // Note that we *do* have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1058 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1059 mxArray_matlab& operator = (const mxArray_matlab&); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1060 |
5900 | 1061 ~mxArray_matlab (void) |
1062 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1063 mxFree (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1064 mxFree (m_dims); |
5900 | 1065 } |
1066 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1067 int iscell (void) const { return m_id == mxCELL_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1068 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1069 int is_char (void) const { return m_id == mxCHAR_CLASS; } |
5900 | 1070 |
1071 int is_complex (void) const { return 0; } | |
1072 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1073 int is_double (void) const { return m_id == mxDOUBLE_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1074 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1075 int is_function_handle (void) const { return m_id == mxFUNCTION_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1076 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1077 int is_int16 (void) const { return m_id == mxINT16_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1078 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1079 int is_int32 (void) const { return m_id == mxINT32_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1080 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1081 int is_int64 (void) const { return m_id == mxINT64_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1082 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1083 int is_int8 (void) const { return m_id == mxINT8_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1084 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1085 int is_logical (void) const { return m_id == mxLOGICAL_CLASS; } |
5900 | 1086 |
1087 int is_numeric (void) const | |
1088 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1089 return (m_id == mxDOUBLE_CLASS || m_id == mxSINGLE_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1090 || m_id == mxINT8_CLASS || m_id == mxUINT8_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1091 || m_id == mxINT16_CLASS || m_id == mxUINT16_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1092 || m_id == mxINT32_CLASS || m_id == mxUINT32_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1093 || m_id == mxINT64_CLASS || m_id == mxUINT64_CLASS); |
5900 | 1094 } |
1095 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1096 int is_single (void) const { return m_id == mxSINGLE_CLASS; } |
5900 | 1097 |
1098 int is_sparse (void) const { return 0; } | |
1099 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1100 int is_struct (void) const { return m_id == mxSTRUCT_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1101 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1102 int is_uint16 (void) const { return m_id == mxUINT16_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1103 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1104 int is_uint32 (void) const { return m_id == mxUINT32_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1105 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1106 int is_uint64 (void) const { return m_id == mxUINT64_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1107 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1108 int is_uint8 (void) const { return m_id == mxUINT8_CLASS; } |
5900 | 1109 |
1110 int is_logical_scalar_true (void) const | |
1111 { | |
1112 return (is_logical_scalar () | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1113 && static_cast<mxLogical *> (get_data ())[0] != 0); |
5900 | 1114 } |
1115 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1116 mwSize get_m (void) const { return m_dims[0]; } |
6686 | 1117 |
1118 mwSize get_n (void) const | |
6187 | 1119 { |
6686 | 1120 mwSize n = 1; |
1121 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1122 for (mwSize i = m_ndims - 1 ; i > 0 ; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1123 n *= m_dims[i]; |
6187 | 1124 |
1125 return n; | |
1126 } | |
5900 | 1127 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1128 mwSize * get_dimensions (void) const { return m_dims; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1129 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1130 mwSize get_number_of_dimensions (void) const { return m_ndims; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1131 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1132 void set_m (mwSize m) { m_dims[0] = m; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1133 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1134 void set_n (mwSize n) { m_dims[1] = n; } |
6686 | 1135 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1136 int set_dimensions (mwSize *dims, mwSize ndims) |
5900 | 1137 { |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1138 m_ndims = ndims; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1139 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1140 mxFree (m_dims); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1141 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1142 if (m_ndims > 0) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1143 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1144 m_dims |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1145 = static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1146 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1147 if (m_dims == nullptr) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1148 return 1; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1149 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1150 for (int i = 0; i < m_ndims; i++) |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1151 m_dims[i] = dims[i]; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1152 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1153 return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1154 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1155 else |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1156 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1157 m_dims = nullptr; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1158 return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1159 } |
5900 | 1160 } |
1161 | |
6686 | 1162 mwSize get_number_of_elements (void) const |
5900 | 1163 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1164 mwSize retval = m_dims[0]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1165 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1166 for (mwIndex i = 1; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1167 retval *= m_dims[i]; |
5900 | 1168 |
1169 return retval; | |
1170 } | |
1171 | |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
1172 int isempty (void) const { return get_number_of_elements () == 0; } |
5900 | 1173 |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1174 bool is_scalar (void) const |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1175 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1176 return m_ndims == 2 && m_dims[0] == 1 && m_dims[1] == 1; |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1177 } |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1178 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1179 mxClassID get_class_id (void) const { return m_id; } |
5900 | 1180 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1181 const char * get_class_name (void) const |
5900 | 1182 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1183 switch (m_id) |
5900 | 1184 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1185 case mxDOUBLE_CLASS: return "double"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1186 case mxSINGLE_CLASS: return "single"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1187 case mxCHAR_CLASS: return "char"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1188 case mxLOGICAL_CLASS: return "logical"; |
5900 | 1189 case mxCELL_CLASS: return "cell"; |
1190 case mxSTRUCT_CLASS: return "struct"; | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1191 case mxFUNCTION_CLASS: return "function_handle"; |
5900 | 1192 case mxINT8_CLASS: return "int8"; |
1193 case mxUINT8_CLASS: return "uint8"; | |
1194 case mxINT16_CLASS: return "int16"; | |
1195 case mxUINT16_CLASS: return "uint16"; | |
1196 case mxINT32_CLASS: return "int32"; | |
1197 case mxUINT32_CLASS: return "uint32"; | |
1198 case mxINT64_CLASS: return "int64"; | |
1199 case mxUINT64_CLASS: return "uint64"; | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1200 case mxUNKNOWN_CLASS: return "unknown"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1201 // FIXME: should return the classname of user-defined objects |
5900 | 1202 default: return "unknown"; |
1203 } | |
1204 } | |
1205 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1206 void set_class_name (const char *name) |
5900 | 1207 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1208 mxFree (m_class_name); |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1209 m_class_name = static_cast<char *> (mxArray::malloc (strlen (name) + 1)); |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1210 strcpy (m_class_name, name); |
5900 | 1211 } |
1212 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1213 mxArray * get_cell (mwIndex /*idx*/) const |
5900 | 1214 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1215 err_invalid_type ("get_cell"); |
5900 | 1216 } |
1217 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1218 void set_cell (mwIndex /*idx*/, mxArray * /*val*/) |
5900 | 1219 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1220 err_invalid_type ("set_cell"); |
5900 | 1221 } |
1222 | |
6332 | 1223 double get_scalar (void) const |
1224 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1225 err_invalid_type ("get_scalar"); |
6332 | 1226 } |
1227 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1228 void * get_data (void) const |
5900 | 1229 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1230 err_invalid_type ("get_data"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1231 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1232 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1233 mxDouble * get_doubles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1234 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1235 err_invalid_type ("get_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1236 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1237 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1238 mxSingle * get_singles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1239 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1240 err_invalid_type ("get_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1241 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1242 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1243 mxInt8 * get_int8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1244 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1245 err_invalid_type ("get_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1246 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1247 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1248 mxInt16 * get_int16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1249 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1250 err_invalid_type ("get_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1251 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1252 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1253 mxInt32 * get_int32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1254 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1255 err_invalid_type ("get_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1256 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1257 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1258 mxInt64 * get_int64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1259 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1260 err_invalid_type ("get_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1261 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1262 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1263 mxUint8 * get_uint8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1264 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1265 err_invalid_type ("get_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1266 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1267 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1268 mxUint16 * get_uint16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1269 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1270 err_invalid_type ("get_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1271 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1272 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1273 mxUint32 * get_uint32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1274 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1275 err_invalid_type ("get_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1276 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1277 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1278 mxUint64 * get_uint64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1279 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1280 err_invalid_type ("get_uint64s"); |
5900 | 1281 } |
1282 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1283 mxComplexDouble * get_complex_doubles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1284 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1285 err_invalid_type ("get_complex_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1286 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1287 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1288 mxComplexSingle * get_complex_singles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1289 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1290 err_invalid_type ("get_complex_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1291 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1292 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1293 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1294 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1295 mxComplexInt8 * get_complex_int8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1296 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1297 err_invalid_type ("get_complex_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1298 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1299 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1300 mxComplexInt16 * get_complex_int16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1301 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1302 err_invalid_type ("get_complex_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1303 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1304 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1305 mxComplexInt32 * get_complex_int32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1306 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1307 err_invalid_type ("get_complex_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1308 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1309 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1310 mxComplexInt64 * get_complex_int64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1311 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1312 err_invalid_type ("get_complex_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1313 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1314 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1315 mxComplexUint8 * get_complex_uint8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1316 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1317 err_invalid_type ("get_complex_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1318 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1319 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1320 mxComplexUint16 * get_complex_uint16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1321 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1322 err_invalid_type ("get_complex_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1323 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1324 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1325 mxComplexUint32 * get_complex_uint32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1326 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1327 err_invalid_type ("get_complex_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1328 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1329 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1330 mxComplexUint64 * get_complex_uint64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1331 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1332 err_invalid_type ("get_complex_uint64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1333 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1334 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1335 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1336 void * get_imag_data (void) const |
5900 | 1337 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1338 err_invalid_type ("get_imag_data"); |
5900 | 1339 } |
1340 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1341 void set_data (void * /*pr*/) |
5900 | 1342 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1343 err_invalid_type ("set_data"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1344 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1345 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1346 int set_doubles (mxDouble *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1347 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1348 err_invalid_type ("set_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1349 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1350 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1351 int set_singles (mxSingle *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1352 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1353 err_invalid_type ("set_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1354 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1355 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1356 int set_int8s (mxInt8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1357 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1358 err_invalid_type ("set_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1359 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1360 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1361 int set_int16s (mxInt16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1362 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1363 err_invalid_type ("set_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1364 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1365 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1366 int set_int32s (mxInt32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1367 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1368 err_invalid_type ("set_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1369 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1370 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1371 int set_int64s (mxInt64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1372 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1373 err_invalid_type ("set_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1374 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1375 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1376 int set_uint8s (mxUint8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1377 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1378 err_invalid_type ("set_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1379 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1380 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1381 int set_uint16s (mxUint16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1382 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1383 err_invalid_type ("set_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1384 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1385 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1386 int set_uint32s (mxUint32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1387 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1388 err_invalid_type ("set_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1389 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1390 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1391 int set_uint64s (mxUint64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1392 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1393 err_invalid_type ("set_uint64s"); |
5900 | 1394 } |
1395 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1396 int set_complex_doubles (mxComplexDouble *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1397 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1398 err_invalid_type ("set_complex_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1399 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1400 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1401 int set_complex_singles (mxComplexSingle *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1402 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1403 err_invalid_type ("set_complex_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1404 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1405 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1406 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1407 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1408 int set_complex_int8s (mxComplexInt8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1409 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1410 err_invalid_type ("set_complex_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1411 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1412 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1413 int set_complex_int16s (mxComplexInt16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1414 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1415 err_invalid_type ("set_complex_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1416 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1417 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1418 int set_complex_int32s (mxComplexInt32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1419 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1420 err_invalid_type ("set_complex_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1421 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1422 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1423 int set_complex_int64s (mxComplexInt64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1424 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1425 err_invalid_type ("set_complex_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1426 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1427 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1428 int set_complex_uint8s (mxComplexUint8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1429 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1430 err_invalid_type ("set_complex_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1431 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1432 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1433 int set_complex_uint16s (mxComplexUint16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1434 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1435 err_invalid_type ("set_complex_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1436 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1437 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1438 int set_complex_uint32s (mxComplexUint32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1439 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1440 err_invalid_type ("set_complex_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1441 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1442 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1443 int set_complex_uint64s (mxComplexUint64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1444 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1445 err_invalid_type ("set_complex_uint64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1446 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1447 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1448 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1449 void set_imag_data (void * /*pi*/) |
5900 | 1450 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1451 err_invalid_type ("set_imag_data"); |
5900 | 1452 } |
1453 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1454 mwIndex * get_ir (void) const |
5900 | 1455 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1456 err_invalid_type ("get_ir"); |
5900 | 1457 } |
1458 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1459 mwIndex * get_jc (void) const |
5900 | 1460 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1461 err_invalid_type ("get_jc"); |
5900 | 1462 } |
1463 | |
6686 | 1464 mwSize get_nzmax (void) const |
5900 | 1465 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1466 err_invalid_type ("get_nzmax"); |
5900 | 1467 } |
1468 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1469 void set_ir (mwIndex * /*ir*/) |
5900 | 1470 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1471 err_invalid_type ("set_ir"); |
5900 | 1472 } |
1473 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1474 void set_jc (mwIndex * /*jc*/) |
5900 | 1475 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1476 err_invalid_type ("set_jc"); |
5900 | 1477 } |
1478 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1479 void set_nzmax (mwSize /*nzmax*/) |
5900 | 1480 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1481 err_invalid_type ("set_nzmax"); |
5900 | 1482 } |
1483 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1484 int add_field (const char * /*key*/) |
5900 | 1485 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1486 err_invalid_type ("add_field"); |
5900 | 1487 } |
1488 | |
1489 void remove_field (int /*key_num*/) | |
1490 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1491 err_invalid_type ("remove_field"); |
5900 | 1492 } |
1493 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1494 mxArray * get_field_by_number (mwIndex /*index*/, int /*key_num*/) const |
5900 | 1495 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1496 err_invalid_type ("get_field_by_number"); |
5900 | 1497 } |
1498 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1499 void set_field_by_number (mwIndex /*index*/, int /*key_num*/, |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1500 mxArray * /*val*/) |
5900 | 1501 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1502 err_invalid_type ("set_field_by_number"); |
5900 | 1503 } |
1504 | |
1505 int get_number_of_fields (void) const | |
1506 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1507 err_invalid_type ("get_number_of_fields"); |
5900 | 1508 } |
1509 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1510 const char * get_field_name_by_number (int /*key_num*/) const |
5900 | 1511 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1512 err_invalid_type ("get_field_name_by_number"); |
5900 | 1513 } |
1514 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1515 int get_field_number (const char * /*key*/) const |
5900 | 1516 { |
1517 return -1; | |
1518 } | |
1519 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1520 int get_string (char * /*buf*/, mwSize /*buflen*/) const |
5900 | 1521 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1522 err_invalid_type ("get_string"); |
5900 | 1523 } |
1524 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1525 char * array_to_string (void) const |
5900 | 1526 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1527 err_invalid_type ("array_to_string"); |
5900 | 1528 } |
1529 | |
6686 | 1530 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const |
5900 | 1531 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1532 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs); |
5900 | 1533 } |
1534 | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1535 std::size_t get_element_size (void) const |
5900 | 1536 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1537 switch (m_id) |
5900 | 1538 { |
1539 case mxCELL_CLASS: return sizeof (mxArray *); | |
1540 case mxSTRUCT_CLASS: return sizeof (mxArray *); | |
1541 case mxLOGICAL_CLASS: return sizeof (mxLogical); | |
1542 case mxCHAR_CLASS: return sizeof (mxChar); | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1543 case mxDOUBLE_CLASS: return get_numeric_element_size (sizeof (mxDouble)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1544 case mxSINGLE_CLASS: return get_numeric_element_size (sizeof (mxSingle)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1545 case mxINT8_CLASS: return get_numeric_element_size (sizeof (mxInt8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1546 case mxUINT8_CLASS: return get_numeric_element_size (sizeof (mxUint8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1547 case mxINT16_CLASS: return get_numeric_element_size (sizeof (mxInt16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1548 case mxUINT16_CLASS: return get_numeric_element_size (sizeof (mxUint16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1549 case mxINT32_CLASS: return get_numeric_element_size (sizeof (mxInt32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1550 case mxUINT32_CLASS: return get_numeric_element_size (sizeof (mxUint32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1551 case mxINT64_CLASS: return get_numeric_element_size (sizeof (mxInt64)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1552 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64)); |
5900 | 1553 case mxFUNCTION_CLASS: return 0; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1554 // FIXME: user-defined objects need their own class ID. |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1555 // What should they return, size of pointer? |
5900 | 1556 default: return 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1557 } |
5900 | 1558 } |
1559 | |
1560 protected: | |
1561 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1562 mxArray_matlab (bool interleaved, mxClassID id = mxUNKNOWN_CLASS) |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1563 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1564 m_ndims (0), m_dims (nullptr) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1565 { } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1566 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1567 mxArray_matlab (bool interleaved, mxClassID id, mwSize ndims, |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1568 const mwSize *dims) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1569 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1570 m_ndims (ndims < 2 ? 2 : ndims), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1571 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1572 { |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1573 if (ndims == 0) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1574 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1575 m_dims[0] = 0; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1576 m_dims[1] = 0; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1577 } |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1578 else if (ndims < 2) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1579 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1580 m_dims[0] = 1; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1581 m_dims[1] = 1; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1582 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1583 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1584 for (mwIndex i = 0; i < ndims; i++) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1585 m_dims[i] = dims[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1586 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1587 for (mwIndex i = m_ndims - 1; i > 1; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1588 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1589 if (m_dims[i] == 1) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1590 m_ndims--; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1591 else |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1592 break; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1593 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1594 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1595 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1596 mxArray_matlab (bool interleaved, mxClassID id, const dim_vector& dv) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1597 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1598 m_ndims (dv.ndims ()), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1599 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1600 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1601 for (mwIndex i = 0; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1602 m_dims[i] = dv(i); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1603 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1604 for (mwIndex i = m_ndims - 1; i > 1; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1605 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1606 if (m_dims[i] == 1) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1607 m_ndims--; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1608 else |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1609 break; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1610 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1611 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1612 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1613 mxArray_matlab (bool interleaved, mxClassID id, mwSize m, mwSize n) |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1614 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1615 m_ndims (2), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1616 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1617 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1618 m_dims[0] = m; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1619 m_dims[1] = n; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1620 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1621 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1622 mxArray_matlab (const mxArray_matlab& val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1623 : mxArray_base (val), m_class_name (mxArray::strsave (val.m_class_name)), |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1624 m_id (val.m_id), m_ndims (val.m_ndims), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1625 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1626 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1627 for (mwIndex i = 0; i < m_ndims; i++) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1628 m_dims[i] = val.m_dims[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1629 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1630 |
5900 | 1631 dim_vector |
1632 dims_to_dim_vector (void) const | |
1633 { | |
6686 | 1634 mwSize nd = get_number_of_dimensions (); |
1635 | |
1636 mwSize *d = get_dimensions (); | |
5900 | 1637 |
1638 dim_vector dv; | |
1639 dv.resize (nd); | |
1640 | |
6686 | 1641 for (mwIndex i = 0; i < nd; i++) |
5900 | 1642 dv(i) = d[i]; |
1643 | |
1644 return dv; | |
1645 } | |
1646 | |
1647 private: | |
1648 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1649 char *m_class_name; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1650 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1651 mxClassID m_id; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1652 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1653 mwSize m_ndims; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1654 mwSize *m_dims; |
5900 | 1655 }; |
1656 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1657 |
5900 | 1658 // Matlab-style numeric, character, and logical data. |
1659 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1660 class mxArray_base_full : public mxArray_matlab |
5900 | 1661 { |
1662 public: | |
1663 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1664 mxArray_base_full (bool interleaved, mxClassID id, mwSize ndims, |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1665 const mwSize *dims, bool init = true) |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1666 : mxArray_matlab (interleaved, id, ndims, dims), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1667 m_pr (mxArray::alloc (init, get_number_of_elements (), get_element_size ())) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1668 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1669 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1670 mxArray_base_full (bool interleaved, mxClassID id, const dim_vector& dv) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1671 : mxArray_matlab (interleaved, id, dv), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1672 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
1673 { } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1674 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1675 mxArray_base_full (bool interleaved, mxClassID id, mwSize m, mwSize n, |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1676 bool init = true) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1677 : mxArray_matlab (interleaved, id, m, n), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1678 m_pr (mxArray::alloc (init, get_number_of_elements (), get_element_size ())) |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
1679 { } |
5900 | 1680 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1681 mxArray_base_full (bool interleaved, mxClassID id, double val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1682 : mxArray_matlab (interleaved, id, 1, 1), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1683 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1684 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1685 double *dpr = static_cast<double *> (m_pr); |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1686 dpr[0] = val; |
5900 | 1687 } |
1688 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1689 mxArray_base_full (bool interleaved, mxClassID id, mxLogical val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1690 : mxArray_matlab (interleaved, id, 1, 1), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1691 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1692 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1693 mxLogical *lpr = static_cast<mxLogical *> (m_pr); |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1694 lpr[0] = val; |
5900 | 1695 } |
1696 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1697 mxArray_base_full (bool interleaved, const char *str) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1698 : mxArray_matlab (interleaved, mxCHAR_CLASS, |
10853
c3813056f94f
mxArray_number (const char *): create empty string if given NULL arg
John W. Eaton <jwe@octave.org>
parents:
10463
diff
changeset
|
1699 str ? (strlen (str) ? 1 : 0) : 0, |
c3813056f94f
mxArray_number (const char *): create empty string if given NULL arg
John W. Eaton <jwe@octave.org>
parents:
10463
diff
changeset
|
1700 str ? strlen (str) : 0), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1701 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1702 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1703 mxChar *cpr = static_cast<mxChar *> (m_pr); |
6686 | 1704 mwSize nel = get_number_of_elements (); |
1705 for (mwIndex i = 0; i < nel; i++) | |
5900 | 1706 cpr[i] = str[i]; |
1707 } | |
1708 | |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17810
diff
changeset
|
1709 // FIXME: ??? |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1710 mxArray_base_full (bool interleaved, mwSize m, const char **str) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1711 : mxArray_matlab (interleaved, mxCHAR_CLASS, m, max_str_len (m, str)), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1712 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1713 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1714 mxChar *cpr = static_cast<mxChar *> (m_pr); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1715 |
6686 | 1716 mwSize *dv = get_dimensions (); |
1717 | |
1718 mwSize nc = dv[1]; | |
1719 | |
1720 for (mwIndex j = 0; j < m; j++) | |
5900 | 1721 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1722 const char *ptr = str[j]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1723 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1724 std::size_t tmp_len = strlen (ptr); |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1725 |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1726 for (std::size_t i = 0; i < tmp_len; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1727 cpr[m*i+j] = static_cast<mxChar> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1728 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1729 for (std::size_t i = tmp_len; i < static_cast<std::size_t> (nc); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1730 cpr[m*i+j] = static_cast<mxChar> (' '); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1731 } |
5900 | 1732 } |
1733 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1734 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1735 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1736 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1737 mxArray_base_full& operator = (const mxArray_base_full&); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1738 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1739 mxArray_base * dup (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1740 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1741 return new mxArray_base_full (*this); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1742 } |
5900 | 1743 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1744 ~mxArray_base_full (void) |
5900 | 1745 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1746 mxFree (m_pr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1747 } |
5907 | 1748 |
6332 | 1749 double get_scalar (void) const |
1750 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1751 // FIXME: how does this work for interleaved complex arrays? |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1752 |
6332 | 1753 double retval = 0; |
1754 | |
1755 switch (get_class_id ()) | |
1756 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1757 case mxDOUBLE_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1758 retval = *(static_cast<double *> (m_pr)); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1759 break; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1760 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1761 case mxSINGLE_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1762 retval = *(static_cast<float *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1763 break; |
6332 | 1764 |
1765 case mxCHAR_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1766 retval = *(static_cast<mxChar *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1767 break; |
6332 | 1768 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1769 case mxLOGICAL_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1770 retval = *(static_cast<bool *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1771 break; |
6332 | 1772 |
1773 case mxINT8_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1774 retval = *(static_cast<int8_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1775 break; |
6332 | 1776 |
1777 case mxUINT8_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1778 retval = *(static_cast<uint8_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1779 break; |
6332 | 1780 |
1781 case mxINT16_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1782 retval = *(static_cast<int16_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1783 break; |
6332 | 1784 |
1785 case mxUINT16_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1786 retval = *(static_cast<uint16_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1787 break; |
6332 | 1788 |
1789 case mxINT32_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1790 retval = *(static_cast<int32_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1791 break; |
6332 | 1792 |
1793 case mxUINT32_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1794 retval = *(static_cast<uint32_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1795 break; |
6332 | 1796 |
1797 case mxINT64_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1798 retval = *(static_cast<int64_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1799 break; |
6332 | 1800 |
1801 case mxUINT64_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1802 retval = *(static_cast<uint64_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1803 break; |
6332 | 1804 |
1805 default: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1806 panic_impossible (); |
6332 | 1807 } |
1808 | |
1809 return retval; | |
1810 } | |
1811 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1812 void * get_data (void) const { return m_pr; } |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1813 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1814 void set_data (void *pr) { m_pr = pr; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1815 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1816 // The typed get and set functions only work for interleaved data but |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1817 // they are defined here because this class owns PR. There are |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1818 // definitions in the mxArray_separate_full class that override these |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1819 // functions. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1820 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1821 mxDouble * get_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1822 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1823 return static_cast<mxDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1824 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1825 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1826 mxSingle * get_singles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1827 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1828 return static_cast<mxSingle *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1829 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1830 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1831 mxInt8 * get_int8s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1832 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1833 return static_cast<mxInt8 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1834 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1835 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1836 mxInt16 * get_int16s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1837 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1838 return static_cast<mxInt16 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1839 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1840 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1841 mxInt32 * get_int32s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1842 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1843 return static_cast<mxInt32 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1844 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1845 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1846 mxInt64 * get_int64s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1847 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1848 return static_cast<mxInt64 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1849 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1850 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1851 mxUint8 * get_uint8s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1852 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1853 return static_cast<mxUint8 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1854 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1855 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1856 mxUint16 * get_uint16s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1857 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1858 return static_cast<mxUint16 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1859 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1860 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1861 mxUint32 * get_uint32s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1862 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1863 return static_cast<mxUint32 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1864 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1865 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1866 mxUint64 * get_uint64s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1867 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1868 return static_cast<mxUint64 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1869 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1870 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1871 mxComplexDouble * get_complex_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1872 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1873 return static_cast<mxComplexDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1874 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1875 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1876 mxComplexSingle * get_complex_singles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1877 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1878 return static_cast<mxComplexSingle *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1879 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1880 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1881 #if 0 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1882 // We don't have these data types. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1883 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1884 int get_complex_int8s (mxComplexInt8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1885 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1886 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1887 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1888 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1889 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1890 int get_complex_int16s (mxComplexInt16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1891 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1892 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1893 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1894 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1895 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1896 int get_complex_int32s (mxComplexInt32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1897 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1898 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1899 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1900 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1901 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1902 int get_complex_int64s (mxComplexInt64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1903 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1904 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1905 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1906 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1907 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1908 int get_complex_uint8s (mxComplexUint8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1909 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1910 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1911 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1912 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1913 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1914 int get_complex_uint16s (mxComplexUint16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1915 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1916 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1917 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1918 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1919 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1920 int get_complex_uint32s (mxComplexUint32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1921 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1922 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1923 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1924 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1925 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1926 int get_complex_uint64s (mxComplexUint64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1927 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1928 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1929 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1930 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1931 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1932 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1933 int set_doubles (mxDouble *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1934 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1935 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1936 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1937 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1938 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1939 int set_singles (mxSingle *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1940 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1941 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1942 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1943 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1944 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1945 int set_int8s (mxInt8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1946 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1947 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1948 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1949 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1950 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1951 int set_int16s (mxInt16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1952 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1953 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1954 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1955 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1956 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1957 int set_int32s (mxInt32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1958 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1959 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1960 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1961 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1962 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1963 int set_int64s (mxInt64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1964 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1965 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1966 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1967 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1968 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1969 int set_uint8s (mxUint8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1970 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1971 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1972 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1973 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1974 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1975 int set_uint16s (mxUint16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1976 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1977 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1978 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1979 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1980 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1981 int set_uint32s (mxUint32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1982 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1983 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1984 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1985 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1986 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1987 int set_uint64s (mxUint64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1988 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1989 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1990 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1991 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1992 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1993 int set_complex_doubles (mxComplexDouble *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1994 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1995 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1996 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1997 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1998 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1999 int set_complex_singles (mxComplexSingle *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2000 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2001 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2002 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2003 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2004 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2005 #if 0 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2006 // We don't have these data types. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2007 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2008 int set_complex_int8s (mxComplexInt8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2009 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2010 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2011 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2012 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2013 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2014 int set_complex_int16s (mxComplexInt16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2015 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2016 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2017 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2018 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2019 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2020 int set_complex_int32s (mxComplexInt32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2021 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2022 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2023 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2024 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2025 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2026 int set_complex_int64s (mxComplexInt64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2027 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2028 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2029 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2030 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2031 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2032 int set_complex_uint8s (mxComplexUint8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2033 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2034 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2035 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2036 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2037 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2038 int set_complex_uint16s (mxComplexUint16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2039 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2040 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2041 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2042 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2043 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2044 int set_complex_uint32s (mxComplexUint32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2045 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2046 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2047 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2048 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2049 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2050 int set_complex_uint64s (mxComplexUint64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2051 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2052 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2053 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2054 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2055 #endif |
5907 | 2056 |
6686 | 2057 int get_string (char *buf, mwSize buflen) const |
5907 | 2058 { |
13753
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2059 int retval = 0; |
5907 | 2060 |
6686 | 2061 mwSize nel = get_number_of_elements (); |
6493 | 2062 |
13753
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2063 if (! (nel < buflen)) |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2064 { |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2065 retval = 1; |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2066 if (buflen > 0) |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2067 nel = buflen-1; |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2068 } |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2069 |
6493 | 2070 if (nel < buflen) |
5907 | 2071 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2072 mxChar *ptr = static_cast<mxChar *> (m_pr); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2073 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2074 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2075 buf[i] = static_cast<char> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2076 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2077 buf[nel] = 0; |
5907 | 2078 } |
2079 | |
2080 return retval; | |
2081 } | |
2082 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2083 char * array_to_string (void) const |
5907 | 2084 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2085 // FIXME: this is supposed to handle multi-byte character strings. |
5907 | 2086 |
6686 | 2087 mwSize nel = get_number_of_elements (); |
5907 | 2088 |
15354
93dff6435fe1
tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents:
15353
diff
changeset
|
2089 char *buf = static_cast<char *> (mxArray::malloc (nel + 1)); |
5907 | 2090 |
2091 if (buf) | |
2092 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2093 mxChar *ptr = static_cast<mxChar *> (m_pr); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2094 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2095 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2096 buf[i] = static_cast<char> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2097 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2098 buf[nel] = '\0'; |
5907 | 2099 } |
2100 | |
2101 return buf; | |
2102 } | |
2103 | |
5900 | 2104 octave_value as_octave_value (void) const |
2105 { | |
2106 octave_value retval; | |
2107 | |
2108 dim_vector dv = dims_to_dim_vector (); | |
2109 | |
2110 switch (get_class_id ()) | |
2111 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2112 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2113 return (is_complex () |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2114 ? fp_to_ov<Complex> (dv) : fp_to_ov<double> (dv)); |
5900 | 2115 |
2116 case mxSINGLE_CLASS: | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2117 return (is_complex () |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2118 ? fp_to_ov<FloatComplex> (dv) : fp_to_ov<float> (dv)); |
5900 | 2119 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2120 case mxCHAR_CLASS: |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2121 return int_to_ov<mxChar, charNDArray, char> (dv); |
5900 | 2122 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2123 case mxLOGICAL_CLASS: |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2124 return int_to_ov<mxLogical, boolNDArray, bool> (dv); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2125 |
5900 | 2126 case mxINT8_CLASS: |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2127 return int_to_ov<int8_t, int8NDArray, octave_int8> (dv); |
5900 | 2128 |
2129 case mxUINT8_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2130 return int_to_ov<uint8_t, uint8NDArray, octave_uint8> (dv); |
5900 | 2131 |
2132 case mxINT16_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2133 return int_to_ov<int16_t, int16NDArray, octave_int16> (dv); |
5900 | 2134 |
2135 case mxUINT16_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2136 return int_to_ov<uint16_t, uint16NDArray, octave_uint16> (dv); |
5900 | 2137 |
2138 case mxINT32_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2139 return int_to_ov<int32_t, int32NDArray, octave_int32> (dv); |
5900 | 2140 |
2141 case mxUINT32_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2142 return int_to_ov<uint32_t, uint32NDArray, octave_uint32> (dv); |
5900 | 2143 |
2144 case mxINT64_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2145 return int_to_ov<int64_t, int64NDArray, octave_int64> (dv); |
5900 | 2146 |
2147 case mxUINT64_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2148 return int_to_ov<uint64_t, uint64NDArray, octave_uint64> (dv); |
5900 | 2149 |
2150 default: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2151 panic_impossible (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2152 } |
5900 | 2153 |
2154 return retval; | |
2155 } | |
2156 | |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2157 protected: |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2158 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2159 mxArray_base_full (const mxArray_base_full& val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2160 : mxArray_matlab (val), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2161 m_pr (mxArray::malloc (get_number_of_elements () * get_element_size ())) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2162 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2163 if (m_pr) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2164 memcpy (m_pr, val.m_pr, get_number_of_elements () * get_element_size ()); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2165 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2166 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2167 template <typename ELT_T> |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2168 octave_value |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2169 fp_to_ov (const dim_vector& dv) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2170 { |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2171 octave_value retval; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2172 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2173 ELT_T *ppr = static_cast<ELT_T *> (m_pr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2174 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
2175 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2176 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2177 if (current_mx_memory_resource == &the_mx_deleting_memory_resource) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2178 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2179 octave::unwind_action act ([=] () { maybe_disown_ptr (m_pr); }); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2180 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2181 return octave_value (Array<ELT_T> (ppr, dv, current_mx_memory_resource)); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2182 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2183 else |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2184 return octave_value (Array<ELT_T> (ppr, dv, current_mx_memory_resource)); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2185 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2186 #else |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2187 |
30769
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2188 // Copy data instead of allowing the octave_value object to borrow |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2189 // the mxArray object data. |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2190 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2191 Array<ELT_T> val (dv); |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2192 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2193 ELT_T *ptr = val.fortran_vec (); |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2194 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2195 mwSize nel = get_number_of_elements (); |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2196 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2197 for (mwIndex i = 0; i < nel; i++) |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2198 ptr[i] = ppr[i]; |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2199 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2200 return octave_value (val); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2201 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2202 #endif |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2203 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2204 |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2205 template <typename ELT_T, typename ARRAY_T, typename ARRAY_ELT_T> |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2206 octave_value |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2207 int_to_ov (const dim_vector& dv) const |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2208 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2209 if (is_complex ()) |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2210 error ("complex integer types are not supported"); |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2211 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2212 ELT_T *ppr = static_cast<ELT_T *> (m_pr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2213 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
2214 #if 0 && defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2215 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2216 // FIXME: Currently not allowed because we don't have the necessary |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2217 // constructors for integer arrays. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2218 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2219 octave::unwind_action act ([=] () { maybe_disown_ptr (m_pr); }); |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2220 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2221 return ARRAY_T (ppr, dv, current_mx_memory_resource); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2222 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2223 #else |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2224 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2225 // Copy data instead of allowing the octave_value object to borrow |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2226 // the mxArray object data. |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2227 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2228 ARRAY_T val (dv); |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2229 |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2230 ARRAY_ELT_T *ptr = val.fortran_vec (); |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2231 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2232 mwSize nel = get_number_of_elements (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2233 |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2234 for (mwIndex i = 0; i < nel; i++) |
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2235 ptr[i] = ppr[i]; |
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2236 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2237 return octave_value (val); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2238 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2239 #endif |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2240 } |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2241 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2242 protected: |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2243 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2244 // If using interleaved complex storage, this is the pointer to data |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2245 // (real, complex, or logical). Otherwise, it is the pointer to the |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2246 // real part of the data. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2247 void *m_pr; |
5900 | 2248 }; |
2249 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2250 class mxArray_interleaved_full : public mxArray_base_full |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2251 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2252 public: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2253 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2254 mxArray_interleaved_full (mxClassID id, mwSize ndims, const mwSize *dims, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2255 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2256 : mxArray_base_full (true, id, ndims, dims, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2257 m_complex (flag == mxCOMPLEX) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2258 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2259 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2260 mxArray_interleaved_full (mxClassID id, const dim_vector& dv, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2261 mxComplexity flag = mxREAL) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2262 : mxArray_base_full (true, id, dv), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2263 m_complex (flag == mxCOMPLEX) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2264 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2265 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2266 mxArray_interleaved_full (mxClassID id, mwSize m, mwSize n, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2267 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2268 : mxArray_base_full (true, id, m, n, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2269 m_complex (flag == mxCOMPLEX) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2270 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2271 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2272 mxArray_interleaved_full (mxClassID id, double val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2273 : mxArray_base_full (true, id, val), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2274 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2275 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2276 mxArray_interleaved_full (mxClassID id, mxLogical val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2277 : mxArray_base_full (true, id, val), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2278 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2279 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2280 mxArray_interleaved_full (const char *str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2281 : mxArray_base_full (true, str), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2282 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2283 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2284 // FIXME: ??? |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2285 mxArray_interleaved_full (mwSize m, const char **str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2286 : mxArray_base_full (true, m, str), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2287 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2288 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2289 // No assignment! FIXME: should this be implemented? Note that we |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2290 // do have a copy constructor. |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2291 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2292 mxArray_interleaved_full& operator = (const mxArray_interleaved_full&); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2293 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2294 mxArray_base * dup (void) const |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2295 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2296 return new mxArray_interleaved_full (*this); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2297 } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2298 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2299 ~mxArray_interleaved_full (void) = default; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2300 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2301 int is_complex (void) const { return m_complex; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2302 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2303 void * get_imag_data (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2304 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2305 void set_imag_data (void */*pi*/) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2306 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2307 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2308 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2309 mxArray_interleaved_full (const mxArray_interleaved_full& val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2310 : mxArray_base_full (val), m_complex (val.m_complex) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2311 { } |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2312 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2313 // Flag to identify complex object. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2314 bool m_complex; |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2315 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2316 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2317 class mxArray_separate_full : public mxArray_base_full |
5900 | 2318 { |
2319 public: | |
2320 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2321 mxArray_separate_full (mxClassID id, mwSize ndims, const mwSize *dims, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2322 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2323 : mxArray_base_full (false, id, ndims, dims, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2324 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2325 ? mxArray::alloc (init, get_number_of_elements (), get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2326 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2327 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2328 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2329 mxArray_separate_full (mxClassID id, const dim_vector& dv, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2330 mxComplexity flag = mxREAL) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2331 : mxArray_base_full (false, id, dv), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2332 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2333 ? mxArray::calloc (get_number_of_elements (), get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2334 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2335 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2336 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2337 mxArray_separate_full (mxClassID id, mwSize m, mwSize n, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2338 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2339 : mxArray_base_full (false, id, m, n, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2340 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2341 ? (mxArray::alloc (init, get_number_of_elements (), get_element_size ())) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2342 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2343 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2344 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2345 mxArray_separate_full (mxClassID id, double val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2346 : mxArray_base_full (false, id, val), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2347 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2348 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2349 mxArray_separate_full (mxClassID id, mxLogical val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2350 : mxArray_base_full (false, id, val), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2351 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2352 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2353 mxArray_separate_full (const char *str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2354 : mxArray_base_full (false, str), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2355 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2356 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2357 // FIXME: ??? |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2358 mxArray_separate_full (mwSize m, const char **str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2359 : mxArray_base_full (false, m, str), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2360 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2361 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2362 // No assignment! FIXME: should this be implemented? Note that we |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2363 // do have a copy constructor. |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2364 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2365 mxArray_separate_full& operator = (const mxArray_separate_full&); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2366 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2367 mxArray_base * dup (void) const |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2368 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2369 return new mxArray_separate_full (*this); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2370 } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2371 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2372 ~mxArray_separate_full (void) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2373 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2374 mxFree (m_pi); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2375 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2376 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2377 int is_complex (void) const { return m_pi != nullptr; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2378 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2379 void * get_imag_data (void) const { return m_pi; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2380 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2381 void set_imag_data (void *pi) { m_pi = pi; } |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2382 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2383 mxDouble * get_doubles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2384 mxSingle * get_singles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2385 mxInt8 * get_int8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2386 mxInt16 * get_int16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2387 mxInt32 * get_int32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2388 mxInt64 * get_int64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2389 mxUint8 * get_uint8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2390 mxUint16 * get_uint16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2391 mxUint32 * get_uint32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2392 mxUint64 * get_uint64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2393 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2394 mxComplexDouble * get_complex_doubles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2395 mxComplexSingle * get_complex_singles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2396 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2397 // We don't have complex integer types, but for separate storage they |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2398 // still would not work. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2399 mxComplexInt8 * get_complex_int8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2400 mxComplexInt16 * get_complex_int16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2401 mxComplexInt32 * get_complex_int32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2402 mxComplexInt64 * get_complex_int64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2403 mxComplexUint8 * get_complex_uint8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2404 mxComplexUint16 * get_complex_uint16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2405 mxComplexUint32 * get_complex_uint32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2406 mxComplexUint64 * get_complex_uint64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2407 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2408 int set_doubles (mxDouble *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2409 int set_singles (mxSingle *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2410 int set_int8s (mxInt8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2411 int set_int16s (mxInt16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2412 int set_int32s (mxInt32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2413 int set_int64s (mxInt64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2414 int set_uint8s (mxUint8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2415 int set_uint16s (mxUint16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2416 int set_uint32s (mxUint32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2417 int set_uint64s (mxUint64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2418 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2419 int set_complex_doubles (mxComplexDouble *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2420 int set_complex_singles (mxComplexSingle *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2421 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2422 // We don't have complex integer types, but for separate storage they |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2423 // still would not work. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2424 int set_complex_int8s (mxComplexInt8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2425 int set_complex_int16s (mxComplexInt16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2426 int set_complex_int32s (mxComplexInt32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2427 int set_complex_int64s (mxComplexInt64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2428 int set_complex_uint8s (mxComplexUint8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2429 int set_complex_uint16s (mxComplexUint16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2430 int set_complex_uint32s (mxComplexUint32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2431 int set_complex_uint64s (mxComplexUint64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2432 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2433 octave_value as_octave_value (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2434 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2435 if (! is_complex ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2436 return mxArray_base_full::as_octave_value (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2437 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2438 octave_value retval; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2439 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2440 dim_vector dv = dims_to_dim_vector (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2441 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2442 switch (get_class_id ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2443 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2444 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2445 return to_ov<double> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2446 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2447 case mxSINGLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2448 return to_ov<float> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2449 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2450 case mxLOGICAL_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2451 case mxINT8_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2452 case mxUINT8_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2453 case mxINT16_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2454 case mxUINT16_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2455 case mxINT32_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2456 case mxUINT32_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2457 case mxINT64_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2458 case mxUINT64_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2459 error ("complex integer types are not supported"); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2460 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2461 default: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2462 panic_impossible (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2463 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2464 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2465 return retval; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2466 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2467 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2468 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2469 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2470 mxArray_separate_full (const mxArray_separate_full& val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2471 : mxArray_base_full (val), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2472 m_pi (val.m_pi |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2473 ? mxArray::malloc (get_number_of_elements () * get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2474 : nullptr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2475 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2476 if (m_pi) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2477 memcpy (m_pi, val.m_pi, get_number_of_elements () * get_element_size ()); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2478 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2479 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2480 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2481 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2482 template <typename T> |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2483 octave_value |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2484 to_ov (const dim_vector& dv) const |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2485 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2486 mwSize nel = get_number_of_elements (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2487 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2488 T *ppr = static_cast<T *> (m_pr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2489 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2490 // We allocate in the Array<T> constructor and copy here, so we |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2491 // don't need the custom allocator for this object. |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2492 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2493 Array<std::complex<T>> val (dv); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2494 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2495 std::complex<T> *ptr = val.fortran_vec (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2496 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2497 T *ppi = static_cast<T *> (m_pi); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2498 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2499 for (mwIndex i = 0; i < nel; i++) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2500 ptr[i] = std::complex<T> (ppr[i], ppi[i]); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2501 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2502 return octave_value (val); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2503 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2504 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2505 // Pointer to the imaginary part of the data. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2506 void *m_pi; |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2507 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2508 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2509 // Matlab-style sparse arrays. |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2510 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2511 class mxArray_base_sparse : public mxArray_matlab |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2512 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2513 public: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2514 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2515 mxArray_base_sparse (bool interleaved, mxClassID id, mwSize m, mwSize n, |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2516 mwSize nzmax) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2517 : mxArray_matlab (interleaved, id, m, n), |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2518 |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2519 m_nzmax (nzmax > 0 ? nzmax : 1), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2520 m_ir (static_cast<mwIndex *> (mxArray::calloc (m_nzmax, sizeof (mwIndex)))), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2521 m_jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex)))), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2522 m_pr (mxArray::calloc (m_nzmax, get_element_size ())) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2523 { } |
5900 | 2524 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2525 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2526 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2527 mxArray_base_sparse (const mxArray_base_sparse& val) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2528 : mxArray_matlab (val), m_nzmax (val.m_nzmax), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2529 m_ir (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2530 m_jc (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2531 m_pr (mxArray::malloc (m_nzmax * get_element_size ())) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2532 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2533 if (m_ir) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2534 memcpy (m_ir, val.m_ir, m_nzmax * sizeof (mwIndex)); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2535 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2536 if (m_jc) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2537 memcpy (m_jc, val.m_jc, (val.get_n () + 1) * sizeof (mwIndex)); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2538 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2539 if (m_pr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2540 memcpy (m_pr, val.m_pr, m_nzmax * get_element_size ()); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2541 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2542 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2543 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2544 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2545 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2546 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2547 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2548 mxArray_base_sparse& operator = (const mxArray_base_sparse&); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2549 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2550 mxArray_base * dup (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2551 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2552 return new mxArray_base_sparse (*this); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2553 } |
5900 | 2554 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2555 ~mxArray_base_sparse (void) |
5900 | 2556 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2557 mxFree (m_ir); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2558 mxFree (m_jc); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2559 mxFree (m_pr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2560 } |
5907 | 2561 |
2562 int is_sparse (void) const { return 1; } | |
2563 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2564 void * get_data (void) const { return m_pr; } |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2565 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2566 void set_data (void *pr) { m_pr = pr; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2567 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2568 mxDouble * get_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2569 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2570 return static_cast<mxDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2571 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2572 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2573 mxComplexDouble * get_complex_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2574 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2575 return static_cast<mxComplexDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2576 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2577 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2578 int set_doubles (mxDouble *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2579 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2580 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2581 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2582 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2583 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2584 int set_complex_doubles (mxComplexDouble *d) |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2585 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2586 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2587 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2588 } |
5907 | 2589 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2590 mwIndex * get_ir (void) const { return m_ir; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2591 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2592 mwIndex * get_jc (void) const { return m_jc; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2593 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2594 mwSize get_nzmax (void) const { return m_nzmax; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2595 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2596 void set_ir (mwIndex *ir) { m_ir = ir; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2597 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2598 void set_jc (mwIndex *jc) { m_jc = jc; } |
6686 | 2599 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2600 void set_nzmax (mwSize nzmax) |
27083
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2601 { |
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2602 /* Require storage for at least 1 element */ |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2603 m_nzmax = (nzmax > 0 ? nzmax : 1); |
27083
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2604 } |
5907 | 2605 |
5900 | 2606 octave_value as_octave_value (void) const |
2607 { | |
5903 | 2608 octave_value retval; |
2609 | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2610 dim_vector dv = dims_to_dim_vector (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2611 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2612 switch (get_class_id ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2613 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2614 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2615 return is_complex () ? to_ov<Complex> (dv): to_ov<double> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2616 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2617 case mxSINGLE_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2618 error ("single precision sparse data type not supported"); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2619 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2620 case mxLOGICAL_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2621 return to_ov<bool> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2622 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2623 default: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2624 panic_impossible (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2625 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2626 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2627 return retval; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2628 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2629 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2630 protected: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2631 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2632 template <typename ELT_T> |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2633 octave_value |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2634 to_ov (const dim_vector& dv) const |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2635 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2636 ELT_T *ppr = static_cast<ELT_T *> (m_pr); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2637 |
30792
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2638 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2639 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2640 if (current_mx_memory_resource == &the_mx_deleting_memory_resource) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2641 { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2642 octave::unwind_action act ([=] () { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2643 maybe_disown_ptr (m_pr); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2644 maybe_disown_ptr (m_ir); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2645 maybe_disown_ptr (m_jc); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2646 }); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2647 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2648 return octave_value |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2649 (Sparse<ELT_T> (dv, static_cast<octave_idx_type> (m_nzmax), |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2650 ppr, m_ir, m_jc, current_mx_memory_resource)); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2651 } |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2652 else |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2653 return octave_value |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2654 (Sparse<ELT_T> (dv, static_cast<octave_idx_type> (m_nzmax), |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2655 ppr, m_ir, m_jc, current_mx_memory_resource)); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2656 #else |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2657 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2658 // Copy data instead of allowing the octave_value object to borrow |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2659 // the mxArray object data. |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2660 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2661 octave_idx_type m = dv(0); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2662 octave_idx_type n = dv(1); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2663 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2664 Sparse<ELT_T> val (m, n, static_cast<octave_idx_type> (m_nzmax)); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2665 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2666 for (mwIndex i = 0; i < m_nzmax; i++) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2667 { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2668 val.xdata (i) = ppr[i]; |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2669 val.xridx (i) = m_ir[i]; |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2670 } |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2671 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2672 for (mwIndex i = 0; i < n + 1; i++) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2673 val.xcidx (i) = m_jc[i]; |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2674 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2675 return octave_value (val); |
30792
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2676 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2677 #endif |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2678 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2679 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2680 // Maximun number of nonzero elements. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2681 mwSize m_nzmax; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2682 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2683 // Sparse storage indexing arrays. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2684 mwIndex *m_ir; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2685 mwIndex *m_jc; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2686 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2687 // If using interleaved complex storage, this is the pointer to data |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2688 // (real, complex, or logical). Otherwise, it is the pointer to the |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2689 // real part of the data. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2690 void *m_pr; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2691 }; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2692 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2693 class mxArray_interleaved_sparse : public mxArray_base_sparse |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2694 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2695 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2696 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2697 mxArray_interleaved_sparse (mxClassID id, mwSize m, mwSize n, mwSize nzmax, |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2698 mxComplexity flag = mxREAL) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2699 : mxArray_base_sparse (true, id, m, n, nzmax), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2700 m_complex (flag == mxCOMPLEX) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2701 { } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2702 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2703 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2704 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2705 mxArray_interleaved_sparse (const mxArray_interleaved_sparse& val) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2706 : mxArray_base_sparse (val), m_complex (val.m_complex) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2707 { } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2708 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2709 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2710 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2711 // No assignment! FIXME: should this be implemented? Note that we |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2712 // do have a copy constructor. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2713 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2714 mxArray_interleaved_sparse& operator = (const mxArray_interleaved_sparse&); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2715 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2716 mxArray_base * dup (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2717 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2718 return new mxArray_interleaved_sparse (*this); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2719 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2720 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2721 ~mxArray_interleaved_sparse (void) = default; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2722 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2723 int is_complex (void) const { return m_complex; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2724 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2725 void * get_imag_data (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2726 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2727 void set_imag_data (void */*pi*/) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2728 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2729 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2730 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2731 // Flag to identify complex object if using interleaved data and PI is |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2732 // always nullptr. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2733 bool m_complex; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2734 }; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2735 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2736 class mxArray_separate_sparse : public mxArray_base_sparse |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2737 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2738 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2739 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2740 mxArray_separate_sparse (mxClassID id, mwSize m, mwSize n, mwSize nzmax, |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2741 mxComplexity flag = mxREAL) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2742 : mxArray_base_sparse (false, id, m, n, nzmax), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2743 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2744 ? mxArray::calloc (m_nzmax, get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2745 : nullptr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2746 { } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2747 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2748 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2749 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2750 mxArray_separate_sparse (const mxArray_separate_sparse& val) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2751 : mxArray_base_sparse (val), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2752 m_pi (val.m_pi |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2753 ? mxArray::malloc (m_nzmax * get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2754 : nullptr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2755 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2756 if (m_pi) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2757 memcpy (m_pi, val.m_pi, m_nzmax * get_element_size ()); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2758 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2759 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2760 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2761 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2762 // No assignment! FIXME: should this be implemented? Note that we |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2763 // do have a copy constructor. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2764 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2765 mxArray_separate_sparse& operator = (const mxArray_separate_sparse&); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2766 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2767 mxArray_base * dup (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2768 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2769 return new mxArray_separate_sparse (*this); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2770 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2771 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2772 ~mxArray_separate_sparse (void) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2773 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2774 mxFree (m_pi); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2775 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2776 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2777 int is_complex (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2778 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2779 return m_pi != nullptr; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2780 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2781 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2782 void * get_imag_data (void) const { return m_pi; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2783 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2784 void set_imag_data (void *pi) { m_pi = pi; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2785 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2786 mxDouble * get_doubles (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2787 mxComplexDouble * get_complex_doubles (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2788 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2789 int set_doubles (mxDouble *) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2790 int set_complex_doubles (mxComplexDouble *) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2791 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2792 octave_value as_octave_value (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2793 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2794 if (! is_complex ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2795 return mxArray_base_sparse::as_octave_value (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2796 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2797 octave_value retval; |
5903 | 2798 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2799 dim_vector dv = dims_to_dim_vector (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2800 |
5903 | 2801 switch (get_class_id ()) |
2802 { | |
2803 case mxDOUBLE_CLASS: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2804 { |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2805 double *ppr = static_cast<double *> (m_pr); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2806 double *ppi = static_cast<double *> (m_pi); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2807 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2808 SparseComplexMatrix val (get_m (), get_n (), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2809 static_cast<octave_idx_type> (m_nzmax)); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2810 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2811 for (mwIndex i = 0; i < m_nzmax; i++) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2812 { |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2813 val.xdata (i) = Complex (ppr[i], ppi[i]); |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2814 val.xridx (i) = m_ir[i]; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2815 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2816 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2817 for (mwIndex i = 0; i < get_n () + 1; i++) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2818 val.xcidx (i) = m_jc[i]; |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2819 |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2820 retval = val; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2821 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2822 break; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2823 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2824 case mxSINGLE_CLASS: |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2825 error ("single precision sparse data type not supported"); |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2826 |
5903 | 2827 default: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2828 panic_impossible (); |
5903 | 2829 } |
2830 | |
2831 return retval; | |
5900 | 2832 } |
2833 | |
2834 private: | |
2835 | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2836 // Pointer to the imaginary part of the data. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2837 void *m_pi; |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2838 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2839 |
5900 | 2840 // Matlab-style struct arrays. |
2841 | |
2842 class mxArray_struct : public mxArray_matlab | |
2843 { | |
2844 public: | |
2845 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2846 mxArray_struct (bool interleaved, mwSize ndims, const mwSize *dims, |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2847 int num_keys, const char **keys) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2848 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, ndims, dims), |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2849 m_nfields (num_keys), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2850 m_fields (static_cast<char **> (mxArray::calloc (m_nfields, |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2851 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2852 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2853 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2854 sizeof (mxArray *)))) |
5900 | 2855 { |
2856 init (keys); | |
2857 } | |
2858 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2859 mxArray_struct (bool interleaved, const dim_vector& dv, int num_keys, |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2860 const char **keys) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2861 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, dv), |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2862 m_nfields (num_keys), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2863 m_fields (static_cast<char **> (mxArray::calloc (m_nfields, |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2864 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2865 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2866 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2867 sizeof (mxArray *)))) |
5900 | 2868 { |
2869 init (keys); | |
2870 } | |
2871 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2872 mxArray_struct (bool interleaved, mwSize m, mwSize n, int num_keys, |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2873 const char **keys) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2874 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, m, n), |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2875 m_nfields (num_keys), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2876 m_fields (static_cast<char **> (mxArray::calloc (m_nfields, |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2877 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2878 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2879 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2880 sizeof (mxArray *)))) |
5900 | 2881 { |
2882 init (keys); | |
2883 } | |
2884 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2885 private: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2886 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2887 mxArray_struct (const mxArray_struct& val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2888 : mxArray_matlab (val), m_nfields (val.m_nfields), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2889 m_fields (static_cast<char **> (mxArray::malloc (m_nfields |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2890 * sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2891 m_data (static_cast<mxArray **> (mxArray::malloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2892 get_number_of_elements () |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2893 * sizeof (mxArray *)))) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2894 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2895 for (int i = 0; i < m_nfields; i++) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2896 m_fields[i] = mxArray::strsave (val.m_fields[i]); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2897 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2898 mwSize nel = get_number_of_elements (); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2899 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2900 for (mwIndex i = 0; i < nel * m_nfields; i++) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2901 { |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2902 mxArray *ptr = val.m_data[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2903 m_data[i] = (ptr ? ptr->dup () : nullptr); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2904 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2905 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2906 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2907 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2908 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2909 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2910 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2911 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2912 mxArray_struct& operator = (const mxArray_struct& val); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2913 |
5900 | 2914 void init (const char **keys) |
2915 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2916 for (int i = 0; i < m_nfields; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2917 m_fields[i] = mxArray::strsave (keys[i]); |
5900 | 2918 } |
2919 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2920 mxArray_base * dup (void) const { return new mxArray_struct (*this); } |
5900 | 2921 |
2922 ~mxArray_struct (void) | |
2923 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2924 for (int i = 0; i < m_nfields; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2925 mxFree (m_fields[i]); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2926 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2927 mxFree (m_fields); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2928 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2929 mwSize ntot = m_nfields * get_number_of_elements (); |
6686 | 2930 |
2931 for (mwIndex i = 0; i < ntot; i++) | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2932 delete m_data[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2933 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2934 mxFree (m_data); |
5900 | 2935 } |
2936 | |
2937 int add_field (const char *key) | |
2938 { | |
2939 int retval = -1; | |
2940 | |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2941 m_nfields++; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2942 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2943 m_fields = static_cast<char **> |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2944 (mxRealloc (m_fields, m_nfields * sizeof (char *))); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2945 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2946 if (m_fields) |
5900 | 2947 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2948 m_fields[m_nfields-1] = mxArray::strsave (key); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2949 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2950 mwSize nel = get_number_of_elements (); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2951 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2952 mwSize ntot = m_nfields * nel; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2953 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2954 mxArray **new_data; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2955 new_data = static_cast<mxArray **> |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2956 (mxArray::malloc (ntot * sizeof (mxArray *))); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2957 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2958 if (new_data) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2959 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2960 mwIndex j = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2961 mwIndex k = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2962 mwIndex n = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2963 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2964 for (mwIndex i = 0; i < ntot; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2965 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2966 if (++n == m_nfields) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2967 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2968 new_data[j++] = nullptr; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2969 n = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2970 } |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2971 else |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2972 new_data[j++] = m_data[k++]; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2973 } |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2974 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2975 mxFree (m_data); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2976 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2977 m_data = new_data; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2978 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2979 retval = m_nfields - 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2980 } |
5900 | 2981 } |
2982 | |
2983 return retval; | |
2984 } | |
2985 | |
2986 void remove_field (int key_num) | |
2987 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2988 if (key_num >= 0 && key_num < m_nfields) |
5900 | 2989 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2990 mwSize nel = get_number_of_elements (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2991 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2992 mwSize ntot = m_nfields * nel; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2993 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2994 int new_nfields = m_nfields - 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2995 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2996 char **new_fields = static_cast<char **> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2997 (mxArray::malloc (new_nfields * sizeof (char *))); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2998 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2999 mxArray **new_data = static_cast<mxArray **> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3000 (mxArray::malloc (new_nfields * nel |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3001 * sizeof (mxArray *))); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3002 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3003 for (int i = 0; i < key_num; i++) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3004 new_fields[i] = m_fields[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3005 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3006 for (int i = key_num + 1; i < m_nfields; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3007 new_fields[i-1] = m_fields[i]; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3008 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3009 if (new_nfields > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3010 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3011 mwIndex j = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3012 mwIndex k = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3013 mwIndex n = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3014 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3015 for (mwIndex i = 0; i < ntot; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3016 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3017 if (n == key_num) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3018 k++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3019 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3020 new_data[j++] = m_data[k++]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3021 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3022 if (++n == m_nfields) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3023 n = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3024 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3025 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3026 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3027 m_nfields = new_nfields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3028 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3029 mxFree (m_fields); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3030 mxFree (m_data); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3031 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3032 m_fields = new_fields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3033 m_data = new_data; |
5900 | 3034 } |
3035 } | |
3036 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3037 mxArray * get_field_by_number (mwIndex index, int key_num) const |
5900 | 3038 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3039 return key_num >= 0 && key_num < m_nfields |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3040 ? m_data[m_nfields * index + key_num] : nullptr; |
5900 | 3041 } |
3042 | |
6686 | 3043 void set_field_by_number (mwIndex index, int key_num, mxArray *val); |
5900 | 3044 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3045 int get_number_of_fields (void) const { return m_nfields; } |
5900 | 3046 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3047 const char * get_field_name_by_number (int key_num) const |
5900 | 3048 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3049 return key_num >= 0 && key_num < m_nfields ? m_fields[key_num] : nullptr; |
5900 | 3050 } |
3051 | |
3052 int get_field_number (const char *key) const | |
3053 { | |
3054 int retval = -1; | |
3055 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3056 for (int i = 0; i < m_nfields; i++) |
5900 | 3057 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3058 if (! strcmp (key, m_fields[i])) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3059 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3060 retval = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3061 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3062 } |
5900 | 3063 } |
3064 | |
3065 return retval; | |
3066 } | |
3067 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3068 void * get_data (void) const { return m_data; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3069 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3070 void set_data (void *data) { m_data = static_cast<mxArray **> (data); } |
5900 | 3071 |
5907 | 3072 octave_value as_octave_value (void) const |
3073 { | |
3074 dim_vector dv = dims_to_dim_vector (); | |
3075 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3076 string_vector keys (m_fields, m_nfields); |
5907 | 3077 |
25922
34e82a829fdd
Create scalar structs of size 1x1 with MEX interface (bug #54799).
Rik <rik@octave.org>
parents:
25751
diff
changeset
|
3078 octave_map m (dv); |
5907 | 3079 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3080 mwSize ntot = m_nfields * get_number_of_elements (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3081 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3082 for (int i = 0; i < m_nfields; i++) |
5907 | 3083 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3084 Cell c (dv); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3085 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3086 octave_value *p = c.fortran_vec (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3087 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3088 mwIndex k = 0; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3089 for (mwIndex j = i; j < ntot; j += m_nfields) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3090 p[k++] = mxArray::as_octave_value (m_data[j]); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3091 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3092 m.assign (keys[i], c); |
5907 | 3093 } |
3094 | |
3095 return m; | |
3096 } | |
3097 | |
5900 | 3098 private: |
3099 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3100 int m_nfields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3101 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3102 char **m_fields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3103 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3104 mxArray **m_data; |
5900 | 3105 }; |
3106 | |
3107 // Matlab-style cell arrays. | |
3108 | |
3109 class mxArray_cell : public mxArray_matlab | |
3110 { | |
3111 public: | |
3112 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
3113 mxArray_cell (bool interleaved, mwSize ndims, const mwSize *dims) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
3114 : mxArray_matlab (interleaved, mxCELL_CLASS, ndims, dims), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3115 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3116 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3117 { } |
5900 | 3118 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3119 mxArray_cell (bool interleaved, const dim_vector& dv) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3120 : mxArray_matlab (interleaved, mxCELL_CLASS, dv), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3121 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3122 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3123 { } |
5900 | 3124 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3125 mxArray_cell (bool interleaved, mwSize m, mwSize n) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3126 : mxArray_matlab (interleaved, mxCELL_CLASS, m, n), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3127 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3128 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3129 { } |
5900 | 3130 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3131 private: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3132 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3133 mxArray_cell (const mxArray_cell& val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3134 : mxArray_matlab (val), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3135 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3136 mxArray::malloc (get_number_of_elements () * sizeof (mxArray *)))) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3137 { |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3138 mwSize nel = get_number_of_elements (); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3139 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3140 for (mwIndex i = 0; i < nel; i++) |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3141 { |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3142 mxArray *ptr = val.m_data[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3143 m_data[i] = (ptr ? ptr->dup () : nullptr); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3144 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3145 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3146 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3147 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3148 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3149 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3150 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3151 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3152 mxArray_cell& operator = (const mxArray_cell&); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3153 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3154 mxArray_base * dup (void) const { return new mxArray_cell (*this); } |
5900 | 3155 |
3156 ~mxArray_cell (void) | |
3157 { | |
6686 | 3158 mwSize nel = get_number_of_elements (); |
3159 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
3160 for (mwIndex i = 0; i < nel; i++) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3161 delete m_data[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3162 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3163 mxFree (m_data); |
5900 | 3164 } |
3165 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3166 mxArray * get_cell (mwIndex idx) const |
6187 | 3167 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3168 return idx >= 0 && idx < get_number_of_elements () ? m_data[idx] : nullptr; |
6187 | 3169 } |
5907 | 3170 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3171 void set_cell (mwIndex idx, mxArray *val); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3172 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3173 void * get_data (void) const { return m_data; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3174 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3175 void set_data (void *data) { m_data = static_cast<mxArray **> (data); } |
5907 | 3176 |
5900 | 3177 octave_value as_octave_value (void) const |
3178 { | |
3179 dim_vector dv = dims_to_dim_vector (); | |
3180 | |
3181 Cell c (dv); | |
3182 | |
6686 | 3183 mwSize nel = get_number_of_elements (); |
5900 | 3184 |
3185 octave_value *p = c.fortran_vec (); | |
3186 | |
6686 | 3187 for (mwIndex i = 0; i < nel; i++) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3188 p[i] = mxArray::as_octave_value (m_data[i]); |
5900 | 3189 |
3190 return c; | |
3191 } | |
3192 | |
3193 private: | |
3194 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3195 mxArray **m_data; |
5900 | 3196 }; |
3197 | |
3198 // ------------------------------------------------------------------ | |
3199 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3200 mxArray::mxArray (bool interleaved, const octave_value& ov) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3201 : m_rep (create_rep (interleaved, ov)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3202 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3203 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3204 mxArray::mxArray (bool interleaved, mxClassID id, mwSize ndims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3205 const mwSize *dims, mxComplexity flag, bool init) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3206 : m_rep (create_rep (interleaved, id, ndims, dims, flag, init)), |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3207 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3208 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3209 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3210 mxArray::mxArray (bool interleaved, mxClassID id, const dim_vector& dv, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3211 mxComplexity flag) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3212 : m_rep (create_rep (interleaved, id, dv, flag)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3213 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3214 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3215 mxArray::mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n, |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
3216 mxComplexity flag, bool init) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3217 : m_rep (create_rep (interleaved, id, m, n, flag, init)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3218 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3219 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3220 mxArray::mxArray (bool interleaved, mxClassID id, double val) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3221 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3222 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3223 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3224 mxArray::mxArray (bool interleaved, mxClassID id, mxLogical val) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3225 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3226 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3227 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3228 mxArray::mxArray (bool interleaved, const char *str) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3229 : m_rep (create_rep (interleaved, str)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3230 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3231 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3232 mxArray::mxArray (bool interleaved, mwSize m, const char **str) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3233 : m_rep (create_rep (interleaved, m, str)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3234 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3235 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3236 mxArray::mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3237 mwSize nzmax, mxComplexity flag) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3238 : m_rep (create_rep (interleaved, id, m, n, nzmax, flag)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3239 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3240 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3241 mxArray::mxArray (bool interleaved, mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3242 int num_keys, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3243 const char **keys) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3244 : m_rep (new mxArray_struct (interleaved, ndims, dims, num_keys, keys)), |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3245 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3246 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3247 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3248 mxArray::mxArray (bool interleaved, const dim_vector& dv, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3249 const char **keys) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3250 : m_rep (new mxArray_struct (interleaved, dv, num_keys, keys)), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3251 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3252 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3253 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3254 mxArray::mxArray (bool interleaved, mwSize m, mwSize n, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3255 const char **keys) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3256 : m_rep (new mxArray_struct (interleaved, m, n, num_keys, keys)), |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3257 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3258 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3259 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3260 mxArray::mxArray (bool interleaved, mwSize ndims, const mwSize *dims) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3261 : m_rep (new mxArray_cell (interleaved, ndims, dims)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3262 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3263 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3264 mxArray::mxArray (bool interleaved, const dim_vector& dv) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3265 : m_rep (new mxArray_cell (interleaved, dv)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3266 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3267 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3268 mxArray::mxArray (bool interleaved, mwSize m, mwSize n) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3269 : m_rep (new mxArray_cell (interleaved, m, n)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3270 { } |
5900 | 3271 |
3272 mxArray::~mxArray (void) | |
3273 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3274 mxFree (m_name); |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3275 |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3276 delete m_rep; |
5900 | 3277 } |
3278 | |
3279 void | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3280 mxArray::set_name (const char *name) |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3281 { |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3282 mxFree (m_name); |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3283 m_name = mxArray::strsave (name); |
5900 | 3284 } |
3285 | |
5907 | 3286 octave_value |
25451
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3287 mxArray::as_octave_value (const mxArray *ptr, bool null_is_empty) |
5907 | 3288 { |
25451
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3289 static const octave_value empty_matrix = Matrix (); |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3290 |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3291 return (ptr |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3292 ? ptr->as_octave_value () |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3293 : (null_is_empty ? empty_matrix : octave_value ())); |
5907 | 3294 } |
3295 | |
3296 octave_value | |
3297 mxArray::as_octave_value (void) const | |
3298 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3299 return m_rep->as_octave_value (); |
5907 | 3300 } |
3301 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3302 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3303 mxArray::create_rep (bool interleaved, const octave_value& ov) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3304 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3305 return new mxArray_octave_value (interleaved, ov); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3306 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3307 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3308 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3309 mxArray::create_rep (bool interleaved, mxClassID id, mwSize ndims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3310 const mwSize *dims, mxComplexity flag, bool init) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3311 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3312 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3313 return new mxArray_interleaved_full (id, ndims, dims, flag, init); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3314 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3315 return new mxArray_separate_full (id, ndims, dims, flag, init); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3316 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3317 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3318 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3319 mxArray::create_rep (bool interleaved, mxClassID id, const dim_vector& dv, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3320 mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3321 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3322 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3323 return new mxArray_interleaved_full (id, dv, flag); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3324 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3325 return new mxArray_separate_full (id, dv, flag); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3326 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3327 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3328 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3329 mxArray::create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3330 mxComplexity flag, bool init) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3331 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3332 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3333 return new mxArray_interleaved_full (id, m, n, flag, init); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3334 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3335 return new mxArray_separate_full (id, m, n, flag, init); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3336 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3337 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3338 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3339 mxArray::create_rep (bool interleaved, mxClassID id, double val) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3340 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3341 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3342 return new mxArray_interleaved_full (id, val); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3343 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3344 return new mxArray_separate_full (id, val); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3345 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3346 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3347 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3348 mxArray::create_rep (bool interleaved, mxClassID id, mxLogical val) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3349 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3350 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3351 return new mxArray_interleaved_full (id, val); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3352 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3353 return new mxArray_separate_full (id, val); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3354 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3355 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3356 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3357 mxArray::create_rep (bool interleaved, const char *str) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3358 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3359 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3360 return new mxArray_interleaved_full (str); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3361 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3362 return new mxArray_separate_full (str); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3363 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3364 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3365 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3366 mxArray::create_rep (bool interleaved, mwSize m, const char **str) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3367 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3368 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3369 return new mxArray_interleaved_full (m, str); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3370 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3371 return new mxArray_separate_full (m, str); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3372 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3373 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3374 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3375 mxArray::create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3376 mwSize nzmax, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3377 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3378 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3379 return new mxArray_interleaved_sparse (id, m, n, nzmax, flag); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3380 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3381 return new mxArray_separate_sparse (id, m, n, nzmax, flag); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3382 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3383 |
5900 | 3384 void |
3385 mxArray::maybe_mutate (void) const | |
3386 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3387 if (m_rep->is_octave_value ()) |
5900 | 3388 { |
3389 // The mutate function returns a pointer to a complete new | |
3390 // mxArray object (or 0, if no mutation happened). We just want | |
3391 // to replace the existing rep with the rep from the new object. | |
3392 | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3393 mxArray *new_val = m_rep->mutate (); |
5900 | 3394 |
3395 if (new_val) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3396 { |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3397 delete m_rep; |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3398 m_rep = new_val->m_rep; |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3399 new_val->m_rep = nullptr; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3400 delete new_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3401 } |
5900 | 3402 } |
3403 } | |
3404 | |
3405 // ------------------------------------------------------------------ | |
3406 | |
6686 | 3407 // A class to manage calls to MEX functions. Mostly deals with memory |
5900 | 3408 // management. |
5864 | 3409 |
3410 class mex | |
3411 { | |
3412 public: | |
3413 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3414 mex (octave_mex_function& f) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3415 : m_curr_mex_fcn (f), m_memlist (), m_arraylist (), m_fname (nullptr) { } |
5864 | 3416 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3417 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3418 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3419 mex (const mex&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3420 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3421 mex& operator = (const mex&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3422 |
5864 | 3423 ~mex (void) |
3424 { | |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3425 // We can't use mex::free here because it modifies memlist. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3426 while (! m_memlist.empty ()) |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3427 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3428 auto p = m_memlist.begin (); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3429 xfree (*p); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3430 m_memlist.erase (p); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3431 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3432 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3433 // We can't use mex::free_value here because it modifies arraylist. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3434 while (! m_arraylist.empty ()) |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3435 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3436 auto p = m_arraylist.begin (); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3437 delete *p; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3438 m_arraylist.erase (p); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3439 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3440 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3441 if (! (m_memlist.empty () && m_arraylist.empty ())) |
5905 | 3442 error ("mex: %s: cleanup failed", function_name ()); |
5900 | 3443 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3444 mxFree (m_fname); |
5864 | 3445 } |
3446 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3447 const char * function_name (void) const |
5900 | 3448 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3449 if (! m_fname) |
5900 | 3450 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
3451 octave::tree_evaluator& tw = octave::__get_evaluator__ (); |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3452 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3453 octave_function *fcn = tw.current_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3454 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3455 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3456 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3457 std::string nm = fcn->name (); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3458 m_fname = mxArray::strsave (nm.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3459 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3460 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3461 m_fname = mxArray::strsave ("unknown"); |
5900 | 3462 } |
3463 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3464 return m_fname; |
5900 | 3465 } |
3466 | |
6071 | 3467 // Allocate memory. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3468 void * malloc_unmarked (std::size_t n) |
5900 | 3469 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3470 void *ptr = xmalloc (n); |
5900 | 3471 |
3472 if (! ptr) | |
3473 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3474 // FIXME: could use "octave_new_handler();" instead |
26159
aa678451b758
Silence compiler warning about incorrect format specifier (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26113
diff
changeset
|
3475 error ("%s: failed to allocate %zd bytes of memory", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3476 function_name (), n); |
5900 | 3477 } |
3478 | |
3479 global_mark (ptr); | |
3480 | |
3481 return ptr; | |
3482 } | |
3483 | |
6071 | 3484 // Allocate memory to be freed on exit. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3485 void * malloc (std::size_t n) |
5900 | 3486 { |
3487 void *ptr = malloc_unmarked (n); | |
3488 | |
3489 mark (ptr); | |
3490 | |
3491 return ptr; | |
3492 } | |
3493 | |
6071 | 3494 // Allocate memory and initialize to 0. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3495 void * calloc_unmarked (std::size_t n, std::size_t t) |
5900 | 3496 { |
3497 void *ptr = malloc_unmarked (n*t); | |
3498 | |
3499 memset (ptr, 0, n*t); | |
3500 | |
3501 return ptr; | |
3502 } | |
3503 | |
6071 | 3504 // Allocate memory to be freed on exit and initialize to 0. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3505 void * calloc (std::size_t n, std::size_t t) |
5900 | 3506 { |
3507 void *ptr = calloc_unmarked (n, t); | |
3508 | |
3509 mark (ptr); | |
3510 | |
3511 return ptr; | |
3512 } | |
3513 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3514 // Reallocate a pointer obtained from malloc or calloc. |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3515 // If the pointer is NULL, allocate using malloc. |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3516 // We don't need an "unmarked" version of this. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3517 void * realloc (void *ptr, std::size_t n) |
5900 | 3518 { |
10225
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3519 void *v; |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3520 |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3521 if (ptr) |
5900 | 3522 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3523 auto p_local = m_memlist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3524 auto p_global = s_global_memlist.find (ptr); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3525 |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3526 v = xrealloc (ptr, n); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3527 |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3528 if (v) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3529 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3530 if (p_local != m_memlist.end ()) |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3531 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3532 m_memlist.erase (p_local); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3533 m_memlist.insert (v); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3534 } |
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3535 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3536 if (p_global != s_global_memlist.end ()) |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3537 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3538 s_global_memlist.erase (p_global); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3539 s_global_memlist.insert (v); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3540 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3541 } |
5900 | 3542 } |
10225
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3543 else |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3544 v = malloc (n); |
5900 | 3545 |
3546 return v; | |
3547 } | |
3548 | |
3549 // Free a pointer obtained from malloc or calloc. | |
3550 void free (void *ptr) | |
3551 { | |
3552 if (ptr) | |
3553 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3554 unmark (ptr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3555 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3556 auto p = s_global_memlist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3557 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3558 if (p != s_global_memlist.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3559 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3560 s_global_memlist.erase (p); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3561 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3562 xfree (ptr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3563 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3564 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3565 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3566 p = m_foreign_memlist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3567 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3568 if (p != m_foreign_memlist.end ()) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3569 m_foreign_memlist.erase (p); |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3570 #if defined (DEBUG) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3571 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3572 warning ("mxFree: skipping memory not allocated by mxMalloc, mxCalloc, or mxRealloc"); |
11276
475e90eb4ff1
mex::free: don't warn about skipping memory not allocated by mx{M,C,Re}alloc
John W. Eaton <jwe@octave.org>
parents:
11132
diff
changeset
|
3573 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3574 } |
5900 | 3575 } |
3576 } | |
3577 | |
7172 | 3578 // Mark a pointer to be freed on exit. |
3579 void mark (void *ptr) | |
3580 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3581 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3582 if (m_memlist.find (ptr) != m_memlist.end ()) |
7172 | 3583 warning ("%s: double registration ignored", function_name ()); |
3584 #endif | |
3585 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3586 m_memlist.insert (ptr); |
7172 | 3587 } |
3588 | |
3589 // Unmark a pointer to be freed on exit, either because it was | |
3590 // made persistent, or because it was already freed. | |
3591 void unmark (void *ptr) | |
3592 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3593 auto p = m_memlist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3594 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3595 if (p != m_memlist.end ()) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3596 m_memlist.erase (p); |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3597 #if defined (DEBUG) |
7172 | 3598 else |
3599 warning ("%s: value not marked", function_name ()); | |
3600 #endif | |
3601 } | |
5900 | 3602 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3603 mxArray * mark_array (mxArray *ptr) |
6065 | 3604 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3605 m_arraylist.insert (ptr); |
6065 | 3606 return ptr; |
3607 } | |
3608 | |
6071 | 3609 void unmark_array (mxArray *ptr) |
3610 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3611 auto p = m_arraylist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3612 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3613 if (p != m_arraylist.end ()) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3614 m_arraylist.erase (p); |
6071 | 3615 } |
3616 | |
7179 | 3617 // Mark a pointer as one we allocated. |
3618 void mark_foreign (void *ptr) | |
3619 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3620 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3621 if (m_foreign_memlist.find (ptr) != m_foreign_memlist.end ()) |
7179 | 3622 warning ("%s: double registration ignored", function_name ()); |
3623 #endif | |
3624 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3625 m_foreign_memlist.insert (ptr); |
7179 | 3626 } |
3627 | |
3628 // Unmark a pointer as one we allocated. | |
3629 void unmark_foreign (void *ptr) | |
3630 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3631 auto p = m_foreign_memlist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3632 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3633 if (p != m_foreign_memlist.end ()) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3634 m_foreign_memlist.erase (p); |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3635 #if defined (DEBUG) |
7179 | 3636 else |
3637 warning ("%s: value not marked", function_name ()); | |
3638 #endif | |
3639 | |
3640 } | |
3641 | |
5900 | 3642 // Make a new array value and initialize from an octave value; it will be |
3643 // freed on exit unless marked as persistent. | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3644 mxArray * make_value (const octave_value& ov) |
5900 | 3645 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3646 bool interleaved = m_curr_mex_fcn.use_interleaved_complex (); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3647 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3648 return mark_array (new mxArray (interleaved, ov)); |
5900 | 3649 } |
3650 | |
3651 // Free an array and its contents. | |
6065 | 3652 bool free_value (mxArray *ptr) |
5900 | 3653 { |
6065 | 3654 bool inlist = false; |
3655 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3656 auto p = m_arraylist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3657 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3658 if (p != m_arraylist.end ()) |
5905 | 3659 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3660 inlist = true; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3661 m_arraylist.erase (p); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3662 delete ptr; |
5905 | 3663 } |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3664 #if defined (DEBUG) |
5905 | 3665 else |
3666 warning ("mex::free_value: skipping memory not allocated by mex::make_value"); | |
3667 #endif | |
6065 | 3668 |
3669 return inlist; | |
5900 | 3670 } |
3671 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3672 octave_mex_function& current_mex_function (void) const |
6068 | 3673 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3674 return m_curr_mex_fcn; |
6068 | 3675 } |
3676 | |
5900 | 3677 // 1 if error should be returned to MEX file, 0 if abort. |
22452
3a8af9d517de
Initialize MEX TrapFlag variable for Matlab compatibility.
Rik <rik@octave.org>
parents:
22451
diff
changeset
|
3678 int trap_feval_error = 0; |
5864 | 3679 |
5900 | 3680 // Mark a pointer as one we allocated. |
5905 | 3681 void global_mark (void *ptr) |
5900 | 3682 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3683 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3684 if (s_global_memlist.find (ptr) != s_global_memlist.end ()) |
5905 | 3685 warning ("%s: double registration ignored", function_name ()); |
5864 | 3686 #endif |
5900 | 3687 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3688 s_global_memlist.insert (ptr); |
5864 | 3689 } |
3690 | |
5900 | 3691 // Unmark a pointer as one we allocated. |
5905 | 3692 void global_unmark (void *ptr) |
5864 | 3693 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3694 auto p = s_global_memlist.find (ptr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3695 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3696 if (p != s_global_memlist.end ()) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3697 s_global_memlist.erase (p); |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3698 #if defined (DEBUG) |
5905 | 3699 else |
3700 warning ("%s: value not marked", function_name ()); | |
5900 | 3701 #endif |
5864 | 3702 } |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3703 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
3704 private: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3705 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3706 // Pointer to the mex function that corresponds to this mex context. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3707 octave_mex_function& m_curr_mex_fcn; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3708 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3709 // List of memory resources that need to be freed upon exit. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3710 std::set<void *> m_memlist; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3711 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3712 // List of mxArray objects that need to be freed upon exit. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3713 std::set<mxArray *> m_arraylist; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3714 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3715 // List of memory resources we know about, but that were allocated |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3716 // elsewhere. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3717 std::set<void *> m_foreign_memlist; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3718 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3719 // The name of the currently executing function. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3720 mutable char *m_fname; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3721 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3722 // List of memory resources we allocated. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3723 static std::set<void *> s_global_memlist; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3724 |
5864 | 3725 }; |
3726 | |
5900 | 3727 // List of memory resources we allocated. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3728 std::set<void *> mex::s_global_memlist; |
5900 | 3729 |
3730 // Current context. | |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
3731 mex *mex_context = nullptr; |
5900 | 3732 |
3733 void * | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3734 mxArray::malloc (std::size_t n) |
5900 | 3735 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3736 return mex_context ? mex_context->malloc_unmarked (n) : xmalloc (n); |
5900 | 3737 } |
3738 | |
3739 void * | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3740 mxArray::calloc (std::size_t n, std::size_t t) |
5900 | 3741 { |
6065 | 3742 return mex_context ? mex_context->calloc_unmarked (n, t) : ::calloc (n, t); |
5900 | 3743 } |
3744 | |
30223
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3745 void * |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3746 mxArray::alloc (bool init, std::size_t n, std::size_t t) |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3747 { |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3748 return init ? mxArray::calloc (n, t) : mxArray::malloc (n * t); |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3749 } |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3750 |
7179 | 3751 static inline void * |
3752 maybe_mark_foreign (void *ptr) | |
3753 { | |
3754 if (mex_context) | |
3755 mex_context->mark_foreign (ptr); | |
3756 | |
3757 return ptr; | |
3758 } | |
3759 | |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3760 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3761 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3762 static inline void |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3763 maybe_disown_ptr (void *ptr) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3764 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3765 if (mex_context) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3766 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3767 mex_context->unmark (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3768 mex_context->global_unmark (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3769 mex_context->mark_foreign (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3770 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3771 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3772 |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3773 #endif |
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3774 |
6071 | 3775 static inline mxArray * |
3776 maybe_unmark_array (mxArray *ptr) | |
3777 { | |
3778 if (mex_context) | |
3779 mex_context->unmark_array (ptr); | |
3780 | |
3781 return ptr; | |
3782 } | |
3783 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3784 template <typename T> |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3785 static inline T * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3786 maybe_unmark (T *ptr) |
7172 | 3787 { |
3788 if (mex_context) | |
3789 mex_context->unmark (ptr); | |
3790 | |
3791 return ptr; | |
3792 } | |
3793 | |
6071 | 3794 void |
6686 | 3795 mxArray_struct::set_field_by_number (mwIndex index, int key_num, mxArray *val) |
6071 | 3796 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3797 if (key_num >= 0 && key_num < m_nfields) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3798 m_data[m_nfields * index + key_num] = maybe_unmark_array (val); |
6071 | 3799 } |
3800 | |
3801 void | |
6686 | 3802 mxArray_cell::set_cell (mwIndex idx, mxArray *val) |
6071 | 3803 { |
6187 | 3804 if (idx >= 0 && idx < get_number_of_elements ()) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3805 m_data[idx] = maybe_unmark_array (val); |
6071 | 3806 } |
3807 | |
5900 | 3808 // ------------------------------------------------------------------ |
3809 | |
3810 // C interface to mxArray objects: | |
3811 | |
3812 // Floating point predicates. | |
3813 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3814 bool |
5900 | 3815 mxIsFinite (const double v) |
3816 { | |
30088
fca57eaad2d4
maint: deprecate lo_ieee_finite and replace with lo_ieee_isfinite.
Rik <rik@octave.org>
parents:
29993
diff
changeset
|
3817 return lo_ieee_isfinite (v) != 0; |
5900 | 3818 } |
3819 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3820 bool |
5900 | 3821 mxIsInf (const double v) |
3822 { | |
3823 return lo_ieee_isinf (v) != 0; | |
3824 } | |
3825 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3826 bool |
5900 | 3827 mxIsNaN (const double v) |
3828 { | |
3829 return lo_ieee_isnan (v) != 0; | |
3830 } | |
3831 | |
3832 double | |
3833 mxGetEps (void) | |
3834 { | |
15220
61822c866ba1
use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3835 return std::numeric_limits<double>::epsilon (); |
5900 | 3836 } |
3837 | |
3838 double | |
3839 mxGetInf (void) | |
3840 { | |
3841 return lo_ieee_inf_value (); | |
3842 } | |
3843 | |
3844 double | |
3845 mxGetNaN (void) | |
3846 { | |
3847 return lo_ieee_nan_value (); | |
3848 } | |
3849 | |
3850 // Memory management. | |
3851 void * | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3852 mxCalloc (std::size_t n, std::size_t size) |
5900 | 3853 { |
15354
93dff6435fe1
tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents:
15353
diff
changeset
|
3854 return mex_context ? mex_context->calloc (n, size) : ::calloc (n, size); |
5900 | 3855 } |
3856 | |
3857 void * | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3858 mxMalloc (std::size_t n) |
5900 | 3859 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3860 return mex_context ? mex_context->malloc (n) : xmalloc (n); |
5900 | 3861 } |
3862 | |
3863 void * | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3864 mxRealloc (void *ptr, std::size_t size) |
5900 | 3865 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3866 return (mex_context |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3867 ? mex_context->realloc (ptr, size) : xrealloc (ptr, size)); |
5900 | 3868 } |
3869 | |
3870 void | |
3871 mxFree (void *ptr) | |
5864 | 3872 { |
5900 | 3873 if (mex_context) |
3874 mex_context->free (ptr); | |
5864 | 3875 else |
6071 | 3876 xfree (ptr); |
5900 | 3877 } |
6065 | 3878 |
3879 static inline mxArray * | |
3880 maybe_mark_array (mxArray *ptr) | |
3881 { | |
3882 return mex_context ? mex_context->mark_array (ptr) : ptr; | |
3883 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3884 |
5900 | 3885 // Constructors. |
3886 mxArray * | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3887 mxCreateCellArray_interleaved (mwSize ndims, const mwSize *dims) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3888 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3889 return maybe_mark_array (new mxArray (true, ndims, dims)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3890 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3891 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3892 mxArray * |
6686 | 3893 mxCreateCellArray (mwSize ndims, const mwSize *dims) |
5900 | 3894 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3895 return maybe_mark_array (new mxArray (false, ndims, dims)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3896 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3897 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3898 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3899 mxCreateCellMatrix_interleaved (mwSize m, mwSize n) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3900 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3901 return maybe_mark_array (new mxArray (true, m, n)); |
5900 | 3902 } |
3903 | |
3904 mxArray * | |
6686 | 3905 mxCreateCellMatrix (mwSize m, mwSize n) |
5900 | 3906 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3907 return maybe_mark_array (new mxArray (false, m, n)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3908 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3909 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3910 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3911 mxCreateCharArray_interleaved (mwSize ndims, const mwSize *dims) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3912 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3913 return maybe_mark_array (new mxArray (true, mxCHAR_CLASS, ndims, dims)); |
5900 | 3914 } |
3915 | |
3916 mxArray * | |
6686 | 3917 mxCreateCharArray (mwSize ndims, const mwSize *dims) |
5900 | 3918 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3919 return maybe_mark_array (new mxArray (false, mxCHAR_CLASS, ndims, dims)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3920 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3921 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3922 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3923 mxCreateCharMatrixFromStrings_interleaved (mwSize m, const char **str) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3924 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3925 return maybe_mark_array (new mxArray (true, m, str)); |
5864 | 3926 } |
3927 | |
5900 | 3928 mxArray * |
6686 | 3929 mxCreateCharMatrixFromStrings (mwSize m, const char **str) |
5900 | 3930 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3931 return maybe_mark_array (new mxArray (false, m, str)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3932 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3933 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3934 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3935 mxCreateDoubleMatrix_interleaved (mwSize m, mwSize n, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3936 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3937 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, flag)); |
5900 | 3938 } |
3939 | |
3940 mxArray * | |
6686 | 3941 mxCreateDoubleMatrix (mwSize m, mwSize n, mxComplexity flag) |
5900 | 3942 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3943 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, m, n, flag)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3944 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3945 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3946 mxArray * |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3947 mxCreateDoubleScalar_interleaved (double val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3948 { |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3949 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, val)); |
5900 | 3950 } |
3951 | |
3952 mxArray * | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3953 mxCreateDoubleScalar (double val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3954 { |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3955 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, val)); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3956 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3957 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3958 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3959 mxCreateLogicalArray_interleaved (mwSize ndims, const mwSize *dims) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3960 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3961 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, ndims, dims)); |
5900 | 3962 } |
3963 | |
3964 mxArray * | |
6686 | 3965 mxCreateLogicalArray (mwSize ndims, const mwSize *dims) |
5864 | 3966 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3967 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, ndims, dims)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3968 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3969 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3970 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3971 mxCreateLogicalMatrix_interleaved (mwSize m, mwSize n) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3972 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3973 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n)); |
5900 | 3974 } |
3975 | |
3976 mxArray * | |
6686 | 3977 mxCreateLogicalMatrix (mwSize m, mwSize n) |
5900 | 3978 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3979 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, m, n)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3980 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3981 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3982 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3983 mxCreateLogicalScalar_interleaved (mxLogical val) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3984 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3985 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, val)); |
5900 | 3986 } |
3987 | |
3988 mxArray * | |
7577
ba8fcc115fee
mex.cc: arg to mxCreateLogicalScalar is now mxLogical
John W. Eaton <jwe@octave.org>
parents:
7357
diff
changeset
|
3989 mxCreateLogicalScalar (mxLogical val) |
5900 | 3990 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3991 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, val)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3992 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3993 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3994 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3995 mxCreateNumericArray_interleaved (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3996 mxClassID class_id, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3997 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3998 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag)); |
5900 | 3999 } |
4000 | |
4001 mxArray * | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4002 mxCreateNumericArray (mwSize ndims, const mwSize *dims, |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
4003 mxClassID class_id, mxComplexity flag) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4004 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4005 return maybe_mark_array (new mxArray (false, class_id, ndims, dims, flag)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4006 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4007 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4008 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4009 mxCreateNumericMatrix_interleaved (mwSize m, mwSize n, mxClassID class_id, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4010 mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4011 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4012 return maybe_mark_array (new mxArray (true, class_id, m, n, flag)); |
5864 | 4013 } |
4014 | |
5900 | 4015 mxArray * |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4016 mxCreateNumericMatrix (mwSize m, mwSize n, mxClassID class_id, |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30349
diff
changeset
|
4017 mxComplexity flag) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4018 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4019 return maybe_mark_array (new mxArray (false, class_id, m, n, flag)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4020 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4021 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4022 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4023 mxCreateUninitNumericArray_interleaved (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4024 mxClassID class_id, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4025 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4026 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4027 false)); |
5900 | 4028 } |
4029 | |
4030 mxArray * | |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4031 mxCreateUninitNumericArray (mwSize ndims, const mwSize *dims, |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30349
diff
changeset
|
4032 mxClassID class_id, mxComplexity flag) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4033 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4034 return maybe_mark_array (new mxArray (false, class_id, ndims, dims, flag, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4035 false)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4036 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4037 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4038 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4039 mxCreateUninitNumericMatrix_interleaved (mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4040 mxClassID class_id, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4041 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4042 return maybe_mark_array (new mxArray (true, class_id, m, n, flag, false)); |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4043 } |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4044 |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4045 mxArray * |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4046 mxCreateUninitNumericMatrix (mwSize m, mwSize n, mxClassID class_id, |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30349
diff
changeset
|
4047 mxComplexity flag) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4048 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4049 return maybe_mark_array (new mxArray (false, class_id, m, n, flag, false)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4050 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4051 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4052 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4053 mxCreateSparse_interleaved (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4054 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4055 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, nzmax, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4056 flag)); |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4057 } |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4058 |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4059 mxArray * |
6686 | 4060 mxCreateSparse (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag) |
5900 | 4061 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4062 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, m, n, nzmax, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4063 flag)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4064 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4065 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4066 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4067 mxCreateSparseLogicalMatrix_interleaved (mwSize m, mwSize n, mwSize nzmax) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4068 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4069 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n, nzmax)); |
5900 | 4070 } |
4071 | |
4072 mxArray * | |
6686 | 4073 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax) |
5900 | 4074 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4075 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, m, n, nzmax)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4076 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4077 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4078 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4079 mxCreateString_interleaved (const char *str) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4080 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4081 return maybe_mark_array (new mxArray (true, str)); |
5900 | 4082 } |
4083 | |
4084 mxArray * | |
4085 mxCreateString (const char *str) | |
4086 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4087 return maybe_mark_array (new mxArray (false, str)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4088 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4089 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4090 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4091 mxCreateStructArray_interleaved (mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4092 int num_keys, const char **keys) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4093 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4094 return maybe_mark_array (new mxArray (true, ndims, dims, num_keys, keys)); |
5900 | 4095 } |
4096 | |
4097 mxArray * | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4098 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys, |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
4099 const char **keys) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4100 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4101 return maybe_mark_array (new mxArray (false, ndims, dims, num_keys, keys)); |
5900 | 4102 } |
5864 | 4103 |
4104 mxArray * | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4105 mxCreateStructMatrix_interleaved (mwSize m, mwSize n, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4106 const char **keys) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4107 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4108 return maybe_mark_array (new mxArray (true, m, n, num_keys, keys)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4109 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4110 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4111 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4112 mxCreateStructMatrix (mwSize m, mwSize n, int num_keys, |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
4113 const char **keys) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4114 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4115 return maybe_mark_array (new mxArray (false, m, n, num_keys, keys)); |
5900 | 4116 } |
4117 | |
4118 // Copy constructor. | |
4119 mxArray * | |
4120 mxDuplicateArray (const mxArray *ptr) | |
4121 { | |
11277
7d5351fc575a
mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents:
11276
diff
changeset
|
4122 return maybe_mark_array (ptr->dup ()); |
5900 | 4123 } |
4124 | |
4125 // Destructor. | |
4126 void | |
4127 mxDestroyArray (mxArray *ptr) | |
4128 { | |
6065 | 4129 if (! (mex_context && mex_context->free_value (ptr))) |
4130 delete ptr; | |
5900 | 4131 } |
4132 | |
4133 // Type Predicates. | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4134 bool |
5900 | 4135 mxIsCell (const mxArray *ptr) |
4136 { | |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
4137 return ptr->iscell (); |
5900 | 4138 } |
4139 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4140 bool |
5900 | 4141 mxIsChar (const mxArray *ptr) |
4142 { | |
4143 return ptr->is_char (); | |
4144 } | |
4145 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4146 bool |
5900 | 4147 mxIsClass (const mxArray *ptr, const char *name) |
4148 { | |
4149 return ptr->is_class (name); | |
4150 } | |
4151 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4152 bool |
5900 | 4153 mxIsComplex (const mxArray *ptr) |
4154 { | |
4155 return ptr->is_complex (); | |
4156 } | |
4157 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4158 bool |
5900 | 4159 mxIsDouble (const mxArray *ptr) |
4160 { | |
4161 return ptr->is_double (); | |
4162 } | |
4163 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4164 bool |
11100
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4165 mxIsFunctionHandle (const mxArray *ptr) |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4166 { |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4167 return ptr->is_function_handle (); |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4168 } |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4169 |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4170 bool |
5900 | 4171 mxIsInt16 (const mxArray *ptr) |
4172 { | |
4173 return ptr->is_int16 (); | |
4174 } | |
4175 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4176 bool |
5900 | 4177 mxIsInt32 (const mxArray *ptr) |
4178 { | |
4179 return ptr->is_int32 (); | |
4180 } | |
4181 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4182 bool |
5900 | 4183 mxIsInt64 (const mxArray *ptr) |
4184 { | |
4185 return ptr->is_int64 (); | |
4186 } | |
4187 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4188 bool |
5900 | 4189 mxIsInt8 (const mxArray *ptr) |
4190 { | |
4191 return ptr->is_int8 (); | |
4192 } | |
4193 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4194 bool |
5900 | 4195 mxIsLogical (const mxArray *ptr) |
4196 { | |
4197 return ptr->is_logical (); | |
4198 } | |
4199 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4200 bool |
5900 | 4201 mxIsNumeric (const mxArray *ptr) |
4202 { | |
4203 return ptr->is_numeric (); | |
4204 } | |
4205 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4206 bool |
5900 | 4207 mxIsSingle (const mxArray *ptr) |
4208 { | |
4209 return ptr->is_single (); | |
4210 } | |
4211 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4212 bool |
5900 | 4213 mxIsSparse (const mxArray *ptr) |
4214 { | |
4215 return ptr->is_sparse (); | |
4216 } | |
4217 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4218 bool |
5900 | 4219 mxIsStruct (const mxArray *ptr) |
4220 { | |
4221 return ptr->is_struct (); | |
4222 } | |
4223 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4224 bool |
5900 | 4225 mxIsUint16 (const mxArray *ptr) |
4226 { | |
4227 return ptr->is_uint16 (); | |
4228 } | |
4229 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4230 bool |
5900 | 4231 mxIsUint32 (const mxArray *ptr) |
4232 { | |
4233 return ptr->is_uint32 (); | |
4234 } | |
4235 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4236 bool |
5900 | 4237 mxIsUint64 (const mxArray *ptr) |
4238 { | |
4239 return ptr->is_uint64 (); | |
4240 } | |
4241 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4242 bool |
5900 | 4243 mxIsUint8 (const mxArray *ptr) |
4244 { | |
4245 return ptr->is_uint8 (); | |
4246 } | |
4247 | |
4248 // Odd type+size predicate. | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4249 bool |
5900 | 4250 mxIsLogicalScalar (const mxArray *ptr) |
4251 { | |
4252 return ptr->is_logical_scalar (); | |
4253 } | |
4254 | |
4255 // Odd type+size+value predicate. | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4256 bool |
5900 | 4257 mxIsLogicalScalarTrue (const mxArray *ptr) |
4258 { | |
4259 return ptr->is_logical_scalar_true (); | |
4260 } | |
4261 | |
4262 // Size predicate. | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4263 bool |
5900 | 4264 mxIsEmpty (const mxArray *ptr) |
4265 { | |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
4266 return ptr->isempty (); |
5900 | 4267 } |
4268 | |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4269 bool |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4270 mxIsScalar (const mxArray *ptr) |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4271 { |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4272 return ptr->is_scalar (); |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4273 } |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4274 |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4275 // FIXME: Just plain odd thing to ask of a value. |
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4276 // Still, Octave is incompatible because it does not implement this. |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4277 bool |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4278 mxIsFromGlobalWS (const mxArray * /*ptr*/) |
5900 | 4279 { |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4280 mexErrMsgTxt ("mxIsFromGlobalWS() is unimplemented"); |
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4281 |
5900 | 4282 return 0; |
4283 } | |
4284 | |
4285 // Dimension extractors. | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
4286 std::size_t |
5900 | 4287 mxGetM (const mxArray *ptr) |
4288 { | |
4289 return ptr->get_m (); | |
4290 } | |
4291 | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
4292 std::size_t |
5900 | 4293 mxGetN (const mxArray *ptr) |
4294 { | |
4295 return ptr->get_n (); | |
4296 } | |
4297 | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4298 const mwSize * |
5900 | 4299 mxGetDimensions (const mxArray *ptr) |
5864 | 4300 { |
5900 | 4301 return ptr->get_dimensions (); |
4302 } | |
4303 | |
6686 | 4304 mwSize |
5900 | 4305 mxGetNumberOfDimensions (const mxArray *ptr) |
4306 { | |
4307 return ptr->get_number_of_dimensions (); | |
4308 } | |
4309 | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
4310 std::size_t |
5900 | 4311 mxGetNumberOfElements (const mxArray *ptr) |
4312 { | |
4313 return ptr->get_number_of_elements (); | |
4314 } | |
4315 | |
4316 // Dimension setters. | |
4317 void | |
6686 | 4318 mxSetM (mxArray *ptr, mwSize m) |
5900 | 4319 { |
4320 ptr->set_m (m); | |
4321 } | |
4322 | |
4323 void | |
6686 | 4324 mxSetN (mxArray *ptr, mwSize n) |
5900 | 4325 { |
4326 ptr->set_n (n); | |
4327 } | |
4328 | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4329 int |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
4330 mxSetDimensions (mxArray *ptr, const mwSize *dims, mwSize ndims) |
5900 | 4331 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4332 return (ptr->set_dimensions (static_cast<mwSize *> |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
4333 (maybe_unmark (const_cast<mwSize *> (dims))), |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
4334 ndims)); |
5900 | 4335 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
4336 |
5900 | 4337 // Data extractors. |
4338 double * | |
4339 mxGetPr (const mxArray *ptr) | |
4340 { | |
4341 return static_cast<double *> (ptr->get_data ()); | |
4342 } | |
4343 | |
4344 double | |
4345 mxGetScalar (const mxArray *ptr) | |
4346 { | |
6332 | 4347 return ptr->get_scalar (); |
5900 | 4348 } |
4349 | |
4350 mxChar * | |
4351 mxGetChars (const mxArray *ptr) | |
4352 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4353 if (mxIsChar (ptr)) |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4354 return static_cast<mxChar *> (ptr->get_data ()); |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4355 else |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4356 return nullptr; |
5900 | 4357 } |
4358 | |
4359 mxLogical * | |
4360 mxGetLogicals (const mxArray *ptr) | |
4361 { | |
4362 return static_cast<mxLogical *> (ptr->get_data ()); | |
4363 } | |
4364 | |
4365 void * | |
4366 mxGetData (const mxArray *ptr) | |
4367 { | |
4368 return ptr->get_data (); | |
4369 } | |
4370 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4371 double * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4372 mxGetPi (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4373 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4374 return static_cast<double *> (ptr->get_imag_data ()); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4375 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4376 |
5900 | 4377 void * |
4378 mxGetImagData (const mxArray *ptr) | |
4379 { | |
4380 return ptr->get_imag_data (); | |
4381 } | |
4382 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4383 mxDouble * mxGetDoubles (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4384 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4385 return ptr->get_doubles (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4386 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4387 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4388 mxSingle * mxGetSingles (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4389 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4390 return ptr->get_singles (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4391 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4392 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4393 mxInt8 * mxGetInt8s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4394 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4395 return ptr->get_int8s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4396 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4397 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4398 mxInt16 * mxGetInt16s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4399 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4400 return ptr->get_int16s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4401 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4402 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4403 mxInt32 * mxGetInt32s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4404 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4405 return ptr->get_int32s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4406 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4407 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4408 mxInt64 * mxGetInt64s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4409 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4410 return ptr->get_int64s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4411 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4412 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4413 mxUint8 * mxGetUint8s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4414 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4415 return ptr->get_uint8s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4416 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4417 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4418 mxUint16 * mxGetUint16s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4419 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4420 return ptr->get_uint16s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4421 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4422 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4423 mxUint32 * mxGetUint32s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4424 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4425 return ptr->get_uint32s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4426 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4427 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4428 mxUint64 * mxGetUint64s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4429 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4430 return ptr->get_uint64s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4431 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4432 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4433 mxComplexDouble * mxGetComplexDoubles (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4434 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4435 return ptr->get_complex_doubles (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4436 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4437 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4438 mxComplexSingle * mxGetComplexSingles (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4439 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4440 return ptr->get_complex_singles (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4441 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4442 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4443 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4444 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4445 mxComplexInt8 * mxGetComplexInt8s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4446 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4447 return ptr->get_complex_int8s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4448 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4449 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4450 mxComplexInt16 * mxGetComplexInt16s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4451 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4452 return ptr->get_complex_int16s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4453 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4454 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4455 mxComplexInt32 * mxGetComplexInt32s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4456 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4457 return ptr->get_complex_int32s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4458 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4459 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4460 mxComplexInt64 * mxGetComplexInt64s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4461 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4462 return ptr->get_complex_int64s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4463 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4464 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4465 mxComplexUint8 * mxGetComplexUint8s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4466 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4467 return ptr->get_complex_uint8s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4468 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4469 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4470 mxComplexUint16 * mxGetComplexUint16s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4471 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4472 return ptr->get_complex_uint16s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4473 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4474 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4475 mxComplexUint32 * mxGetComplexUint32s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4476 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4477 return ptr->get_complex_uint32s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4478 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4479 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4480 mxComplexUint64 * mxGetComplexUint64s (const mxArray *ptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4481 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4482 return ptr->get_complex_uint64s (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4483 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4484 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4485 |
5900 | 4486 // Data setters. |
4487 void | |
4488 mxSetPr (mxArray *ptr, double *pr) | |
4489 { | |
7172 | 4490 ptr->set_data (maybe_unmark (pr)); |
5900 | 4491 } |
4492 | |
4493 void | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4494 mxSetData (mxArray *ptr, void *pr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4495 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4496 ptr->set_data (maybe_unmark (pr)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4497 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4498 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4499 int mxSetDoubles (mxArray *ptr, mxDouble *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4500 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4501 return ptr->set_doubles (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4502 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4503 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4504 int mxSetSingles (mxArray *ptr, mxSingle *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4505 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4506 return ptr->set_singles (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4507 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4508 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4509 int mxSetInt8s (mxArray *ptr, mxInt8 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4510 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4511 return ptr->set_int8s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4512 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4513 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4514 int mxSetInt16s (mxArray *ptr, mxInt16 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4515 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4516 return ptr->set_int16s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4517 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4518 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4519 int mxSetInt32s (mxArray *ptr, mxInt32 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4520 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4521 return ptr->set_int32s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4522 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4523 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4524 int mxSetInt64s (mxArray *ptr, mxInt64 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4525 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4526 return ptr->set_int64s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4527 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4528 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4529 int mxSetUint8s (mxArray *ptr, mxUint8 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4530 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4531 return ptr->set_uint8s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4532 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4533 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4534 int mxSetUint16s (mxArray *ptr, mxUint16 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4535 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4536 return ptr->set_uint16s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4537 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4538 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4539 int mxSetUint32s (mxArray *ptr, mxUint32 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4540 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4541 return ptr->set_uint32s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4542 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4543 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4544 int mxSetUint64s (mxArray *ptr, mxUint64 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4545 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4546 return ptr->set_uint64s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4547 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4548 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4549 int mxSetComplexDoubles (mxArray *ptr, mxComplexDouble *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4550 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4551 return ptr->set_complex_doubles (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4552 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4553 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4554 int mxSetComplexSingles (mxArray *ptr, mxComplexSingle *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4555 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4556 return ptr->set_complex_singles (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4557 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4558 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4559 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4560 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4561 int mxSetComplexInt8s (mxArray *ptr, mxComplexInt8 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4562 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4563 return ptr->set_complex_int8s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4564 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4565 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4566 int mxSetComplexInt16s (mxArray *ptr, mxComplexInt16 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4567 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4568 return ptr->set_complex_int16s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4569 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4570 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4571 int mxSetComplexInt32s (mxArray *ptr, mxComplexInt32 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4572 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4573 return ptr->set_complex_int32s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4574 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4575 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4576 int mxSetComplexInt64s (mxArray *ptr, mxComplexInt64 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4577 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4578 return ptr->set_complex_int64s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4579 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4580 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4581 int mxSetComplexUint8s (mxArray *ptr, mxComplexUint8 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4582 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4583 return ptr->set_complex_uint8s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4584 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4585 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4586 int mxSetComplexUint16s (mxArray *ptr, mxComplexUint16 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4587 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4588 return ptr->set_complex_uint16s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4589 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4590 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4591 int mxSetComplexUint32s (mxArray *ptr, mxComplexUint32 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4592 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4593 return ptr->set_complex_uint32s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4594 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4595 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4596 int mxSetComplexUint64s (mxArray *ptr, mxComplexUint64 *data) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4597 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4598 return ptr->set_complex_uint64s (maybe_unmark (data)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4599 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4600 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4601 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4602 void |
5900 | 4603 mxSetPi (mxArray *ptr, double *pi) |
4604 { | |
7172 | 4605 ptr->set_imag_data (maybe_unmark (pi)); |
5864 | 4606 } |
4607 | |
5900 | 4608 void |
4609 mxSetImagData (mxArray *ptr, void *pi) | |
4610 { | |
7172 | 4611 ptr->set_imag_data (maybe_unmark (pi)); |
5900 | 4612 } |
4613 | |
4614 // Classes. | |
4615 mxClassID | |
4616 mxGetClassID (const mxArray *ptr) | |
4617 { | |
4618 return ptr->get_class_id (); | |
4619 } | |
4620 | |
4621 const char * | |
4622 mxGetClassName (const mxArray *ptr) | |
4623 { | |
4624 return ptr->get_class_name (); | |
4625 } | |
4626 | |
4627 void | |
4628 mxSetClassName (mxArray *ptr, const char *name) | |
4629 { | |
4630 ptr->set_class_name (name); | |
4631 } | |
4632 | |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4633 void |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4634 mxSetProperty (mxArray *ptr, mwIndex idx, const char *property_name, |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4635 const mxArray *property_value) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4636 { |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4637 ptr->set_property (idx, property_name, property_value); |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4638 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4639 |
23891
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4640 mxArray * |
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4641 mxGetProperty (const mxArray *ptr, mwIndex idx, const char *property_name) |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4642 { |
23891
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4643 return ptr->get_property (idx, property_name); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4644 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4645 |
5900 | 4646 // Cell support. |
4647 mxArray * | |
6686 | 4648 mxGetCell (const mxArray *ptr, mwIndex idx) |
5900 | 4649 { |
4650 return ptr->get_cell (idx); | |
4651 } | |
4652 | |
4653 void | |
6686 | 4654 mxSetCell (mxArray *ptr, mwIndex idx, mxArray *val) |
5900 | 4655 { |
4656 ptr->set_cell (idx, val); | |
4657 } | |
4658 | |
4659 // Sparse support. | |
6686 | 4660 mwIndex * |
5900 | 4661 mxGetIr (const mxArray *ptr) |
4662 { | |
4663 return ptr->get_ir (); | |
4664 } | |
4665 | |
6686 | 4666 mwIndex * |
5900 | 4667 mxGetJc (const mxArray *ptr) |
4668 { | |
4669 return ptr->get_jc (); | |
4670 } | |
4671 | |
6686 | 4672 mwSize |
5900 | 4673 mxGetNzmax (const mxArray *ptr) |
4674 { | |
4675 return ptr->get_nzmax (); | |
4676 } | |
4677 | |
4678 void | |
6686 | 4679 mxSetIr (mxArray *ptr, mwIndex *ir) |
5900 | 4680 { |
19739
3fa35defe495
Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
4681 ptr->set_ir (static_cast<mwIndex *> (maybe_unmark (ir))); |
5900 | 4682 } |
4683 | |
4684 void | |
6686 | 4685 mxSetJc (mxArray *ptr, mwIndex *jc) |
5900 | 4686 { |
7172 | 4687 ptr->set_jc (static_cast<mwIndex *> (maybe_unmark (jc))); |
5900 | 4688 } |
4689 | |
4690 void | |
6686 | 4691 mxSetNzmax (mxArray *ptr, mwSize nzmax) |
5900 | 4692 { |
4693 ptr->set_nzmax (nzmax); | |
4694 } | |
4695 | |
4696 // Structure support. | |
4697 int | |
4698 mxAddField (mxArray *ptr, const char *key) | |
4699 { | |
4700 return ptr->add_field (key); | |
4701 } | |
4702 | |
4703 void | |
4704 mxRemoveField (mxArray *ptr, int key_num) | |
4705 { | |
4706 ptr->remove_field (key_num); | |
4707 } | |
5864 | 4708 |
4709 mxArray * | |
6686 | 4710 mxGetField (const mxArray *ptr, mwIndex index, const char *key) |
5900 | 4711 { |
4712 int key_num = mxGetFieldNumber (ptr, key); | |
4713 return mxGetFieldByNumber (ptr, index, key_num); | |
4714 } | |
4715 | |
4716 mxArray * | |
6686 | 4717 mxGetFieldByNumber (const mxArray *ptr, mwIndex index, int key_num) |
5864 | 4718 { |
5900 | 4719 return ptr->get_field_by_number (index, key_num); |
5864 | 4720 } |
4721 | |
5900 | 4722 void |
6686 | 4723 mxSetField (mxArray *ptr, mwIndex index, const char *key, mxArray *val) |
5900 | 4724 { |
4725 int key_num = mxGetFieldNumber (ptr, key); | |
4726 mxSetFieldByNumber (ptr, index, key_num, val); | |
4727 } | |
5864 | 4728 |
4729 void | |
6686 | 4730 mxSetFieldByNumber (mxArray *ptr, mwIndex index, int key_num, mxArray *val) |
5864 | 4731 { |
5900 | 4732 ptr->set_field_by_number (index, key_num, val); |
4733 } | |
4734 | |
4735 int | |
4736 mxGetNumberOfFields (const mxArray *ptr) | |
4737 { | |
4738 return ptr->get_number_of_fields (); | |
5864 | 4739 } |
4740 | |
5900 | 4741 const char * |
4742 mxGetFieldNameByNumber (const mxArray *ptr, int key_num) | |
5864 | 4743 { |
5900 | 4744 return ptr->get_field_name_by_number (key_num); |
4745 } | |
4746 | |
4747 int | |
4748 mxGetFieldNumber (const mxArray *ptr, const char *key) | |
4749 { | |
4750 return ptr->get_field_number (key); | |
5864 | 4751 } |
4752 | |
5900 | 4753 int |
6686 | 4754 mxGetString (const mxArray *ptr, char *buf, mwSize buflen) |
5900 | 4755 { |
4756 return ptr->get_string (buf, buflen); | |
4757 } | |
4758 | |
4759 char * | |
4760 mxArrayToString (const mxArray *ptr) | |
5864 | 4761 { |
5900 | 4762 return ptr->array_to_string (); |
4763 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
4764 |
6686 | 4765 mwIndex |
4766 mxCalcSingleSubscript (const mxArray *ptr, mwSize nsubs, mwIndex *subs) | |
5900 | 4767 { |
4768 return ptr->calc_single_subscript (nsubs, subs); | |
5864 | 4769 } |
5900 | 4770 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
4771 std::size_t |
5900 | 4772 mxGetElementSize (const mxArray *ptr) |
4773 { | |
4774 return ptr->get_element_size (); | |
4775 } | |
4776 | |
4777 // ------------------------------------------------------------------ | |
5864 | 4778 |
4779 typedef void (*cmex_fptr) (int nlhs, mxArray **plhs, int nrhs, mxArray **prhs); | |
23498
647705ffb110
use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
4780 typedef F77_RET_T (*fmex_fptr) (F77_INT& nlhs, mxArray **plhs, |
647705ffb110
use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
4781 F77_INT& nrhs, mxArray **prhs); |
5864 | 4782 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31383
diff
changeset
|
4783 OCTAVE_BEGIN_NAMESPACE(octave) |
30919
4ed7dfe28584
move eval of anon fcn handles and built-in and mex functions to pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
30793
diff
changeset
|
4784 |
5864 | 4785 octave_value_list |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4786 call_mex (octave_mex_function& mex_fcn, const octave_value_list& args, |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4787 int nargout_arg) |
5864 | 4788 { |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4789 octave_quit (); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4790 |
5900 | 4791 // Use at least 1 for nargout since even for zero specified args, |
4792 // still want to be able to return an ans. | |
5864 | 4793 |
8806 | 4794 volatile int nargout = nargout_arg; |
4795 | |
5864 | 4796 int nargin = args.length (); |
5900 | 4797 OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin); |
5864 | 4798 for (int i = 0; i < nargin; i++) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23703
diff
changeset
|
4799 argin[i] = nullptr; |
5864 | 4800 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
4801 int nout = (nargout == 0 ? 1 : nargout); |
5900 | 4802 OCTAVE_LOCAL_BUFFER (mxArray *, argout, nout); |
5864 | 4803 for (int i = 0; i < nout; i++) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23703
diff
changeset
|
4804 argout[i] = nullptr; |
5864 | 4805 |
5905 | 4806 // Save old mex pointer. |
28823
26cfccfee9a0
Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents:
28370
diff
changeset
|
4807 octave::unwind_protect_var<mex *> restore_var (mex_context); |
5905 | 4808 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4809 mex context (mex_fcn); |
5900 | 4810 |
5864 | 4811 for (int i = 0; i < nargin; i++) |
4812 argin[i] = context.make_value (args(i)); | |
4813 | |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4814 mex_context = &context; |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4815 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4816 void *mex_fcn_ptr = mex_fcn.mex_fcn_ptr (); |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4817 |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4818 if (mex_fcn.is_fmex ()) |
5864 | 4819 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4820 fmex_fptr fcn = reinterpret_cast<fmex_fptr> (mex_fcn_ptr); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4821 |
23498
647705ffb110
use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
4822 F77_INT tmp_nargout = nargout; |
647705ffb110
use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
4823 F77_INT tmp_nargin = nargin; |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4824 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4825 fcn (tmp_nargout, argout, tmp_nargin, argin); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4826 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4827 else |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4828 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4829 cmex_fptr fcn = reinterpret_cast<cmex_fptr> (mex_fcn_ptr); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4830 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4831 fcn (nargout, argout, nargin, argin); |
5864 | 4832 } |
4833 | |
4834 // Convert returned array entries back into octave values. | |
4835 | |
4836 octave_value_list retval; | |
4837 | |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4838 if (nargout == 0 && argout[0]) |
5864 | 4839 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4840 // We have something for ans. |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4841 nargout = 1; |
5864 | 4842 } |
4843 | |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4844 retval.resize (nargout); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4845 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4846 // If using std::pmr::memory_resource object to manage memory, pass |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4847 // default allocator here because we are done with these mxArray |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4848 // values and want Octave to delete them. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4849 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4850 for (int i = 0; i < nargout; i++) |
25451
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
4851 retval(i) = mxArray::as_octave_value (argout[i], false); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4852 |
5864 | 4853 return retval; |
4854 } | |
4855 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31383
diff
changeset
|
4856 OCTAVE_END_NAMESPACE(octave) |
30919
4ed7dfe28584
move eval of anon fcn handles and built-in and mex functions to pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
30793
diff
changeset
|
4857 |
5864 | 4858 // C interface to mex functions: |
4859 | |
4860 const char * | |
4861 mexFunctionName (void) | |
4862 { | |
5900 | 4863 return mex_context ? mex_context->function_name () : "unknown"; |
4864 } | |
4865 | |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4866 static inline octave_value_list |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4867 mx_to_ov_args (int nargin, mxArray *argin[]) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4868 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4869 // Use a separate function for this job so that the |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4870 // current_mx_memory_resource will be restored immediately after the |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4871 // octave_value objects borrow the mxArray data. We could also use a |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4872 // dummy scope in mexCallMATLAB, but this function seems less likely |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4873 // to be accidentally deleted. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4874 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4875 octave_value_list args (nargin); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4876 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4877 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4878 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4879 // Use allocator that doesn't free memory because Octave may mutate |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4880 // the value (single element mxArray -> scalar octave_value object, |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4881 // for example) and we need these objects to continue to exist after |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4882 // mexCallMATLAB returns. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4883 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4884 octave::unwind_protect_var<std::pmr::memory_resource *> |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4885 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4886 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4887 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4888 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4889 for (int i = 0; i < nargin; i++) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4890 args(i) = mxArray::as_octave_value (argin[i]); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4891 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4892 return args; |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4893 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4894 |
5900 | 4895 int |
15354
93dff6435fe1
tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents:
15353
diff
changeset
|
4896 mexCallMATLAB (int nargout, mxArray *argout[], int nargin, |
15373
b5d0a47c171c
* mex.cc (mexCallMATLAB): Remove stray const added in 93dff6435fe1 (bug #37342).
John W. Eaton <jwe@octave.org>
parents:
15354
diff
changeset
|
4897 mxArray *argin[], const char *fname) |
5900 | 4898 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4899 octave_value_list args = mx_to_ov_args (nargin, argin); |
5900 | 4900 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
4901 octave::interpreter& interp = octave::__get_interpreter__ (); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4902 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4903 bool execution_error = false; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4904 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4905 octave_value_list retval; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4906 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4907 try |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4908 { |
29172
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4909 octave::tree_evaluator& tw = interp.get_evaluator (); |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4910 |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4911 octave::unwind_action act |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4912 ([&tw] (const std::list<octave::octave_lvalue> *lvl) |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4913 { |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4914 tw.set_lvalue_list (lvl); |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4915 }, tw.lvalue_list ()); |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4916 |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4917 tw.set_lvalue_list (nullptr); |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4918 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
4919 retval = octave::feval (fname, args, nargout); |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4920 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4921 catch (const octave::execution_exception&) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4922 { |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4923 if (mex_context->trap_feval_error) |
22450
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4924 { |
27471 | 4925 // FIXME: is there a way to indicate what error occurred? |
4926 // Should the error message be displayed here? Do we need to | |
4927 // save the exception info for lasterror? | |
4928 | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4929 interp.recover_from_exception (); |
22450
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4930 |
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4931 execution_error = true; |
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4932 } |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4933 else |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4934 { |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4935 args.resize (0); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4936 retval.resize (0); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4937 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4938 throw; |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4939 } |
5900 | 4940 } |
4941 | |
4942 int num_to_copy = retval.length (); | |
4943 | |
4944 if (nargout < retval.length ()) | |
4945 num_to_copy = nargout; | |
4946 | |
4947 for (int i = 0; i < num_to_copy; i++) | |
4948 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4949 // FIXME: it would be nice to avoid copying the value here, |
5900 | 4950 // but there is no way to steal memory from a matrix, never mind |
4951 // that matrix memory is allocated by new[] and mxArray memory | |
4952 // is allocated by malloc(). | |
22450
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4953 argout[i] = mex_context->make_value (retval(i)); |
5900 | 4954 } |
4955 | |
4956 while (num_to_copy < nargout) | |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23703
diff
changeset
|
4957 argout[num_to_copy++] = nullptr; |
5900 | 4958 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4959 return execution_error ? 1 : 0; |
5900 | 4960 } |
4961 | |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4962 mxArray * |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4963 mexCallMATLABWithTrap (int nargout, mxArray *argout[], int nargin, |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4964 mxArray *argin[], const char *fname) |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4965 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4966 mxArray *mx = nullptr; |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4967 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
4968 int old_flag = (mex_context ? mex_context->trap_feval_error : 0); |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4969 mexSetTrapFlag (1); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4970 if (mexCallMATLAB (nargout, argout, nargin, argin, fname)) |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4971 { |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4972 const char *field_names[] = {"identifier", "message", "case", "stack"}; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4973 mx = mxCreateStructMatrix (1, 1, 4, field_names); |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4974 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX")); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4975 std::string msg = "mexCallMATLABWithTrap: function call <" |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4976 + std::string (fname) + "> failed"; |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4977 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ())); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4978 mxSetFieldByNumber (mx, 0, 2, mxCreateCellMatrix (0, 0)); |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4979 mxSetFieldByNumber (mx, 0, 3, mxCreateStructMatrix (0, 1, 0, nullptr)); |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4980 } |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4981 mexSetTrapFlag (old_flag); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4982 |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4983 return mx; |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4984 } |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4985 |
5900 | 4986 void |
4987 mexSetTrapFlag (int flag) | |
4988 { | |
4989 if (mex_context) | |
4990 mex_context->trap_feval_error = flag; | |
4991 } | |
4992 | |
4993 int | |
4994 mexEvalString (const char *s) | |
4995 { | |
4996 int retval = 0; | |
4997 | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
4998 octave::interpreter& interp = octave::__get_interpreter__ (); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4999 |
5900 | 5000 int parse_status; |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5001 bool execution_error = false; |
5900 | 5002 |
5003 octave_value_list ret; | |
5004 | |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5005 try |
5900 | 5006 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25922
diff
changeset
|
5007 ret = interp.eval_string (std::string (s), false, parse_status, 0); |
5900 | 5008 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5009 catch (const octave::execution_exception&) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5010 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5011 interp.recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
5012 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5013 execution_error = true; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5014 } |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5015 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5016 if (parse_status || execution_error) |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5017 retval = 1; |
5864 | 5018 |
5019 return retval; | |
5020 } | |
5021 | |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5022 mxArray * |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5023 mexEvalStringWithTrap (const char *s) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5024 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5025 mxArray *mx = nullptr; |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5026 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5027 octave::interpreter& interp = octave::__get_interpreter__ (); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5028 |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5029 int parse_status; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5030 bool execution_error = false; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5031 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5032 octave_value_list ret; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5033 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5034 try |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5035 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25922
diff
changeset
|
5036 ret = interp.eval_string (std::string (s), false, parse_status, 0); |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5037 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5038 catch (const octave::execution_exception&) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5039 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5040 interp.recover_from_exception (); |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5041 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5042 execution_error = true; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5043 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5044 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5045 if (parse_status || execution_error) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5046 { |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5047 const char *field_names[] = {"identifier", "message", "case", "stack"}; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5048 mx = mxCreateStructMatrix (1, 1, 4, field_names); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5049 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX")); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5050 std::string msg = "mexEvalStringWithTrap: eval of <" |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5051 + std::string (s) + "> failed"; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5052 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ())); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5053 mxSetFieldByNumber (mx, 0, 2, mxCreateCellMatrix (0, 0)); |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5054 mxSetFieldByNumber (mx, 0, 3, mxCreateStructMatrix (0, 1, 0, nullptr)); |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5055 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5056 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5057 return mx; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5058 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5059 |
5864 | 5060 void |
5061 mexErrMsgTxt (const char *s) | |
5062 { | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5063 std::size_t len; |
25751
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5064 |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5065 if (s && (len = strlen (s)) > 0) |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5066 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5067 if (s[len - 1] == '\n') |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5068 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5069 std::string s_tmp (s, len - 1); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5070 error ("%s: %s\n", mexFunctionName (), s_tmp.c_str ()); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5071 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5072 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5073 error ("%s: %s", mexFunctionName (), s); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5074 } |
5864 | 5075 else |
16851
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5076 { |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5077 // For compatibility with Matlab, print an empty message. |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5078 // Octave's error routine requires a non-null input so use a SPACE. |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5079 error (" "); |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5080 } |
5864 | 5081 } |
5082 | |
5879 | 5083 void |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
5084 mexErrMsgIdAndTxt (const char *id, const char *fmt, ...) |
5879 | 5085 { |
6338 | 5086 if (fmt && strlen (fmt) > 0) |
5087 { | |
5088 const char *fname = mexFunctionName (); | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5089 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1; |
6338 | 5090 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); |
5091 sprintf (tmpfmt, "%s: %s", fname, fmt); | |
5092 va_list args; | |
5093 va_start (args, fmt); | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
5094 verror_with_id (id, tmpfmt, args); |
6338 | 5095 va_end (args); |
5096 } | |
5879 | 5097 else |
16851
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5098 { |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5099 // For compatibility with Matlab, print an empty message. |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5100 // Octave's error routine requires a non-null input so use a SPACE. |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5101 error (" "); |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5102 } |
5879 | 5103 } |
5104 | |
5105 void | |
5106 mexWarnMsgTxt (const char *s) | |
5107 { | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5108 std::size_t len; |
25751
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5109 |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5110 if (s && (len = strlen (s)) > 0) |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5111 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5112 if (s[len - 1] == '\n') |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5113 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5114 std::string s_tmp (s, len - 1); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5115 warning ("%s\n", s_tmp.c_str ()); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5116 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5117 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5118 warning ("%s", s); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5119 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5120 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5121 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5122 // For compatibility with Matlab, print an empty message. |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5123 // Octave's warning routine requires a non-null input so use a SPACE. |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5124 warning (" "); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5125 } |
5879 | 5126 } |
5127 | |
5128 void | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
5129 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...) |
5879 | 5130 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5131 // FIXME: is this right? What does Matlab do if fmt is NULL or |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5132 // an empty string? |
6338 | 5133 |
5134 if (fmt && strlen (fmt) > 0) | |
5135 { | |
5136 const char *fname = mexFunctionName (); | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5137 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1; |
6338 | 5138 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); |
5139 sprintf (tmpfmt, "%s: %s", fname, fmt); | |
5140 va_list args; | |
5141 va_start (args, fmt); | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
5142 vwarning_with_id (id, tmpfmt, args); |
6338 | 5143 va_end (args); |
5144 } | |
5879 | 5145 } |
5864 | 5146 |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5147 int |
5864 | 5148 mexPrintf (const char *fmt, ...) |
5149 { | |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5150 int retval; |
5864 | 5151 va_list args; |
5152 va_start (args, fmt); | |
25646
4d565baa475e
move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25452
diff
changeset
|
5153 retval = octave::vformat (octave_stdout, fmt, args); |
5864 | 5154 va_end (args); |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5155 return retval; |
5864 | 5156 } |
5157 | |
5158 mxArray * | |
5879 | 5159 mexGetVariable (const char *space, const char *name) |
5864 | 5160 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5161 mxArray *retval = nullptr; |
5864 | 5162 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5163 octave_value val; |
5864 | 5164 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5165 octave::interpreter& interp = octave::__get_interpreter__ (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5166 |
5864 | 5167 if (! strcmp (space, "global")) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5168 val = interp.global_varval (name); |
5864 | 5169 else |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5170 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5171 // FIXME: should this be in variables.cc? |
9144
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
5172 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
5173 octave::unwind_protect frame; |
9144
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
5174 |
7901 | 5175 bool caller = ! strcmp (space, "caller"); |
5176 bool base = ! strcmp (space, "base"); | |
5177 | |
5178 if (caller || base) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5179 { |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5180 // MEX files don't create a separate frame in the call stack, |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5181 // so we are already in the "caller" frame. |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5182 |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5183 if (base) |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5184 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5185 octave::tree_evaluator& tw = interp.get_evaluator (); |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5186 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5187 frame.add (&octave::tree_evaluator::restore_frame, &tw, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5188 tw.current_call_stack_frame_number ()); |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5189 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5190 tw.goto_base_frame (); |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5191 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5192 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5193 val = interp.varval (name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5194 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5195 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5196 mexErrMsgTxt ("mexGetVariable: symbol table does not exist"); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5197 } |
7336 | 5198 |
5199 if (val.is_defined ()) | |
5864 | 5200 { |
7336 | 5201 retval = mex_context->make_value (val); |
5202 | |
5203 retval->set_name (name); | |
5864 | 5204 } |
5205 | |
5206 return retval; | |
5207 } | |
5208 | |
5879 | 5209 const mxArray * |
5210 mexGetVariablePtr (const char *space, const char *name) | |
5864 | 5211 { |
5879 | 5212 return mexGetVariable (space, name); |
5864 | 5213 } |
5214 | |
5900 | 5215 int |
15353
5f3a69a309a7
fix decl of mexPutVariable
John W. Eaton <jwe@octave.org>
parents:
15351
diff
changeset
|
5216 mexPutVariable (const char *space, const char *name, const mxArray *ptr) |
5864 | 5217 { |
5900 | 5218 if (! ptr) |
5219 return 1; | |
5220 | |
5221 if (! name) | |
5222 return 1; | |
5223 | |
5224 if (name[0] == '\0') | |
5225 name = ptr->get_name (); | |
5226 | |
5227 if (! name || name[0] == '\0') | |
5228 return 1; | |
5229 | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5230 octave::interpreter& interp = octave::__get_interpreter__ (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5231 |
5900 | 5232 if (! strcmp (space, "global")) |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5233 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5234 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5235 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5236 // Use allocator that doesn't free memory because Octave may mutate |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5237 // the value (single element mxArray -> scalar octave_value object, |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5238 // for example) and we need these objects to continue to exist after |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5239 // mexCallMATLAB returns. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5240 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5241 octave::unwind_protect_var<std::pmr::memory_resource *> |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5242 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5243 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5244 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5245 interp.global_assign (name, mxArray::as_octave_value (ptr)); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5246 } |
5900 | 5247 else |
5248 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5249 // FIXME: should this be in variables.cc? |
7336 | 5250 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
5251 octave::unwind_protect frame; |
9144
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
5252 |
7901 | 5253 bool caller = ! strcmp (space, "caller"); |
5254 bool base = ! strcmp (space, "base"); | |
5255 | |
5256 if (caller || base) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5257 { |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5258 // MEX files don't create a separate frame in the call stack, |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5259 // so we are already in the "caller" frame. |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5260 |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5261 if (base) |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5262 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5263 octave::tree_evaluator& tw = interp.get_evaluator (); |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5264 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5265 frame.add (&octave::tree_evaluator::restore_frame, &tw, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5266 tw.current_call_stack_frame_number ()); |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5267 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5268 tw.goto_base_frame (); |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5269 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5270 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5271 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5272 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5273 // Use allocator that doesn't free memory because Octave may |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5274 // mutate the value (single element mxArray -> scalar |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5275 // octave_value object, for example) and we need these objects |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5276 // to continue to exist after mexCallMATLAB returns. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5277 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5278 octave::unwind_protect_var<std::pmr::memory_resource *> |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5279 upv (current_mx_memory_resource, |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5280 &the_mx_preserving_memory_resource); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5281 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5282 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5283 interp.assign (name, mxArray::as_octave_value (ptr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5284 } |
5900 | 5285 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5286 mexErrMsgTxt ("mexPutVariable: symbol table does not exist"); |
5900 | 5287 } |
5288 | |
5289 return 0; | |
5864 | 5290 } |
5291 | |
5292 void | |
5900 | 5293 mexMakeArrayPersistent (mxArray *ptr) |
5864 | 5294 { |
7172 | 5295 maybe_unmark_array (ptr); |
5864 | 5296 } |
5879 | 5297 |
5864 | 5298 void |
5900 | 5299 mexMakeMemoryPersistent (void *ptr) |
5864 | 5300 { |
7172 | 5301 maybe_unmark (ptr); |
5864 | 5302 } |
5303 | |
5900 | 5304 int |
6068 | 5305 mexAtExit (void (*f) (void)) |
5864 | 5306 { |
6068 | 5307 if (mex_context) |
5308 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5309 octave_mex_function& curr_mex_fcn = mex_context->current_mex_function (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5310 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5311 curr_mex_fcn.atexit (f); |
6068 | 5312 } |
5313 | |
5900 | 5314 return 0; |
5864 | 5315 } |
5316 | |
5900 | 5317 const mxArray * |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5318 mexGet_interleaved (double handle, const char *property) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5319 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5320 mxArray *m = nullptr; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5321 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5322 octave_value ret |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5323 = octave::get_property_from_handle (handle, property, "mexGet"); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5324 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5325 if (ret.is_defined ()) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5326 m = ret.as_mxArray (true); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5327 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5328 return m; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5329 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5330 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5331 const mxArray * |
6595 | 5332 mexGet (double handle, const char *property) |
5864 | 5333 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5334 mxArray *m = nullptr; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5335 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5336 octave_value ret |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5337 = octave::get_property_from_handle (handle, property, "mexGet"); |
6595 | 5338 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5339 if (ret.is_defined ()) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5340 m = ret.as_mxArray (false); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5341 |
6595 | 5342 return m; |
5864 | 5343 } |
5344 | |
5900 | 5345 int |
5346 mexIsGlobal (const mxArray *ptr) | |
5864 | 5347 { |
5900 | 5348 return mxIsFromGlobalWS (ptr); |
5864 | 5349 } |
5350 | |
5900 | 5351 int |
5352 mexIsLocked (void) | |
5864 | 5353 { |
5900 | 5354 int retval = 0; |
5355 | |
5356 if (mex_context) | |
5357 { | |
5358 const char *fname = mexFunctionName (); | |
5359 | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5360 octave::interpreter& interp = octave::__get_interpreter__ (); |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5361 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5362 retval = interp.mislocked (fname); |
5900 | 5363 } |
5364 | |
5365 return retval; | |
5864 | 5366 } |
5367 | |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30349
diff
changeset
|
5368 std::map<std::string, int> mex_lock_count; |
5900 | 5369 |
5370 void | |
5371 mexLock (void) | |
5864 | 5372 { |
5900 | 5373 if (mex_context) |
5864 | 5374 { |
5900 | 5375 const char *fname = mexFunctionName (); |
5376 | |
5377 if (mex_lock_count.find (fname) == mex_lock_count.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5378 mex_lock_count[fname] = 1; |
5900 | 5379 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5380 mex_lock_count[fname]++; |
5900 | 5381 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5382 octave::interpreter& interp = octave::__get_interpreter__ (); |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5383 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5384 interp.mlock (); |
5864 | 5385 } |
5386 } | |
5387 | |
5900 | 5388 int |
6595 | 5389 mexSet (double handle, const char *property, mxArray *val) |
5900 | 5390 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5391 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5392 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5393 // Use allocator that doesn't free memory because Octave may mutate |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5394 // the value (single element mxArray -> scalar octave_value object, |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5395 // for example) and we need these objects to continue to exist after |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5396 // mexCallMATLAB returns. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5397 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5398 octave::unwind_protect_var<std::pmr::memory_resource *> |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5399 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5400 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5401 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5402 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5403 bool ret = octave::set_property_in_handle (handle, property, |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5404 mxArray::as_octave_value (val), |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5405 "mexSet"); |
6595 | 5406 return (ret ? 0 : 1); |
5900 | 5407 } |
5408 | |
5409 void | |
5410 mexUnlock (void) | |
5864 | 5411 { |
5900 | 5412 if (mex_context) |
5864 | 5413 { |
5900 | 5414 const char *fname = mexFunctionName (); |
5415 | |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
5416 auto p = mex_lock_count.find (fname); |
5905 | 5417 |
6062 | 5418 if (p != mex_lock_count.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5419 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5420 int count = --mex_lock_count[fname]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5421 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5422 if (count == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5423 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5424 octave::interpreter& interp = octave::__get_interpreter__ (); |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5425 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5426 interp.munlock (fname); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5427 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5428 mex_lock_count.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5429 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5430 } |
5864 | 5431 } |
5432 } |