Mercurial > octave
annotate libinterp/corefcn/mex.cc @ 31362:4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
* mex.cc (maybe_disown_ptr): Surround use of maybe_disown_ptr() prototype and
function definition with
"#if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)".
author | Rik <rik@octave.org> |
---|---|
date | Sat, 29 Oct 2022 17:57:56 -0700 |
parents | 670a0d878af1 |
children | 8dc9508b8364 |
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 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
49 // Needed to instantiate Array objects with custom allocator. |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
50 #include "Array.cc" |
5900 | 51 #include "f77-fcn.h" |
52 #include "lo-ieee.h" | |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
7901
diff
changeset
|
53 #include "oct-locbuf.h" |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
54 #include "quit.h" |
5900 | 55 |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15096
diff
changeset
|
56 #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
|
57 #include "error.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23499
diff
changeset
|
58 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
59 #include "interpreter.h" |
5900 | 60 // 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
|
61 #include "mxarray.h" |
5900 | 62 #include "mexproto.h" |
63 #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
|
64 #include "ovl.h" |
5900 | 65 #include "ov.h" |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
66 #include "ov-classdef.h" |
6068 | 67 #include "ov-mex-fcn.h" |
5900 | 68 #include "ov-usr-fcn.h" |
5864 | 69 #include "pager.h" |
70 #include "parse.h" | |
5900 | 71 #include "unwind-prot.h" |
72 #include "utils.h" | |
5864 | 73 #include "variables.h" |
6595 | 74 #include "graphics.h" |
5900 | 75 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
76 // 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
|
77 // 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
|
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 "C" |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
80 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
81 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
|
82 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
|
83 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
84 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
|
85 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
|
86 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
87 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
|
88 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
|
89 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
90 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
|
91 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
|
92 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
93 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
|
94 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
|
95 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
96 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
|
97 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
|
98 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
99 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
|
100 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
|
101 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
102 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
|
103 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
|
104 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
105 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
|
106 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
|
107 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
108 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
|
109 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
|
110 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
123 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
|
124 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
|
125 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
|
126 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
127 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
|
128 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
|
129 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
130 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
|
131 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
|
132 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
133 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
|
134 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
|
135 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
144 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
|
145 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
|
146 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
147 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
|
148 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
|
149 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
150 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
|
151 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
|
152 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
153 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
|
154 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
|
155 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
156 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
|
157 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
|
158 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
159 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
|
160 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
|
161 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
162 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
|
163 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
|
164 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
165 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
|
166 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
|
167 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
168 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
|
169 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
|
170 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
171 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
|
172 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
|
173 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
|
174 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 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
|
183 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 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
|
188 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
189 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
|
190 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
|
191 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
|
192 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
193 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
|
194 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
|
195 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
196 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
|
197 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
|
198 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
207 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
|
208 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
|
209 |
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 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
221 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
|
222 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
|
223 #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
|
224 /* 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
234 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
235 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
|
236 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
|
237 |
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 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
249 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
|
250 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
|
251 #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
|
252 /* 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
262 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
263 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
|
264 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
|
265 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
266 |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
267 static void * |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
268 xmalloc (size_t n) |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
269 { |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
270 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
|
271 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
272 #if defined (DEBUG) |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
273 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
|
274 #endif |
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 return ptr; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
277 } |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
278 |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
279 static void * |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
280 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
|
281 { |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
282 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
|
283 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
284 #if defined (DEBUG) |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
285 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
|
286 << std::endl; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
287 #endif |
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 return newptr; |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
290 } |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
291 |
5905 | 292 static void |
293 xfree (void *ptr) | |
294 { | |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
295 #if defined (DEBUG) |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
296 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
|
297 #endif |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
298 |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
299 std::free (ptr); |
5905 | 300 } |
301 | |
6806 | 302 static mwSize |
303 max_str_len (mwSize m, const char **str) | |
5900 | 304 { |
305 int max_len = 0; | |
306 | |
6806 | 307 for (mwSize i = 0; i < m; i++) |
5900 | 308 { |
6806 | 309 mwSize tmp = strlen (str[i]); |
5900 | 310 |
311 if (tmp > max_len) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
312 max_len = tmp; |
5900 | 313 } |
314 | |
315 return max_len; | |
316 } | |
317 | |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
318 // 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
|
319 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
320 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
|
321 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
|
322 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
323 public: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
324 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
|
325 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
326 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
327 template <> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
328 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
|
329 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
330 public: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
331 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
|
332 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
333 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
334 template <> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
335 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
|
336 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
337 public: |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
338 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
|
339 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
340 |
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
|
341 #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
|
342 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
343 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
|
344 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
345 private: |
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 * 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
|
348 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
349 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
|
350 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
351 if (! ptr) |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
352 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
|
353 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
354 return ptr; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
355 } |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
356 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
357 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
|
358 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
|
359 { |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
360 xfree (ptr); |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
361 } |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
362 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
363 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
|
364 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
365 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
|
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 }; |
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 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
|
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 private: |
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 * 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
|
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 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
|
376 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
377 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
|
378 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
|
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 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
|
381 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
382 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
383 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
|
384 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
|
385 { } |
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 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
|
388 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
389 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
|
390 } |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
391 }; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
392 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
393 // 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
|
394 // 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
|
395 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
|
396 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
|
397 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
398 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
|
399 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
400 #endif |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
401 |
5900 | 402 // ------------------------------------------------------------------ |
403 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
404 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
|
405 : 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
|
406 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
407 |
7357 | 408 static mwIndex |
409 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
|
410 mwSize nsubs, const mwIndex *subs) |
7357 | 411 { |
412 mwIndex retval = 0; | |
413 | |
414 switch (nsubs) | |
415 { | |
416 case 0: | |
417 break; | |
418 | |
419 case 1: | |
420 retval = subs[0]; | |
421 break; | |
422 | |
423 default: | |
424 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
425 // 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
|
426 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
427 mwSize n = (nsubs <= ndims ? nsubs : ndims); |
10315
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 retval = subs[--n]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
430 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
431 while (--n >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
432 retval = dims[n] * retval + subs[n]; |
7357 | 433 } |
434 break; | |
435 } | |
436 | |
437 return retval; | |
438 } | |
439 | |
5900 | 440 // The object that handles values pass to MEX files from Octave. Some |
441 // methods in this class may set mutate_flag to TRUE to tell the | |
442 // mxArray class to convert to the Matlab-style representation and | |
443 // then invoke the method on that object instead (for example, getting | |
444 // a pointer to real or imaginary data from a complex object requires | |
445 // a mutation but getting a pointer to real data from a real object | |
446 // does not). Changing the representation causes a copy so we try to | |
447 // avoid it unless it is really necessary. Once the conversion | |
448 // happens, we delete this representation, so the conversion can only | |
449 // happen once per call to a MEX file. | |
450 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
451 static inline void * maybe_mark_foreign (void *ptr); |
7179 | 452 |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
453 #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
|
454 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
|
455 #endif |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
456 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
457 #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
|
458 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
|
459 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
460 #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
|
461 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
|
462 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
463 #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
|
464 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
|
465 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
466 #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
|
467 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
|
468 |
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
|
469 #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
|
470 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
|
471 |
5900 | 472 class mxArray_octave_value : public mxArray_base |
473 { | |
474 public: | |
475 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
476 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
|
477 : 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
|
478 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
|
479 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
|
480 { } |
5900 | 481 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
482 // 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
|
483 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
484 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
485 mxArray_octave_value& operator = (const mxArray_octave_value&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
486 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
487 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
|
488 |
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
489 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
|
490 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
491 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
|
492 |
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 // 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
|
494 // 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
|
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 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
|
497 { |
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 // 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
|
499 // 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
|
500 |
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 // 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
|
502 // 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
|
503 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
504 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
|
505 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
506 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
|
507 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
508 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
|
509 } |
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 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
511 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
|
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 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
|
514 |
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
|
515 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
|
516 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
517 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
|
518 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
519 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
|
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 } |
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
|
522 |
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
|
523 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
|
524 } |
5900 | 525 |
526 ~mxArray_octave_value (void) | |
527 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
528 mxFree (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
529 mxFree (m_dims); |
5900 | 530 } |
531 | |
532 bool is_octave_value (void) const { return true; } | |
533 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
534 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
|
535 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
536 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
|
537 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
538 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
|
539 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
540 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
|
541 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
542 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
|
543 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
544 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
|
545 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
546 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
|
547 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
548 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
|
549 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
550 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
|
551 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
552 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
|
553 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
554 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
|
555 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
556 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
|
557 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
558 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
|
559 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
560 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
|
561 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
562 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
|
563 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
564 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
|
565 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
566 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
|
567 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
568 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
|
569 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
570 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
|
571 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
572 int isreal (void) const { return m_val.isreal (); } |
5900 | 573 |
574 int is_logical_scalar_true (void) const | |
575 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
576 return (is_logical_scalar () && m_val.is_true ()); |
5900 | 577 } |
578 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
579 mwSize get_m (void) const { return m_val.rows (); } |
6686 | 580 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
581 mwSize get_n (void) const |
6187 | 582 { |
6686 | 583 mwSize n = 1; |
6187 | 584 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
585 // 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
|
586 get_dimensions (); |
6187 | 587 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
588 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
|
589 n *= m_dims[i]; |
6187 | 590 |
591 return n; | |
592 } | |
5900 | 593 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
594 mwSize * get_dimensions (void) const |
5900 | 595 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
596 if (! m_dims) |
5900 | 597 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
598 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
|
599 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
600 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
|
601 * sizeof (mwSize))); |
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 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
|
604 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
605 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
|
606 m_dims[i] = dv(i); |
5900 | 607 } |
608 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
609 return m_dims; |
5900 | 610 } |
611 | |
6686 | 612 mwSize get_number_of_dimensions (void) const |
5900 | 613 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
614 // Force m_dims and m_ndims to be cached. |
6332 | 615 get_dimensions (); |
5900 | 616 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
617 return m_ndims; |
5900 | 618 } |
619 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
620 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
|
621 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
|
622 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
623 MUTATION_METHOD (int, set_dimensions, (mwSize *, mwSize), 0) |
5900 | 624 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
625 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
|
626 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
627 int isempty (void) const { return m_val.isempty (); } |
5900 | 628 |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
629 bool is_scalar (void) const |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
630 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
631 // 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
|
632 get_dimensions (); |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
633 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
634 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
|
635 } |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
636 |
5900 | 637 mxClassID get_class_id (void) const |
638 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
639 m_id = mxUNKNOWN_CLASS; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
640 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
641 std::string cn = m_val.class_name (); |
5900 | 642 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
643 if (cn == "double") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
644 m_id = mxDOUBLE_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
645 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
|
646 m_id = mxSINGLE_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
647 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
|
648 m_id = mxCHAR_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
649 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
|
650 m_id = mxLOGICAL_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
651 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
|
652 m_id = mxCELL_CLASS; |
5900 | 653 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
|
654 m_id = mxSTRUCT_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
655 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
|
656 m_id = mxFUNCTION_CLASS; |
5900 | 657 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
|
658 m_id = mxINT8_CLASS; |
5900 | 659 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
|
660 m_id = mxUINT8_CLASS; |
5900 | 661 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
|
662 m_id = mxINT16_CLASS; |
5900 | 663 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
|
664 m_id = mxUINT16_CLASS; |
5900 | 665 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
|
666 m_id = mxINT32_CLASS; |
5900 | 667 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
|
668 m_id = mxUINT32_CLASS; |
5900 | 669 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
|
670 m_id = mxINT64_CLASS; |
5900 | 671 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
|
672 m_id = mxUINT64_CLASS; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
673 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
674 return m_id; |
5900 | 675 } |
676 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
677 const char * get_class_name (void) const |
5900 | 678 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
679 if (! m_class_name) |
5900 | 680 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
681 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
|
682 m_class_name = mxArray::strsave (s.c_str ()); |
5900 | 683 } |
684 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
685 return m_class_name; |
5900 | 686 } |
687 | |
688 // 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
|
689 VOID_MUTATION_METHOD (set_class_name, (const char *)) |
5900 | 690 |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
691 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
|
692 { |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
693 mxArray *retval = nullptr; |
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 if (m_val.is_classdef_object ()) |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
696 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
697 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
|
698 |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
699 if (ov_cdef) |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
700 { |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
701 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
|
702 |
23898
a490e729f2f2
correctly return NULL for unknown properties in mxGetProperty (bug #51725)
John W. Eaton <jwe@octave.org>
parents:
23893
diff
changeset
|
703 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
|
704 retval = new mxArray (m_interleaved, pval); |
23884
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 } |
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 return retval; |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
709 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
710 |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
711 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
|
712 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
713 if (m_val.is_classdef_object ()) |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
714 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
715 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
|
716 |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
717 if (ov_cdef) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
718 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
|
719 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
720 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
|
721 err_invalid_type ("set_property"); |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
722 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
723 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
724 CONST_MUTATION_METHOD (mxArray *, get_cell, (mwIndex), nullptr) |
5900 | 725 |
726 // 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
|
727 VOID_MUTATION_METHOD (set_cell, (mwIndex, mxArray *)) |
5900 | 728 |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
729 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
|
730 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
731 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
|
732 { |
22599
51b395d24782
maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents:
22480
diff
changeset
|
733 // 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
|
734 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
|
735 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
|
736 return 0.0; |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
737 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
738 if (m_val.islogical ()) |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
739 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
|
740 else if (m_val.isreal ()) |
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 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
|
743 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
|
744 } |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
745 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
746 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
|
747 } |
6332 | 748 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
749 void * get_data (void) const |
5900 | 750 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
751 // 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
|
752 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
753 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
|
754 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
755 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
|
756 { |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
757 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
|
758 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
|
759 } |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
760 |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
761 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
|
762 return nullptr; |
5900 | 763 } |
764 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
765 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
|
766 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
|
767 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
768 // 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
|
769 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
770 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
|
771 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
772 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
|
773 |
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
|
774 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
|
775 { |
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 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
|
777 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
|
778 } |
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 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
780 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
|
781 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
|
782 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
783 |
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
|
784 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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
801 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
802 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
|
803 |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
804 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
|
805 mxDOUBLE_CLASS, mxCOMPLEX); |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
806 |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
807 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
|
808 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
|
809 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
810 #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
|
811 /* 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
|
812 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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
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 (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
|
825 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
826 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
|
827 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
828 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
829 void * get_imag_data (void) const |
5900 | 830 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
831 void *retval = nullptr; |
5900 | 832 |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23581
diff
changeset
|
833 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
|
834 retval = nullptr; |
5900 | 835 else |
836 request_mutation (); | |
837 | |
838 return retval; | |
839 } | |
840 | |
841 // 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
|
842 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
|
843 |
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_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
|
845 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
|
846 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
|
847 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
|
848 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
|
849 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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
855 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
|
856 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
|
857 #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
|
858 /* 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 #endif |
5900 | 868 |
869 // 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
|
870 VOID_MUTATION_METHOD (set_imag_data, (void *)) |
5900 | 871 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
872 mwIndex * get_ir (void) const |
5900 | 873 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
874 // 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
|
875 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
876 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
|
877 return static_cast<mwIndex *> (maybe_mark_foreign (ptr)); |
5900 | 878 } |
879 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
880 mwIndex * get_jc (void) const |
5900 | 881 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
882 // 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
|
883 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
884 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
|
885 return static_cast<mwIndex *> (maybe_mark_foreign (ptr)); |
5900 | 886 } |
887 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
888 mwSize get_nzmax (void) const { return m_val.nzmax (); } |
5900 | 889 |
890 // 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
|
891 VOID_MUTATION_METHOD (set_ir, (mwIndex *)) |
5900 | 892 |
893 // 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
|
894 VOID_MUTATION_METHOD (set_jc, (mwIndex *)) |
5900 | 895 |
896 // 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
|
897 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
|
898 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
899 // 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
|
900 MUTATION_METHOD (int, add_field, (const char *), 0) |
5900 | 901 |
902 // 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
|
903 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
|
904 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
905 CONST_MUTATION_METHOD (mxArray *, get_field_by_number, (mwIndex, int), nullptr) |
5900 | 906 |
907 // 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
|
908 VOID_MUTATION_METHOD (set_field_by_number, (mwIndex, int, mxArray *)) |
5900 | 909 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
910 int get_number_of_fields (void) const { return m_val.nfields (); } |
5900 | 911 |
28126
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 (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
|
913 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
914 CONST_MUTATION_METHOD (int, get_field_number, (const char *), 0) |
5900 | 915 |
6686 | 916 int get_string (char *buf, mwSize buflen) const |
5900 | 917 { |
918 int retval = 1; | |
919 | |
6686 | 920 mwSize nel = get_number_of_elements (); |
5900 | 921 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
922 if (m_val.is_string () && nel < buflen) |
5900 | 923 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
924 charNDArray tmp = m_val.char_array_value (); |
10315
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 const char *p = tmp.data (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
927 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
928 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
929 buf[i] = p[i]; |
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 buf[nel] = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
932 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
933 retval = 0; |
5900 | 934 } |
935 | |
936 return retval; | |
937 } | |
938 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
939 char * array_to_string (void) const |
5900 | 940 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
941 // FIXME: this is supposed to handle multi-byte character strings. |
5900 | 942 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
943 char *buf = nullptr; |
5900 | 944 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
945 if (m_val.is_string ()) |
5900 | 946 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
947 mwSize nel = get_number_of_elements (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
948 |
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
|
949 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
|
950 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
951 if (buf) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
952 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
953 charNDArray tmp = m_val.char_array_value (); |
10315
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 const char *p = tmp.data (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
956 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
957 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
958 buf[i] = p[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
959 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
960 buf[nel] = '\0'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
961 } |
5900 | 962 } |
963 | |
964 return buf; | |
965 } | |
966 | |
6686 | 967 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const |
5900 | 968 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
969 // Force m_ndims, n_dims to be cached. |
5900 | 970 get_dimensions (); |
971 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
972 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs); |
5900 | 973 } |
974 | |
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
|
975 std::size_t get_element_size (void) const |
5900 | 976 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
977 // Force m_id to be cached. |
5900 | 978 get_class_id (); |
979 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
980 switch (m_id) |
5900 | 981 { |
982 case mxCELL_CLASS: return sizeof (mxArray *); | |
983 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
|
984 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
|
985 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
|
986 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
|
987 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
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 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
|
994 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
|
995 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
|
996 case mxFUNCTION_CLASS: return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
997 // 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
|
998 // What should they return, size of pointer? |
5900 | 999 default: return 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1000 } |
5900 | 1001 } |
1002 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1003 bool mutation_needed (void) const { return m_mutate_flag; } |
5900 | 1004 |
1005 void request_mutation (void) const | |
1006 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1007 if (m_mutate_flag) |
5900 | 1008 panic_impossible (); |
1009 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1010 m_mutate_flag = true; |
5900 | 1011 } |
1012 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1013 mxArray * mutate (void) const { return as_mxArray (); } |
5900 | 1014 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1015 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
|
1016 |
5900 | 1017 protected: |
1018 | |
1019 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
|
1020 : 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
|
1021 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
|
1022 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
|
1023 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
|
1024 ? 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
|
1025 : nullptr) |
5900 | 1026 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1027 if (m_dims) |
5900 | 1028 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1029 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
|
1030 m_dims[i] = arg.m_dims[i]; |
5900 | 1031 } |
1032 } | |
1033 | |
1034 private: | |
1035 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1036 octave_value m_val; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1037 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1038 mutable bool m_mutate_flag; |
5900 | 1039 |
1040 // Caching these does not cost much or lead to much duplicated | |
1041 // code. For other things, we just request mutation to a | |
1042 // Matlab-style mxArray object. | |
1043 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1044 mutable mxClassID m_id; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1045 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
|
1046 mutable mwSize m_ndims; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1047 mutable mwSize *m_dims; |
5900 | 1048 }; |
1049 | |
1050 // The base class for the Matlab-style representation, used to handle | |
1051 // things that are common to all Matlab-style objects. | |
1052 | |
1053 class mxArray_matlab : public mxArray_base | |
1054 { | |
1055 public: | |
1056 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1057 // No assignment! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1058 // FIXME: should this be implemented? |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1059 // Note that we *do* have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1060 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1061 mxArray_matlab& operator = (const mxArray_matlab&); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1062 |
5900 | 1063 ~mxArray_matlab (void) |
1064 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1065 mxFree (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1066 mxFree (m_dims); |
5900 | 1067 } |
1068 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1069 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
|
1070 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1071 int is_char (void) const { return m_id == mxCHAR_CLASS; } |
5900 | 1072 |
1073 int is_complex (void) const { return 0; } | |
1074 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1075 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
|
1076 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1077 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
|
1078 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1079 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
|
1080 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1081 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
|
1082 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1083 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
|
1084 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1085 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
|
1086 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1087 int is_logical (void) const { return m_id == mxLOGICAL_CLASS; } |
5900 | 1088 |
1089 int is_numeric (void) const | |
1090 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1091 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
|
1092 || 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
|
1093 || 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
|
1094 || 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
|
1095 || m_id == mxINT64_CLASS || m_id == mxUINT64_CLASS); |
5900 | 1096 } |
1097 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1098 int is_single (void) const { return m_id == mxSINGLE_CLASS; } |
5900 | 1099 |
1100 int is_sparse (void) const { return 0; } | |
1101 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1102 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
|
1103 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1104 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
|
1105 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1106 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
|
1107 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1108 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
|
1109 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1110 int is_uint8 (void) const { return m_id == mxUINT8_CLASS; } |
5900 | 1111 |
1112 int is_logical_scalar_true (void) const | |
1113 { | |
1114 return (is_logical_scalar () | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1115 && static_cast<mxLogical *> (get_data ())[0] != 0); |
5900 | 1116 } |
1117 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1118 mwSize get_m (void) const { return m_dims[0]; } |
6686 | 1119 |
1120 mwSize get_n (void) const | |
6187 | 1121 { |
6686 | 1122 mwSize n = 1; |
1123 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1124 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
|
1125 n *= m_dims[i]; |
6187 | 1126 |
1127 return n; | |
1128 } | |
5900 | 1129 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1130 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
|
1131 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1132 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
|
1133 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1134 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
|
1135 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1136 void set_n (mwSize n) { m_dims[1] = n; } |
6686 | 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 int set_dimensions (mwSize *dims, mwSize ndims) |
5900 | 1139 { |
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
|
1140 m_ndims = ndims; |
30129
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 mxFree (m_dims); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1143 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1144 if (m_ndims > 0) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1145 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1146 m_dims |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1147 = 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
|
1148 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1149 if (m_dims == nullptr) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1150 return 1; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1151 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1152 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
|
1153 m_dims[i] = dims[i]; |
22471
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 return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1156 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1157 else |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1158 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1159 m_dims = nullptr; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1160 return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1161 } |
5900 | 1162 } |
1163 | |
6686 | 1164 mwSize get_number_of_elements (void) const |
5900 | 1165 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1166 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
|
1167 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1168 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
|
1169 retval *= m_dims[i]; |
5900 | 1170 |
1171 return retval; | |
1172 } | |
1173 | |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
1174 int isempty (void) const { return get_number_of_elements () == 0; } |
5900 | 1175 |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1176 bool is_scalar (void) const |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1177 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1178 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
|
1179 } |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1180 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1181 mxClassID get_class_id (void) const { return m_id; } |
5900 | 1182 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1183 const char * get_class_name (void) const |
5900 | 1184 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1185 switch (m_id) |
5900 | 1186 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1187 case mxDOUBLE_CLASS: return "double"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1188 case mxSINGLE_CLASS: return "single"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1189 case mxCHAR_CLASS: return "char"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1190 case mxLOGICAL_CLASS: return "logical"; |
5900 | 1191 case mxCELL_CLASS: return "cell"; |
1192 case mxSTRUCT_CLASS: return "struct"; | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1193 case mxFUNCTION_CLASS: return "function_handle"; |
5900 | 1194 case mxINT8_CLASS: return "int8"; |
1195 case mxUINT8_CLASS: return "uint8"; | |
1196 case mxINT16_CLASS: return "int16"; | |
1197 case mxUINT16_CLASS: return "uint16"; | |
1198 case mxINT32_CLASS: return "int32"; | |
1199 case mxUINT32_CLASS: return "uint32"; | |
1200 case mxINT64_CLASS: return "int64"; | |
1201 case mxUINT64_CLASS: return "uint64"; | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1202 case mxUNKNOWN_CLASS: return "unknown"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1203 // FIXME: should return the classname of user-defined objects |
5900 | 1204 default: return "unknown"; |
1205 } | |
1206 } | |
1207 | |
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
|
1208 void set_class_name (const char *name) |
5900 | 1209 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1210 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
|
1211 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
|
1212 strcpy (m_class_name, name); |
5900 | 1213 } |
1214 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1215 mxArray * get_cell (mwIndex /*idx*/) const |
5900 | 1216 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1217 err_invalid_type ("get_cell"); |
5900 | 1218 } |
1219 | |
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
|
1220 void set_cell (mwIndex /*idx*/, mxArray * /*val*/) |
5900 | 1221 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1222 err_invalid_type ("set_cell"); |
5900 | 1223 } |
1224 | |
6332 | 1225 double get_scalar (void) const |
1226 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1227 err_invalid_type ("get_scalar"); |
6332 | 1228 } |
1229 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1230 void * get_data (void) const |
5900 | 1231 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1232 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
|
1233 } |
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 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
|
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 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
|
1238 } |
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 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
|
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 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
|
1243 } |
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 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
|
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 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
|
1248 } |
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 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
|
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 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
|
1253 } |
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 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
|
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 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
|
1258 } |
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 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
|
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 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
|
1263 } |
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 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
|
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 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
|
1268 } |
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 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
|
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 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
|
1273 } |
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 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
|
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 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
|
1278 } |
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 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
|
1281 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1282 err_invalid_type ("get_uint64s"); |
5900 | 1283 } |
1284 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1285 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
|
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 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
|
1288 } |
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 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
|
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 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
|
1293 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1294 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1295 #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
|
1296 /* 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
|
1297 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
|
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 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
|
1300 } |
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 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
|
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 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
|
1305 } |
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 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
|
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 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
|
1310 } |
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 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
|
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 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
|
1315 } |
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 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
|
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 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
|
1320 } |
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 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
|
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 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
|
1325 } |
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 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
|
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 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
|
1330 } |
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 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
|
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 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
|
1335 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1336 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1337 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1338 void * get_imag_data (void) const |
5900 | 1339 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1340 err_invalid_type ("get_imag_data"); |
5900 | 1341 } |
1342 | |
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
|
1343 void set_data (void * /*pr*/) |
5900 | 1344 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1345 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
|
1346 } |
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 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
|
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 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
|
1351 } |
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 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
|
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 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
|
1356 } |
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 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
|
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 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
|
1361 } |
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 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
|
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 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
|
1366 } |
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 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
|
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 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
|
1371 } |
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 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
|
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 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
|
1376 } |
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 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
|
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 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
|
1381 } |
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 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
|
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 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
|
1386 } |
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 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
|
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 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
|
1391 } |
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 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
|
1394 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1395 err_invalid_type ("set_uint64s"); |
5900 | 1396 } |
1397 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1398 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
|
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 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
|
1401 } |
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 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
|
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 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
|
1406 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1407 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1408 #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
|
1409 /* 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
|
1410 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
|
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 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
|
1413 } |
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 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
|
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 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
|
1418 } |
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 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
|
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 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
|
1423 } |
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 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
|
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 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
|
1428 } |
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 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
|
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 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
|
1433 } |
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 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
|
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 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
|
1438 } |
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 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
|
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 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
|
1443 } |
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 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
|
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 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
|
1448 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1449 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1450 |
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
|
1451 void set_imag_data (void * /*pi*/) |
5900 | 1452 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1453 err_invalid_type ("set_imag_data"); |
5900 | 1454 } |
1455 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1456 mwIndex * get_ir (void) const |
5900 | 1457 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1458 err_invalid_type ("get_ir"); |
5900 | 1459 } |
1460 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1461 mwIndex * get_jc (void) const |
5900 | 1462 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1463 err_invalid_type ("get_jc"); |
5900 | 1464 } |
1465 | |
6686 | 1466 mwSize get_nzmax (void) const |
5900 | 1467 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1468 err_invalid_type ("get_nzmax"); |
5900 | 1469 } |
1470 | |
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
|
1471 void set_ir (mwIndex * /*ir*/) |
5900 | 1472 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1473 err_invalid_type ("set_ir"); |
5900 | 1474 } |
1475 | |
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
|
1476 void set_jc (mwIndex * /*jc*/) |
5900 | 1477 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1478 err_invalid_type ("set_jc"); |
5900 | 1479 } |
1480 | |
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
|
1481 void set_nzmax (mwSize /*nzmax*/) |
5900 | 1482 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1483 err_invalid_type ("set_nzmax"); |
5900 | 1484 } |
1485 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1486 int add_field (const char * /*key*/) |
5900 | 1487 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1488 err_invalid_type ("add_field"); |
5900 | 1489 } |
1490 | |
1491 void remove_field (int /*key_num*/) | |
1492 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1493 err_invalid_type ("remove_field"); |
5900 | 1494 } |
1495 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1496 mxArray * get_field_by_number (mwIndex /*index*/, int /*key_num*/) const |
5900 | 1497 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1498 err_invalid_type ("get_field_by_number"); |
5900 | 1499 } |
1500 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1501 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
|
1502 mxArray * /*val*/) |
5900 | 1503 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1504 err_invalid_type ("set_field_by_number"); |
5900 | 1505 } |
1506 | |
1507 int get_number_of_fields (void) const | |
1508 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1509 err_invalid_type ("get_number_of_fields"); |
5900 | 1510 } |
1511 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1512 const char * get_field_name_by_number (int /*key_num*/) const |
5900 | 1513 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1514 err_invalid_type ("get_field_name_by_number"); |
5900 | 1515 } |
1516 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1517 int get_field_number (const char * /*key*/) const |
5900 | 1518 { |
1519 return -1; | |
1520 } | |
1521 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1522 int get_string (char * /*buf*/, mwSize /*buflen*/) const |
5900 | 1523 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1524 err_invalid_type ("get_string"); |
5900 | 1525 } |
1526 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1527 char * array_to_string (void) const |
5900 | 1528 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1529 err_invalid_type ("array_to_string"); |
5900 | 1530 } |
1531 | |
6686 | 1532 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const |
5900 | 1533 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1534 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs); |
5900 | 1535 } |
1536 | |
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
|
1537 std::size_t get_element_size (void) const |
5900 | 1538 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1539 switch (m_id) |
5900 | 1540 { |
1541 case mxCELL_CLASS: return sizeof (mxArray *); | |
1542 case mxSTRUCT_CLASS: return sizeof (mxArray *); | |
1543 case mxLOGICAL_CLASS: return sizeof (mxLogical); | |
1544 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
|
1545 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
|
1546 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
|
1547 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
|
1548 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
|
1549 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
|
1550 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
|
1551 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
|
1552 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
|
1553 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
|
1554 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64)); |
5900 | 1555 case mxFUNCTION_CLASS: return 0; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1556 // 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
|
1557 // What should they return, size of pointer? |
5900 | 1558 default: return 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1559 } |
5900 | 1560 } |
1561 | |
1562 protected: | |
1563 | |
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
|
1564 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
|
1565 : 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
|
1566 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
|
1567 { } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1568 |
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
|
1569 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
|
1570 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
|
1571 : 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
|
1572 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
|
1573 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
|
1574 { |
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
|
1575 if (ndims == 0) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1576 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1577 m_dims[0] = 0; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1578 m_dims[1] = 0; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1579 } |
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
|
1580 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
|
1581 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1582 m_dims[0] = 1; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1583 m_dims[1] = 1; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1584 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1585 |
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
|
1586 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
|
1587 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
|
1588 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1589 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
|
1590 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1591 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
|
1592 m_ndims--; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1593 else |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1594 break; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1595 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1596 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1597 |
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
|
1598 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
|
1599 : 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
|
1600 m_ndims (dv.ndims ()), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1601 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
|
1602 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1603 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
|
1604 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
|
1605 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1606 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
|
1607 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1608 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
|
1609 m_ndims--; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1610 else |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1611 break; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1612 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1613 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1614 |
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
|
1615 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
|
1616 : 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
|
1617 m_ndims (2), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1618 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
|
1619 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1620 m_dims[0] = m; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1621 m_dims[1] = n; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1622 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1623 |
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
|
1624 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
|
1625 : 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
|
1626 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
|
1627 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
|
1628 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1629 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
|
1630 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
|
1631 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1632 |
5900 | 1633 dim_vector |
1634 dims_to_dim_vector (void) const | |
1635 { | |
6686 | 1636 mwSize nd = get_number_of_dimensions (); |
1637 | |
1638 mwSize *d = get_dimensions (); | |
5900 | 1639 |
1640 dim_vector dv; | |
1641 dv.resize (nd); | |
1642 | |
6686 | 1643 for (mwIndex i = 0; i < nd; i++) |
5900 | 1644 dv(i) = d[i]; |
1645 | |
1646 return dv; | |
1647 } | |
1648 | |
1649 private: | |
1650 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1651 char *m_class_name; |
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 mxClassID m_id; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1654 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1655 mwSize m_ndims; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1656 mwSize *m_dims; |
5900 | 1657 }; |
1658 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1659 |
5900 | 1660 // Matlab-style numeric, character, and logical data. |
1661 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1662 class mxArray_base_full : public mxArray_matlab |
5900 | 1663 { |
1664 public: | |
1665 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1666 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
|
1667 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
|
1668 : 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
|
1669 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
|
1670 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1671 |
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
|
1672 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
|
1673 : 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
|
1674 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
|
1675 { } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1676 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1677 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
|
1678 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
|
1679 : 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
|
1680 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
|
1681 { } |
5900 | 1682 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1683 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
|
1684 : 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
|
1685 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1686 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1687 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
|
1688 dpr[0] = val; |
5900 | 1689 } |
1690 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1691 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
|
1692 : 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
|
1693 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1694 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1695 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
|
1696 lpr[0] = val; |
5900 | 1697 } |
1698 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1699 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
|
1700 : 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
|
1701 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
|
1702 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
|
1703 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1704 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1705 mxChar *cpr = static_cast<mxChar *> (m_pr); |
6686 | 1706 mwSize nel = get_number_of_elements (); |
1707 for (mwIndex i = 0; i < nel; i++) | |
5900 | 1708 cpr[i] = str[i]; |
1709 } | |
1710 | |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17810
diff
changeset
|
1711 // FIXME: ??? |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1712 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
|
1713 : 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
|
1714 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1715 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1716 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
|
1717 |
6686 | 1718 mwSize *dv = get_dimensions (); |
1719 | |
1720 mwSize nc = dv[1]; | |
1721 | |
1722 for (mwIndex j = 0; j < m; j++) | |
5900 | 1723 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1724 const char *ptr = str[j]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1725 |
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
|
1726 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
|
1727 |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1728 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
|
1729 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
|
1730 |
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
|
1731 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
|
1732 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
|
1733 } |
5900 | 1734 } |
1735 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1736 // 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
|
1737 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1738 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1739 mxArray_base_full& operator = (const mxArray_base_full&); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1740 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1741 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
|
1742 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1743 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
|
1744 } |
5900 | 1745 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1746 ~mxArray_base_full (void) |
5900 | 1747 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1748 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
|
1749 } |
5907 | 1750 |
6332 | 1751 double get_scalar (void) const |
1752 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1753 // 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
|
1754 |
6332 | 1755 double retval = 0; |
1756 | |
1757 switch (get_class_id ()) | |
1758 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1759 case mxDOUBLE_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1760 retval = *(static_cast<double *> (m_pr)); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1761 break; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1762 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1763 case mxSINGLE_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1764 retval = *(static_cast<float *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1765 break; |
6332 | 1766 |
1767 case mxCHAR_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1768 retval = *(static_cast<mxChar *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1769 break; |
6332 | 1770 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1771 case mxLOGICAL_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1772 retval = *(static_cast<bool *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1773 break; |
6332 | 1774 |
1775 case mxINT8_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1776 retval = *(static_cast<int8_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1777 break; |
6332 | 1778 |
1779 case mxUINT8_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1780 retval = *(static_cast<uint8_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1781 break; |
6332 | 1782 |
1783 case mxINT16_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1784 retval = *(static_cast<int16_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1785 break; |
6332 | 1786 |
1787 case mxUINT16_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1788 retval = *(static_cast<uint16_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1789 break; |
6332 | 1790 |
1791 case mxINT32_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1792 retval = *(static_cast<int32_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1793 break; |
6332 | 1794 |
1795 case mxUINT32_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1796 retval = *(static_cast<uint32_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1797 break; |
6332 | 1798 |
1799 case mxINT64_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1800 retval = *(static_cast<int64_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1801 break; |
6332 | 1802 |
1803 case mxUINT64_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1804 retval = *(static_cast<uint64_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1805 break; |
6332 | 1806 |
1807 default: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1808 panic_impossible (); |
6332 | 1809 } |
1810 | |
1811 return retval; | |
1812 } | |
1813 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1814 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
|
1815 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1816 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
|
1817 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1818 // 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
|
1819 // 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
|
1820 // 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
|
1821 // functions. |
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 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
|
1824 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1825 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
|
1826 } |
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 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
|
1829 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1830 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
|
1831 } |
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 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
|
1834 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1835 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
|
1836 } |
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 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
|
1839 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1840 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
|
1841 } |
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 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
|
1844 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1845 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
|
1846 } |
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 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
|
1849 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1850 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
|
1851 } |
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 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
|
1854 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1855 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
|
1856 } |
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 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
|
1859 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1860 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
|
1861 } |
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 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
|
1864 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1865 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
|
1866 } |
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 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
|
1869 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1870 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
|
1871 } |
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 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
|
1874 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1875 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
|
1876 } |
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 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
|
1879 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1880 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
|
1881 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1882 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1883 #if 0 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1884 // 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
|
1885 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1886 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
|
1887 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1888 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1889 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1890 } |
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 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
|
1893 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1894 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1895 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1896 } |
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 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
|
1899 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1900 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1901 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1902 } |
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 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
|
1905 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1906 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1907 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1908 } |
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 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
|
1911 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1912 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1913 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1914 } |
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 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
|
1917 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1918 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1919 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1920 } |
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 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
|
1923 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1924 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1925 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1926 } |
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 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
|
1929 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1930 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1931 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1932 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1933 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1934 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1935 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
|
1936 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1937 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1938 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1939 } |
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 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
|
1942 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1943 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1944 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1945 } |
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 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
|
1948 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1949 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1950 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1951 } |
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 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
|
1954 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1955 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1956 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1957 } |
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 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
|
1960 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1961 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1962 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1963 } |
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 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
|
1966 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1967 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1968 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1969 } |
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 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
|
1972 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1973 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1974 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1975 } |
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 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
|
1978 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1979 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1980 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1981 } |
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 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
|
1984 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1985 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1986 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1987 } |
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 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
|
1990 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1991 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1992 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1993 } |
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 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
|
1996 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1997 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1998 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1999 } |
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 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
|
2002 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2003 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2004 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2005 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2006 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2007 #if 0 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2008 // 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
|
2009 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2010 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
|
2011 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2012 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2013 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2014 } |
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 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
|
2017 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2018 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2019 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2020 } |
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 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
|
2023 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2024 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2025 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2026 } |
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 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
|
2029 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2030 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2031 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2032 } |
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 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
|
2035 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2036 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2037 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2038 } |
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 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
|
2041 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2042 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2043 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2044 } |
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 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
|
2047 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2048 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2049 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2050 } |
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 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
|
2053 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2054 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2055 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2056 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2057 #endif |
5907 | 2058 |
6686 | 2059 int get_string (char *buf, mwSize buflen) const |
5907 | 2060 { |
13753
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2061 int retval = 0; |
5907 | 2062 |
6686 | 2063 mwSize nel = get_number_of_elements (); |
6493 | 2064 |
13753
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2065 if (! (nel < buflen)) |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2066 { |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2067 retval = 1; |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2068 if (buflen > 0) |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2069 nel = buflen-1; |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2070 } |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2071 |
6493 | 2072 if (nel < buflen) |
5907 | 2073 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2074 mxChar *ptr = static_cast<mxChar *> (m_pr); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2075 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2076 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2077 buf[i] = static_cast<char> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2078 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2079 buf[nel] = 0; |
5907 | 2080 } |
2081 | |
2082 return retval; | |
2083 } | |
2084 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2085 char * array_to_string (void) const |
5907 | 2086 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2087 // FIXME: this is supposed to handle multi-byte character strings. |
5907 | 2088 |
6686 | 2089 mwSize nel = get_number_of_elements (); |
5907 | 2090 |
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
|
2091 char *buf = static_cast<char *> (mxArray::malloc (nel + 1)); |
5907 | 2092 |
2093 if (buf) | |
2094 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2095 mxChar *ptr = static_cast<mxChar *> (m_pr); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2096 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2097 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2098 buf[i] = static_cast<char> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2099 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2100 buf[nel] = '\0'; |
5907 | 2101 } |
2102 | |
2103 return buf; | |
2104 } | |
2105 | |
5900 | 2106 octave_value as_octave_value (void) const |
2107 { | |
2108 octave_value retval; | |
2109 | |
2110 dim_vector dv = dims_to_dim_vector (); | |
2111 | |
2112 switch (get_class_id ()) | |
2113 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2114 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2115 return (is_complex () |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2116 ? fp_to_ov<Complex> (dv) : fp_to_ov<double> (dv)); |
5900 | 2117 |
2118 case mxSINGLE_CLASS: | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2119 return (is_complex () |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2120 ? fp_to_ov<FloatComplex> (dv) : fp_to_ov<float> (dv)); |
5900 | 2121 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2122 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
|
2123 return int_to_ov<mxChar, charNDArray, char> (dv); |
5900 | 2124 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2125 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
|
2126 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
|
2127 |
5900 | 2128 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
|
2129 return int_to_ov<int8_t, int8NDArray, octave_int8> (dv); |
5900 | 2130 |
2131 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
|
2132 return int_to_ov<uint8_t, uint8NDArray, octave_uint8> (dv); |
5900 | 2133 |
2134 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
|
2135 return int_to_ov<int16_t, int16NDArray, octave_int16> (dv); |
5900 | 2136 |
2137 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
|
2138 return int_to_ov<uint16_t, uint16NDArray, octave_uint16> (dv); |
5900 | 2139 |
2140 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
|
2141 return int_to_ov<int32_t, int32NDArray, octave_int32> (dv); |
5900 | 2142 |
2143 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
|
2144 return int_to_ov<uint32_t, uint32NDArray, octave_uint32> (dv); |
5900 | 2145 |
2146 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
|
2147 return int_to_ov<int64_t, int64NDArray, octave_int64> (dv); |
5900 | 2148 |
2149 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
|
2150 return int_to_ov<uint64_t, uint64NDArray, octave_uint64> (dv); |
5900 | 2151 |
2152 default: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2153 panic_impossible (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2154 } |
5900 | 2155 |
2156 return retval; | |
2157 } | |
2158 | |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2159 protected: |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2160 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2161 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
|
2162 : 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
|
2163 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
|
2164 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2165 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
|
2166 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
|
2167 } |
f3ffb4596bd8
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 |
f3ffb4596bd8
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 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
|
2170 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
|
2171 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
|
2172 { |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2173 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
|
2174 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2175 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
|
2176 |
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
|
2177 #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
|
2178 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2179 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
|
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 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
|
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 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
|
2184 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2185 else |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2186 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
|
2187 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2188 #else |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2189 |
30769
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2190 // 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
|
2191 // the mxArray object data. |
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 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
|
2194 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2195 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
|
2196 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2197 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
|
2198 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2199 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
|
2200 ptr[i] = ppr[i]; |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2201 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2202 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
|
2203 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2204 #endif |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2205 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2206 |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2207 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
|
2208 octave_value |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2209 int_to_ov (const dim_vector& dv) const |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2210 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2211 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
|
2212 error ("complex integer types are not supported"); |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2213 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2214 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
|
2215 |
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
|
2216 #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
|
2217 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2218 // 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
|
2219 // 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
|
2220 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2221 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
|
2222 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2223 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
|
2224 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2225 #else |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2226 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2227 // 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
|
2228 // 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
|
2229 |
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
|
2230 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
|
2231 |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2232 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
|
2233 |
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
|
2234 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
|
2235 |
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
|
2236 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
|
2237 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
|
2238 |
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
|
2239 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
|
2240 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2241 #endif |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2242 } |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2243 |
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
|
2244 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
|
2245 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2246 // 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
|
2247 // (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
|
2248 // 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
|
2249 void *m_pr; |
5900 | 2250 }; |
2251 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2252 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
|
2253 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2254 public: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2255 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2256 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
|
2257 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
|
2258 : 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
|
2259 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
|
2260 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2261 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2262 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
|
2263 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
|
2264 : 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
|
2265 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
|
2266 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2267 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2268 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
|
2269 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
|
2270 : 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
|
2271 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
|
2272 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2273 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2274 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
|
2275 : 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
|
2276 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2277 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2278 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
|
2279 : 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
|
2280 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2281 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2282 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
|
2283 : 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
|
2284 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2285 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2286 // FIXME: ??? |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2287 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
|
2288 : 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
|
2289 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2290 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2291 // 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
|
2292 // 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
|
2293 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2294 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
|
2295 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2296 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
|
2297 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2298 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
|
2299 } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2300 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2301 ~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
|
2302 |
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
|
2303 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
|
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 * 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
|
2306 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2307 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
|
2308 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2309 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2310 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2311 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
|
2312 : 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
|
2313 { } |
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
|
2314 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2315 // 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
|
2316 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
|
2317 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2318 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2319 class mxArray_separate_full : public mxArray_base_full |
5900 | 2320 { |
2321 public: | |
2322 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2323 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
|
2324 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
|
2325 : 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
|
2326 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
|
2327 ? 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
|
2328 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2329 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2330 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2331 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
|
2332 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
|
2333 : 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
|
2334 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
|
2335 ? 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
|
2336 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2337 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2338 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2339 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
|
2340 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
|
2341 : 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
|
2342 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
|
2343 ? (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
|
2344 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2345 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2346 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2347 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
|
2348 : 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
|
2349 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2350 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2351 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
|
2352 : 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
|
2353 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2354 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2355 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
|
2356 : 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
|
2357 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2358 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2359 // FIXME: ??? |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2360 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
|
2361 : 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
|
2362 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2363 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2364 // 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
|
2365 // 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
|
2366 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2367 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
|
2368 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2369 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
|
2370 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2371 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
|
2372 } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2373 |
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
|
2374 ~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
|
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 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
|
2377 } |
f3ffb4596bd8
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 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
|
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 * 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
|
2382 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2383 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
|
2384 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2385 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
|
2386 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
|
2387 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
|
2388 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
|
2389 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
|
2390 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
|
2391 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
|
2392 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
|
2393 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
|
2394 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
|
2395 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2396 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
|
2397 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
|
2398 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2399 // 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
|
2400 // 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
|
2401 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
|
2402 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
|
2403 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
|
2404 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
|
2405 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
|
2406 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
|
2407 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
|
2408 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
|
2409 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2410 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
|
2411 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
|
2412 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
|
2413 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
|
2414 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
|
2415 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
|
2416 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
|
2417 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
|
2418 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
|
2419 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
|
2420 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2421 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
|
2422 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
|
2423 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2424 // 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
|
2425 // 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
|
2426 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
|
2427 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
|
2428 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
|
2429 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
|
2430 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
|
2431 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
|
2432 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
|
2433 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
|
2434 |
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
|
2435 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
|
2436 { |
f3ffb4596bd8
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 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
|
2438 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
|
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 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
|
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 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
|
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 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
|
2445 { |
f3ffb4596bd8
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 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2447 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
|
2448 |
f3ffb4596bd8
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 case mxSINGLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2450 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
|
2451 |
f3ffb4596bd8
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 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
|
2453 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
|
2454 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
|
2455 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
|
2456 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
|
2457 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
|
2458 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
|
2459 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
|
2460 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
|
2461 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
|
2462 |
f3ffb4596bd8
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 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
|
2464 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
|
2465 } |
f3ffb4596bd8
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 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
|
2468 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2469 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2470 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2471 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2472 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
|
2473 : 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
|
2474 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
|
2475 ? 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
|
2476 : 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
|
2477 { |
f3ffb4596bd8
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 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
|
2479 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
|
2480 } |
f3ffb4596bd8
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 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2482 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
|
2483 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2484 template <typename T> |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2485 octave_value |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2486 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
|
2487 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2488 mwSize nel = get_number_of_elements (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2489 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2490 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
|
2491 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2492 // 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
|
2493 // 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
|
2494 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2495 Array<std::complex<T>> val (dv); |
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 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
|
2498 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2499 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
|
2500 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2501 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
|
2502 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
|
2503 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2504 return octave_value (val); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2505 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2506 |
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
|
2507 // 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
|
2508 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
|
2509 }; |
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 // 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
|
2512 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2513 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
|
2514 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2515 public: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2516 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2517 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
|
2518 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
|
2519 : 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
|
2520 |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2521 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
|
2522 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
|
2523 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
|
2524 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
|
2525 { } |
5900 | 2526 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2527 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2528 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2529 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
|
2530 : 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
|
2531 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
|
2532 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
|
2533 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
|
2534 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2535 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
|
2536 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
|
2537 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2538 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
|
2539 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
|
2540 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2541 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
|
2542 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
|
2543 } |
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 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2546 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2547 // 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
|
2548 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2549 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2550 mxArray_base_sparse& operator = (const mxArray_base_sparse&); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2551 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2552 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
|
2553 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2554 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
|
2555 } |
5900 | 2556 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2557 ~mxArray_base_sparse (void) |
5900 | 2558 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2559 mxFree (m_ir); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2560 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
|
2561 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
|
2562 } |
5907 | 2563 |
2564 int is_sparse (void) const { return 1; } | |
2565 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2566 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
|
2567 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2568 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
|
2569 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2570 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
|
2571 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2572 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
|
2573 } |
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 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
|
2576 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2577 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
|
2578 } |
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 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
|
2581 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2582 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2583 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2584 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2585 |
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
|
2586 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
|
2587 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2588 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2589 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2590 } |
5907 | 2591 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2592 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
|
2593 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2594 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
|
2595 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2596 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
|
2597 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2598 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
|
2599 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2600 void set_jc (mwIndex *jc) { m_jc = jc; } |
6686 | 2601 |
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
|
2602 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
|
2603 { |
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2604 /* 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
|
2605 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
|
2606 } |
5907 | 2607 |
5900 | 2608 octave_value as_octave_value (void) const |
2609 { | |
5903 | 2610 octave_value retval; |
2611 | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2612 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
|
2613 |
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
|
2614 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
|
2615 { |
f3ffb4596bd8
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 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2617 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
|
2618 |
f3ffb4596bd8
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 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
|
2620 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
|
2621 |
f3ffb4596bd8
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 case mxLOGICAL_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2623 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
|
2624 |
f3ffb4596bd8
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 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
|
2626 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
|
2627 } |
f3ffb4596bd8
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 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
|
2630 } |
f3ffb4596bd8
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 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
|
2633 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2634 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
|
2635 octave_value |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2636 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
|
2637 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2638 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
|
2639 |
30792
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2640 #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
|
2641 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2642 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
|
2643 { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2644 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
|
2645 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
|
2646 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
|
2647 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
|
2648 }); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2649 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2650 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
|
2651 (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
|
2652 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
|
2653 } |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2654 else |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2655 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
|
2656 (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
|
2657 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
|
2658 #else |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2659 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2660 // 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
|
2661 // 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
|
2662 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2663 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
|
2664 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
|
2665 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2666 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
|
2667 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2668 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
|
2669 { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2670 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
|
2671 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
|
2672 } |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2673 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2674 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
|
2675 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
|
2676 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2677 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
|
2678 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2679 #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
|
2680 } |
f3ffb4596bd8
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 |
f3ffb4596bd8
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 // 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
|
2683 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
|
2684 |
f3ffb4596bd8
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 // 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
|
2686 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
|
2687 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
|
2688 |
f3ffb4596bd8
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 // 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
|
2690 // (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
|
2691 // 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
|
2692 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
|
2693 }; |
f3ffb4596bd8
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 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
|
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 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
|
2698 |
f3ffb4596bd8
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_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
|
2700 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
|
2701 : 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
|
2702 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
|
2703 { } |
f3ffb4596bd8
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 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
|
2706 |
f3ffb4596bd8
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 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
|
2708 : 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
|
2709 { } |
f3ffb4596bd8
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 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
|
2712 |
f3ffb4596bd8
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 // 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
|
2714 // 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
|
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_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
|
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 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
|
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 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
|
2721 } |
f3ffb4596bd8
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 ~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
|
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 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
|
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 * 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
|
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 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
|
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 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
|
2732 |
f3ffb4596bd8
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 // 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
|
2734 // 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
|
2735 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
|
2736 }; |
f3ffb4596bd8
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 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
|
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 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
|
2741 |
f3ffb4596bd8
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_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
|
2743 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
|
2744 : 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
|
2745 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
|
2746 ? 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
|
2747 : 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
|
2748 { } |
f3ffb4596bd8
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 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
|
2751 |
f3ffb4596bd8
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 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
|
2753 : 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
|
2754 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
|
2755 ? 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
|
2756 : 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
|
2757 { |
f3ffb4596bd8
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 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
|
2759 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
|
2760 } |
f3ffb4596bd8
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 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
|
2763 |
f3ffb4596bd8
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 // 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
|
2765 // 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
|
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_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
|
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 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
|
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 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
|
2772 } |
f3ffb4596bd8
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 ~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
|
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 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
|
2777 } |
f3ffb4596bd8
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 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
|
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 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
|
2782 } |
f3ffb4596bd8
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 * 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
|
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 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
|
2787 |
f3ffb4596bd8
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 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
|
2789 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
|
2790 |
f3ffb4596bd8
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 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
|
2792 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
|
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 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
|
2795 { |
f3ffb4596bd8
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 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
|
2797 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
|
2798 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2799 octave_value retval; |
5903 | 2800 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2801 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
|
2802 |
5903 | 2803 switch (get_class_id ()) |
2804 { | |
2805 case mxDOUBLE_CLASS: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2806 { |
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
|
2807 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
|
2808 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
|
2809 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2810 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
|
2811 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
|
2812 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2813 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
|
2814 { |
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
|
2815 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
|
2816 val.xridx (i) = m_ir[i]; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2817 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2818 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2819 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
|
2820 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
|
2821 |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2822 retval = val; |
22471
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 break; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2825 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2826 case mxSINGLE_CLASS: |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2827 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
|
2828 |
5903 | 2829 default: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2830 panic_impossible (); |
5903 | 2831 } |
2832 | |
2833 return retval; | |
5900 | 2834 } |
2835 | |
2836 private: | |
2837 | |
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
|
2838 // 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
|
2839 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
|
2840 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2841 |
5900 | 2842 // Matlab-style struct arrays. |
2843 | |
2844 class mxArray_struct : public mxArray_matlab | |
2845 { | |
2846 public: | |
2847 | |
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
|
2848 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
|
2849 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
|
2850 : 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
|
2851 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
|
2852 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
|
2853 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2854 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
|
2855 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2856 sizeof (mxArray *)))) |
5900 | 2857 { |
2858 init (keys); | |
2859 } | |
2860 | |
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
|
2861 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
|
2862 const char **keys) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2863 : 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
|
2864 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
|
2865 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
|
2866 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2867 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
|
2868 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2869 sizeof (mxArray *)))) |
5900 | 2870 { |
2871 init (keys); | |
2872 } | |
2873 | |
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
|
2874 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
|
2875 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
|
2876 : 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
|
2877 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
|
2878 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
|
2879 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2880 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
|
2881 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2882 sizeof (mxArray *)))) |
5900 | 2883 { |
2884 init (keys); | |
2885 } | |
2886 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2887 private: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2888 |
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
|
2889 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
|
2890 : 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
|
2891 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
|
2892 * sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2893 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
|
2894 get_number_of_elements () |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2895 * sizeof (mxArray *)))) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2896 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2897 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
|
2898 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
|
2899 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2900 mwSize nel = get_number_of_elements (); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2901 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2902 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
|
2903 { |
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
|
2904 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
|
2905 m_data[i] = (ptr ? ptr->dup () : nullptr); |
22869
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 } |
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 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2910 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2911 // 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
|
2912 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2913 |
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
|
2914 mxArray_struct& operator = (const mxArray_struct& val); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2915 |
5900 | 2916 void init (const char **keys) |
2917 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2918 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
|
2919 m_fields[i] = mxArray::strsave (keys[i]); |
5900 | 2920 } |
2921 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2922 mxArray_base * dup (void) const { return new mxArray_struct (*this); } |
5900 | 2923 |
2924 ~mxArray_struct (void) | |
2925 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2926 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
|
2927 mxFree (m_fields[i]); |
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 mxFree (m_fields); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2930 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2931 mwSize ntot = m_nfields * get_number_of_elements (); |
6686 | 2932 |
2933 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
|
2934 delete m_data[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2935 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2936 mxFree (m_data); |
5900 | 2937 } |
2938 | |
2939 int add_field (const char *key) | |
2940 { | |
2941 int retval = -1; | |
2942 | |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2943 m_nfields++; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2944 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2945 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
|
2946 (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
|
2947 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2948 if (m_fields) |
5900 | 2949 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2950 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
|
2951 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2952 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
|
2953 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2954 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
|
2955 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2956 mxArray **new_data; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2957 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
|
2958 (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
|
2959 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2960 if (new_data) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2961 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2962 mwIndex j = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2963 mwIndex k = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2964 mwIndex n = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2965 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2966 for (mwIndex i = 0; i < ntot; i++) |
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 if (++n == m_nfields) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2969 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2970 new_data[j++] = nullptr; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2971 n = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2972 } |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2973 else |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2974 new_data[j++] = m_data[k++]; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2975 } |
30349
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 mxFree (m_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 m_data = new_data; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2980 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2981 retval = m_nfields - 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2982 } |
5900 | 2983 } |
2984 | |
2985 return retval; | |
2986 } | |
2987 | |
2988 void remove_field (int key_num) | |
2989 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2990 if (key_num >= 0 && key_num < m_nfields) |
5900 | 2991 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2992 mwSize nel = get_number_of_elements (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2993 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2994 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
|
2995 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2996 int new_nfields = m_nfields - 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2997 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2998 char **new_fields = static_cast<char **> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2999 (mxArray::malloc (new_nfields * sizeof (char *))); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3000 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3001 mxArray **new_data = static_cast<mxArray **> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3002 (mxArray::malloc (new_nfields * nel |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3003 * sizeof (mxArray *))); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3004 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3005 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
|
3006 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
|
3007 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3008 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
|
3009 new_fields[i-1] = m_fields[i]; |
10315
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 if (new_nfields > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3012 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3013 mwIndex j = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3014 mwIndex k = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3015 mwIndex n = 0; |
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 for (mwIndex i = 0; i < ntot; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3018 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3019 if (n == key_num) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3020 k++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3021 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3022 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
|
3023 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3024 if (++n == m_nfields) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3025 n = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3026 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3027 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3028 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3029 m_nfields = new_nfields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3030 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3031 mxFree (m_fields); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3032 mxFree (m_data); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3033 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3034 m_fields = new_fields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3035 m_data = new_data; |
5900 | 3036 } |
3037 } | |
3038 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3039 mxArray * get_field_by_number (mwIndex index, int key_num) const |
5900 | 3040 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3041 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
|
3042 ? m_data[m_nfields * index + key_num] : nullptr; |
5900 | 3043 } |
3044 | |
6686 | 3045 void set_field_by_number (mwIndex index, int key_num, mxArray *val); |
5900 | 3046 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3047 int get_number_of_fields (void) const { return m_nfields; } |
5900 | 3048 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3049 const char * get_field_name_by_number (int key_num) const |
5900 | 3050 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3051 return key_num >= 0 && key_num < m_nfields ? m_fields[key_num] : nullptr; |
5900 | 3052 } |
3053 | |
3054 int get_field_number (const char *key) const | |
3055 { | |
3056 int retval = -1; | |
3057 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3058 for (int i = 0; i < m_nfields; i++) |
5900 | 3059 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3060 if (! strcmp (key, m_fields[i])) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3061 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3062 retval = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3063 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3064 } |
5900 | 3065 } |
3066 | |
3067 return retval; | |
3068 } | |
3069 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3070 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
|
3071 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3072 void set_data (void *data) { m_data = static_cast<mxArray **> (data); } |
5900 | 3073 |
5907 | 3074 octave_value as_octave_value (void) const |
3075 { | |
3076 dim_vector dv = dims_to_dim_vector (); | |
3077 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3078 string_vector keys (m_fields, m_nfields); |
5907 | 3079 |
25922
34e82a829fdd
Create scalar structs of size 1x1 with MEX interface (bug #54799).
Rik <rik@octave.org>
parents:
25751
diff
changeset
|
3080 octave_map m (dv); |
5907 | 3081 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3082 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
|
3083 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3084 for (int i = 0; i < m_nfields; i++) |
5907 | 3085 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3086 Cell c (dv); |
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 octave_value *p = c.fortran_vec (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3089 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3090 mwIndex k = 0; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3091 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
|
3092 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
|
3093 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3094 m.assign (keys[i], c); |
5907 | 3095 } |
3096 | |
3097 return m; | |
3098 } | |
3099 | |
5900 | 3100 private: |
3101 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3102 int m_nfields; |
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 char **m_fields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3105 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3106 mxArray **m_data; |
5900 | 3107 }; |
3108 | |
3109 // Matlab-style cell arrays. | |
3110 | |
3111 class mxArray_cell : public mxArray_matlab | |
3112 { | |
3113 public: | |
3114 | |
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
|
3115 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
|
3116 : 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
|
3117 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
|
3118 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
|
3119 { } |
5900 | 3120 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3121 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
|
3122 : 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
|
3123 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
|
3124 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
|
3125 { } |
5900 | 3126 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3127 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
|
3128 : 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
|
3129 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
|
3130 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
|
3131 { } |
5900 | 3132 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3133 private: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3134 |
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
|
3135 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
|
3136 : mxArray_matlab (val), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3137 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
|
3138 mxArray::malloc (get_number_of_elements () * sizeof (mxArray *)))) |
22869
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 mwSize nel = get_number_of_elements (); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3141 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3142 for (mwIndex i = 0; i < nel; i++) |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3143 { |
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
|
3144 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
|
3145 m_data[i] = (ptr ? ptr->dup () : nullptr); |
22869
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 } |
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 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3150 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3151 // 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
|
3152 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3153 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3154 mxArray_cell& operator = (const mxArray_cell&); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3155 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3156 mxArray_base * dup (void) const { return new mxArray_cell (*this); } |
5900 | 3157 |
3158 ~mxArray_cell (void) | |
3159 { | |
6686 | 3160 mwSize nel = get_number_of_elements (); |
3161 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
3162 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
|
3163 delete m_data[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3164 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3165 mxFree (m_data); |
5900 | 3166 } |
3167 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3168 mxArray * get_cell (mwIndex idx) const |
6187 | 3169 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3170 return idx >= 0 && idx < get_number_of_elements () ? m_data[idx] : nullptr; |
6187 | 3171 } |
5907 | 3172 |
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
|
3173 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
|
3174 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3175 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
|
3176 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3177 void set_data (void *data) { m_data = static_cast<mxArray **> (data); } |
5907 | 3178 |
5900 | 3179 octave_value as_octave_value (void) const |
3180 { | |
3181 dim_vector dv = dims_to_dim_vector (); | |
3182 | |
3183 Cell c (dv); | |
3184 | |
6686 | 3185 mwSize nel = get_number_of_elements (); |
5900 | 3186 |
3187 octave_value *p = c.fortran_vec (); | |
3188 | |
6686 | 3189 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
|
3190 p[i] = mxArray::as_octave_value (m_data[i]); |
5900 | 3191 |
3192 return c; | |
3193 } | |
3194 | |
3195 private: | |
3196 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3197 mxArray **m_data; |
5900 | 3198 }; |
3199 | |
3200 // ------------------------------------------------------------------ | |
3201 | |
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 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
|
3203 : 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
|
3204 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3205 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3206 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
|
3207 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
|
3208 : 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
|
3209 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
|
3210 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3211 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3212 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
|
3213 mxComplexity flag) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3214 : 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
|
3215 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3216 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3217 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
|
3218 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
|
3219 : 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
|
3220 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3221 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3222 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
|
3223 : 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
|
3224 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3225 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3226 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
|
3227 : 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
|
3228 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3229 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3230 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
|
3231 : 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
|
3232 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3233 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3234 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
|
3235 : 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
|
3236 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3237 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3238 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
|
3239 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
|
3240 : 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
|
3241 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3242 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3243 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
|
3244 int num_keys, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3245 const char **keys) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3246 : 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
|
3247 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
|
3248 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3249 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3250 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
|
3251 const char **keys) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3252 : 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
|
3253 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
|
3254 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3255 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3256 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
|
3257 const char **keys) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3258 : 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
|
3259 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
|
3260 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3261 |
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
|
3262 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
|
3263 : 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
|
3264 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3265 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3266 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
|
3267 : 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
|
3268 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3269 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3270 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
|
3271 : 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
|
3272 { } |
5900 | 3273 |
3274 mxArray::~mxArray (void) | |
3275 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3276 mxFree (m_name); |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3277 |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3278 delete m_rep; |
5900 | 3279 } |
3280 | |
3281 void | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3282 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
|
3283 { |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3284 mxFree (m_name); |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3285 m_name = mxArray::strsave (name); |
5900 | 3286 } |
3287 | |
5907 | 3288 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
|
3289 mxArray::as_octave_value (const mxArray *ptr, bool null_is_empty) |
5907 | 3290 { |
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
|
3291 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
|
3292 |
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 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
|
3294 ? 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
|
3295 : (null_is_empty ? empty_matrix : octave_value ())); |
5907 | 3296 } |
3297 | |
3298 octave_value | |
3299 mxArray::as_octave_value (void) const | |
3300 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3301 return m_rep->as_octave_value (); |
5907 | 3302 } |
3303 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3304 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
|
3305 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
|
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 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
|
3308 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3309 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3310 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
|
3311 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
|
3312 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
|
3313 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3314 if (interleaved) |
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_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
|
3316 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3317 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
|
3318 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3319 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3320 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
|
3321 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
|
3322 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
|
3323 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3324 if (interleaved) |
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_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
|
3326 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3327 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
|
3328 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3329 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3330 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
|
3331 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
|
3332 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
|
3333 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3334 if (interleaved) |
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_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
|
3336 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3337 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
|
3338 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3339 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3340 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
|
3341 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
|
3342 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3343 if (interleaved) |
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_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
|
3345 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3346 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
|
3347 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3348 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3349 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
|
3350 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
|
3351 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3352 if (interleaved) |
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_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
|
3354 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3355 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
|
3356 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3357 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3358 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
|
3359 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
|
3360 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3361 if (interleaved) |
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_interleaved_full (str); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3363 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3364 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
|
3365 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3366 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3367 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
|
3368 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
|
3369 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3370 if (interleaved) |
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_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
|
3372 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3373 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
|
3374 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3375 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3376 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
|
3377 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
|
3378 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
|
3379 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3380 if (interleaved) |
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_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
|
3382 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3383 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
|
3384 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3385 |
5900 | 3386 void |
3387 mxArray::maybe_mutate (void) const | |
3388 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3389 if (m_rep->is_octave_value ()) |
5900 | 3390 { |
3391 // The mutate function returns a pointer to a complete new | |
3392 // mxArray object (or 0, if no mutation happened). We just want | |
3393 // to replace the existing rep with the rep from the new object. | |
3394 | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3395 mxArray *new_val = m_rep->mutate (); |
5900 | 3396 |
3397 if (new_val) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3398 { |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3399 delete m_rep; |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3400 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
|
3401 new_val->m_rep = nullptr; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3402 delete new_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3403 } |
5900 | 3404 } |
3405 } | |
3406 | |
3407 // ------------------------------------------------------------------ | |
3408 | |
6686 | 3409 // A class to manage calls to MEX functions. Mostly deals with memory |
5900 | 3410 // management. |
5864 | 3411 |
3412 class mex | |
3413 { | |
3414 public: | |
3415 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3416 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
|
3417 : m_curr_mex_fcn (f), m_memlist (), m_arraylist (), m_fname (nullptr) { } |
5864 | 3418 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3419 // No copying! |
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 (const mex&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3422 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3423 mex& operator = (const mex&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3424 |
5864 | 3425 ~mex (void) |
3426 { | |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3427 // 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
|
3428 while (! m_memlist.empty ()) |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3429 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3430 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
|
3431 xfree (*p); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3432 m_memlist.erase (p); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3433 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3434 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3435 // 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
|
3436 while (! m_arraylist.empty ()) |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3437 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3438 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
|
3439 delete *p; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3440 m_arraylist.erase (p); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3441 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3442 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3443 if (! (m_memlist.empty () && m_arraylist.empty ())) |
5905 | 3444 error ("mex: %s: cleanup failed", function_name ()); |
5900 | 3445 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3446 mxFree (m_fname); |
5864 | 3447 } |
3448 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3449 const char * function_name (void) const |
5900 | 3450 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3451 if (! m_fname) |
5900 | 3452 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
3453 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
|
3454 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3455 octave_function *fcn = tw.current_function (); |
10315
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 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3458 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3459 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
|
3460 m_fname = mxArray::strsave (nm.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3461 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3462 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3463 m_fname = mxArray::strsave ("unknown"); |
5900 | 3464 } |
3465 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3466 return m_fname; |
5900 | 3467 } |
3468 | |
6071 | 3469 // 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
|
3470 void * malloc_unmarked (std::size_t n) |
5900 | 3471 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3472 void *ptr = xmalloc (n); |
5900 | 3473 |
3474 if (! ptr) | |
3475 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3476 // 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
|
3477 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
|
3478 function_name (), n); |
5900 | 3479 } |
3480 | |
3481 global_mark (ptr); | |
3482 | |
3483 return ptr; | |
3484 } | |
3485 | |
6071 | 3486 // 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
|
3487 void * malloc (std::size_t n) |
5900 | 3488 { |
3489 void *ptr = malloc_unmarked (n); | |
3490 | |
3491 mark (ptr); | |
3492 | |
3493 return ptr; | |
3494 } | |
3495 | |
6071 | 3496 // 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
|
3497 void * calloc_unmarked (std::size_t n, std::size_t t) |
5900 | 3498 { |
3499 void *ptr = malloc_unmarked (n*t); | |
3500 | |
3501 memset (ptr, 0, n*t); | |
3502 | |
3503 return ptr; | |
3504 } | |
3505 | |
6071 | 3506 // 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
|
3507 void * calloc (std::size_t n, std::size_t t) |
5900 | 3508 { |
3509 void *ptr = calloc_unmarked (n, t); | |
3510 | |
3511 mark (ptr); | |
3512 | |
3513 return ptr; | |
3514 } | |
3515 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3516 // 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
|
3517 // 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
|
3518 // 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
|
3519 void * realloc (void *ptr, std::size_t n) |
5900 | 3520 { |
10225
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3521 void *v; |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3522 |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3523 if (ptr) |
5900 | 3524 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3525 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
|
3526 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
|
3527 |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3528 v = xrealloc (ptr, n); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3529 |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3530 if (v) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
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 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
|
3533 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3534 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
|
3535 m_memlist.insert (v); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3536 } |
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 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
|
3539 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3540 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
|
3541 s_global_memlist.insert (v); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3542 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3543 } |
5900 | 3544 } |
10225
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3545 else |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3546 v = malloc (n); |
5900 | 3547 |
3548 return v; | |
3549 } | |
3550 | |
3551 // Free a pointer obtained from malloc or calloc. | |
3552 void free (void *ptr) | |
3553 { | |
3554 if (ptr) | |
3555 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3556 unmark (ptr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3557 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3558 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
|
3559 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3560 if (p != s_global_memlist.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3561 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3562 s_global_memlist.erase (p); |
10315
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 xfree (ptr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3565 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3566 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3567 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3568 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
|
3569 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3570 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
|
3571 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
|
3572 #if defined (DEBUG) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3573 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3574 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
|
3575 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3576 } |
5900 | 3577 } |
3578 } | |
3579 | |
7172 | 3580 // Mark a pointer to be freed on exit. |
3581 void mark (void *ptr) | |
3582 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3583 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3584 if (m_memlist.find (ptr) != m_memlist.end ()) |
7172 | 3585 warning ("%s: double registration ignored", function_name ()); |
3586 #endif | |
3587 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3588 m_memlist.insert (ptr); |
7172 | 3589 } |
3590 | |
3591 // Unmark a pointer to be freed on exit, either because it was | |
3592 // made persistent, or because it was already freed. | |
3593 void unmark (void *ptr) | |
3594 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3595 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
|
3596 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3597 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
|
3598 m_memlist.erase (p); |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3599 #if defined (DEBUG) |
7172 | 3600 else |
3601 warning ("%s: value not marked", function_name ()); | |
3602 #endif | |
3603 } | |
5900 | 3604 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3605 mxArray * mark_array (mxArray *ptr) |
6065 | 3606 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3607 m_arraylist.insert (ptr); |
6065 | 3608 return ptr; |
3609 } | |
3610 | |
6071 | 3611 void unmark_array (mxArray *ptr) |
3612 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3613 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
|
3614 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3615 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
|
3616 m_arraylist.erase (p); |
6071 | 3617 } |
3618 | |
7179 | 3619 // Mark a pointer as one we allocated. |
3620 void mark_foreign (void *ptr) | |
3621 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3622 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3623 if (m_foreign_memlist.find (ptr) != m_foreign_memlist.end ()) |
7179 | 3624 warning ("%s: double registration ignored", function_name ()); |
3625 #endif | |
3626 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3627 m_foreign_memlist.insert (ptr); |
7179 | 3628 } |
3629 | |
3630 // Unmark a pointer as one we allocated. | |
3631 void unmark_foreign (void *ptr) | |
3632 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3633 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
|
3634 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3635 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
|
3636 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
|
3637 #if defined (DEBUG) |
7179 | 3638 else |
3639 warning ("%s: value not marked", function_name ()); | |
3640 #endif | |
3641 | |
3642 } | |
3643 | |
5900 | 3644 // Make a new array value and initialize from an octave value; it will be |
3645 // 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
|
3646 mxArray * make_value (const octave_value& ov) |
5900 | 3647 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3648 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
|
3649 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3650 return mark_array (new mxArray (interleaved, ov)); |
5900 | 3651 } |
3652 | |
3653 // Free an array and its contents. | |
6065 | 3654 bool free_value (mxArray *ptr) |
5900 | 3655 { |
6065 | 3656 bool inlist = false; |
3657 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3658 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
|
3659 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3660 if (p != m_arraylist.end ()) |
5905 | 3661 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3662 inlist = true; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3663 m_arraylist.erase (p); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3664 delete ptr; |
5905 | 3665 } |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3666 #if defined (DEBUG) |
5905 | 3667 else |
3668 warning ("mex::free_value: skipping memory not allocated by mex::make_value"); | |
3669 #endif | |
6065 | 3670 |
3671 return inlist; | |
5900 | 3672 } |
3673 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3674 octave_mex_function& current_mex_function (void) const |
6068 | 3675 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3676 return m_curr_mex_fcn; |
6068 | 3677 } |
3678 | |
5900 | 3679 // 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
|
3680 int trap_feval_error = 0; |
5864 | 3681 |
5900 | 3682 // Mark a pointer as one we allocated. |
5905 | 3683 void global_mark (void *ptr) |
5900 | 3684 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3685 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3686 if (s_global_memlist.find (ptr) != s_global_memlist.end ()) |
5905 | 3687 warning ("%s: double registration ignored", function_name ()); |
5864 | 3688 #endif |
5900 | 3689 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3690 s_global_memlist.insert (ptr); |
5864 | 3691 } |
3692 | |
5900 | 3693 // Unmark a pointer as one we allocated. |
5905 | 3694 void global_unmark (void *ptr) |
5864 | 3695 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3696 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
|
3697 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3698 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
|
3699 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
|
3700 #if defined (DEBUG) |
5905 | 3701 else |
3702 warning ("%s: value not marked", function_name ()); | |
5900 | 3703 #endif |
5864 | 3704 } |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3705 |
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
|
3706 private: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3707 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3708 // 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
|
3709 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
|
3710 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3711 // 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
|
3712 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
|
3713 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3714 // 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
|
3715 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
|
3716 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3717 // 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
|
3718 // elsewhere. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3719 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
|
3720 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3721 // 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
|
3722 mutable char *m_fname; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3723 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3724 // 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
|
3725 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
|
3726 |
5864 | 3727 }; |
3728 | |
5900 | 3729 // 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
|
3730 std::set<void *> mex::s_global_memlist; |
5900 | 3731 |
3732 // Current context. | |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
3733 mex *mex_context = nullptr; |
5900 | 3734 |
3735 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
|
3736 mxArray::malloc (std::size_t n) |
5900 | 3737 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3738 return mex_context ? mex_context->malloc_unmarked (n) : xmalloc (n); |
5900 | 3739 } |
3740 | |
3741 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
|
3742 mxArray::calloc (std::size_t n, std::size_t t) |
5900 | 3743 { |
6065 | 3744 return mex_context ? mex_context->calloc_unmarked (n, t) : ::calloc (n, t); |
5900 | 3745 } |
3746 | |
30223
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3747 void * |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3748 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
|
3749 { |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3750 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
|
3751 } |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3752 |
7179 | 3753 static inline void * |
3754 maybe_mark_foreign (void *ptr) | |
3755 { | |
3756 if (mex_context) | |
3757 mex_context->mark_foreign (ptr); | |
3758 | |
3759 return ptr; | |
3760 } | |
3761 | |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3762 #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
|
3763 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3764 static inline void |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3765 maybe_disown_ptr (void *ptr) |
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 if (mex_context) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3768 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3769 mex_context->unmark (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3770 mex_context->global_unmark (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3771 mex_context->mark_foreign (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3772 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3773 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3774 |
31362
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3775 #endif |
4e12be13186d
build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
3776 |
6071 | 3777 static inline mxArray * |
3778 maybe_unmark_array (mxArray *ptr) | |
3779 { | |
3780 if (mex_context) | |
3781 mex_context->unmark_array (ptr); | |
3782 | |
3783 return ptr; | |
3784 } | |
3785 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3786 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
|
3787 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
|
3788 maybe_unmark (T *ptr) |
7172 | 3789 { |
3790 if (mex_context) | |
3791 mex_context->unmark (ptr); | |
3792 | |
3793 return ptr; | |
3794 } | |
3795 | |
6071 | 3796 void |
6686 | 3797 mxArray_struct::set_field_by_number (mwIndex index, int key_num, mxArray *val) |
6071 | 3798 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3799 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
|
3800 m_data[m_nfields * index + key_num] = maybe_unmark_array (val); |
6071 | 3801 } |
3802 | |
3803 void | |
6686 | 3804 mxArray_cell::set_cell (mwIndex idx, mxArray *val) |
6071 | 3805 { |
6187 | 3806 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
|
3807 m_data[idx] = maybe_unmark_array (val); |
6071 | 3808 } |
3809 | |
5900 | 3810 // ------------------------------------------------------------------ |
3811 | |
3812 // C interface to mxArray objects: | |
3813 | |
3814 // Floating point predicates. | |
3815 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3816 bool |
5900 | 3817 mxIsFinite (const double v) |
3818 { | |
30088
fca57eaad2d4
maint: deprecate lo_ieee_finite and replace with lo_ieee_isfinite.
Rik <rik@octave.org>
parents:
29993
diff
changeset
|
3819 return lo_ieee_isfinite (v) != 0; |
5900 | 3820 } |
3821 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3822 bool |
5900 | 3823 mxIsInf (const double v) |
3824 { | |
3825 return lo_ieee_isinf (v) != 0; | |
3826 } | |
3827 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3828 bool |
5900 | 3829 mxIsNaN (const double v) |
3830 { | |
3831 return lo_ieee_isnan (v) != 0; | |
3832 } | |
3833 | |
3834 double | |
3835 mxGetEps (void) | |
3836 { | |
15220
61822c866ba1
use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3837 return std::numeric_limits<double>::epsilon (); |
5900 | 3838 } |
3839 | |
3840 double | |
3841 mxGetInf (void) | |
3842 { | |
3843 return lo_ieee_inf_value (); | |
3844 } | |
3845 | |
3846 double | |
3847 mxGetNaN (void) | |
3848 { | |
3849 return lo_ieee_nan_value (); | |
3850 } | |
3851 | |
3852 // Memory management. | |
3853 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
|
3854 mxCalloc (std::size_t n, std::size_t size) |
5900 | 3855 { |
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
|
3856 return mex_context ? mex_context->calloc (n, size) : ::calloc (n, size); |
5900 | 3857 } |
3858 | |
3859 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
|
3860 mxMalloc (std::size_t n) |
5900 | 3861 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3862 return mex_context ? mex_context->malloc (n) : xmalloc (n); |
5900 | 3863 } |
3864 | |
3865 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
|
3866 mxRealloc (void *ptr, std::size_t size) |
5900 | 3867 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3868 return (mex_context |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3869 ? mex_context->realloc (ptr, size) : xrealloc (ptr, size)); |
5900 | 3870 } |
3871 | |
3872 void | |
3873 mxFree (void *ptr) | |
5864 | 3874 { |
5900 | 3875 if (mex_context) |
3876 mex_context->free (ptr); | |
5864 | 3877 else |
6071 | 3878 xfree (ptr); |
5900 | 3879 } |
6065 | 3880 |
3881 static inline mxArray * | |
3882 maybe_mark_array (mxArray *ptr) | |
3883 { | |
3884 return mex_context ? mex_context->mark_array (ptr) : ptr; | |
3885 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3886 |
5900 | 3887 // Constructors. |
3888 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
|
3889 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
|
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 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
|
3892 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3893 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3894 mxArray * |
6686 | 3895 mxCreateCellArray (mwSize ndims, const mwSize *dims) |
5900 | 3896 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3897 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
|
3898 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3899 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3900 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3901 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
|
3902 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3903 return maybe_mark_array (new mxArray (true, m, n)); |
5900 | 3904 } |
3905 | |
3906 mxArray * | |
6686 | 3907 mxCreateCellMatrix (mwSize m, mwSize n) |
5900 | 3908 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3909 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
|
3910 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3911 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3912 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3913 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
|
3914 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3915 return maybe_mark_array (new mxArray (true, mxCHAR_CLASS, ndims, dims)); |
5900 | 3916 } |
3917 | |
3918 mxArray * | |
6686 | 3919 mxCreateCharArray (mwSize ndims, const mwSize *dims) |
5900 | 3920 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3921 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
|
3922 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3923 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3924 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3925 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
|
3926 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3927 return maybe_mark_array (new mxArray (true, m, str)); |
5864 | 3928 } |
3929 | |
5900 | 3930 mxArray * |
6686 | 3931 mxCreateCharMatrixFromStrings (mwSize m, const char **str) |
5900 | 3932 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3933 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
|
3934 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3935 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3936 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3937 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
|
3938 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3939 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, flag)); |
5900 | 3940 } |
3941 | |
3942 mxArray * | |
6686 | 3943 mxCreateDoubleMatrix (mwSize m, mwSize n, mxComplexity flag) |
5900 | 3944 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3945 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
|
3946 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3947 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3948 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
|
3949 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
|
3950 { |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3951 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, val)); |
5900 | 3952 } |
3953 | |
3954 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
|
3955 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
|
3956 { |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3957 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
|
3958 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3959 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3960 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3961 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
|
3962 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3963 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, ndims, dims)); |
5900 | 3964 } |
3965 | |
3966 mxArray * | |
6686 | 3967 mxCreateLogicalArray (mwSize ndims, const mwSize *dims) |
5864 | 3968 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3969 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
|
3970 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3971 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3972 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3973 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
|
3974 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3975 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n)); |
5900 | 3976 } |
3977 | |
3978 mxArray * | |
6686 | 3979 mxCreateLogicalMatrix (mwSize m, mwSize n) |
5900 | 3980 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3981 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
|
3982 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3983 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3984 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3985 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
|
3986 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3987 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, val)); |
5900 | 3988 } |
3989 | |
3990 mxArray * | |
7577
ba8fcc115fee
mex.cc: arg to mxCreateLogicalScalar is now mxLogical
John W. Eaton <jwe@octave.org>
parents:
7357
diff
changeset
|
3991 mxCreateLogicalScalar (mxLogical val) |
5900 | 3992 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3993 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
|
3994 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3995 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3996 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3997 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
|
3998 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
|
3999 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4000 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag)); |
5900 | 4001 } |
4002 | |
4003 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
|
4004 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
|
4005 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
|
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 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
|
4008 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4009 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4010 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4011 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
|
4012 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
|
4013 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4014 return maybe_mark_array (new mxArray (true, class_id, m, n, flag)); |
5864 | 4015 } |
4016 | |
5900 | 4017 mxArray * |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4018 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
|
4019 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
|
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 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
|
4022 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4023 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4024 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4025 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
|
4026 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
|
4027 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4028 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
|
4029 false)); |
5900 | 4030 } |
4031 | |
4032 mxArray * | |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4033 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
|
4034 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
|
4035 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4036 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
|
4037 false)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4038 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4039 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4040 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4041 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
|
4042 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
|
4043 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4044 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
|
4045 } |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4046 |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4047 mxArray * |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4048 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
|
4049 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
|
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 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
|
4052 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4053 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4054 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4055 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
|
4056 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4057 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
|
4058 flag)); |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4059 } |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4060 |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4061 mxArray * |
6686 | 4062 mxCreateSparse (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag) |
5900 | 4063 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4064 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
|
4065 flag)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4066 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4067 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4068 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4069 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
|
4070 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4071 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n, nzmax)); |
5900 | 4072 } |
4073 | |
4074 mxArray * | |
6686 | 4075 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax) |
5900 | 4076 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4077 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
|
4078 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4079 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4080 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4081 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
|
4082 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4083 return maybe_mark_array (new mxArray (true, str)); |
5900 | 4084 } |
4085 | |
4086 mxArray * | |
4087 mxCreateString (const char *str) | |
4088 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4089 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
|
4090 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4091 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4092 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4093 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
|
4094 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
|
4095 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4096 return maybe_mark_array (new mxArray (true, ndims, dims, num_keys, keys)); |
5900 | 4097 } |
4098 | |
4099 mxArray * | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4100 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
|
4101 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
|
4102 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4103 return maybe_mark_array (new mxArray (false, ndims, dims, num_keys, keys)); |
5900 | 4104 } |
5864 | 4105 |
4106 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
|
4107 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
|
4108 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
|
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 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
|
4111 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4112 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4113 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4114 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
|
4115 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
|
4116 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4117 return maybe_mark_array (new mxArray (false, m, n, num_keys, keys)); |
5900 | 4118 } |
4119 | |
4120 // Copy constructor. | |
4121 mxArray * | |
4122 mxDuplicateArray (const mxArray *ptr) | |
4123 { | |
11277
7d5351fc575a
mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents:
11276
diff
changeset
|
4124 return maybe_mark_array (ptr->dup ()); |
5900 | 4125 } |
4126 | |
4127 // Destructor. | |
4128 void | |
4129 mxDestroyArray (mxArray *ptr) | |
4130 { | |
6065 | 4131 if (! (mex_context && mex_context->free_value (ptr))) |
4132 delete ptr; | |
5900 | 4133 } |
4134 | |
4135 // 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
|
4136 bool |
5900 | 4137 mxIsCell (const mxArray *ptr) |
4138 { | |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
4139 return ptr->iscell (); |
5900 | 4140 } |
4141 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4142 bool |
5900 | 4143 mxIsChar (const mxArray *ptr) |
4144 { | |
4145 return ptr->is_char (); | |
4146 } | |
4147 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4148 bool |
5900 | 4149 mxIsClass (const mxArray *ptr, const char *name) |
4150 { | |
4151 return ptr->is_class (name); | |
4152 } | |
4153 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4154 bool |
5900 | 4155 mxIsComplex (const mxArray *ptr) |
4156 { | |
4157 return ptr->is_complex (); | |
4158 } | |
4159 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4160 bool |
5900 | 4161 mxIsDouble (const mxArray *ptr) |
4162 { | |
4163 return ptr->is_double (); | |
4164 } | |
4165 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4166 bool |
11100
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4167 mxIsFunctionHandle (const mxArray *ptr) |
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 return ptr->is_function_handle (); |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4170 } |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4171 |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4172 bool |
5900 | 4173 mxIsInt16 (const mxArray *ptr) |
4174 { | |
4175 return ptr->is_int16 (); | |
4176 } | |
4177 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4178 bool |
5900 | 4179 mxIsInt32 (const mxArray *ptr) |
4180 { | |
4181 return ptr->is_int32 (); | |
4182 } | |
4183 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4184 bool |
5900 | 4185 mxIsInt64 (const mxArray *ptr) |
4186 { | |
4187 return ptr->is_int64 (); | |
4188 } | |
4189 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4190 bool |
5900 | 4191 mxIsInt8 (const mxArray *ptr) |
4192 { | |
4193 return ptr->is_int8 (); | |
4194 } | |
4195 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4196 bool |
5900 | 4197 mxIsLogical (const mxArray *ptr) |
4198 { | |
4199 return ptr->is_logical (); | |
4200 } | |
4201 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4202 bool |
5900 | 4203 mxIsNumeric (const mxArray *ptr) |
4204 { | |
4205 return ptr->is_numeric (); | |
4206 } | |
4207 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4208 bool |
5900 | 4209 mxIsSingle (const mxArray *ptr) |
4210 { | |
4211 return ptr->is_single (); | |
4212 } | |
4213 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4214 bool |
5900 | 4215 mxIsSparse (const mxArray *ptr) |
4216 { | |
4217 return ptr->is_sparse (); | |
4218 } | |
4219 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4220 bool |
5900 | 4221 mxIsStruct (const mxArray *ptr) |
4222 { | |
4223 return ptr->is_struct (); | |
4224 } | |
4225 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4226 bool |
5900 | 4227 mxIsUint16 (const mxArray *ptr) |
4228 { | |
4229 return ptr->is_uint16 (); | |
4230 } | |
4231 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4232 bool |
5900 | 4233 mxIsUint32 (const mxArray *ptr) |
4234 { | |
4235 return ptr->is_uint32 (); | |
4236 } | |
4237 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4238 bool |
5900 | 4239 mxIsUint64 (const mxArray *ptr) |
4240 { | |
4241 return ptr->is_uint64 (); | |
4242 } | |
4243 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4244 bool |
5900 | 4245 mxIsUint8 (const mxArray *ptr) |
4246 { | |
4247 return ptr->is_uint8 (); | |
4248 } | |
4249 | |
4250 // 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
|
4251 bool |
5900 | 4252 mxIsLogicalScalar (const mxArray *ptr) |
4253 { | |
4254 return ptr->is_logical_scalar (); | |
4255 } | |
4256 | |
4257 // 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
|
4258 bool |
5900 | 4259 mxIsLogicalScalarTrue (const mxArray *ptr) |
4260 { | |
4261 return ptr->is_logical_scalar_true (); | |
4262 } | |
4263 | |
4264 // 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
|
4265 bool |
5900 | 4266 mxIsEmpty (const mxArray *ptr) |
4267 { | |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
4268 return ptr->isempty (); |
5900 | 4269 } |
4270 | |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4271 bool |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4272 mxIsScalar (const mxArray *ptr) |
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 return ptr->is_scalar (); |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4275 } |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4276 |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4277 // 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
|
4278 // 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
|
4279 bool |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4280 mxIsFromGlobalWS (const mxArray * /*ptr*/) |
5900 | 4281 { |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4282 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
|
4283 |
5900 | 4284 return 0; |
4285 } | |
4286 | |
4287 // 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
|
4288 std::size_t |
5900 | 4289 mxGetM (const mxArray *ptr) |
4290 { | |
4291 return ptr->get_m (); | |
4292 } | |
4293 | |
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
|
4294 std::size_t |
5900 | 4295 mxGetN (const mxArray *ptr) |
4296 { | |
4297 return ptr->get_n (); | |
4298 } | |
4299 | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4300 const mwSize * |
5900 | 4301 mxGetDimensions (const mxArray *ptr) |
5864 | 4302 { |
5900 | 4303 return ptr->get_dimensions (); |
4304 } | |
4305 | |
6686 | 4306 mwSize |
5900 | 4307 mxGetNumberOfDimensions (const mxArray *ptr) |
4308 { | |
4309 return ptr->get_number_of_dimensions (); | |
4310 } | |
4311 | |
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
|
4312 std::size_t |
5900 | 4313 mxGetNumberOfElements (const mxArray *ptr) |
4314 { | |
4315 return ptr->get_number_of_elements (); | |
4316 } | |
4317 | |
4318 // Dimension setters. | |
4319 void | |
6686 | 4320 mxSetM (mxArray *ptr, mwSize m) |
5900 | 4321 { |
4322 ptr->set_m (m); | |
4323 } | |
4324 | |
4325 void | |
6686 | 4326 mxSetN (mxArray *ptr, mwSize n) |
5900 | 4327 { |
4328 ptr->set_n (n); | |
4329 } | |
4330 | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4331 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
|
4332 mxSetDimensions (mxArray *ptr, const mwSize *dims, mwSize ndims) |
5900 | 4333 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4334 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
|
4335 (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
|
4336 ndims)); |
5900 | 4337 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
4338 |
5900 | 4339 // Data extractors. |
4340 double * | |
4341 mxGetPr (const mxArray *ptr) | |
4342 { | |
4343 return static_cast<double *> (ptr->get_data ()); | |
4344 } | |
4345 | |
4346 double | |
4347 mxGetScalar (const mxArray *ptr) | |
4348 { | |
6332 | 4349 return ptr->get_scalar (); |
5900 | 4350 } |
4351 | |
4352 mxChar * | |
4353 mxGetChars (const mxArray *ptr) | |
4354 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4355 if (mxIsChar (ptr)) |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4356 return static_cast<mxChar *> (ptr->get_data ()); |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4357 else |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4358 return nullptr; |
5900 | 4359 } |
4360 | |
4361 mxLogical * | |
4362 mxGetLogicals (const mxArray *ptr) | |
4363 { | |
4364 return static_cast<mxLogical *> (ptr->get_data ()); | |
4365 } | |
4366 | |
4367 void * | |
4368 mxGetData (const mxArray *ptr) | |
4369 { | |
4370 return ptr->get_data (); | |
4371 } | |
4372 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4373 double * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4374 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
|
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 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
|
4377 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4378 |
5900 | 4379 void * |
4380 mxGetImagData (const mxArray *ptr) | |
4381 { | |
4382 return ptr->get_imag_data (); | |
4383 } | |
4384 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4385 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
|
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 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
|
4388 } |
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 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
|
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 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
|
4393 } |
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 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
|
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 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
|
4398 } |
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 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
|
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 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
|
4403 } |
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 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
|
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 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
|
4408 } |
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 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
|
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 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
|
4413 } |
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 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
|
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 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
|
4418 } |
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 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
|
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 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
|
4423 } |
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 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
|
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 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
|
4428 } |
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 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
|
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 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
|
4433 } |
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 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
|
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 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
|
4438 } |
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 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
|
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 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
|
4443 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4444 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4445 #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
|
4446 /* 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
|
4447 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
|
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 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
|
4450 } |
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 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
|
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 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
|
4455 } |
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 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
|
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 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
|
4460 } |
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 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
|
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 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
|
4465 } |
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 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
|
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 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
|
4470 } |
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 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
|
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 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
|
4475 } |
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 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
|
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 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
|
4480 } |
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 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
|
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 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
|
4485 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4486 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4487 |
5900 | 4488 // Data setters. |
4489 void | |
4490 mxSetPr (mxArray *ptr, double *pr) | |
4491 { | |
7172 | 4492 ptr->set_data (maybe_unmark (pr)); |
5900 | 4493 } |
4494 | |
4495 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
|
4496 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
|
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 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
|
4499 } |
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 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
|
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 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
|
4504 } |
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 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
|
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 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
|
4509 } |
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 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
|
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 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
|
4514 } |
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 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
|
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 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
|
4519 } |
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 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
|
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 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
|
4524 } |
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 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
|
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 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
|
4529 } |
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 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
|
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 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
|
4534 } |
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 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
|
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 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
|
4539 } |
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 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
|
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 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
|
4544 } |
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 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
|
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 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
|
4549 } |
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 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
|
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 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
|
4554 } |
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 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
|
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 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
|
4559 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4560 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4561 #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
|
4562 /* 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
|
4563 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
|
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 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
|
4566 } |
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 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
|
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 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
|
4571 } |
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 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
|
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 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
|
4576 } |
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 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
|
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 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
|
4581 } |
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 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
|
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 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
|
4586 } |
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 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
|
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 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
|
4591 } |
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 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
|
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 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
|
4596 } |
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 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
|
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 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
|
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 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4603 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4604 void |
5900 | 4605 mxSetPi (mxArray *ptr, double *pi) |
4606 { | |
7172 | 4607 ptr->set_imag_data (maybe_unmark (pi)); |
5864 | 4608 } |
4609 | |
5900 | 4610 void |
4611 mxSetImagData (mxArray *ptr, void *pi) | |
4612 { | |
7172 | 4613 ptr->set_imag_data (maybe_unmark (pi)); |
5900 | 4614 } |
4615 | |
4616 // Classes. | |
4617 mxClassID | |
4618 mxGetClassID (const mxArray *ptr) | |
4619 { | |
4620 return ptr->get_class_id (); | |
4621 } | |
4622 | |
4623 const char * | |
4624 mxGetClassName (const mxArray *ptr) | |
4625 { | |
4626 return ptr->get_class_name (); | |
4627 } | |
4628 | |
4629 void | |
4630 mxSetClassName (mxArray *ptr, const char *name) | |
4631 { | |
4632 ptr->set_class_name (name); | |
4633 } | |
4634 | |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4635 void |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4636 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
|
4637 const mxArray *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 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
|
4640 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4641 |
23891
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4642 mxArray * |
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4643 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
|
4644 { |
23891
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4645 return ptr->get_property (idx, property_name); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4646 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4647 |
5900 | 4648 // Cell support. |
4649 mxArray * | |
6686 | 4650 mxGetCell (const mxArray *ptr, mwIndex idx) |
5900 | 4651 { |
4652 return ptr->get_cell (idx); | |
4653 } | |
4654 | |
4655 void | |
6686 | 4656 mxSetCell (mxArray *ptr, mwIndex idx, mxArray *val) |
5900 | 4657 { |
4658 ptr->set_cell (idx, val); | |
4659 } | |
4660 | |
4661 // Sparse support. | |
6686 | 4662 mwIndex * |
5900 | 4663 mxGetIr (const mxArray *ptr) |
4664 { | |
4665 return ptr->get_ir (); | |
4666 } | |
4667 | |
6686 | 4668 mwIndex * |
5900 | 4669 mxGetJc (const mxArray *ptr) |
4670 { | |
4671 return ptr->get_jc (); | |
4672 } | |
4673 | |
6686 | 4674 mwSize |
5900 | 4675 mxGetNzmax (const mxArray *ptr) |
4676 { | |
4677 return ptr->get_nzmax (); | |
4678 } | |
4679 | |
4680 void | |
6686 | 4681 mxSetIr (mxArray *ptr, mwIndex *ir) |
5900 | 4682 { |
19739
3fa35defe495
Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
4683 ptr->set_ir (static_cast<mwIndex *> (maybe_unmark (ir))); |
5900 | 4684 } |
4685 | |
4686 void | |
6686 | 4687 mxSetJc (mxArray *ptr, mwIndex *jc) |
5900 | 4688 { |
7172 | 4689 ptr->set_jc (static_cast<mwIndex *> (maybe_unmark (jc))); |
5900 | 4690 } |
4691 | |
4692 void | |
6686 | 4693 mxSetNzmax (mxArray *ptr, mwSize nzmax) |
5900 | 4694 { |
4695 ptr->set_nzmax (nzmax); | |
4696 } | |
4697 | |
4698 // Structure support. | |
4699 int | |
4700 mxAddField (mxArray *ptr, const char *key) | |
4701 { | |
4702 return ptr->add_field (key); | |
4703 } | |
4704 | |
4705 void | |
4706 mxRemoveField (mxArray *ptr, int key_num) | |
4707 { | |
4708 ptr->remove_field (key_num); | |
4709 } | |
5864 | 4710 |
4711 mxArray * | |
6686 | 4712 mxGetField (const mxArray *ptr, mwIndex index, const char *key) |
5900 | 4713 { |
4714 int key_num = mxGetFieldNumber (ptr, key); | |
4715 return mxGetFieldByNumber (ptr, index, key_num); | |
4716 } | |
4717 | |
4718 mxArray * | |
6686 | 4719 mxGetFieldByNumber (const mxArray *ptr, mwIndex index, int key_num) |
5864 | 4720 { |
5900 | 4721 return ptr->get_field_by_number (index, key_num); |
5864 | 4722 } |
4723 | |
5900 | 4724 void |
6686 | 4725 mxSetField (mxArray *ptr, mwIndex index, const char *key, mxArray *val) |
5900 | 4726 { |
4727 int key_num = mxGetFieldNumber (ptr, key); | |
4728 mxSetFieldByNumber (ptr, index, key_num, val); | |
4729 } | |
5864 | 4730 |
4731 void | |
6686 | 4732 mxSetFieldByNumber (mxArray *ptr, mwIndex index, int key_num, mxArray *val) |
5864 | 4733 { |
5900 | 4734 ptr->set_field_by_number (index, key_num, val); |
4735 } | |
4736 | |
4737 int | |
4738 mxGetNumberOfFields (const mxArray *ptr) | |
4739 { | |
4740 return ptr->get_number_of_fields (); | |
5864 | 4741 } |
4742 | |
5900 | 4743 const char * |
4744 mxGetFieldNameByNumber (const mxArray *ptr, int key_num) | |
5864 | 4745 { |
5900 | 4746 return ptr->get_field_name_by_number (key_num); |
4747 } | |
4748 | |
4749 int | |
4750 mxGetFieldNumber (const mxArray *ptr, const char *key) | |
4751 { | |
4752 return ptr->get_field_number (key); | |
5864 | 4753 } |
4754 | |
5900 | 4755 int |
6686 | 4756 mxGetString (const mxArray *ptr, char *buf, mwSize buflen) |
5900 | 4757 { |
4758 return ptr->get_string (buf, buflen); | |
4759 } | |
4760 | |
4761 char * | |
4762 mxArrayToString (const mxArray *ptr) | |
5864 | 4763 { |
5900 | 4764 return ptr->array_to_string (); |
4765 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
4766 |
6686 | 4767 mwIndex |
4768 mxCalcSingleSubscript (const mxArray *ptr, mwSize nsubs, mwIndex *subs) | |
5900 | 4769 { |
4770 return ptr->calc_single_subscript (nsubs, subs); | |
5864 | 4771 } |
5900 | 4772 |
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
|
4773 std::size_t |
5900 | 4774 mxGetElementSize (const mxArray *ptr) |
4775 { | |
4776 return ptr->get_element_size (); | |
4777 } | |
4778 | |
4779 // ------------------------------------------------------------------ | |
5864 | 4780 |
4781 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
|
4782 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
|
4783 F77_INT& nrhs, mxArray **prhs); |
5864 | 4784 |
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
|
4785 OCTAVE_NAMESPACE_BEGIN |
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
|
4786 |
5864 | 4787 octave_value_list |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4788 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
|
4789 int nargout_arg) |
5864 | 4790 { |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4791 octave_quit (); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4792 |
5900 | 4793 // Use at least 1 for nargout since even for zero specified args, |
4794 // still want to be able to return an ans. | |
5864 | 4795 |
8806 | 4796 volatile int nargout = nargout_arg; |
4797 | |
5864 | 4798 int nargin = args.length (); |
5900 | 4799 OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin); |
5864 | 4800 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
|
4801 argin[i] = nullptr; |
5864 | 4802 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
4803 int nout = (nargout == 0 ? 1 : nargout); |
5900 | 4804 OCTAVE_LOCAL_BUFFER (mxArray *, argout, nout); |
5864 | 4805 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
|
4806 argout[i] = nullptr; |
5864 | 4807 |
5905 | 4808 // Save old mex pointer. |
28823
26cfccfee9a0
Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents:
28370
diff
changeset
|
4809 octave::unwind_protect_var<mex *> restore_var (mex_context); |
5905 | 4810 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4811 mex context (mex_fcn); |
5900 | 4812 |
5864 | 4813 for (int i = 0; i < nargin; i++) |
4814 argin[i] = context.make_value (args(i)); | |
4815 | |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4816 mex_context = &context; |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4817 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4818 void *mex_fcn_ptr = mex_fcn.mex_fcn_ptr (); |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4819 |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4820 if (mex_fcn.is_fmex ()) |
5864 | 4821 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4822 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
|
4823 |
23498
647705ffb110
use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
4824 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
|
4825 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
|
4826 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4827 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
|
4828 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4829 else |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4830 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4831 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
|
4832 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4833 fcn (nargout, argout, nargin, argin); |
5864 | 4834 } |
4835 | |
4836 // Convert returned array entries back into octave values. | |
4837 | |
4838 octave_value_list retval; | |
4839 | |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4840 if (nargout == 0 && argout[0]) |
5864 | 4841 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4842 // We have something for ans. |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4843 nargout = 1; |
5864 | 4844 } |
4845 | |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4846 retval.resize (nargout); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4847 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4848 // 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
|
4849 // 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
|
4850 // 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
|
4851 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4852 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
|
4853 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
|
4854 |
5864 | 4855 return retval; |
4856 } | |
4857 | |
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
|
4858 OCTAVE_NAMESPACE_END |
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
|
4859 |
5864 | 4860 // C interface to mex functions: |
4861 | |
4862 const char * | |
4863 mexFunctionName (void) | |
4864 { | |
5900 | 4865 return mex_context ? mex_context->function_name () : "unknown"; |
4866 } | |
4867 | |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4868 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
|
4869 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
|
4870 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4871 // 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
|
4872 // 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
|
4873 // 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
|
4874 // 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
|
4875 // 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
|
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 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
|
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 #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
|
4880 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4881 // 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
|
4882 // 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
|
4883 // 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
|
4884 // 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
|
4885 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4886 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
|
4887 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
|
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 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4890 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4891 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
|
4892 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
|
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 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
|
4895 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4896 |
5900 | 4897 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
|
4898 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
|
4899 mxArray *argin[], const char *fname) |
5900 | 4900 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4901 octave_value_list args = mx_to_ov_args (nargin, argin); |
5900 | 4902 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
4903 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
|
4904 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4905 bool execution_error = false; |
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 octave_value_list retval; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4908 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4909 try |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4910 { |
29172
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4911 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
|
4912 |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4913 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
|
4914 ([&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
|
4915 { |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4916 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
|
4917 }, tw.lvalue_list ()); |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4918 |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4919 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
|
4920 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
4921 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
|
4922 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4923 catch (const octave::execution_exception&) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4924 { |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4925 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
|
4926 { |
27471 | 4927 // FIXME: is there a way to indicate what error occurred? |
4928 // Should the error message be displayed here? Do we need to | |
4929 // save the exception info for lasterror? | |
4930 | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4931 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
|
4932 |
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4933 execution_error = true; |
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4934 } |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4935 else |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4936 { |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4937 args.resize (0); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4938 retval.resize (0); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4939 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4940 throw; |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4941 } |
5900 | 4942 } |
4943 | |
4944 int num_to_copy = retval.length (); | |
4945 | |
4946 if (nargout < retval.length ()) | |
4947 num_to_copy = nargout; | |
4948 | |
4949 for (int i = 0; i < num_to_copy; i++) | |
4950 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4951 // FIXME: it would be nice to avoid copying the value here, |
5900 | 4952 // but there is no way to steal memory from a matrix, never mind |
4953 // that matrix memory is allocated by new[] and mxArray memory | |
4954 // 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
|
4955 argout[i] = mex_context->make_value (retval(i)); |
5900 | 4956 } |
4957 | |
4958 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
|
4959 argout[num_to_copy++] = nullptr; |
5900 | 4960 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4961 return execution_error ? 1 : 0; |
5900 | 4962 } |
4963 | |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4964 mxArray * |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4965 mexCallMATLABWithTrap (int nargout, mxArray *argout[], int nargin, |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4966 mxArray *argin[], const char *fname) |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4967 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4968 mxArray *mx = nullptr; |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4969 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
4970 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
|
4971 mexSetTrapFlag (1); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4972 if (mexCallMATLAB (nargout, argout, nargin, argin, fname)) |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4973 { |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4974 const char *field_names[] = {"identifier", "message", "case", "stack"}; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4975 mx = mxCreateStructMatrix (1, 1, 4, field_names); |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4976 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX")); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4977 std::string msg = "mexCallMATLABWithTrap: function call <" |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4978 + std::string (fname) + "> failed"; |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4979 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ())); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4980 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
|
4981 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
|
4982 } |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4983 mexSetTrapFlag (old_flag); |
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 return mx; |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4986 } |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4987 |
5900 | 4988 void |
4989 mexSetTrapFlag (int flag) | |
4990 { | |
4991 if (mex_context) | |
4992 mex_context->trap_feval_error = flag; | |
4993 } | |
4994 | |
4995 int | |
4996 mexEvalString (const char *s) | |
4997 { | |
4998 int retval = 0; | |
4999 | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5000 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
|
5001 |
5900 | 5002 int parse_status; |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5003 bool execution_error = false; |
5900 | 5004 |
5005 octave_value_list ret; | |
5006 | |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5007 try |
5900 | 5008 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25922
diff
changeset
|
5009 ret = interp.eval_string (std::string (s), false, parse_status, 0); |
5900 | 5010 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5011 catch (const octave::execution_exception&) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5012 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5013 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
|
5014 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5015 execution_error = true; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5016 } |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5017 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5018 if (parse_status || execution_error) |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5019 retval = 1; |
5864 | 5020 |
5021 return retval; | |
5022 } | |
5023 | |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5024 mxArray * |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5025 mexEvalStringWithTrap (const char *s) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5026 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5027 mxArray *mx = nullptr; |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5028 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5029 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
|
5030 |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5031 int parse_status; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5032 bool execution_error = false; |
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 octave_value_list ret; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5035 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5036 try |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5037 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25922
diff
changeset
|
5038 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
|
5039 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5040 catch (const octave::execution_exception&) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5041 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5042 interp.recover_from_exception (); |
22454
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 execution_error = true; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5045 } |
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 if (parse_status || execution_error) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5048 { |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5049 const char *field_names[] = {"identifier", "message", "case", "stack"}; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5050 mx = mxCreateStructMatrix (1, 1, 4, field_names); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5051 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX")); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5052 std::string msg = "mexEvalStringWithTrap: eval of <" |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5053 + std::string (s) + "> failed"; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5054 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ())); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5055 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
|
5056 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
|
5057 } |
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 return mx; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5060 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5061 |
5864 | 5062 void |
5063 mexErrMsgTxt (const char *s) | |
5064 { | |
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
|
5065 std::size_t len; |
25751
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 = strlen (s)) > 0) |
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 if (s[len - 1] == '\n') |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5070 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5071 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
|
5072 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
|
5073 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5074 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5075 error ("%s: %s", mexFunctionName (), s); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5076 } |
5864 | 5077 else |
16851
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5078 { |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5079 // 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
|
5080 // 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
|
5081 error (" "); |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5082 } |
5864 | 5083 } |
5084 | |
5879 | 5085 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
|
5086 mexErrMsgIdAndTxt (const char *id, const char *fmt, ...) |
5879 | 5087 { |
6338 | 5088 if (fmt && strlen (fmt) > 0) |
5089 { | |
5090 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
|
5091 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1; |
6338 | 5092 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); |
5093 sprintf (tmpfmt, "%s: %s", fname, fmt); | |
5094 va_list args; | |
5095 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
|
5096 verror_with_id (id, tmpfmt, args); |
6338 | 5097 va_end (args); |
5098 } | |
5879 | 5099 else |
16851
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5100 { |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5101 // 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
|
5102 // 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
|
5103 error (" "); |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5104 } |
5879 | 5105 } |
5106 | |
5107 void | |
5108 mexWarnMsgTxt (const char *s) | |
5109 { | |
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
|
5110 std::size_t len; |
25751
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 = strlen (s)) > 0) |
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 if (s[len - 1] == '\n') |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5115 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5116 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
|
5117 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
|
5118 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5119 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5120 warning ("%s", s); |
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 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5123 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5124 // 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
|
5125 // 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
|
5126 warning (" "); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5127 } |
5879 | 5128 } |
5129 | |
5130 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
|
5131 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...) |
5879 | 5132 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5133 // 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
|
5134 // an empty string? |
6338 | 5135 |
5136 if (fmt && strlen (fmt) > 0) | |
5137 { | |
5138 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
|
5139 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1; |
6338 | 5140 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); |
5141 sprintf (tmpfmt, "%s: %s", fname, fmt); | |
5142 va_list args; | |
5143 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
|
5144 vwarning_with_id (id, tmpfmt, args); |
6338 | 5145 va_end (args); |
5146 } | |
5879 | 5147 } |
5864 | 5148 |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5149 int |
5864 | 5150 mexPrintf (const char *fmt, ...) |
5151 { | |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5152 int retval; |
5864 | 5153 va_list args; |
5154 va_start (args, fmt); | |
25646
4d565baa475e
move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25452
diff
changeset
|
5155 retval = octave::vformat (octave_stdout, fmt, args); |
5864 | 5156 va_end (args); |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5157 return retval; |
5864 | 5158 } |
5159 | |
5160 mxArray * | |
5879 | 5161 mexGetVariable (const char *space, const char *name) |
5864 | 5162 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5163 mxArray *retval = nullptr; |
5864 | 5164 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5165 octave_value val; |
5864 | 5166 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5167 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
|
5168 |
5864 | 5169 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
|
5170 val = interp.global_varval (name); |
5864 | 5171 else |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5172 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5173 // 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
|
5174 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
5175 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
|
5176 |
7901 | 5177 bool caller = ! strcmp (space, "caller"); |
5178 bool base = ! strcmp (space, "base"); | |
5179 | |
5180 if (caller || base) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5181 { |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5182 // 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
|
5183 // 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
|
5184 |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5185 if (base) |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5186 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5187 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
|
5188 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5189 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
|
5190 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
|
5191 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5192 tw.goto_base_frame (); |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5193 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5194 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5195 val = interp.varval (name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5196 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5197 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5198 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
|
5199 } |
7336 | 5200 |
5201 if (val.is_defined ()) | |
5864 | 5202 { |
7336 | 5203 retval = mex_context->make_value (val); |
5204 | |
5205 retval->set_name (name); | |
5864 | 5206 } |
5207 | |
5208 return retval; | |
5209 } | |
5210 | |
5879 | 5211 const mxArray * |
5212 mexGetVariablePtr (const char *space, const char *name) | |
5864 | 5213 { |
5879 | 5214 return mexGetVariable (space, name); |
5864 | 5215 } |
5216 | |
5900 | 5217 int |
15353
5f3a69a309a7
fix decl of mexPutVariable
John W. Eaton <jwe@octave.org>
parents:
15351
diff
changeset
|
5218 mexPutVariable (const char *space, const char *name, const mxArray *ptr) |
5864 | 5219 { |
5900 | 5220 if (! ptr) |
5221 return 1; | |
5222 | |
5223 if (! name) | |
5224 return 1; | |
5225 | |
5226 if (name[0] == '\0') | |
5227 name = ptr->get_name (); | |
5228 | |
5229 if (! name || name[0] == '\0') | |
5230 return 1; | |
5231 | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5232 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
|
5233 |
5900 | 5234 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
|
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 #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
|
5237 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5238 // 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
|
5239 // 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
|
5240 // 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
|
5241 // 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
|
5242 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5243 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
|
5244 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
|
5245 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5246 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5247 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
|
5248 } |
5900 | 5249 else |
5250 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5251 // FIXME: should this be in variables.cc? |
7336 | 5252 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
5253 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
|
5254 |
7901 | 5255 bool caller = ! strcmp (space, "caller"); |
5256 bool base = ! strcmp (space, "base"); | |
5257 | |
5258 if (caller || base) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5259 { |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5260 // 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
|
5261 // 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
|
5262 |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5263 if (base) |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5264 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5265 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
|
5266 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5267 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
|
5268 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
|
5269 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5270 tw.goto_base_frame (); |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5271 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5272 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5273 #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
|
5274 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5275 // 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
|
5276 // 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
|
5277 // 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
|
5278 // 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
|
5279 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5280 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
|
5281 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
|
5282 &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
|
5283 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5284 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5285 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
|
5286 } |
5900 | 5287 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5288 mexErrMsgTxt ("mexPutVariable: symbol table does not exist"); |
5900 | 5289 } |
5290 | |
5291 return 0; | |
5864 | 5292 } |
5293 | |
5294 void | |
5900 | 5295 mexMakeArrayPersistent (mxArray *ptr) |
5864 | 5296 { |
7172 | 5297 maybe_unmark_array (ptr); |
5864 | 5298 } |
5879 | 5299 |
5864 | 5300 void |
5900 | 5301 mexMakeMemoryPersistent (void *ptr) |
5864 | 5302 { |
7172 | 5303 maybe_unmark (ptr); |
5864 | 5304 } |
5305 | |
5900 | 5306 int |
6068 | 5307 mexAtExit (void (*f) (void)) |
5864 | 5308 { |
6068 | 5309 if (mex_context) |
5310 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5311 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
|
5312 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5313 curr_mex_fcn.atexit (f); |
6068 | 5314 } |
5315 | |
5900 | 5316 return 0; |
5864 | 5317 } |
5318 | |
5900 | 5319 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
|
5320 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
|
5321 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5322 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
|
5323 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5324 octave_value ret |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5325 = 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
|
5326 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5327 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
|
5328 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
|
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 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
|
5331 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5332 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5333 const mxArray * |
6595 | 5334 mexGet (double handle, const char *property) |
5864 | 5335 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5336 mxArray *m = nullptr; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5337 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5338 octave_value ret |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5339 = octave::get_property_from_handle (handle, property, "mexGet"); |
6595 | 5340 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5341 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
|
5342 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
|
5343 |
6595 | 5344 return m; |
5864 | 5345 } |
5346 | |
5900 | 5347 int |
5348 mexIsGlobal (const mxArray *ptr) | |
5864 | 5349 { |
5900 | 5350 return mxIsFromGlobalWS (ptr); |
5864 | 5351 } |
5352 | |
5900 | 5353 int |
5354 mexIsLocked (void) | |
5864 | 5355 { |
5900 | 5356 int retval = 0; |
5357 | |
5358 if (mex_context) | |
5359 { | |
5360 const char *fname = mexFunctionName (); | |
5361 | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5362 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
|
5363 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5364 retval = interp.mislocked (fname); |
5900 | 5365 } |
5366 | |
5367 return retval; | |
5864 | 5368 } |
5369 | |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30349
diff
changeset
|
5370 std::map<std::string, int> mex_lock_count; |
5900 | 5371 |
5372 void | |
5373 mexLock (void) | |
5864 | 5374 { |
5900 | 5375 if (mex_context) |
5864 | 5376 { |
5900 | 5377 const char *fname = mexFunctionName (); |
5378 | |
5379 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
|
5380 mex_lock_count[fname] = 1; |
5900 | 5381 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5382 mex_lock_count[fname]++; |
5900 | 5383 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5384 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
|
5385 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5386 interp.mlock (); |
5864 | 5387 } |
5388 } | |
5389 | |
5900 | 5390 int |
6595 | 5391 mexSet (double handle, const char *property, mxArray *val) |
5900 | 5392 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5393 #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
|
5394 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5395 // 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
|
5396 // 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
|
5397 // 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
|
5398 // 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
|
5399 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5400 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
|
5401 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
|
5402 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5403 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5404 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5405 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
|
5406 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
|
5407 "mexSet"); |
6595 | 5408 return (ret ? 0 : 1); |
5900 | 5409 } |
5410 | |
5411 void | |
5412 mexUnlock (void) | |
5864 | 5413 { |
5900 | 5414 if (mex_context) |
5864 | 5415 { |
5900 | 5416 const char *fname = mexFunctionName (); |
5417 | |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
5418 auto p = mex_lock_count.find (fname); |
5905 | 5419 |
6062 | 5420 if (p != mex_lock_count.end ()) |
10315
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 int count = --mex_lock_count[fname]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5423 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5424 if (count == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5425 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
5426 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
|
5427 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5428 interp.munlock (fname); |
10315
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 mex_lock_count.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5431 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5432 } |
5864 | 5433 } |
5434 } |