Mercurial > octave
annotate libinterp/corefcn/mex.cc @ 30793:85a580a6b292
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 28 Feb 2022 14:04:03 -0500 |
parents | 9a95ccd6c417 4fc0b7269803 |
children | 4ed7dfe28584 |
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 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
453 static inline void maybe_disown_ptr (void *ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
454 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
455 #define VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
456 void FCN_NAME ARG_LIST { request_mutation (); } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
457 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
458 #define CONST_VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
459 void FCN_NAME ARG_LIST const { request_mutation (); } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
460 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
461 #define MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
462 RET_TYPE FCN_NAME ARG_LIST { request_mutation (); return RET_VAL; } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
463 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
464 #define CONST_MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
465 RET_TYPE FCN_NAME ARG_LIST const { request_mutation (); return RET_VAL; } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
466 |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
467 #define GET_DATA_METHOD(RT, FCN_NAME, ID, COMPLEXITY) \ |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
468 RT * FCN_NAME (void) const { return get_data<RT> (ID, COMPLEXITY); } |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
469 |
5900 | 470 class mxArray_octave_value : public mxArray_base |
471 { | |
472 public: | |
473 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
474 mxArray_octave_value (bool interleaved, const octave_value& ov) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
475 : mxArray_base (interleaved), m_val (ov), m_mutate_flag (false), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
476 m_id (mxUNKNOWN_CLASS), m_class_name (nullptr), m_ndims (-1), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
477 m_dims (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
478 { } |
5900 | 479 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
480 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
481 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
482 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
483 mxArray_octave_value& operator = (const mxArray_octave_value&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
484 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
485 mxArray_base * dup (void) const { return new mxArray_octave_value (*this); } |
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
486 |
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
487 mxArray * as_mxArray (void) const |
12331
f39436e14734
mex.cc (mxArray_octave_value::dup): if value can't be converted to mxArray object, create a clone of the mxArray_octave_value container
John W. Eaton <jwe@octave.org>
parents:
12123
diff
changeset
|
488 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
489 mxArray *retval = m_val.as_mxArray (m_interleaved); |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
490 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
491 // RETVAL is assumed to be an mxArray_matlab object. Should we |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
492 // error_unless that condition here? |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
493 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
494 if (retval) |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
495 { |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
496 // Preserve cached values of class name and dimensions in case |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
497 // they will be used after we mutate. |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
498 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
499 // set_class_name will handle deleting class name that comes |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
500 // from as_mxArray conversion function. |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
501 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
502 if (m_class_name) |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
503 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
504 retval->set_class_name (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
505 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
506 m_class_name = nullptr; |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
507 } |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
508 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
509 if (m_dims) |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
510 { |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
511 mwSize *xdims = retval->get_dimensions (); |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
512 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
513 mxFree (xdims); |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
514 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
515 retval->set_dimensions (m_dims, m_ndims); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
516 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
517 m_dims = nullptr; |
17810
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
518 } |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
519 } |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
520 |
6da521da1c70
preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
521 return retval; |
12331
f39436e14734
mex.cc (mxArray_octave_value::dup): if value can't be converted to mxArray object, create a clone of the mxArray_octave_value container
John W. Eaton <jwe@octave.org>
parents:
12123
diff
changeset
|
522 } |
5900 | 523 |
524 ~mxArray_octave_value (void) | |
525 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
526 mxFree (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
527 mxFree (m_dims); |
5900 | 528 } |
529 | |
530 bool is_octave_value (void) const { return true; } | |
531 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
532 int iscell (void) const { return m_val.iscell (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
533 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
534 int is_char (void) const { return m_val.is_string (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
535 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
536 int is_complex (void) const { return m_val.iscomplex (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
537 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
538 int is_double (void) const { return m_val.is_double_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
539 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
540 int is_function_handle (void) const { return m_val.is_function_handle (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
541 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
542 int is_int16 (void) const { return m_val.is_int16_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
543 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
544 int is_int32 (void) const { return m_val.is_int32_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
545 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
546 int is_int64 (void) const { return m_val.is_int64_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
547 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
548 int is_int8 (void) const { return m_val.is_int8_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
549 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
550 int is_logical (void) const { return m_val.islogical (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
551 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
552 int is_numeric (void) const { return m_val.isnumeric (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
553 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
554 int is_single (void) const { return m_val.is_single_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
555 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
556 int is_sparse (void) const { return m_val.issparse (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
557 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
558 int is_struct (void) const { return m_val.isstruct (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
559 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
560 int is_uint16 (void) const { return m_val.is_uint16_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
561 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
562 int is_uint32 (void) const { return m_val.is_uint32_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
563 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
564 int is_uint64 (void) const { return m_val.is_uint64_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
565 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
566 int is_uint8 (void) const { return m_val.is_uint8_type (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
567 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
568 int is_range (void) const { return m_val.is_range (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
569 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
570 int isreal (void) const { return m_val.isreal (); } |
5900 | 571 |
572 int is_logical_scalar_true (void) const | |
573 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
574 return (is_logical_scalar () && m_val.is_true ()); |
5900 | 575 } |
576 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
577 mwSize get_m (void) const { return m_val.rows (); } |
6686 | 578 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
579 mwSize get_n (void) const |
6187 | 580 { |
6686 | 581 mwSize n = 1; |
6187 | 582 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
583 // Force m_dims and m_ndims to be cached. |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14840
diff
changeset
|
584 get_dimensions (); |
6187 | 585 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
586 for (mwIndex i = m_ndims - 1; i > 0; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
587 n *= m_dims[i]; |
6187 | 588 |
589 return n; | |
590 } | |
5900 | 591 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
592 mwSize * get_dimensions (void) const |
5900 | 593 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
594 if (! m_dims) |
5900 | 595 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
596 m_ndims = m_val.ndims (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
597 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
598 m_dims = static_cast<mwSize *> (mxArray::malloc (m_ndims |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
599 * sizeof (mwSize))); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
600 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
601 dim_vector dv = m_val.dims (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
602 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
603 for (mwIndex i = 0; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
604 m_dims[i] = dv(i); |
5900 | 605 } |
606 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
607 return m_dims; |
5900 | 608 } |
609 | |
6686 | 610 mwSize get_number_of_dimensions (void) const |
5900 | 611 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
612 // Force m_dims and m_ndims to be cached. |
6332 | 613 get_dimensions (); |
5900 | 614 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
615 return m_ndims; |
5900 | 616 } |
617 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
618 VOID_MUTATION_METHOD (set_m, (mwSize)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
619 VOID_MUTATION_METHOD (set_n, (mwSize)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
620 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
621 MUTATION_METHOD (int, set_dimensions, (mwSize *, mwSize), 0) |
5900 | 622 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
623 mwSize get_number_of_elements (void) const { return m_val.numel (); } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
624 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
625 int isempty (void) const { return m_val.isempty (); } |
5900 | 626 |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
627 bool is_scalar (void) const |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
628 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
629 // Force m_dims and m_ndims to be cached. |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
630 get_dimensions (); |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
631 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
632 return m_ndims == 2 && m_dims[0] == 1 && m_dims[1] == 1; |
22599
51b395d24782
maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents:
22480
diff
changeset
|
633 } |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
634 |
5900 | 635 mxClassID get_class_id (void) const |
636 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
637 m_id = mxUNKNOWN_CLASS; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
638 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
639 std::string cn = m_val.class_name (); |
5900 | 640 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
641 if (cn == "double") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
642 m_id = mxDOUBLE_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
643 else if (cn == "single") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
644 m_id = mxSINGLE_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
645 else if (cn == "char") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
646 m_id = mxCHAR_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
647 else if (cn == "logical") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
648 m_id = mxLOGICAL_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
649 else if (cn == "cell") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
650 m_id = mxCELL_CLASS; |
5900 | 651 else if (cn == "struct") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
652 m_id = mxSTRUCT_CLASS; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
653 else if (cn == "function_handle") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
654 m_id = mxFUNCTION_CLASS; |
5900 | 655 else if (cn == "int8") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
656 m_id = mxINT8_CLASS; |
5900 | 657 else if (cn == "uint8") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
658 m_id = mxUINT8_CLASS; |
5900 | 659 else if (cn == "int16") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
660 m_id = mxINT16_CLASS; |
5900 | 661 else if (cn == "uint16") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
662 m_id = mxUINT16_CLASS; |
5900 | 663 else if (cn == "int32") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
664 m_id = mxINT32_CLASS; |
5900 | 665 else if (cn == "uint32") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
666 m_id = mxUINT32_CLASS; |
5900 | 667 else if (cn == "int64") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
668 m_id = mxINT64_CLASS; |
5900 | 669 else if (cn == "uint64") |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
670 m_id = mxUINT64_CLASS; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
671 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
672 return m_id; |
5900 | 673 } |
674 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
675 const char * get_class_name (void) const |
5900 | 676 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
677 if (! m_class_name) |
5900 | 678 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
679 std::string s = m_val.class_name (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
680 m_class_name = mxArray::strsave (s.c_str ()); |
5900 | 681 } |
682 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
683 return m_class_name; |
5900 | 684 } |
685 | |
686 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
687 VOID_MUTATION_METHOD (set_class_name, (const char *)) |
5900 | 688 |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
689 mxArray * get_property (mwIndex idx, const char *pname) const |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
690 { |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
691 mxArray *retval = nullptr; |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
692 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
693 if (m_val.is_classdef_object ()) |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
694 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
695 octave_classdef *ov_cdef = m_val.classdef_object_value (); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
696 |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
697 if (ov_cdef) |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
698 { |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
699 octave_value pval = ov_cdef->get_property (idx, pname); |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
700 |
23898
a490e729f2f2
correctly return NULL for unknown properties in mxGetProperty (bug #51725)
John W. Eaton <jwe@octave.org>
parents:
23893
diff
changeset
|
701 if (pval.is_defined()) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
702 retval = new mxArray (m_interleaved, pval); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
703 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
704 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
705 |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
706 return retval; |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
707 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
708 |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
709 void set_property (mwIndex idx, const char *pname, const mxArray *pval) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
710 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
711 if (m_val.is_classdef_object ()) |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
712 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
713 octave_classdef *ov_cdef = m_val.classdef_object_value (); |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
714 |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
715 if (ov_cdef) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
716 ov_cdef->set_property (idx, pname, pval->as_octave_value ()); |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
717 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
718 else |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
719 err_invalid_type ("set_property"); |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
720 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
721 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
722 CONST_MUTATION_METHOD (mxArray *, get_cell, (mwIndex), nullptr) |
5900 | 723 |
724 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
725 VOID_MUTATION_METHOD (set_cell, (mwIndex, mxArray *)) |
5900 | 726 |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
727 double get_scalar (void) const |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
728 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
729 if (m_val.issparse ()) |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
730 { |
22599
51b395d24782
maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents:
22480
diff
changeset
|
731 // For sparse arrays, return the first non-zero value. |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
732 const void *m_data = m_val.mex_get_data (); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
733 if (m_data == nullptr) |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
734 return 0.0; |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
735 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
736 if (m_val.islogical ()) |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
737 return *static_cast<const bool *> (m_data); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
738 else if (m_val.isreal ()) |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
739 return *static_cast<const double *> (m_data); |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
740 else // Complex type, only return real part |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
741 return *static_cast<const double *> (m_data); |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
742 } |
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
743 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
744 return m_val.scalar_value (true); |
22480
9263b2889003
Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents:
22471
diff
changeset
|
745 } |
6332 | 746 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
747 void * get_data (void) const |
5900 | 748 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
749 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
750 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
751 void *retval = const_cast<void *> (m_val.mex_get_data ()); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
752 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
753 if (retval && (m_val.isreal () || m_interleaved)) |
29870
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
754 { |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
755 maybe_mark_foreign (retval); |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
756 return retval; |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
757 } |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
758 |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
759 request_mutation (); |
79fe39e852db
mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents:
29869
diff
changeset
|
760 return nullptr; |
5900 | 761 } |
762 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
763 template <typename T> |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
764 T * get_data (mxClassID class_id, mxComplexity complexity) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
765 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
766 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
767 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
768 void *ptr = const_cast<void *> (m_val.mex_get_data (class_id, complexity)); |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
769 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
770 T *retval = static_cast<T *> (ptr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
771 |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
772 if (retval && (complexity == mxREAL || m_interleaved)) |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
773 { |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
774 maybe_mark_foreign (retval); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
775 return retval; |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
776 } |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
777 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
778 request_mutation (); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
779 return nullptr; |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
780 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
781 |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
782 GET_DATA_METHOD (mxDouble, get_doubles, mxDOUBLE_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
783 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
784 GET_DATA_METHOD (mxSingle, get_singles, mxSINGLE_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
785 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
786 GET_DATA_METHOD (mxInt8, get_int8s, mxINT8_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
787 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
788 GET_DATA_METHOD (mxInt16, get_int16s, mxINT16_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
789 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
790 GET_DATA_METHOD (mxInt32, get_int32s, mxINT32_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
791 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
792 GET_DATA_METHOD (mxInt64, get_int64s, mxINT64_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
793 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
794 GET_DATA_METHOD (mxUint8, get_uint8s, mxUINT8_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
795 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
796 GET_DATA_METHOD (mxUint16, get_uint16s, mxUINT16_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
797 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
798 GET_DATA_METHOD (mxUint32, get_uint32s, mxUINT32_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
799 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
800 GET_DATA_METHOD (mxUint64, get_uint64s, mxUINT64_CLASS, mxREAL); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
801 |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
802 GET_DATA_METHOD (mxComplexDouble, get_complex_doubles, |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
803 mxDOUBLE_CLASS, mxCOMPLEX); |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
804 |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
805 GET_DATA_METHOD (mxComplexSingle, get_complex_singles, |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
806 mxDOUBLE_CLASS, mxCOMPLEX); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
807 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
808 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
809 /* We don't have these yet. */ |
29869
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
810 GET_DATA_METHOD (mxComplexInt8 *, get_complex_int8s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
811 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
812 GET_DATA_METHOD (mxComplexInt16 *, get_complex_int16s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
813 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
814 GET_DATA_METHOD (mxComplexInt32 *, get_complex_int32s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
815 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
816 GET_DATA_METHOD (mxComplexInt64 *, get_complex_int64s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
817 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
818 GET_DATA_METHOD (mxComplexUint8 *, get_complex_uint8s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
819 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
820 GET_DATA_METHOD (mxComplexUint16 *, get_complex_uint16s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
821 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
822 GET_DATA_METHOD (mxComplexUint32 *, get_complex_uint32s, (void), nullptr); |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
823 |
5411391a4cc0
allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
824 GET_DATA_METHOD (mxComplexUint64 *, get_complex_uint64s, (void), nullptr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
825 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
826 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
827 void * get_imag_data (void) const |
5900 | 828 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
829 void *retval = nullptr; |
5900 | 830 |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23581
diff
changeset
|
831 if (is_numeric () && isreal ()) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23703
diff
changeset
|
832 retval = nullptr; |
5900 | 833 else |
834 request_mutation (); | |
835 | |
836 return retval; | |
837 } | |
838 | |
839 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
840 VOID_MUTATION_METHOD (set_data, (void *)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
841 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
842 MUTATION_METHOD (int, set_doubles, (mxDouble *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
843 MUTATION_METHOD (int, set_singles, (mxSingle *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
844 MUTATION_METHOD (int, set_int8s, (mxInt8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
845 MUTATION_METHOD (int, set_int16s, (mxInt16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
846 MUTATION_METHOD (int, set_int32s, (mxInt32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
847 MUTATION_METHOD (int, set_int64s, (mxInt64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
848 MUTATION_METHOD (int, set_uint8s, (mxUint8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
849 MUTATION_METHOD (int, set_uint16s, (mxUint16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
850 MUTATION_METHOD (int, set_uint32s, (mxUint32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
851 MUTATION_METHOD (int, set_uint64s, (mxUint64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
852 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
853 MUTATION_METHOD (int, set_complex_doubles, (mxComplexDouble *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
854 MUTATION_METHOD (int, set_complex_singles, (mxComplexSingle *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
855 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
856 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
857 MUTATION_METHOD (int, set_complex_int8s, (mxComplexInt8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
858 MUTATION_METHOD (int, set_complex_int16s, (mxComplexInt16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
859 MUTATION_METHOD (int, set_complex_int32s, (mxComplexInt32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
860 MUTATION_METHOD (int, set_complex_int64s, (mxComplexInt64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
861 MUTATION_METHOD (int, set_complex_uint8s, (mxComplexUint8 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
862 MUTATION_METHOD (int, set_complex_uint16s, (mxComplexUint16 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
863 MUTATION_METHOD (int, set_complex_uint32s, (mxComplexUint32 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
864 MUTATION_METHOD (int, set_complex_uint64s, (mxComplexUint64 *), 0) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
865 #endif |
5900 | 866 |
867 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
868 VOID_MUTATION_METHOD (set_imag_data, (void *)) |
5900 | 869 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
870 mwIndex * get_ir (void) const |
5900 | 871 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
872 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
873 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
874 octave_idx_type *ptr = const_cast<octave_idx_type *> (m_val.mex_get_ir ()); |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
875 return static_cast<mwIndex *> (maybe_mark_foreign (ptr)); |
5900 | 876 } |
877 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
878 mwIndex * get_jc (void) const |
5900 | 879 { |
30232
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
880 // Casting away const required for MEX interface. |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
881 |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
882 octave_idx_type *ptr = const_cast<octave_idx_type *> (m_val.mex_get_jc ()); |
a2936935c7c8
attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents:
30227
diff
changeset
|
883 return static_cast<mwIndex *> (maybe_mark_foreign (ptr)); |
5900 | 884 } |
885 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
886 mwSize get_nzmax (void) const { return m_val.nzmax (); } |
5900 | 887 |
888 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
889 VOID_MUTATION_METHOD (set_ir, (mwIndex *)) |
5900 | 890 |
891 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
892 VOID_MUTATION_METHOD (set_jc, (mwIndex *)) |
5900 | 893 |
894 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
895 VOID_MUTATION_METHOD (set_nzmax, (mwSize)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
896 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
897 // Not allowed. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
898 MUTATION_METHOD (int, add_field, (const char *), 0) |
5900 | 899 |
900 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
901 VOID_MUTATION_METHOD (remove_field, (int)) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
902 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
903 CONST_MUTATION_METHOD (mxArray *, get_field_by_number, (mwIndex, int), nullptr) |
5900 | 904 |
905 // Not allowed. | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
906 VOID_MUTATION_METHOD (set_field_by_number, (mwIndex, int, mxArray *)) |
5900 | 907 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
908 int get_number_of_fields (void) const { return m_val.nfields (); } |
5900 | 909 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
910 CONST_MUTATION_METHOD (const char *, get_field_name_by_number, (int), nullptr) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
911 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
912 CONST_MUTATION_METHOD (int, get_field_number, (const char *), 0) |
5900 | 913 |
6686 | 914 int get_string (char *buf, mwSize buflen) const |
5900 | 915 { |
916 int retval = 1; | |
917 | |
6686 | 918 mwSize nel = get_number_of_elements (); |
5900 | 919 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
920 if (m_val.is_string () && nel < buflen) |
5900 | 921 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
922 charNDArray tmp = m_val.char_array_value (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
923 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
924 const char *p = tmp.data (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
925 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
926 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
927 buf[i] = p[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
928 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
929 buf[nel] = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
930 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
931 retval = 0; |
5900 | 932 } |
933 | |
934 return retval; | |
935 } | |
936 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
937 char * array_to_string (void) const |
5900 | 938 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
939 // FIXME: this is supposed to handle multi-byte character strings. |
5900 | 940 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
941 char *buf = nullptr; |
5900 | 942 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
943 if (m_val.is_string ()) |
5900 | 944 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
945 mwSize nel = get_number_of_elements (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
946 |
15354
93dff6435fe1
tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents:
15353
diff
changeset
|
947 buf = static_cast<char *> (mxArray::malloc (nel + 1)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
948 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
949 if (buf) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
950 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
951 charNDArray tmp = m_val.char_array_value (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
952 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
953 const char *p = tmp.data (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
954 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
955 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
956 buf[i] = p[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
957 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
958 buf[nel] = '\0'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
959 } |
5900 | 960 } |
961 | |
962 return buf; | |
963 } | |
964 | |
6686 | 965 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const |
5900 | 966 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
967 // Force m_ndims, n_dims to be cached. |
5900 | 968 get_dimensions (); |
969 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
970 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs); |
5900 | 971 } |
972 | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
973 std::size_t get_element_size (void) const |
5900 | 974 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
975 // Force m_id to be cached. |
5900 | 976 get_class_id (); |
977 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
978 switch (m_id) |
5900 | 979 { |
980 case mxCELL_CLASS: return sizeof (mxArray *); | |
981 case mxSTRUCT_CLASS: return sizeof (mxArray *); | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
982 case mxLOGICAL_CLASS: return sizeof (mxLogical); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
983 case mxCHAR_CLASS: return sizeof (mxChar); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
984 case mxDOUBLE_CLASS: return get_numeric_element_size (sizeof (mxDouble)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
985 case mxSINGLE_CLASS: return get_numeric_element_size (sizeof (mxSingle)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
986 case mxINT8_CLASS: return get_numeric_element_size (sizeof (mxInt8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
987 case mxUINT8_CLASS: return get_numeric_element_size (sizeof (mxUint8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
988 case mxINT16_CLASS: return get_numeric_element_size (sizeof (mxInt16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
989 case mxUINT16_CLASS: return get_numeric_element_size (sizeof (mxUint16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
990 case mxINT32_CLASS: return get_numeric_element_size (sizeof (mxInt32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
991 case mxUINT32_CLASS: return get_numeric_element_size (sizeof (mxUint32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
992 case mxINT64_CLASS: return get_numeric_element_size (sizeof (mxInt64)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
993 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64)); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
994 case mxFUNCTION_CLASS: return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
995 // FIXME: user-defined objects need their own class ID. |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
996 // What should they return, size of pointer? |
5900 | 997 default: return 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
998 } |
5900 | 999 } |
1000 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1001 bool mutation_needed (void) const { return m_mutate_flag; } |
5900 | 1002 |
1003 void request_mutation (void) const | |
1004 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1005 if (m_mutate_flag) |
5900 | 1006 panic_impossible (); |
1007 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1008 m_mutate_flag = true; |
5900 | 1009 } |
1010 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1011 mxArray * mutate (void) const { return as_mxArray (); } |
5900 | 1012 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1013 octave_value as_octave_value (void) const { return m_val; } |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
1014 |
5900 | 1015 protected: |
1016 | |
1017 mxArray_octave_value (const mxArray_octave_value& arg) | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1018 : mxArray_base (arg), m_val (arg.m_val), m_mutate_flag (arg.m_mutate_flag), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1019 m_id (arg.m_id), m_class_name (mxArray::strsave (arg.m_class_name)), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1020 m_ndims (arg.m_ndims), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1021 m_dims (m_ndims > 0 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1022 ? static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1023 : nullptr) |
5900 | 1024 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1025 if (m_dims) |
5900 | 1026 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1027 for (mwIndex i = 0; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1028 m_dims[i] = arg.m_dims[i]; |
5900 | 1029 } |
1030 } | |
1031 | |
1032 private: | |
1033 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1034 octave_value m_val; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1035 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1036 mutable bool m_mutate_flag; |
5900 | 1037 |
1038 // Caching these does not cost much or lead to much duplicated | |
1039 // code. For other things, we just request mutation to a | |
1040 // Matlab-style mxArray object. | |
1041 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1042 mutable mxClassID m_id; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1043 mutable char *m_class_name; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1044 mutable mwSize m_ndims; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1045 mutable mwSize *m_dims; |
5900 | 1046 }; |
1047 | |
1048 // The base class for the Matlab-style representation, used to handle | |
1049 // things that are common to all Matlab-style objects. | |
1050 | |
1051 class mxArray_matlab : public mxArray_base | |
1052 { | |
1053 public: | |
1054 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1055 // No assignment! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1056 // FIXME: should this be implemented? |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1057 // Note that we *do* have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1058 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1059 mxArray_matlab& operator = (const mxArray_matlab&); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1060 |
5900 | 1061 ~mxArray_matlab (void) |
1062 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1063 mxFree (m_class_name); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1064 mxFree (m_dims); |
5900 | 1065 } |
1066 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1067 int iscell (void) const { return m_id == mxCELL_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1068 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1069 int is_char (void) const { return m_id == mxCHAR_CLASS; } |
5900 | 1070 |
1071 int is_complex (void) const { return 0; } | |
1072 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1073 int is_double (void) const { return m_id == mxDOUBLE_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1074 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1075 int is_function_handle (void) const { return m_id == mxFUNCTION_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1076 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1077 int is_int16 (void) const { return m_id == mxINT16_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1078 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1079 int is_int32 (void) const { return m_id == mxINT32_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1080 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1081 int is_int64 (void) const { return m_id == mxINT64_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1082 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1083 int is_int8 (void) const { return m_id == mxINT8_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1084 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1085 int is_logical (void) const { return m_id == mxLOGICAL_CLASS; } |
5900 | 1086 |
1087 int is_numeric (void) const | |
1088 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1089 return (m_id == mxDOUBLE_CLASS || m_id == mxSINGLE_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1090 || m_id == mxINT8_CLASS || m_id == mxUINT8_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1091 || m_id == mxINT16_CLASS || m_id == mxUINT16_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1092 || m_id == mxINT32_CLASS || m_id == mxUINT32_CLASS |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1093 || m_id == mxINT64_CLASS || m_id == mxUINT64_CLASS); |
5900 | 1094 } |
1095 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1096 int is_single (void) const { return m_id == mxSINGLE_CLASS; } |
5900 | 1097 |
1098 int is_sparse (void) const { return 0; } | |
1099 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1100 int is_struct (void) const { return m_id == mxSTRUCT_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1101 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1102 int is_uint16 (void) const { return m_id == mxUINT16_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1103 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1104 int is_uint32 (void) const { return m_id == mxUINT32_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1105 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1106 int is_uint64 (void) const { return m_id == mxUINT64_CLASS; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1107 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1108 int is_uint8 (void) const { return m_id == mxUINT8_CLASS; } |
5900 | 1109 |
1110 int is_logical_scalar_true (void) const | |
1111 { | |
1112 return (is_logical_scalar () | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1113 && static_cast<mxLogical *> (get_data ())[0] != 0); |
5900 | 1114 } |
1115 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1116 mwSize get_m (void) const { return m_dims[0]; } |
6686 | 1117 |
1118 mwSize get_n (void) const | |
6187 | 1119 { |
6686 | 1120 mwSize n = 1; |
1121 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1122 for (mwSize i = m_ndims - 1 ; i > 0 ; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1123 n *= m_dims[i]; |
6187 | 1124 |
1125 return n; | |
1126 } | |
5900 | 1127 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1128 mwSize * get_dimensions (void) const { return m_dims; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1129 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1130 mwSize get_number_of_dimensions (void) const { return m_ndims; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1131 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1132 void set_m (mwSize m) { m_dims[0] = m; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1133 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1134 void set_n (mwSize n) { m_dims[1] = n; } |
6686 | 1135 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1136 int set_dimensions (mwSize *dims, mwSize ndims) |
5900 | 1137 { |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1138 m_ndims = ndims; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1139 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1140 mxFree (m_dims); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1141 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1142 if (m_ndims > 0) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1143 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1144 m_dims |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1145 = static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1146 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1147 if (m_dims == nullptr) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1148 return 1; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1149 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1150 for (int i = 0; i < m_ndims; i++) |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1151 m_dims[i] = dims[i]; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1152 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1153 return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1154 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1155 else |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1156 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1157 m_dims = nullptr; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1158 return 0; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1159 } |
5900 | 1160 } |
1161 | |
6686 | 1162 mwSize get_number_of_elements (void) const |
5900 | 1163 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1164 mwSize retval = m_dims[0]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1165 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1166 for (mwIndex i = 1; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1167 retval *= m_dims[i]; |
5900 | 1168 |
1169 return retval; | |
1170 } | |
1171 | |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
1172 int isempty (void) const { return get_number_of_elements () == 0; } |
5900 | 1173 |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1174 bool is_scalar (void) const |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1175 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1176 return m_ndims == 2 && m_dims[0] == 1 && m_dims[1] == 1; |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1177 } |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
1178 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1179 mxClassID get_class_id (void) const { return m_id; } |
5900 | 1180 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1181 const char * get_class_name (void) const |
5900 | 1182 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1183 switch (m_id) |
5900 | 1184 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1185 case mxDOUBLE_CLASS: return "double"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1186 case mxSINGLE_CLASS: return "single"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1187 case mxCHAR_CLASS: return "char"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1188 case mxLOGICAL_CLASS: return "logical"; |
5900 | 1189 case mxCELL_CLASS: return "cell"; |
1190 case mxSTRUCT_CLASS: return "struct"; | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1191 case mxFUNCTION_CLASS: return "function_handle"; |
5900 | 1192 case mxINT8_CLASS: return "int8"; |
1193 case mxUINT8_CLASS: return "uint8"; | |
1194 case mxINT16_CLASS: return "int16"; | |
1195 case mxUINT16_CLASS: return "uint16"; | |
1196 case mxINT32_CLASS: return "int32"; | |
1197 case mxUINT32_CLASS: return "uint32"; | |
1198 case mxINT64_CLASS: return "int64"; | |
1199 case mxUINT64_CLASS: return "uint64"; | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1200 case mxUNKNOWN_CLASS: return "unknown"; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1201 // FIXME: should return the classname of user-defined objects |
5900 | 1202 default: return "unknown"; |
1203 } | |
1204 } | |
1205 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1206 void set_class_name (const char *name) |
5900 | 1207 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1208 mxFree (m_class_name); |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1209 m_class_name = static_cast<char *> (mxArray::malloc (strlen (name) + 1)); |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1210 strcpy (m_class_name, name); |
5900 | 1211 } |
1212 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1213 mxArray * get_cell (mwIndex /*idx*/) const |
5900 | 1214 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1215 err_invalid_type ("get_cell"); |
5900 | 1216 } |
1217 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1218 void set_cell (mwIndex /*idx*/, mxArray * /*val*/) |
5900 | 1219 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1220 err_invalid_type ("set_cell"); |
5900 | 1221 } |
1222 | |
6332 | 1223 double get_scalar (void) const |
1224 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1225 err_invalid_type ("get_scalar"); |
6332 | 1226 } |
1227 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1228 void * get_data (void) const |
5900 | 1229 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1230 err_invalid_type ("get_data"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1231 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1232 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1233 mxDouble * get_doubles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1234 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1235 err_invalid_type ("get_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1236 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1237 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1238 mxSingle * get_singles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1239 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1240 err_invalid_type ("get_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1241 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1242 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1243 mxInt8 * get_int8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1244 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1245 err_invalid_type ("get_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1246 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1247 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1248 mxInt16 * get_int16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1249 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1250 err_invalid_type ("get_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1251 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1252 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1253 mxInt32 * get_int32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1254 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1255 err_invalid_type ("get_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1256 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1257 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1258 mxInt64 * get_int64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1259 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1260 err_invalid_type ("get_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1261 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1262 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1263 mxUint8 * get_uint8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1264 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1265 err_invalid_type ("get_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1266 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1267 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1268 mxUint16 * get_uint16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1269 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1270 err_invalid_type ("get_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1271 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1272 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1273 mxUint32 * get_uint32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1274 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1275 err_invalid_type ("get_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1276 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1277 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1278 mxUint64 * get_uint64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1279 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1280 err_invalid_type ("get_uint64s"); |
5900 | 1281 } |
1282 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1283 mxComplexDouble * get_complex_doubles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1284 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1285 err_invalid_type ("get_complex_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1286 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1287 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1288 mxComplexSingle * get_complex_singles (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1289 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1290 err_invalid_type ("get_complex_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1291 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1292 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1293 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1294 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1295 mxComplexInt8 * get_complex_int8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1296 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1297 err_invalid_type ("get_complex_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1298 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1299 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1300 mxComplexInt16 * get_complex_int16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1301 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1302 err_invalid_type ("get_complex_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1303 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1304 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1305 mxComplexInt32 * get_complex_int32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1306 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1307 err_invalid_type ("get_complex_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1308 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1309 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1310 mxComplexInt64 * get_complex_int64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1311 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1312 err_invalid_type ("get_complex_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1313 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1314 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1315 mxComplexUint8 * get_complex_uint8s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1316 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1317 err_invalid_type ("get_complex_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1318 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1319 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1320 mxComplexUint16 * get_complex_uint16s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1321 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1322 err_invalid_type ("get_complex_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1323 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1324 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1325 mxComplexUint32 * get_complex_uint32s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1326 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1327 err_invalid_type ("get_complex_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1328 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1329 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1330 mxComplexUint64 * get_complex_uint64s (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1331 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1332 err_invalid_type ("get_complex_uint64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1333 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1334 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1335 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1336 void * get_imag_data (void) const |
5900 | 1337 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1338 err_invalid_type ("get_imag_data"); |
5900 | 1339 } |
1340 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1341 void set_data (void * /*pr*/) |
5900 | 1342 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1343 err_invalid_type ("set_data"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1344 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1345 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1346 int set_doubles (mxDouble *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1347 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1348 err_invalid_type ("set_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1349 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1350 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1351 int set_singles (mxSingle *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1352 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1353 err_invalid_type ("set_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1354 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1355 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1356 int set_int8s (mxInt8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1357 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1358 err_invalid_type ("set_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1359 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1360 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1361 int set_int16s (mxInt16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1362 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1363 err_invalid_type ("set_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1364 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1365 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1366 int set_int32s (mxInt32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1367 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1368 err_invalid_type ("set_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1369 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1370 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1371 int set_int64s (mxInt64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1372 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1373 err_invalid_type ("set_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1374 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1375 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1376 int set_uint8s (mxUint8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1377 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1378 err_invalid_type ("set_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1379 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1380 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1381 int set_uint16s (mxUint16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1382 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1383 err_invalid_type ("set_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1384 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1385 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1386 int set_uint32s (mxUint32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1387 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1388 err_invalid_type ("set_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1389 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1390 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1391 int set_uint64s (mxUint64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1392 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1393 err_invalid_type ("set_uint64s"); |
5900 | 1394 } |
1395 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1396 int set_complex_doubles (mxComplexDouble *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1397 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1398 err_invalid_type ("set_complex_doubles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1399 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1400 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1401 int set_complex_singles (mxComplexSingle *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1402 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1403 err_invalid_type ("set_complex_singles"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1404 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1405 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1406 #if 0 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1407 /* We don't have these yet. */ |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1408 int set_complex_int8s (mxComplexInt8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1409 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1410 err_invalid_type ("set_complex_int8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1411 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1412 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1413 int set_complex_int16s (mxComplexInt16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1414 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1415 err_invalid_type ("set_complex_int16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1416 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1417 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1418 int set_complex_int32s (mxComplexInt32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1419 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1420 err_invalid_type ("set_complex_int32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1421 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1422 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1423 int set_complex_int64s (mxComplexInt64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1424 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1425 err_invalid_type ("set_complex_int64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1426 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1427 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1428 int set_complex_uint8s (mxComplexUint8 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1429 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1430 err_invalid_type ("set_complex_uint8s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1431 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1432 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1433 int set_complex_uint16s (mxComplexUint16 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1434 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1435 err_invalid_type ("set_complex_uint16s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1436 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1437 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1438 int set_complex_uint32s (mxComplexUint32 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1439 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1440 err_invalid_type ("set_complex_uint32s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1441 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1442 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1443 int set_complex_uint64s (mxComplexUint64 *) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1444 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1445 err_invalid_type ("set_complex_uint64s"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1446 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1447 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1448 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1449 void set_imag_data (void * /*pi*/) |
5900 | 1450 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1451 err_invalid_type ("set_imag_data"); |
5900 | 1452 } |
1453 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1454 mwIndex * get_ir (void) const |
5900 | 1455 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1456 err_invalid_type ("get_ir"); |
5900 | 1457 } |
1458 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1459 mwIndex * get_jc (void) const |
5900 | 1460 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1461 err_invalid_type ("get_jc"); |
5900 | 1462 } |
1463 | |
6686 | 1464 mwSize get_nzmax (void) const |
5900 | 1465 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1466 err_invalid_type ("get_nzmax"); |
5900 | 1467 } |
1468 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1469 void set_ir (mwIndex * /*ir*/) |
5900 | 1470 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1471 err_invalid_type ("set_ir"); |
5900 | 1472 } |
1473 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1474 void set_jc (mwIndex * /*jc*/) |
5900 | 1475 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1476 err_invalid_type ("set_jc"); |
5900 | 1477 } |
1478 | |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1479 void set_nzmax (mwSize /*nzmax*/) |
5900 | 1480 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1481 err_invalid_type ("set_nzmax"); |
5900 | 1482 } |
1483 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1484 int add_field (const char * /*key*/) |
5900 | 1485 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1486 err_invalid_type ("add_field"); |
5900 | 1487 } |
1488 | |
1489 void remove_field (int /*key_num*/) | |
1490 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1491 err_invalid_type ("remove_field"); |
5900 | 1492 } |
1493 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1494 mxArray * get_field_by_number (mwIndex /*index*/, int /*key_num*/) const |
5900 | 1495 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1496 err_invalid_type ("get_field_by_number"); |
5900 | 1497 } |
1498 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1499 void set_field_by_number (mwIndex /*index*/, int /*key_num*/, |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1500 mxArray * /*val*/) |
5900 | 1501 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1502 err_invalid_type ("set_field_by_number"); |
5900 | 1503 } |
1504 | |
1505 int get_number_of_fields (void) const | |
1506 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1507 err_invalid_type ("get_number_of_fields"); |
5900 | 1508 } |
1509 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1510 const char * get_field_name_by_number (int /*key_num*/) const |
5900 | 1511 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1512 err_invalid_type ("get_field_name_by_number"); |
5900 | 1513 } |
1514 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1515 int get_field_number (const char * /*key*/) const |
5900 | 1516 { |
1517 return -1; | |
1518 } | |
1519 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1520 int get_string (char * /*buf*/, mwSize /*buflen*/) const |
5900 | 1521 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1522 err_invalid_type ("get_string"); |
5900 | 1523 } |
1524 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1525 char * array_to_string (void) const |
5900 | 1526 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1527 err_invalid_type ("array_to_string"); |
5900 | 1528 } |
1529 | |
6686 | 1530 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const |
5900 | 1531 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1532 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs); |
5900 | 1533 } |
1534 | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1535 std::size_t get_element_size (void) const |
5900 | 1536 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1537 switch (m_id) |
5900 | 1538 { |
1539 case mxCELL_CLASS: return sizeof (mxArray *); | |
1540 case mxSTRUCT_CLASS: return sizeof (mxArray *); | |
1541 case mxLOGICAL_CLASS: return sizeof (mxLogical); | |
1542 case mxCHAR_CLASS: return sizeof (mxChar); | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1543 case mxDOUBLE_CLASS: return get_numeric_element_size (sizeof (mxDouble)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1544 case mxSINGLE_CLASS: return get_numeric_element_size (sizeof (mxSingle)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1545 case mxINT8_CLASS: return get_numeric_element_size (sizeof (mxInt8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1546 case mxUINT8_CLASS: return get_numeric_element_size (sizeof (mxUint8)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1547 case mxINT16_CLASS: return get_numeric_element_size (sizeof (mxInt16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1548 case mxUINT16_CLASS: return get_numeric_element_size (sizeof (mxUint16)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1549 case mxINT32_CLASS: return get_numeric_element_size (sizeof (mxInt32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1550 case mxUINT32_CLASS: return get_numeric_element_size (sizeof (mxUint32)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1551 case mxINT64_CLASS: return get_numeric_element_size (sizeof (mxInt64)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1552 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64)); |
5900 | 1553 case mxFUNCTION_CLASS: return 0; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1554 // FIXME: user-defined objects need their own class ID. |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1555 // What should they return, size of pointer? |
5900 | 1556 default: return 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1557 } |
5900 | 1558 } |
1559 | |
1560 protected: | |
1561 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1562 mxArray_matlab (bool interleaved, mxClassID id = mxUNKNOWN_CLASS) |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1563 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1564 m_ndims (0), m_dims (nullptr) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1565 { } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1566 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1567 mxArray_matlab (bool interleaved, mxClassID id, mwSize ndims, |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1568 const mwSize *dims) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1569 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1570 m_ndims (ndims < 2 ? 2 : ndims), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1571 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1572 { |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1573 if (ndims == 0) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1574 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1575 m_dims[0] = 0; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1576 m_dims[1] = 0; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1577 } |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1578 else if (ndims < 2) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1579 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1580 m_dims[0] = 1; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1581 m_dims[1] = 1; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1582 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1583 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1584 for (mwIndex i = 0; i < ndims; i++) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1585 m_dims[i] = dims[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1586 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1587 for (mwIndex i = m_ndims - 1; i > 1; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1588 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1589 if (m_dims[i] == 1) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1590 m_ndims--; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1591 else |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1592 break; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1593 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1594 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1595 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1596 mxArray_matlab (bool interleaved, mxClassID id, const dim_vector& dv) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1597 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1598 m_ndims (dv.ndims ()), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1599 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1600 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1601 for (mwIndex i = 0; i < m_ndims; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1602 m_dims[i] = dv(i); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1603 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1604 for (mwIndex i = m_ndims - 1; i > 1; i--) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1605 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1606 if (m_dims[i] == 1) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1607 m_ndims--; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1608 else |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1609 break; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1610 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1611 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1612 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1613 mxArray_matlab (bool interleaved, mxClassID id, mwSize m, mwSize n) |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1614 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id), |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
1615 m_ndims (2), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1616 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1617 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1618 m_dims[0] = m; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1619 m_dims[1] = n; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1620 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1621 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1622 mxArray_matlab (const mxArray_matlab& val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1623 : mxArray_base (val), m_class_name (mxArray::strsave (val.m_class_name)), |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1624 m_id (val.m_id), m_ndims (val.m_ndims), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1625 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1626 { |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1627 for (mwIndex i = 0; i < m_ndims; i++) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1628 m_dims[i] = val.m_dims[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1629 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1630 |
5900 | 1631 dim_vector |
1632 dims_to_dim_vector (void) const | |
1633 { | |
6686 | 1634 mwSize nd = get_number_of_dimensions (); |
1635 | |
1636 mwSize *d = get_dimensions (); | |
5900 | 1637 |
1638 dim_vector dv; | |
1639 dv.resize (nd); | |
1640 | |
6686 | 1641 for (mwIndex i = 0; i < nd; i++) |
5900 | 1642 dv(i) = d[i]; |
1643 | |
1644 return dv; | |
1645 } | |
1646 | |
1647 private: | |
1648 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1649 char *m_class_name; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1650 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1651 mxClassID m_id; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1652 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1653 mwSize m_ndims; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1654 mwSize *m_dims; |
5900 | 1655 }; |
1656 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1657 |
5900 | 1658 // Matlab-style numeric, character, and logical data. |
1659 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1660 class mxArray_base_full : public mxArray_matlab |
5900 | 1661 { |
1662 public: | |
1663 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1664 mxArray_base_full (bool interleaved, mxClassID id, mwSize ndims, |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1665 const mwSize *dims, bool init = true) |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
1666 : mxArray_matlab (interleaved, id, ndims, dims), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1667 m_pr (mxArray::alloc (init, get_number_of_elements (), get_element_size ())) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1668 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1669 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1670 mxArray_base_full (bool interleaved, mxClassID id, const dim_vector& dv) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1671 : mxArray_matlab (interleaved, id, dv), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1672 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
1673 { } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1674 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1675 mxArray_base_full (bool interleaved, mxClassID id, mwSize m, mwSize n, |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1676 bool init = true) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1677 : mxArray_matlab (interleaved, id, m, n), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1678 m_pr (mxArray::alloc (init, get_number_of_elements (), get_element_size ())) |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
1679 { } |
5900 | 1680 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1681 mxArray_base_full (bool interleaved, mxClassID id, double val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1682 : mxArray_matlab (interleaved, id, 1, 1), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1683 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1684 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1685 double *dpr = static_cast<double *> (m_pr); |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1686 dpr[0] = val; |
5900 | 1687 } |
1688 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1689 mxArray_base_full (bool interleaved, mxClassID id, mxLogical val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1690 : mxArray_matlab (interleaved, id, 1, 1), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1691 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1692 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1693 mxLogical *lpr = static_cast<mxLogical *> (m_pr); |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
1694 lpr[0] = val; |
5900 | 1695 } |
1696 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1697 mxArray_base_full (bool interleaved, const char *str) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1698 : mxArray_matlab (interleaved, mxCHAR_CLASS, |
10853
c3813056f94f
mxArray_number (const char *): create empty string if given NULL arg
John W. Eaton <jwe@octave.org>
parents:
10463
diff
changeset
|
1699 str ? (strlen (str) ? 1 : 0) : 0, |
c3813056f94f
mxArray_number (const char *): create empty string if given NULL arg
John W. Eaton <jwe@octave.org>
parents:
10463
diff
changeset
|
1700 str ? strlen (str) : 0), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1701 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1702 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1703 mxChar *cpr = static_cast<mxChar *> (m_pr); |
6686 | 1704 mwSize nel = get_number_of_elements (); |
1705 for (mwIndex i = 0; i < nel; i++) | |
5900 | 1706 cpr[i] = str[i]; |
1707 } | |
1708 | |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17810
diff
changeset
|
1709 // FIXME: ??? |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1710 mxArray_base_full (bool interleaved, mwSize m, const char **str) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1711 : mxArray_matlab (interleaved, mxCHAR_CLASS, m, max_str_len (m, str)), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
1712 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())) |
5900 | 1713 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1714 mxChar *cpr = static_cast<mxChar *> (m_pr); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1715 |
6686 | 1716 mwSize *dv = get_dimensions (); |
1717 | |
1718 mwSize nc = dv[1]; | |
1719 | |
1720 for (mwIndex j = 0; j < m; j++) | |
5900 | 1721 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1722 const char *ptr = str[j]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1723 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1724 std::size_t tmp_len = strlen (ptr); |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1725 |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1726 for (std::size_t i = 0; i < tmp_len; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1727 cpr[m*i+j] = static_cast<mxChar> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1728 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1729 for (std::size_t i = tmp_len; i < static_cast<std::size_t> (nc); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1730 cpr[m*i+j] = static_cast<mxChar> (' '); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1731 } |
5900 | 1732 } |
1733 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1734 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1735 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1736 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1737 mxArray_base_full& operator = (const mxArray_base_full&); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
1738 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1739 mxArray_base * dup (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1740 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1741 return new mxArray_base_full (*this); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1742 } |
5900 | 1743 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
1744 ~mxArray_base_full (void) |
5900 | 1745 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1746 mxFree (m_pr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1747 } |
5907 | 1748 |
6332 | 1749 double get_scalar (void) const |
1750 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1751 // FIXME: how does this work for interleaved complex arrays? |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1752 |
6332 | 1753 double retval = 0; |
1754 | |
1755 switch (get_class_id ()) | |
1756 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1757 case mxDOUBLE_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1758 retval = *(static_cast<double *> (m_pr)); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1759 break; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1760 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1761 case mxSINGLE_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1762 retval = *(static_cast<float *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1763 break; |
6332 | 1764 |
1765 case mxCHAR_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1766 retval = *(static_cast<mxChar *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1767 break; |
6332 | 1768 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
1769 case mxLOGICAL_CLASS: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1770 retval = *(static_cast<bool *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1771 break; |
6332 | 1772 |
1773 case mxINT8_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1774 retval = *(static_cast<int8_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1775 break; |
6332 | 1776 |
1777 case mxUINT8_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1778 retval = *(static_cast<uint8_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1779 break; |
6332 | 1780 |
1781 case mxINT16_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1782 retval = *(static_cast<int16_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1783 break; |
6332 | 1784 |
1785 case mxUINT16_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1786 retval = *(static_cast<uint16_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1787 break; |
6332 | 1788 |
1789 case mxINT32_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1790 retval = *(static_cast<int32_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1791 break; |
6332 | 1792 |
1793 case mxUINT32_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1794 retval = *(static_cast<uint32_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1795 break; |
6332 | 1796 |
1797 case mxINT64_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1798 retval = *(static_cast<int64_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1799 break; |
6332 | 1800 |
1801 case mxUINT64_CLASS: | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1802 retval = *(static_cast<uint64_t *> (m_pr)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1803 break; |
6332 | 1804 |
1805 default: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
1806 panic_impossible (); |
6332 | 1807 } |
1808 | |
1809 return retval; | |
1810 } | |
1811 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1812 void * get_data (void) const { return m_pr; } |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1813 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1814 void set_data (void *pr) { m_pr = pr; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
1815 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1816 // The typed get and set functions only work for interleaved data but |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1817 // they are defined here because this class owns PR. There are |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1818 // definitions in the mxArray_separate_full class that override these |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1819 // functions. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1820 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1821 mxDouble * get_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1822 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1823 return static_cast<mxDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1824 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1825 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1826 mxSingle * get_singles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1827 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1828 return static_cast<mxSingle *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1829 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1830 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1831 mxInt8 * get_int8s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1832 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1833 return static_cast<mxInt8 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1834 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1835 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1836 mxInt16 * get_int16s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1837 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1838 return static_cast<mxInt16 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1839 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1840 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1841 mxInt32 * get_int32s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1842 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1843 return static_cast<mxInt32 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1844 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1845 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1846 mxInt64 * get_int64s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1847 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1848 return static_cast<mxInt64 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1849 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1850 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1851 mxUint8 * get_uint8s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1852 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1853 return static_cast<mxUint8 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1854 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1855 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1856 mxUint16 * get_uint16s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1857 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1858 return static_cast<mxUint16 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1859 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1860 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1861 mxUint32 * get_uint32s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1862 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1863 return static_cast<mxUint32 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1864 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1865 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1866 mxUint64 * get_uint64s (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1867 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1868 return static_cast<mxUint64 *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1869 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1870 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1871 mxComplexDouble * get_complex_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1872 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1873 return static_cast<mxComplexDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1874 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1875 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1876 mxComplexSingle * get_complex_singles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1877 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1878 return static_cast<mxComplexSingle *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1879 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1880 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1881 #if 0 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1882 // We don't have these data types. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1883 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1884 int get_complex_int8s (mxComplexInt8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1885 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1886 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1887 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1888 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1889 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1890 int get_complex_int16s (mxComplexInt16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1891 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1892 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1893 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1894 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1895 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1896 int get_complex_int32s (mxComplexInt32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1897 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1898 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1899 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1900 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1901 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1902 int get_complex_int64s (mxComplexInt64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1903 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1904 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1905 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1906 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1907 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1908 int get_complex_uint8s (mxComplexUint8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1909 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1910 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1911 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1912 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1913 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1914 int get_complex_uint16s (mxComplexUint16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1915 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1916 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1917 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1918 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1919 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1920 int get_complex_uint32s (mxComplexUint32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1921 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1922 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1923 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1924 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1925 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1926 int get_complex_uint64s (mxComplexUint64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1927 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1928 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1929 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1930 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1931 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1932 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1933 int set_doubles (mxDouble *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1934 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1935 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1936 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1937 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1938 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1939 int set_singles (mxSingle *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1940 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1941 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1942 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1943 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1944 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1945 int set_int8s (mxInt8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1946 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1947 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1948 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1949 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1950 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1951 int set_int16s (mxInt16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1952 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1953 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1954 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1955 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1956 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1957 int set_int32s (mxInt32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1958 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1959 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1960 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1961 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1962 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1963 int set_int64s (mxInt64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1964 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1965 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1966 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1967 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1968 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1969 int set_uint8s (mxUint8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1970 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1971 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1972 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1973 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1974 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1975 int set_uint16s (mxUint16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1976 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1977 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1978 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1979 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1980 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1981 int set_uint32s (mxUint32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1982 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1983 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1984 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1985 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1986 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1987 int set_uint64s (mxUint64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1988 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1989 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1990 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1991 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1992 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1993 int set_complex_doubles (mxComplexDouble *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1994 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1995 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1996 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1997 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1998 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
1999 int set_complex_singles (mxComplexSingle *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2000 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2001 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2002 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2003 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2004 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2005 #if 0 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2006 // We don't have these data types. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2007 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2008 int set_complex_int8s (mxComplexInt8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2009 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2010 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2011 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2012 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2013 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2014 int set_complex_int16s (mxComplexInt16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2015 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2016 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2017 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2018 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2019 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2020 int set_complex_int32s (mxComplexInt32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2021 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2022 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2023 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2024 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2025 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2026 int set_complex_int64s (mxComplexInt64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2027 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2028 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2029 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2030 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2031 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2032 int set_complex_uint8s (mxComplexUint8 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2033 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2034 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2035 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2036 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2037 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2038 int set_complex_uint16s (mxComplexUint16 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2039 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2040 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2041 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2042 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2043 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2044 int set_complex_uint32s (mxComplexUint32 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2045 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2046 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2047 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2048 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2049 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2050 int set_complex_uint64s (mxComplexUint64 *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2051 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2052 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2053 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2054 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2055 #endif |
5907 | 2056 |
6686 | 2057 int get_string (char *buf, mwSize buflen) const |
5907 | 2058 { |
13753
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2059 int retval = 0; |
5907 | 2060 |
6686 | 2061 mwSize nel = get_number_of_elements (); |
6493 | 2062 |
13753
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2063 if (! (nel < buflen)) |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2064 { |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2065 retval = 1; |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2066 if (buflen > 0) |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2067 nel = buflen-1; |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2068 } |
ab4238b0b09b
Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents:
12472
diff
changeset
|
2069 |
6493 | 2070 if (nel < buflen) |
5907 | 2071 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2072 mxChar *ptr = static_cast<mxChar *> (m_pr); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2073 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2074 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2075 buf[i] = static_cast<char> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2076 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2077 buf[nel] = 0; |
5907 | 2078 } |
2079 | |
2080 return retval; | |
2081 } | |
2082 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2083 char * array_to_string (void) const |
5907 | 2084 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2085 // FIXME: this is supposed to handle multi-byte character strings. |
5907 | 2086 |
6686 | 2087 mwSize nel = get_number_of_elements (); |
5907 | 2088 |
15354
93dff6435fe1
tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents:
15353
diff
changeset
|
2089 char *buf = static_cast<char *> (mxArray::malloc (nel + 1)); |
5907 | 2090 |
2091 if (buf) | |
2092 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2093 mxChar *ptr = static_cast<mxChar *> (m_pr); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2094 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2095 for (mwIndex i = 0; i < nel; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2096 buf[i] = static_cast<char> (ptr[i]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2097 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2098 buf[nel] = '\0'; |
5907 | 2099 } |
2100 | |
2101 return buf; | |
2102 } | |
2103 | |
5900 | 2104 octave_value as_octave_value (void) const |
2105 { | |
2106 octave_value retval; | |
2107 | |
2108 dim_vector dv = dims_to_dim_vector (); | |
2109 | |
2110 switch (get_class_id ()) | |
2111 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2112 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2113 return (is_complex () |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2114 ? fp_to_ov<Complex> (dv) : fp_to_ov<double> (dv)); |
5900 | 2115 |
2116 case mxSINGLE_CLASS: | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2117 return (is_complex () |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2118 ? fp_to_ov<FloatComplex> (dv) : fp_to_ov<float> (dv)); |
5900 | 2119 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2120 case mxCHAR_CLASS: |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2121 return int_to_ov<mxChar, charNDArray, char> (dv); |
5900 | 2122 |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2123 case mxLOGICAL_CLASS: |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2124 return int_to_ov<mxLogical, boolNDArray, bool> (dv); |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2125 |
5900 | 2126 case mxINT8_CLASS: |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2127 return int_to_ov<int8_t, int8NDArray, octave_int8> (dv); |
5900 | 2128 |
2129 case mxUINT8_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2130 return int_to_ov<uint8_t, uint8NDArray, octave_uint8> (dv); |
5900 | 2131 |
2132 case mxINT16_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2133 return int_to_ov<int16_t, int16NDArray, octave_int16> (dv); |
5900 | 2134 |
2135 case mxUINT16_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2136 return int_to_ov<uint16_t, uint16NDArray, octave_uint16> (dv); |
5900 | 2137 |
2138 case mxINT32_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2139 return int_to_ov<int32_t, int32NDArray, octave_int32> (dv); |
5900 | 2140 |
2141 case mxUINT32_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2142 return int_to_ov<uint32_t, uint32NDArray, octave_uint32> (dv); |
5900 | 2143 |
2144 case mxINT64_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2145 return int_to_ov<int64_t, int64NDArray, octave_int64> (dv); |
5900 | 2146 |
2147 case mxUINT64_CLASS: | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2148 return int_to_ov<uint64_t, uint64NDArray, octave_uint64> (dv); |
5900 | 2149 |
2150 default: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2151 panic_impossible (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2152 } |
5900 | 2153 |
2154 return retval; | |
2155 } | |
2156 | |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2157 protected: |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2158 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2159 mxArray_base_full (const mxArray_base_full& val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2160 : mxArray_matlab (val), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2161 m_pr (mxArray::malloc (get_number_of_elements () * get_element_size ())) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2162 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2163 if (m_pr) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2164 memcpy (m_pr, val.m_pr, get_number_of_elements () * get_element_size ()); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2165 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2166 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2167 template <typename ELT_T> |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2168 octave_value |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2169 fp_to_ov (const dim_vector& dv) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2170 { |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2171 octave_value retval; |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2172 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2173 ELT_T *ppr = static_cast<ELT_T *> (m_pr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2174 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
2175 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2176 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2177 if (current_mx_memory_resource == &the_mx_deleting_memory_resource) |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2178 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2179 octave::unwind_action act ([=] () { maybe_disown_ptr (m_pr); }); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2180 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2181 return octave_value (Array<ELT_T> (ppr, dv, current_mx_memory_resource)); |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2182 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2183 else |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2184 return octave_value (Array<ELT_T> (ppr, dv, current_mx_memory_resource)); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2185 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2186 #else |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2187 |
30769
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2188 // Copy data instead of allowing the octave_value object to borrow |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2189 // the mxArray object data. |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2190 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2191 Array<ELT_T> val (dv); |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2192 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2193 ELT_T *ptr = val.fortran_vec (); |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2194 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2195 mwSize nel = get_number_of_elements (); |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2196 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2197 for (mwIndex i = 0; i < nel; i++) |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2198 ptr[i] = ppr[i]; |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2199 |
822649f5f193
don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30768
diff
changeset
|
2200 return octave_value (val); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2201 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2202 #endif |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2203 } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2204 |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2205 template <typename ELT_T, typename ARRAY_T, typename ARRAY_ELT_T> |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2206 octave_value |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2207 int_to_ov (const dim_vector& dv) const |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2208 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2209 if (is_complex ()) |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2210 error ("complex integer types are not supported"); |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2211 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2212 ELT_T *ppr = static_cast<ELT_T *> (m_pr); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2213 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30494
diff
changeset
|
2214 #if 0 && defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2215 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2216 // FIXME: Currently not allowed because we don't have the necessary |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2217 // constructors for integer arrays. |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2218 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2219 octave::unwind_action act ([=] () { maybe_disown_ptr (m_pr); }); |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2220 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2221 return ARRAY_T (ppr, dv, current_mx_memory_resource); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2222 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2223 #else |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2224 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2225 // Copy data instead of allowing the octave_value object to borrow |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
2226 // the mxArray object data. |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2227 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2228 ARRAY_T val (dv); |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2229 |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2230 ARRAY_ELT_T *ptr = val.fortran_vec (); |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2231 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2232 mwSize nel = get_number_of_elements (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2233 |
21151
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2234 for (mwIndex i = 0; i < nel; i++) |
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2235 ptr[i] = ppr[i]; |
bfd5e48c41a1
Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2236 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2237 return octave_value (val); |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2238 |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2239 #endif |
15351
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2240 } |
a291f850743c
modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
2241 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2242 protected: |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2243 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2244 // If using interleaved complex storage, this is the pointer to data |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2245 // (real, complex, or logical). Otherwise, it is the pointer to the |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2246 // real part of the data. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2247 void *m_pr; |
5900 | 2248 }; |
2249 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2250 class mxArray_interleaved_full : public mxArray_base_full |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2251 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2252 public: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2253 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2254 mxArray_interleaved_full (mxClassID id, mwSize ndims, const mwSize *dims, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2255 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2256 : mxArray_base_full (true, id, ndims, dims, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2257 m_complex (flag == mxCOMPLEX) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2258 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2259 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2260 mxArray_interleaved_full (mxClassID id, const dim_vector& dv, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2261 mxComplexity flag = mxREAL) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2262 : mxArray_base_full (true, id, dv), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2263 m_complex (flag == mxCOMPLEX) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2264 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2265 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2266 mxArray_interleaved_full (mxClassID id, mwSize m, mwSize n, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2267 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2268 : mxArray_base_full (true, id, m, n, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2269 m_complex (flag == mxCOMPLEX) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2270 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2271 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2272 mxArray_interleaved_full (mxClassID id, double val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2273 : mxArray_base_full (true, id, val), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2274 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2275 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2276 mxArray_interleaved_full (mxClassID id, mxLogical val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2277 : mxArray_base_full (true, id, val), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2278 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2279 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2280 mxArray_interleaved_full (const char *str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2281 : mxArray_base_full (true, str), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2282 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2283 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2284 // FIXME: ??? |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2285 mxArray_interleaved_full (mwSize m, const char **str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2286 : mxArray_base_full (true, m, str), m_complex (false) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2287 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2288 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2289 // No assignment! FIXME: should this be implemented? Note that we |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2290 // do have a copy constructor. |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2291 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2292 mxArray_interleaved_full& operator = (const mxArray_interleaved_full&); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2293 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2294 mxArray_base * dup (void) const |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2295 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2296 return new mxArray_interleaved_full (*this); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2297 } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2298 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2299 ~mxArray_interleaved_full (void) = default; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2300 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2301 int is_complex (void) const { return m_complex; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2302 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2303 void * get_imag_data (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2304 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2305 void set_imag_data (void */*pi*/) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2306 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2307 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2308 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2309 mxArray_interleaved_full (const mxArray_interleaved_full& val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2310 : mxArray_base_full (val), m_complex (val.m_complex) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2311 { } |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2312 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2313 // Flag to identify complex object. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2314 bool m_complex; |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2315 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2316 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2317 class mxArray_separate_full : public mxArray_base_full |
5900 | 2318 { |
2319 public: | |
2320 | |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2321 mxArray_separate_full (mxClassID id, mwSize ndims, const mwSize *dims, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2322 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2323 : mxArray_base_full (false, id, ndims, dims, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2324 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2325 ? mxArray::alloc (init, get_number_of_elements (), get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2326 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2327 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2328 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2329 mxArray_separate_full (mxClassID id, const dim_vector& dv, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2330 mxComplexity flag = mxREAL) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2331 : mxArray_base_full (false, id, dv), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2332 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2333 ? mxArray::calloc (get_number_of_elements (), get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2334 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2335 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2336 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2337 mxArray_separate_full (mxClassID id, mwSize m, mwSize n, |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2338 mxComplexity flag = mxREAL, bool init = true) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2339 : mxArray_base_full (false, id, m, n, init), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2340 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2341 ? (mxArray::alloc (init, get_number_of_elements (), get_element_size ())) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2342 : nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2343 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2344 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2345 mxArray_separate_full (mxClassID id, double val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2346 : mxArray_base_full (false, id, val), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2347 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2348 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2349 mxArray_separate_full (mxClassID id, mxLogical val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2350 : mxArray_base_full (false, id, val), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2351 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2352 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2353 mxArray_separate_full (const char *str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2354 : mxArray_base_full (false, str), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2355 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2356 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2357 // FIXME: ??? |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2358 mxArray_separate_full (mwSize m, const char **str) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2359 : mxArray_base_full (false, m, str), m_pi (nullptr) |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2360 { } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2361 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2362 // No assignment! FIXME: should this be implemented? Note that we |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2363 // do have a copy constructor. |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2364 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2365 mxArray_separate_full& operator = (const mxArray_separate_full&); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2366 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2367 mxArray_base * dup (void) const |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2368 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2369 return new mxArray_separate_full (*this); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2370 } |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2371 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2372 ~mxArray_separate_full (void) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2373 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2374 mxFree (m_pi); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2375 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2376 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2377 int is_complex (void) const { return m_pi != nullptr; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2378 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2379 void * get_imag_data (void) const { return m_pi; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2380 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2381 void set_imag_data (void *pi) { m_pi = pi; } |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2382 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2383 mxDouble * get_doubles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2384 mxSingle * get_singles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2385 mxInt8 * get_int8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2386 mxInt16 * get_int16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2387 mxInt32 * get_int32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2388 mxInt64 * get_int64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2389 mxUint8 * get_uint8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2390 mxUint16 * get_uint16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2391 mxUint32 * get_uint32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2392 mxUint64 * get_uint64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2393 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2394 mxComplexDouble * get_complex_doubles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2395 mxComplexSingle * get_complex_singles (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2396 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2397 // We don't have complex integer types, but for separate storage they |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2398 // still would not work. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2399 mxComplexInt8 * get_complex_int8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2400 mxComplexInt16 * get_complex_int16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2401 mxComplexInt32 * get_complex_int32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2402 mxComplexInt64 * get_complex_int64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2403 mxComplexUint8 * get_complex_uint8s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2404 mxComplexUint16 * get_complex_uint16s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2405 mxComplexUint32 * get_complex_uint32s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2406 mxComplexUint64 * get_complex_uint64s (void) const { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2407 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2408 int set_doubles (mxDouble *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2409 int set_singles (mxSingle *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2410 int set_int8s (mxInt8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2411 int set_int16s (mxInt16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2412 int set_int32s (mxInt32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2413 int set_int64s (mxInt64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2414 int set_uint8s (mxUint8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2415 int set_uint16s (mxUint16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2416 int set_uint32s (mxUint32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2417 int set_uint64s (mxUint64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2418 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2419 int set_complex_doubles (mxComplexDouble *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2420 int set_complex_singles (mxComplexSingle *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2421 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2422 // We don't have complex integer types, but for separate storage they |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2423 // still would not work. |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2424 int set_complex_int8s (mxComplexInt8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2425 int set_complex_int16s (mxComplexInt16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2426 int set_complex_int32s (mxComplexInt32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2427 int set_complex_int64s (mxComplexInt64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2428 int set_complex_uint8s (mxComplexUint8 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2429 int set_complex_uint16s (mxComplexUint16 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2430 int set_complex_uint32s (mxComplexUint32 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2431 int set_complex_uint64s (mxComplexUint64 *) { panic_impossible (); } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2432 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2433 octave_value as_octave_value (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2434 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2435 if (! is_complex ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2436 return mxArray_base_full::as_octave_value (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2437 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2438 octave_value retval; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2439 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2440 dim_vector dv = dims_to_dim_vector (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2441 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2442 switch (get_class_id ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2443 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2444 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2445 return to_ov<double> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2446 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2447 case mxSINGLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2448 return to_ov<float> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2449 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2450 case mxLOGICAL_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2451 case mxINT8_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2452 case mxUINT8_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2453 case mxINT16_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2454 case mxUINT16_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2455 case mxINT32_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2456 case mxUINT32_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2457 case mxINT64_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2458 case mxUINT64_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2459 error ("complex integer types are not supported"); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2460 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2461 default: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2462 panic_impossible (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2463 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2464 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2465 return retval; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2466 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2467 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2468 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2469 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2470 mxArray_separate_full (const mxArray_separate_full& val) |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2471 : mxArray_base_full (val), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2472 m_pi (val.m_pi |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2473 ? mxArray::malloc (get_number_of_elements () * get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2474 : nullptr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2475 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2476 if (m_pi) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2477 memcpy (m_pi, val.m_pi, get_number_of_elements () * get_element_size ()); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2478 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2479 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2480 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2481 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2482 template <typename T> |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2483 octave_value |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2484 to_ov (const dim_vector& dv) const |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2485 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2486 mwSize nel = get_number_of_elements (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2487 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2488 T *ppr = static_cast<T *> (m_pr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2489 |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2490 // We allocate in the Array<T> constructor and copy here, so we |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2491 // don't need the custom allocator for this object. |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30428
diff
changeset
|
2492 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2493 Array<std::complex<T>> val (dv); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2494 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2495 std::complex<T> *ptr = val.fortran_vec (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2496 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2497 T *ppi = static_cast<T *> (m_pi); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2498 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2499 for (mwIndex i = 0; i < nel; i++) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2500 ptr[i] = std::complex<T> (ppr[i], ppi[i]); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2501 |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2502 return octave_value (val); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2503 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2504 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2505 // Pointer to the imaginary part of the data. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2506 void *m_pi; |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2507 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2508 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2509 // Matlab-style sparse arrays. |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2510 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2511 class mxArray_base_sparse : public mxArray_matlab |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2512 { |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2513 public: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2514 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2515 mxArray_base_sparse (bool interleaved, mxClassID id, mwSize m, mwSize n, |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2516 mwSize nzmax) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2517 : mxArray_matlab (interleaved, id, m, n), |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2518 |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2519 m_nzmax (nzmax > 0 ? nzmax : 1), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2520 m_ir (static_cast<mwIndex *> (mxArray::calloc (m_nzmax, sizeof (mwIndex)))), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2521 m_jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex)))), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2522 m_pr (mxArray::calloc (m_nzmax, get_element_size ())) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2523 { } |
5900 | 2524 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2525 protected: |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2526 |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2527 mxArray_base_sparse (const mxArray_base_sparse& val) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2528 : mxArray_matlab (val), m_nzmax (val.m_nzmax), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2529 m_ir (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))), |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2530 m_jc (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2531 m_pr (mxArray::malloc (m_nzmax * get_element_size ())) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2532 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2533 if (m_ir) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2534 memcpy (m_ir, val.m_ir, m_nzmax * sizeof (mwIndex)); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2535 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2536 if (m_jc) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2537 memcpy (m_jc, val.m_jc, (val.get_n () + 1) * sizeof (mwIndex)); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2538 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2539 if (m_pr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2540 memcpy (m_pr, val.m_pr, m_nzmax * get_element_size ()); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2541 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2542 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2543 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2544 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2545 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2546 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2547 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2548 mxArray_base_sparse& operator = (const mxArray_base_sparse&); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2549 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2550 mxArray_base * dup (void) const |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2551 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2552 return new mxArray_base_sparse (*this); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2553 } |
5900 | 2554 |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2555 ~mxArray_base_sparse (void) |
5900 | 2556 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2557 mxFree (m_ir); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2558 mxFree (m_jc); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2559 mxFree (m_pr); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2560 } |
5907 | 2561 |
2562 int is_sparse (void) const { return 1; } | |
2563 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2564 void * get_data (void) const { return m_pr; } |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2565 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2566 void set_data (void *pr) { m_pr = pr; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2567 |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2568 mxDouble * get_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2569 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2570 return static_cast<mxDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2571 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2572 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2573 mxComplexDouble * get_complex_doubles (void) const |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2574 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2575 return static_cast<mxComplexDouble *> (m_pr); |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2576 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2577 |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2578 int set_doubles (mxDouble *d) |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2579 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2580 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2581 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2582 } |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2583 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2584 int set_complex_doubles (mxComplexDouble *d) |
30225
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2585 { |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2586 m_pr = d; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2587 return 0; |
3a988323d5d7
refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents:
30224
diff
changeset
|
2588 } |
5907 | 2589 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2590 mwIndex * get_ir (void) const { return m_ir; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2591 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2592 mwIndex * get_jc (void) const { return m_jc; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2593 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2594 mwSize get_nzmax (void) const { return m_nzmax; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2595 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2596 void set_ir (mwIndex *ir) { m_ir = ir; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2597 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2598 void set_jc (mwIndex *jc) { m_jc = jc; } |
6686 | 2599 |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2600 void set_nzmax (mwSize nzmax) |
27083
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2601 { |
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2602 /* Require storage for at least 1 element */ |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2603 m_nzmax = (nzmax > 0 ? nzmax : 1); |
27083
23761e83756f
Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents:
26997
diff
changeset
|
2604 } |
5907 | 2605 |
5900 | 2606 octave_value as_octave_value (void) const |
2607 { | |
5903 | 2608 octave_value retval; |
2609 | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2610 dim_vector dv = dims_to_dim_vector (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2611 |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2612 switch (get_class_id ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2613 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2614 case mxDOUBLE_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2615 return is_complex () ? to_ov<Complex> (dv): to_ov<double> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2616 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2617 case mxSINGLE_CLASS: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2618 error ("single precision sparse data type not supported"); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2619 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2620 case mxLOGICAL_CLASS: |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2621 return to_ov<bool> (dv); |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2622 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2623 default: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2624 panic_impossible (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2625 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2626 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2627 return retval; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2628 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2629 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2630 protected: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2631 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2632 template <typename ELT_T> |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2633 octave_value |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2634 to_ov (const dim_vector& dv) const |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2635 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2636 ELT_T *ppr = static_cast<ELT_T *> (m_pr); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2637 |
30792
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2638 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2639 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2640 if (current_mx_memory_resource == &the_mx_deleting_memory_resource) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2641 { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2642 octave::unwind_action act ([=] () { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2643 maybe_disown_ptr (m_pr); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2644 maybe_disown_ptr (m_ir); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2645 maybe_disown_ptr (m_jc); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2646 }); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2647 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2648 return octave_value |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2649 (Sparse<ELT_T> (dv, static_cast<octave_idx_type> (m_nzmax), |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2650 ppr, m_ir, m_jc, current_mx_memory_resource)); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2651 } |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2652 else |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2653 return octave_value |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2654 (Sparse<ELT_T> (dv, static_cast<octave_idx_type> (m_nzmax), |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2655 ppr, m_ir, m_jc, current_mx_memory_resource)); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2656 #else |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2657 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2658 // Copy data instead of allowing the octave_value object to borrow |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2659 // the mxArray object data. |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2660 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2661 octave_idx_type m = dv(0); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2662 octave_idx_type n = dv(1); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2663 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2664 Sparse<ELT_T> val (m, n, static_cast<octave_idx_type> (m_nzmax)); |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2665 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2666 for (mwIndex i = 0; i < m_nzmax; i++) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2667 { |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2668 val.xdata (i) = ppr[i]; |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2669 val.xridx (i) = m_ir[i]; |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2670 } |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2671 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2672 for (mwIndex i = 0; i < n + 1; i++) |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2673 val.xcidx (i) = m_jc[i]; |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2674 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2675 return octave_value (val); |
30792
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2676 |
4fc0b7269803
use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30770
diff
changeset
|
2677 #endif |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2678 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2679 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2680 // Maximun number of nonzero elements. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2681 mwSize m_nzmax; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2682 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2683 // Sparse storage indexing arrays. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2684 mwIndex *m_ir; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2685 mwIndex *m_jc; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2686 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2687 // If using interleaved complex storage, this is the pointer to data |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2688 // (real, complex, or logical). Otherwise, it is the pointer to the |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2689 // real part of the data. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2690 void *m_pr; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2691 }; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2692 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2693 class mxArray_interleaved_sparse : public mxArray_base_sparse |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2694 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2695 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2696 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2697 mxArray_interleaved_sparse (mxClassID id, mwSize m, mwSize n, mwSize nzmax, |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2698 mxComplexity flag = mxREAL) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2699 : mxArray_base_sparse (true, id, m, n, nzmax), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2700 m_complex (flag == mxCOMPLEX) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2701 { } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2702 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2703 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2704 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2705 mxArray_interleaved_sparse (const mxArray_interleaved_sparse& val) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2706 : mxArray_base_sparse (val), m_complex (val.m_complex) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2707 { } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2708 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2709 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2710 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2711 // No assignment! FIXME: should this be implemented? Note that we |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2712 // do have a copy constructor. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2713 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2714 mxArray_interleaved_sparse& operator = (const mxArray_interleaved_sparse&); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2715 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2716 mxArray_base * dup (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2717 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2718 return new mxArray_interleaved_sparse (*this); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2719 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2720 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2721 ~mxArray_interleaved_sparse (void) = default; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2722 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2723 int is_complex (void) const { return m_complex; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2724 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2725 void * get_imag_data (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2726 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2727 void set_imag_data (void */*pi*/) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2728 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2729 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2730 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2731 // Flag to identify complex object if using interleaved data and PI is |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2732 // always nullptr. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2733 bool m_complex; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2734 }; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2735 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2736 class mxArray_separate_sparse : public mxArray_base_sparse |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2737 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2738 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2739 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2740 mxArray_separate_sparse (mxClassID id, mwSize m, mwSize n, mwSize nzmax, |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2741 mxComplexity flag = mxREAL) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2742 : mxArray_base_sparse (false, id, m, n, nzmax), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2743 m_pi (flag == mxCOMPLEX |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2744 ? mxArray::calloc (m_nzmax, get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2745 : nullptr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2746 { } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2747 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2748 private: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2749 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2750 mxArray_separate_sparse (const mxArray_separate_sparse& val) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2751 : mxArray_base_sparse (val), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2752 m_pi (val.m_pi |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2753 ? mxArray::malloc (m_nzmax * get_element_size ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2754 : nullptr) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2755 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2756 if (m_pi) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2757 memcpy (m_pi, val.m_pi, m_nzmax * get_element_size ()); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2758 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2759 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2760 public: |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2761 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2762 // No assignment! FIXME: should this be implemented? Note that we |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2763 // do have a copy constructor. |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2764 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2765 mxArray_separate_sparse& operator = (const mxArray_separate_sparse&); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2766 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2767 mxArray_base * dup (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2768 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2769 return new mxArray_separate_sparse (*this); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2770 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2771 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2772 ~mxArray_separate_sparse (void) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2773 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2774 mxFree (m_pi); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2775 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2776 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2777 int is_complex (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2778 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2779 return m_pi != nullptr; |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2780 } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2781 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2782 void * get_imag_data (void) const { return m_pi; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2783 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2784 void set_imag_data (void *pi) { m_pi = pi; } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2785 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2786 mxDouble * get_doubles (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2787 mxComplexDouble * get_complex_doubles (void) const { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2788 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2789 int set_doubles (mxDouble *) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2790 int set_complex_doubles (mxComplexDouble *) { panic_impossible (); } |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2791 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2792 octave_value as_octave_value (void) const |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2793 { |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2794 if (! is_complex ()) |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2795 return mxArray_base_sparse::as_octave_value (); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2796 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2797 octave_value retval; |
5903 | 2798 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2799 dim_vector dv = dims_to_dim_vector (); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
2800 |
5903 | 2801 switch (get_class_id ()) |
2802 { | |
2803 case mxDOUBLE_CLASS: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2804 { |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2805 double *ppr = static_cast<double *> (m_pr); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2806 double *ppi = static_cast<double *> (m_pi); |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2807 |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2808 SparseComplexMatrix val (get_m (), get_n (), |
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2809 static_cast<octave_idx_type> (m_nzmax)); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2810 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2811 for (mwIndex i = 0; i < m_nzmax; i++) |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2812 { |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2813 val.xdata (i) = Complex (ppr[i], ppi[i]); |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2814 val.xridx (i) = m_ir[i]; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2815 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2816 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2817 for (mwIndex i = 0; i < get_n () + 1; i++) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2818 val.xcidx (i) = m_jc[i]; |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2819 |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2820 retval = val; |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2821 } |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2822 break; |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2823 |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2824 case mxSINGLE_CLASS: |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2825 error ("single precision sparse data type not supported"); |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
2826 |
5903 | 2827 default: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2828 panic_impossible (); |
5903 | 2829 } |
2830 | |
2831 return retval; | |
5900 | 2832 } |
2833 | |
2834 private: | |
2835 | |
30226
f3ffb4596bd8
move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents:
30225
diff
changeset
|
2836 // Pointer to the imaginary part of the data. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2837 void *m_pi; |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2838 }; |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
2839 |
5900 | 2840 // Matlab-style struct arrays. |
2841 | |
2842 class mxArray_struct : public mxArray_matlab | |
2843 { | |
2844 public: | |
2845 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2846 mxArray_struct (bool interleaved, mwSize ndims, const mwSize *dims, |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2847 int num_keys, const char **keys) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2848 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, ndims, dims), |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2849 m_nfields (num_keys), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2850 m_fields (static_cast<char **> (mxArray::calloc (m_nfields, |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2851 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2852 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2853 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2854 sizeof (mxArray *)))) |
5900 | 2855 { |
2856 init (keys); | |
2857 } | |
2858 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2859 mxArray_struct (bool interleaved, const dim_vector& dv, int num_keys, |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2860 const char **keys) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2861 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, dv), |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2862 m_nfields (num_keys), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2863 m_fields (static_cast<char **> (mxArray::calloc (m_nfields, |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2864 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2865 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2866 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2867 sizeof (mxArray *)))) |
5900 | 2868 { |
2869 init (keys); | |
2870 } | |
2871 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2872 mxArray_struct (bool interleaved, mwSize m, mwSize n, int num_keys, |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2873 const char **keys) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
2874 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, m, n), |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
2875 m_nfields (num_keys), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2876 m_fields (static_cast<char **> (mxArray::calloc (m_nfields, |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2877 sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2878 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2879 get_number_of_elements (), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2880 sizeof (mxArray *)))) |
5900 | 2881 { |
2882 init (keys); | |
2883 } | |
2884 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2885 private: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2886 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2887 mxArray_struct (const mxArray_struct& val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2888 : mxArray_matlab (val), m_nfields (val.m_nfields), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2889 m_fields (static_cast<char **> (mxArray::malloc (m_nfields |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2890 * sizeof (char *)))), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2891 m_data (static_cast<mxArray **> (mxArray::malloc (m_nfields * |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2892 get_number_of_elements () |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2893 * sizeof (mxArray *)))) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2894 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2895 for (int i = 0; i < m_nfields; i++) |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2896 m_fields[i] = mxArray::strsave (val.m_fields[i]); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2897 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2898 mwSize nel = get_number_of_elements (); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2899 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2900 for (mwIndex i = 0; i < nel * m_nfields; i++) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2901 { |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2902 mxArray *ptr = val.m_data[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2903 m_data[i] = (ptr ? ptr->dup () : nullptr); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2904 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2905 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2906 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2907 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2908 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2909 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2910 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2911 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
2912 mxArray_struct& operator = (const mxArray_struct& val); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
2913 |
5900 | 2914 void init (const char **keys) |
2915 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2916 for (int i = 0; i < m_nfields; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2917 m_fields[i] = mxArray::strsave (keys[i]); |
5900 | 2918 } |
2919 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
2920 mxArray_base * dup (void) const { return new mxArray_struct (*this); } |
5900 | 2921 |
2922 ~mxArray_struct (void) | |
2923 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2924 for (int i = 0; i < m_nfields; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2925 mxFree (m_fields[i]); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2926 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2927 mxFree (m_fields); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2928 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2929 mwSize ntot = m_nfields * get_number_of_elements (); |
6686 | 2930 |
2931 for (mwIndex i = 0; i < ntot; i++) | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2932 delete m_data[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2933 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2934 mxFree (m_data); |
5900 | 2935 } |
2936 | |
2937 int add_field (const char *key) | |
2938 { | |
2939 int retval = -1; | |
2940 | |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2941 m_nfields++; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2942 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2943 m_fields = static_cast<char **> |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2944 (mxRealloc (m_fields, m_nfields * sizeof (char *))); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2945 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2946 if (m_fields) |
5900 | 2947 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2948 m_fields[m_nfields-1] = mxArray::strsave (key); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2949 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2950 mwSize nel = get_number_of_elements (); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2951 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2952 mwSize ntot = m_nfields * nel; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2953 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2954 mxArray **new_data; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2955 new_data = static_cast<mxArray **> |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2956 (mxArray::malloc (ntot * sizeof (mxArray *))); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2957 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2958 if (new_data) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2959 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2960 mwIndex j = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2961 mwIndex k = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2962 mwIndex n = 0; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2963 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2964 for (mwIndex i = 0; i < ntot; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2965 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2966 if (++n == m_nfields) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2967 { |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2968 new_data[j++] = nullptr; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2969 n = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2970 } |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2971 else |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2972 new_data[j++] = m_data[k++]; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2973 } |
30349
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2974 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2975 mxFree (m_data); |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2976 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2977 m_data = new_data; |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2978 |
5c6c5c8bbefd
mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents:
30232
diff
changeset
|
2979 retval = m_nfields - 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2980 } |
5900 | 2981 } |
2982 | |
2983 return retval; | |
2984 } | |
2985 | |
2986 void remove_field (int key_num) | |
2987 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2988 if (key_num >= 0 && key_num < m_nfields) |
5900 | 2989 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2990 mwSize nel = get_number_of_elements (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2991 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2992 mwSize ntot = m_nfields * nel; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2993 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
2994 int new_nfields = m_nfields - 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
2995 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2996 char **new_fields = static_cast<char **> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2997 (mxArray::malloc (new_nfields * sizeof (char *))); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2998 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2999 mxArray **new_data = static_cast<mxArray **> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3000 (mxArray::malloc (new_nfields * nel |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3001 * sizeof (mxArray *))); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3002 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3003 for (int i = 0; i < key_num; i++) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3004 new_fields[i] = m_fields[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3005 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3006 for (int i = key_num + 1; i < m_nfields; i++) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3007 new_fields[i-1] = m_fields[i]; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3008 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3009 if (new_nfields > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3010 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3011 mwIndex j = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3012 mwIndex k = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3013 mwIndex n = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3014 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3015 for (mwIndex i = 0; i < ntot; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3016 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3017 if (n == key_num) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3018 k++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3019 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3020 new_data[j++] = m_data[k++]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3021 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3022 if (++n == m_nfields) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3023 n = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3024 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3025 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3026 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3027 m_nfields = new_nfields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3028 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3029 mxFree (m_fields); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3030 mxFree (m_data); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3031 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3032 m_fields = new_fields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3033 m_data = new_data; |
5900 | 3034 } |
3035 } | |
3036 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3037 mxArray * get_field_by_number (mwIndex index, int key_num) const |
5900 | 3038 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3039 return key_num >= 0 && key_num < m_nfields |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3040 ? m_data[m_nfields * index + key_num] : nullptr; |
5900 | 3041 } |
3042 | |
6686 | 3043 void set_field_by_number (mwIndex index, int key_num, mxArray *val); |
5900 | 3044 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3045 int get_number_of_fields (void) const { return m_nfields; } |
5900 | 3046 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3047 const char * get_field_name_by_number (int key_num) const |
5900 | 3048 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3049 return key_num >= 0 && key_num < m_nfields ? m_fields[key_num] : nullptr; |
5900 | 3050 } |
3051 | |
3052 int get_field_number (const char *key) const | |
3053 { | |
3054 int retval = -1; | |
3055 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3056 for (int i = 0; i < m_nfields; i++) |
5900 | 3057 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3058 if (! strcmp (key, m_fields[i])) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3059 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3060 retval = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3061 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3062 } |
5900 | 3063 } |
3064 | |
3065 return retval; | |
3066 } | |
3067 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3068 void * get_data (void) const { return m_data; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3069 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3070 void set_data (void *data) { m_data = static_cast<mxArray **> (data); } |
5900 | 3071 |
5907 | 3072 octave_value as_octave_value (void) const |
3073 { | |
3074 dim_vector dv = dims_to_dim_vector (); | |
3075 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3076 string_vector keys (m_fields, m_nfields); |
5907 | 3077 |
25922
34e82a829fdd
Create scalar structs of size 1x1 with MEX interface (bug #54799).
Rik <rik@octave.org>
parents:
25751
diff
changeset
|
3078 octave_map m (dv); |
5907 | 3079 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3080 mwSize ntot = m_nfields * get_number_of_elements (); |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3081 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3082 for (int i = 0; i < m_nfields; i++) |
5907 | 3083 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3084 Cell c (dv); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3085 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3086 octave_value *p = c.fortran_vec (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3087 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3088 mwIndex k = 0; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3089 for (mwIndex j = i; j < ntot; j += m_nfields) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3090 p[k++] = mxArray::as_octave_value (m_data[j]); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3091 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3092 m.assign (keys[i], c); |
5907 | 3093 } |
3094 | |
3095 return m; | |
3096 } | |
3097 | |
5900 | 3098 private: |
3099 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3100 int m_nfields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3101 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3102 char **m_fields; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3103 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3104 mxArray **m_data; |
5900 | 3105 }; |
3106 | |
3107 // Matlab-style cell arrays. | |
3108 | |
3109 class mxArray_cell : public mxArray_matlab | |
3110 { | |
3111 public: | |
3112 | |
30213
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
3113 mxArray_cell (bool interleaved, mwSize ndims, const mwSize *dims) |
27791344a45c
* mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents:
30212
diff
changeset
|
3114 : mxArray_matlab (interleaved, mxCELL_CLASS, ndims, dims), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3115 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3116 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3117 { } |
5900 | 3118 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3119 mxArray_cell (bool interleaved, const dim_vector& dv) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3120 : mxArray_matlab (interleaved, mxCELL_CLASS, dv), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3121 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3122 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3123 { } |
5900 | 3124 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3125 mxArray_cell (bool interleaved, mwSize m, mwSize n) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3126 : mxArray_matlab (interleaved, mxCELL_CLASS, m, n), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3127 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3128 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3129 { } |
5900 | 3130 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3131 private: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3132 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3133 mxArray_cell (const mxArray_cell& val) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3134 : mxArray_matlab (val), |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3135 m_data (static_cast<mxArray **> ( |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3136 mxArray::malloc (get_number_of_elements () * sizeof (mxArray *)))) |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3137 { |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3138 mwSize nel = get_number_of_elements (); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3139 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3140 for (mwIndex i = 0; i < nel; i++) |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3141 { |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3142 mxArray *ptr = val.m_data[i]; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3143 m_data[i] = (ptr ? ptr->dup () : nullptr); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3144 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3145 } |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3146 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3147 public: |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3148 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3149 // No assignment! FIXME: should this be implemented? Note that we |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3150 // do have a copy constructor. |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3151 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3152 mxArray_cell& operator = (const mxArray_cell&); |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3153 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3154 mxArray_base * dup (void) const { return new mxArray_cell (*this); } |
5900 | 3155 |
3156 ~mxArray_cell (void) | |
3157 { | |
6686 | 3158 mwSize nel = get_number_of_elements (); |
3159 | |
22449
e337b8e3592c
Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
3160 for (mwIndex i = 0; i < nel; i++) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3161 delete m_data[i]; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3162 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3163 mxFree (m_data); |
5900 | 3164 } |
3165 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3166 mxArray * get_cell (mwIndex idx) const |
6187 | 3167 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3168 return idx >= 0 && idx < get_number_of_elements () ? m_data[idx] : nullptr; |
6187 | 3169 } |
5907 | 3170 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3171 void set_cell (mwIndex idx, mxArray *val); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3172 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3173 void * get_data (void) const { return m_data; } |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3174 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3175 void set_data (void *data) { m_data = static_cast<mxArray **> (data); } |
5907 | 3176 |
5900 | 3177 octave_value as_octave_value (void) const |
3178 { | |
3179 dim_vector dv = dims_to_dim_vector (); | |
3180 | |
3181 Cell c (dv); | |
3182 | |
6686 | 3183 mwSize nel = get_number_of_elements (); |
5900 | 3184 |
3185 octave_value *p = c.fortran_vec (); | |
3186 | |
6686 | 3187 for (mwIndex i = 0; i < nel; i++) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3188 p[i] = mxArray::as_octave_value (m_data[i]); |
5900 | 3189 |
3190 return c; | |
3191 } | |
3192 | |
3193 private: | |
3194 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3195 mxArray **m_data; |
5900 | 3196 }; |
3197 | |
3198 // ------------------------------------------------------------------ | |
3199 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3200 mxArray::mxArray (bool interleaved, const octave_value& ov) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3201 : m_rep (create_rep (interleaved, ov)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3202 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3203 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3204 mxArray::mxArray (bool interleaved, mxClassID id, mwSize ndims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3205 const mwSize *dims, mxComplexity flag, bool init) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3206 : m_rep (create_rep (interleaved, id, ndims, dims, flag, init)), |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3207 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3208 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3209 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3210 mxArray::mxArray (bool interleaved, mxClassID id, const dim_vector& dv, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3211 mxComplexity flag) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3212 : m_rep (create_rep (interleaved, id, dv, flag)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3213 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3214 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3215 mxArray::mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n, |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
3216 mxComplexity flag, bool init) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3217 : m_rep (create_rep (interleaved, id, m, n, flag, init)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3218 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3219 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3220 mxArray::mxArray (bool interleaved, mxClassID id, double val) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3221 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3222 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3223 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3224 mxArray::mxArray (bool interleaved, mxClassID id, mxLogical val) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3225 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3226 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3227 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3228 mxArray::mxArray (bool interleaved, const char *str) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3229 : m_rep (create_rep (interleaved, str)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3230 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3231 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3232 mxArray::mxArray (bool interleaved, mwSize m, const char **str) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3233 : m_rep (create_rep (interleaved, m, str)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3234 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3235 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3236 mxArray::mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3237 mwSize nzmax, mxComplexity flag) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3238 : m_rep (create_rep (interleaved, id, m, n, nzmax, flag)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3239 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3240 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3241 mxArray::mxArray (bool interleaved, mwSize ndims, const mwSize *dims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3242 int num_keys, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3243 const char **keys) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3244 : m_rep (new mxArray_struct (interleaved, ndims, dims, num_keys, keys)), |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3245 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3246 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3247 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3248 mxArray::mxArray (bool interleaved, const dim_vector& dv, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3249 const char **keys) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3250 : m_rep (new mxArray_struct (interleaved, dv, num_keys, keys)), |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3251 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3252 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3253 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3254 mxArray::mxArray (bool interleaved, mwSize m, mwSize n, int num_keys, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3255 const char **keys) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3256 : m_rep (new mxArray_struct (interleaved, m, n, num_keys, keys)), |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3257 m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3258 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3259 |
30212
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3260 mxArray::mxArray (bool interleaved, mwSize ndims, const mwSize *dims) |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3261 : m_rep (new mxArray_cell (interleaved, ndims, dims)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3262 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3263 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3264 mxArray::mxArray (bool interleaved, const dim_vector& dv) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3265 : m_rep (new mxArray_cell (interleaved, dv)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3266 { } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3267 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3268 mxArray::mxArray (bool interleaved, mwSize m, mwSize n) |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3269 : m_rep (new mxArray_cell (interleaved, m, n)), m_name (nullptr) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3270 { } |
5900 | 3271 |
3272 mxArray::~mxArray (void) | |
3273 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3274 mxFree (m_name); |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3275 |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3276 delete m_rep; |
5900 | 3277 } |
3278 | |
3279 void | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3280 mxArray::set_name (const char *name) |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3281 { |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3282 mxFree (m_name); |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3283 m_name = mxArray::strsave (name); |
5900 | 3284 } |
3285 | |
5907 | 3286 octave_value |
25451
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3287 mxArray::as_octave_value (const mxArray *ptr, bool null_is_empty) |
5907 | 3288 { |
25451
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3289 static const octave_value empty_matrix = Matrix (); |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3290 |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3291 return (ptr |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3292 ? ptr->as_octave_value () |
f84755f24ccd
allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents:
25450
diff
changeset
|
3293 : (null_is_empty ? empty_matrix : octave_value ())); |
5907 | 3294 } |
3295 | |
3296 octave_value | |
3297 mxArray::as_octave_value (void) const | |
3298 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3299 return m_rep->as_octave_value (); |
5907 | 3300 } |
3301 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3302 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3303 mxArray::create_rep (bool interleaved, const octave_value& ov) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3304 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3305 return new mxArray_octave_value (interleaved, ov); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3306 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3307 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3308 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3309 mxArray::create_rep (bool interleaved, mxClassID id, mwSize ndims, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3310 const mwSize *dims, mxComplexity flag, bool init) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3311 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3312 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3313 return new mxArray_interleaved_full (id, ndims, dims, flag, init); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3314 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3315 return new mxArray_separate_full (id, ndims, dims, flag, init); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3316 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3317 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3318 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3319 mxArray::create_rep (bool interleaved, mxClassID id, const dim_vector& dv, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3320 mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3321 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3322 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3323 return new mxArray_interleaved_full (id, dv, flag); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3324 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3325 return new mxArray_separate_full (id, dv, flag); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3326 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3327 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3328 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3329 mxArray::create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3330 mxComplexity flag, bool init) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3331 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3332 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3333 return new mxArray_interleaved_full (id, m, n, flag, init); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3334 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3335 return new mxArray_separate_full (id, m, n, flag, init); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3336 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3337 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3338 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3339 mxArray::create_rep (bool interleaved, mxClassID id, double val) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3340 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3341 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3342 return new mxArray_interleaved_full (id, val); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3343 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3344 return new mxArray_separate_full (id, val); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3345 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3346 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3347 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3348 mxArray::create_rep (bool interleaved, mxClassID id, mxLogical val) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3349 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3350 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3351 return new mxArray_interleaved_full (id, val); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3352 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3353 return new mxArray_separate_full (id, val); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3354 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3355 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3356 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3357 mxArray::create_rep (bool interleaved, const char *str) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3358 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3359 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3360 return new mxArray_interleaved_full (str); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3361 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3362 return new mxArray_separate_full (str); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3363 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3364 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3365 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3366 mxArray::create_rep (bool interleaved, mwSize m, const char **str) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3367 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3368 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3369 return new mxArray_interleaved_full (m, str); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3370 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3371 return new mxArray_separate_full (m, str); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3372 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3373 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3374 mxArray_base * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3375 mxArray::create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n, |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3376 mwSize nzmax, mxComplexity flag) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3377 { |
30224
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3378 if (interleaved) |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3379 return new mxArray_interleaved_sparse (id, m, n, nzmax, flag); |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3380 else |
8670f5165430
use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents:
30223
diff
changeset
|
3381 return new mxArray_separate_sparse (id, m, n, nzmax, flag); |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3382 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3383 |
5900 | 3384 void |
3385 mxArray::maybe_mutate (void) const | |
3386 { | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3387 if (m_rep->is_octave_value ()) |
5900 | 3388 { |
3389 // The mutate function returns a pointer to a complete new | |
3390 // mxArray object (or 0, if no mutation happened). We just want | |
3391 // to replace the existing rep with the rep from the new object. | |
3392 | |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3393 mxArray *new_val = m_rep->mutate (); |
5900 | 3394 |
3395 if (new_val) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3396 { |
30122
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3397 delete m_rep; |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3398 m_rep = new_val->m_rep; |
8418f99cfcd0
maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents:
30088
diff
changeset
|
3399 new_val->m_rep = nullptr; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3400 delete new_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3401 } |
5900 | 3402 } |
3403 } | |
3404 | |
3405 // ------------------------------------------------------------------ | |
3406 | |
6686 | 3407 // A class to manage calls to MEX functions. Mostly deals with memory |
5900 | 3408 // management. |
5864 | 3409 |
3410 class mex | |
3411 { | |
3412 public: | |
3413 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3414 mex (octave_mex_function& f) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3415 : m_curr_mex_fcn (f), m_memlist (), m_arraylist (), m_fname (nullptr) { } |
5864 | 3416 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3417 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3418 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3419 mex (const mex&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3420 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3421 mex& operator = (const mex&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
3422 |
5864 | 3423 ~mex (void) |
3424 { | |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3425 // We can't use mex::free here because it modifies memlist. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3426 while (! m_memlist.empty ()) |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3427 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3428 auto p = m_memlist.begin (); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3429 xfree (*p); |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3430 m_memlist.erase (p); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3431 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3432 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3433 // We can't use mex::free_value here because it modifies arraylist. |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3434 while (! m_arraylist.empty ()) |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3435 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3436 auto p = m_arraylist.begin (); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3437 delete *p; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3438 m_arraylist.erase (p); |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3439 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
3440 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3441 if (! (m_memlist.empty () && m_arraylist.empty ())) |
5905 | 3442 error ("mex: %s: cleanup failed", function_name ()); |
5900 | 3443 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3444 mxFree (m_fname); |
5864 | 3445 } |
3446 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3447 const char * function_name (void) const |
5900 | 3448 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3449 if (! m_fname) |
5900 | 3450 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3451 octave::tree_evaluator& tw |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3452 = octave::__get_evaluator__ ("mex::function_name"); |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3453 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
3454 octave_function *fcn = tw.current_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3455 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3456 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3457 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3458 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
|
3459 m_fname = mxArray::strsave (nm.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3460 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3461 else |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3462 m_fname = mxArray::strsave ("unknown"); |
5900 | 3463 } |
3464 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3465 return m_fname; |
5900 | 3466 } |
3467 | |
6071 | 3468 // 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
|
3469 void * malloc_unmarked (std::size_t n) |
5900 | 3470 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3471 void *ptr = xmalloc (n); |
5900 | 3472 |
3473 if (! ptr) | |
3474 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3475 // 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
|
3476 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
|
3477 function_name (), n); |
5900 | 3478 } |
3479 | |
3480 global_mark (ptr); | |
3481 | |
3482 return ptr; | |
3483 } | |
3484 | |
6071 | 3485 // 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
|
3486 void * malloc (std::size_t n) |
5900 | 3487 { |
3488 void *ptr = malloc_unmarked (n); | |
3489 | |
3490 mark (ptr); | |
3491 | |
3492 return ptr; | |
3493 } | |
3494 | |
6071 | 3495 // 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
|
3496 void * calloc_unmarked (std::size_t n, std::size_t t) |
5900 | 3497 { |
3498 void *ptr = malloc_unmarked (n*t); | |
3499 | |
3500 memset (ptr, 0, n*t); | |
3501 | |
3502 return ptr; | |
3503 } | |
3504 | |
6071 | 3505 // 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
|
3506 void * calloc (std::size_t n, std::size_t t) |
5900 | 3507 { |
3508 void *ptr = calloc_unmarked (n, t); | |
3509 | |
3510 mark (ptr); | |
3511 | |
3512 return ptr; | |
3513 } | |
3514 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3515 // 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
|
3516 // 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
|
3517 // 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
|
3518 void * realloc (void *ptr, std::size_t n) |
5900 | 3519 { |
10225
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3520 void *v; |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3521 |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3522 if (ptr) |
5900 | 3523 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3524 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
|
3525 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
|
3526 |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3527 v = xrealloc (ptr, n); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3528 |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3529 if (v) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3530 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3531 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
|
3532 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3533 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
|
3534 m_memlist.insert (v); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3535 } |
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3536 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3537 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
|
3538 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3539 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
|
3540 s_global_memlist.insert (v); |
26438
c048a6ac0f79
mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3541 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3542 } |
5900 | 3543 } |
10225
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3544 else |
477d05b0a739
mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents:
10127
diff
changeset
|
3545 v = malloc (n); |
5900 | 3546 |
3547 return v; | |
3548 } | |
3549 | |
3550 // Free a pointer obtained from malloc or calloc. | |
3551 void free (void *ptr) | |
3552 { | |
3553 if (ptr) | |
3554 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3555 unmark (ptr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3556 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3557 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
|
3558 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3559 if (p != s_global_memlist.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3560 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3561 s_global_memlist.erase (p); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3562 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3563 xfree (ptr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3564 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3565 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3566 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3567 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
|
3568 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3569 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
|
3570 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
|
3571 #if defined (DEBUG) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3572 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3573 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
|
3574 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3575 } |
5900 | 3576 } |
3577 } | |
3578 | |
7172 | 3579 // Mark a pointer to be freed on exit. |
3580 void mark (void *ptr) | |
3581 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3582 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3583 if (m_memlist.find (ptr) != m_memlist.end ()) |
7172 | 3584 warning ("%s: double registration ignored", function_name ()); |
3585 #endif | |
3586 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3587 m_memlist.insert (ptr); |
7172 | 3588 } |
3589 | |
3590 // Unmark a pointer to be freed on exit, either because it was | |
3591 // made persistent, or because it was already freed. | |
3592 void unmark (void *ptr) | |
3593 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3594 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
|
3595 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3596 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
|
3597 m_memlist.erase (p); |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3598 #if defined (DEBUG) |
7172 | 3599 else |
3600 warning ("%s: value not marked", function_name ()); | |
3601 #endif | |
3602 } | |
5900 | 3603 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
3604 mxArray * mark_array (mxArray *ptr) |
6065 | 3605 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3606 m_arraylist.insert (ptr); |
6065 | 3607 return ptr; |
3608 } | |
3609 | |
6071 | 3610 void unmark_array (mxArray *ptr) |
3611 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3612 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
|
3613 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3614 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
|
3615 m_arraylist.erase (p); |
6071 | 3616 } |
3617 | |
7179 | 3618 // Mark a pointer as one we allocated. |
3619 void mark_foreign (void *ptr) | |
3620 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3621 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3622 if (m_foreign_memlist.find (ptr) != m_foreign_memlist.end ()) |
7179 | 3623 warning ("%s: double registration ignored", function_name ()); |
3624 #endif | |
3625 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3626 m_foreign_memlist.insert (ptr); |
7179 | 3627 } |
3628 | |
3629 // Unmark a pointer as one we allocated. | |
3630 void unmark_foreign (void *ptr) | |
3631 { | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3632 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
|
3633 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3634 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
|
3635 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
|
3636 #if defined (DEBUG) |
7179 | 3637 else |
3638 warning ("%s: value not marked", function_name ()); | |
3639 #endif | |
3640 | |
3641 } | |
3642 | |
5900 | 3643 // Make a new array value and initialize from an octave value; it will be |
3644 // 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
|
3645 mxArray * make_value (const octave_value& ov) |
5900 | 3646 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3647 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
|
3648 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3649 return mark_array (new mxArray (interleaved, ov)); |
5900 | 3650 } |
3651 | |
3652 // Free an array and its contents. | |
6065 | 3653 bool free_value (mxArray *ptr) |
5900 | 3654 { |
6065 | 3655 bool inlist = false; |
3656 | |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3657 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
|
3658 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3659 if (p != m_arraylist.end ()) |
5905 | 3660 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3661 inlist = true; |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3662 m_arraylist.erase (p); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
3663 delete ptr; |
5905 | 3664 } |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3665 #if defined (DEBUG) |
5905 | 3666 else |
3667 warning ("mex::free_value: skipping memory not allocated by mex::make_value"); | |
3668 #endif | |
6065 | 3669 |
3670 return inlist; | |
5900 | 3671 } |
3672 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3673 octave_mex_function& current_mex_function (void) const |
6068 | 3674 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3675 return m_curr_mex_fcn; |
6068 | 3676 } |
3677 | |
5900 | 3678 // 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
|
3679 int trap_feval_error = 0; |
5864 | 3680 |
5900 | 3681 // Mark a pointer as one we allocated. |
5905 | 3682 void global_mark (void *ptr) |
5900 | 3683 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
3684 #if defined (DEBUG) |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3685 if (s_global_memlist.find (ptr) != s_global_memlist.end ()) |
5905 | 3686 warning ("%s: double registration ignored", function_name ()); |
5864 | 3687 #endif |
5900 | 3688 |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3689 s_global_memlist.insert (ptr); |
5864 | 3690 } |
3691 | |
5900 | 3692 // Unmark a pointer as one we allocated. |
5905 | 3693 void global_unmark (void *ptr) |
5864 | 3694 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3695 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
|
3696 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3697 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
|
3698 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
|
3699 #if defined (DEBUG) |
5905 | 3700 else |
3701 warning ("%s: value not marked", function_name ()); | |
5900 | 3702 #endif |
5864 | 3703 } |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3704 |
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
|
3705 private: |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3706 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3707 // 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
|
3708 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
|
3709 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3710 // 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
|
3711 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
|
3712 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3713 // 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
|
3714 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
|
3715 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3716 // 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
|
3717 // elsewhere. |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3718 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
|
3719 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3720 // 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
|
3721 mutable char *m_fname; |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3722 |
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3723 // 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
|
3724 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
|
3725 |
5864 | 3726 }; |
3727 | |
5900 | 3728 // 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
|
3729 std::set<void *> mex::s_global_memlist; |
5900 | 3730 |
3731 // Current context. | |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
3732 mex *mex_context = nullptr; |
5900 | 3733 |
3734 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
|
3735 mxArray::malloc (std::size_t n) |
5900 | 3736 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3737 return mex_context ? mex_context->malloc_unmarked (n) : xmalloc (n); |
5900 | 3738 } |
3739 | |
3740 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
|
3741 mxArray::calloc (std::size_t n, std::size_t t) |
5900 | 3742 { |
6065 | 3743 return mex_context ? mex_context->calloc_unmarked (n, t) : ::calloc (n, t); |
5900 | 3744 } |
3745 | |
30223
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3746 void * |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3747 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
|
3748 { |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3749 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
|
3750 } |
b8841fcd28c8
combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents:
30213
diff
changeset
|
3751 |
7179 | 3752 static inline void * |
3753 maybe_mark_foreign (void *ptr) | |
3754 { | |
3755 if (mex_context) | |
3756 mex_context->mark_foreign (ptr); | |
3757 | |
3758 return ptr; | |
3759 } | |
3760 | |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3761 static inline void |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3762 maybe_disown_ptr (void *ptr) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3763 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3764 if (mex_context) |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3765 { |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3766 mex_context->unmark (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3767 mex_context->global_unmark (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3768 mex_context->mark_foreign (ptr); |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3769 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3770 } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
30226
diff
changeset
|
3771 |
6071 | 3772 static inline mxArray * |
3773 maybe_unmark_array (mxArray *ptr) | |
3774 { | |
3775 if (mex_context) | |
3776 mex_context->unmark_array (ptr); | |
3777 | |
3778 return ptr; | |
3779 } | |
3780 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3781 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
|
3782 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
|
3783 maybe_unmark (T *ptr) |
7172 | 3784 { |
3785 if (mex_context) | |
3786 mex_context->unmark (ptr); | |
3787 | |
3788 return ptr; | |
3789 } | |
3790 | |
6071 | 3791 void |
6686 | 3792 mxArray_struct::set_field_by_number (mwIndex index, int key_num, mxArray *val) |
6071 | 3793 { |
30129
b7c04a5036d3
maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents:
30122
diff
changeset
|
3794 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
|
3795 m_data[m_nfields * index + key_num] = maybe_unmark_array (val); |
6071 | 3796 } |
3797 | |
3798 void | |
6686 | 3799 mxArray_cell::set_cell (mwIndex idx, mxArray *val) |
6071 | 3800 { |
6187 | 3801 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
|
3802 m_data[idx] = maybe_unmark_array (val); |
6071 | 3803 } |
3804 | |
5900 | 3805 // ------------------------------------------------------------------ |
3806 | |
3807 // C interface to mxArray objects: | |
3808 | |
3809 // Floating point predicates. | |
3810 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3811 bool |
5900 | 3812 mxIsFinite (const double v) |
3813 { | |
30088
fca57eaad2d4
maint: deprecate lo_ieee_finite and replace with lo_ieee_isfinite.
Rik <rik@octave.org>
parents:
29993
diff
changeset
|
3814 return lo_ieee_isfinite (v) != 0; |
5900 | 3815 } |
3816 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3817 bool |
5900 | 3818 mxIsInf (const double v) |
3819 { | |
3820 return lo_ieee_isinf (v) != 0; | |
3821 } | |
3822 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
3823 bool |
5900 | 3824 mxIsNaN (const double v) |
3825 { | |
3826 return lo_ieee_isnan (v) != 0; | |
3827 } | |
3828 | |
3829 double | |
3830 mxGetEps (void) | |
3831 { | |
15220
61822c866ba1
use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3832 return std::numeric_limits<double>::epsilon (); |
5900 | 3833 } |
3834 | |
3835 double | |
3836 mxGetInf (void) | |
3837 { | |
3838 return lo_ieee_inf_value (); | |
3839 } | |
3840 | |
3841 double | |
3842 mxGetNaN (void) | |
3843 { | |
3844 return lo_ieee_nan_value (); | |
3845 } | |
3846 | |
3847 // Memory management. | |
3848 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
|
3849 mxCalloc (std::size_t n, std::size_t size) |
5900 | 3850 { |
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
|
3851 return mex_context ? mex_context->calloc (n, size) : ::calloc (n, size); |
5900 | 3852 } |
3853 | |
3854 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
|
3855 mxMalloc (std::size_t n) |
5900 | 3856 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3857 return mex_context ? mex_context->malloc (n) : xmalloc (n); |
5900 | 3858 } |
3859 | |
3860 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
|
3861 mxRealloc (void *ptr, std::size_t size) |
5900 | 3862 { |
30428
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3863 return (mex_context |
2ac26917bdec
mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3864 ? mex_context->realloc (ptr, size) : xrealloc (ptr, size)); |
5900 | 3865 } |
3866 | |
3867 void | |
3868 mxFree (void *ptr) | |
5864 | 3869 { |
5900 | 3870 if (mex_context) |
3871 mex_context->free (ptr); | |
5864 | 3872 else |
6071 | 3873 xfree (ptr); |
5900 | 3874 } |
6065 | 3875 |
3876 static inline mxArray * | |
3877 maybe_mark_array (mxArray *ptr) | |
3878 { | |
3879 return mex_context ? mex_context->mark_array (ptr) : ptr; | |
3880 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3881 |
5900 | 3882 // Constructors. |
3883 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
|
3884 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
|
3885 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3886 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
|
3887 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3888 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3889 mxArray * |
6686 | 3890 mxCreateCellArray (mwSize ndims, const mwSize *dims) |
5900 | 3891 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3892 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
|
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 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3895 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3896 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
|
3897 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3898 return maybe_mark_array (new mxArray (true, m, n)); |
5900 | 3899 } |
3900 | |
3901 mxArray * | |
6686 | 3902 mxCreateCellMatrix (mwSize m, mwSize n) |
5900 | 3903 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3904 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
|
3905 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3906 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3907 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3908 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
|
3909 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3910 return maybe_mark_array (new mxArray (true, mxCHAR_CLASS, ndims, dims)); |
5900 | 3911 } |
3912 | |
3913 mxArray * | |
6686 | 3914 mxCreateCharArray (mwSize ndims, const mwSize *dims) |
5900 | 3915 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3916 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
|
3917 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3918 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3919 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3920 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
|
3921 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3922 return maybe_mark_array (new mxArray (true, m, str)); |
5864 | 3923 } |
3924 | |
5900 | 3925 mxArray * |
6686 | 3926 mxCreateCharMatrixFromStrings (mwSize m, const char **str) |
5900 | 3927 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3928 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
|
3929 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3930 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3931 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3932 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
|
3933 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3934 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, flag)); |
5900 | 3935 } |
3936 | |
3937 mxArray * | |
6686 | 3938 mxCreateDoubleMatrix (mwSize m, mwSize n, mxComplexity flag) |
5900 | 3939 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3940 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
|
3941 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3942 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3943 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
|
3944 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
|
3945 { |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3946 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, val)); |
5900 | 3947 } |
3948 | |
3949 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
|
3950 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
|
3951 { |
c27b9ba4c9bd
* mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents:
30129
diff
changeset
|
3952 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
|
3953 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3954 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3955 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3956 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
|
3957 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3958 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, ndims, dims)); |
5900 | 3959 } |
3960 | |
3961 mxArray * | |
6686 | 3962 mxCreateLogicalArray (mwSize ndims, const mwSize *dims) |
5864 | 3963 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3964 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
|
3965 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3966 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3967 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3968 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
|
3969 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3970 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n)); |
5900 | 3971 } |
3972 | |
3973 mxArray * | |
6686 | 3974 mxCreateLogicalMatrix (mwSize m, mwSize n) |
5900 | 3975 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3976 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
|
3977 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3978 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3979 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3980 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
|
3981 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3982 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, val)); |
5900 | 3983 } |
3984 | |
3985 mxArray * | |
7577
ba8fcc115fee
mex.cc: arg to mxCreateLogicalScalar is now mxLogical
John W. Eaton <jwe@octave.org>
parents:
7357
diff
changeset
|
3986 mxCreateLogicalScalar (mxLogical val) |
5900 | 3987 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3988 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
|
3989 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3990 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3991 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
3992 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
|
3993 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
|
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 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag)); |
5900 | 3996 } |
3997 | |
3998 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
|
3999 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
|
4000 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
|
4001 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4002 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
|
4003 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4004 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4005 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4006 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
|
4007 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
|
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 return maybe_mark_array (new mxArray (true, class_id, m, n, flag)); |
5864 | 4010 } |
4011 | |
5900 | 4012 mxArray * |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4013 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
|
4014 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
|
4015 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4016 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
|
4017 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4018 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4019 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4020 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
|
4021 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
|
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 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
|
4024 false)); |
5900 | 4025 } |
4026 | |
4027 mxArray * | |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4028 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
|
4029 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
|
4030 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4031 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
|
4032 false)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4033 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4034 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4035 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4036 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
|
4037 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
|
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 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
|
4040 } |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4041 |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4042 mxArray * |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4043 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
|
4044 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
|
4045 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4046 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
|
4047 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4048 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4049 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4050 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
|
4051 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4052 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
|
4053 flag)); |
22464
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4054 } |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4055 |
1d2960b5efe6
Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents:
22462
diff
changeset
|
4056 mxArray * |
6686 | 4057 mxCreateSparse (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag) |
5900 | 4058 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4059 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
|
4060 flag)); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4061 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4062 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4063 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4064 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
|
4065 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4066 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n, nzmax)); |
5900 | 4067 } |
4068 | |
4069 mxArray * | |
6686 | 4070 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax) |
5900 | 4071 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4072 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
|
4073 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4074 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4075 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4076 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
|
4077 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4078 return maybe_mark_array (new mxArray (true, str)); |
5900 | 4079 } |
4080 | |
4081 mxArray * | |
4082 mxCreateString (const char *str) | |
4083 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4084 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
|
4085 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4086 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4087 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4088 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
|
4089 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
|
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 return maybe_mark_array (new mxArray (true, ndims, dims, num_keys, keys)); |
5900 | 4092 } |
4093 | |
4094 mxArray * | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4095 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
|
4096 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
|
4097 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4098 return maybe_mark_array (new mxArray (false, ndims, dims, num_keys, keys)); |
5900 | 4099 } |
5864 | 4100 |
4101 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
|
4102 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
|
4103 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
|
4104 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4105 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
|
4106 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4107 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4108 mxArray * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4109 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
|
4110 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
|
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 return maybe_mark_array (new mxArray (false, m, n, num_keys, keys)); |
5900 | 4113 } |
4114 | |
4115 // Copy constructor. | |
4116 mxArray * | |
4117 mxDuplicateArray (const mxArray *ptr) | |
4118 { | |
11277
7d5351fc575a
mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents:
11276
diff
changeset
|
4119 return maybe_mark_array (ptr->dup ()); |
5900 | 4120 } |
4121 | |
4122 // Destructor. | |
4123 void | |
4124 mxDestroyArray (mxArray *ptr) | |
4125 { | |
6065 | 4126 if (! (mex_context && mex_context->free_value (ptr))) |
4127 delete ptr; | |
5900 | 4128 } |
4129 | |
4130 // 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
|
4131 bool |
5900 | 4132 mxIsCell (const mxArray *ptr) |
4133 { | |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
4134 return ptr->iscell (); |
5900 | 4135 } |
4136 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4137 bool |
5900 | 4138 mxIsChar (const mxArray *ptr) |
4139 { | |
4140 return ptr->is_char (); | |
4141 } | |
4142 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4143 bool |
5900 | 4144 mxIsClass (const mxArray *ptr, const char *name) |
4145 { | |
4146 return ptr->is_class (name); | |
4147 } | |
4148 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4149 bool |
5900 | 4150 mxIsComplex (const mxArray *ptr) |
4151 { | |
4152 return ptr->is_complex (); | |
4153 } | |
4154 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4155 bool |
5900 | 4156 mxIsDouble (const mxArray *ptr) |
4157 { | |
4158 return ptr->is_double (); | |
4159 } | |
4160 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4161 bool |
11100
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4162 mxIsFunctionHandle (const mxArray *ptr) |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4163 { |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4164 return ptr->is_function_handle (); |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4165 } |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
11073
diff
changeset
|
4166 |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4167 bool |
5900 | 4168 mxIsInt16 (const mxArray *ptr) |
4169 { | |
4170 return ptr->is_int16 (); | |
4171 } | |
4172 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4173 bool |
5900 | 4174 mxIsInt32 (const mxArray *ptr) |
4175 { | |
4176 return ptr->is_int32 (); | |
4177 } | |
4178 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4179 bool |
5900 | 4180 mxIsInt64 (const mxArray *ptr) |
4181 { | |
4182 return ptr->is_int64 (); | |
4183 } | |
4184 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4185 bool |
5900 | 4186 mxIsInt8 (const mxArray *ptr) |
4187 { | |
4188 return ptr->is_int8 (); | |
4189 } | |
4190 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4191 bool |
5900 | 4192 mxIsLogical (const mxArray *ptr) |
4193 { | |
4194 return ptr->is_logical (); | |
4195 } | |
4196 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4197 bool |
5900 | 4198 mxIsNumeric (const mxArray *ptr) |
4199 { | |
4200 return ptr->is_numeric (); | |
4201 } | |
4202 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4203 bool |
5900 | 4204 mxIsSingle (const mxArray *ptr) |
4205 { | |
4206 return ptr->is_single (); | |
4207 } | |
4208 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4209 bool |
5900 | 4210 mxIsSparse (const mxArray *ptr) |
4211 { | |
4212 return ptr->is_sparse (); | |
4213 } | |
4214 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4215 bool |
5900 | 4216 mxIsStruct (const mxArray *ptr) |
4217 { | |
4218 return ptr->is_struct (); | |
4219 } | |
4220 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4221 bool |
5900 | 4222 mxIsUint16 (const mxArray *ptr) |
4223 { | |
4224 return ptr->is_uint16 (); | |
4225 } | |
4226 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4227 bool |
5900 | 4228 mxIsUint32 (const mxArray *ptr) |
4229 { | |
4230 return ptr->is_uint32 (); | |
4231 } | |
4232 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4233 bool |
5900 | 4234 mxIsUint64 (const mxArray *ptr) |
4235 { | |
4236 return ptr->is_uint64 (); | |
4237 } | |
4238 | |
22465
6149f6b34cbc
Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents:
22464
diff
changeset
|
4239 bool |
5900 | 4240 mxIsUint8 (const mxArray *ptr) |
4241 { | |
4242 return ptr->is_uint8 (); | |
4243 } | |
4244 | |
4245 // 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
|
4246 bool |
5900 | 4247 mxIsLogicalScalar (const mxArray *ptr) |
4248 { | |
4249 return ptr->is_logical_scalar (); | |
4250 } | |
4251 | |
4252 // 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
|
4253 bool |
5900 | 4254 mxIsLogicalScalarTrue (const mxArray *ptr) |
4255 { | |
4256 return ptr->is_logical_scalar_true (); | |
4257 } | |
4258 | |
4259 // 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
|
4260 bool |
5900 | 4261 mxIsEmpty (const mxArray *ptr) |
4262 { | |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
4263 return ptr->isempty (); |
5900 | 4264 } |
4265 | |
22462
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4266 bool |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4267 mxIsScalar (const mxArray *ptr) |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4268 { |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4269 return ptr->is_scalar (); |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4270 } |
6cb7813e5b2f
Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents:
22454
diff
changeset
|
4271 |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4272 // 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
|
4273 // 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
|
4274 bool |
20527
2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents:
20362
diff
changeset
|
4275 mxIsFromGlobalWS (const mxArray * /*ptr*/) |
5900 | 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 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
|
4278 |
5900 | 4279 return 0; |
4280 } | |
4281 | |
4282 // 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
|
4283 std::size_t |
5900 | 4284 mxGetM (const mxArray *ptr) |
4285 { | |
4286 return ptr->get_m (); | |
4287 } | |
4288 | |
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
|
4289 std::size_t |
5900 | 4290 mxGetN (const mxArray *ptr) |
4291 { | |
4292 return ptr->get_n (); | |
4293 } | |
4294 | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4295 const mwSize * |
5900 | 4296 mxGetDimensions (const mxArray *ptr) |
5864 | 4297 { |
5900 | 4298 return ptr->get_dimensions (); |
4299 } | |
4300 | |
6686 | 4301 mwSize |
5900 | 4302 mxGetNumberOfDimensions (const mxArray *ptr) |
4303 { | |
4304 return ptr->get_number_of_dimensions (); | |
4305 } | |
4306 | |
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
|
4307 std::size_t |
5900 | 4308 mxGetNumberOfElements (const mxArray *ptr) |
4309 { | |
4310 return ptr->get_number_of_elements (); | |
4311 } | |
4312 | |
4313 // Dimension setters. | |
4314 void | |
6686 | 4315 mxSetM (mxArray *ptr, mwSize m) |
5900 | 4316 { |
4317 ptr->set_m (m); | |
4318 } | |
4319 | |
4320 void | |
6686 | 4321 mxSetN (mxArray *ptr, mwSize n) |
5900 | 4322 { |
4323 ptr->set_n (n); | |
4324 } | |
4325 | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4326 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
|
4327 mxSetDimensions (mxArray *ptr, const mwSize *dims, mwSize ndims) |
5900 | 4328 { |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4329 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
|
4330 (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
|
4331 ndims)); |
5900 | 4332 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
4333 |
5900 | 4334 // Data extractors. |
4335 double * | |
4336 mxGetPr (const mxArray *ptr) | |
4337 { | |
4338 return static_cast<double *> (ptr->get_data ()); | |
4339 } | |
4340 | |
4341 double | |
4342 mxGetScalar (const mxArray *ptr) | |
4343 { | |
6332 | 4344 return ptr->get_scalar (); |
5900 | 4345 } |
4346 | |
4347 mxChar * | |
4348 mxGetChars (const mxArray *ptr) | |
4349 { | |
22471
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4350 if (mxIsChar (ptr)) |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4351 return static_cast<mxChar *> (ptr->get_data ()); |
667d353d1ab8
Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents:
22465
diff
changeset
|
4352 else |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4353 return nullptr; |
5900 | 4354 } |
4355 | |
4356 mxLogical * | |
4357 mxGetLogicals (const mxArray *ptr) | |
4358 { | |
4359 return static_cast<mxLogical *> (ptr->get_data ()); | |
4360 } | |
4361 | |
4362 void * | |
4363 mxGetData (const mxArray *ptr) | |
4364 { | |
4365 return ptr->get_data (); | |
4366 } | |
4367 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4368 double * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4369 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
|
4370 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4371 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
|
4372 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4373 |
5900 | 4374 void * |
4375 mxGetImagData (const mxArray *ptr) | |
4376 { | |
4377 return ptr->get_imag_data (); | |
4378 } | |
4379 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4380 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
|
4381 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4382 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
|
4383 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4384 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4385 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
|
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_singles (); |
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 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
|
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_int8s (); |
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 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
|
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_int16s (); |
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 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
|
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_int32s (); |
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 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
|
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_int64s (); |
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 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
|
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_uint8s (); |
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 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
|
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_uint16s (); |
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 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
|
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_uint32s (); |
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 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
|
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_uint64s (); |
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 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
|
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_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
|
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 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
|
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_singles (); |
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 #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
|
4441 /* 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
|
4442 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
|
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 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
|
4445 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4446 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4447 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
|
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_int16s (); |
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 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
|
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_int32s (); |
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 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
|
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_int64s (); |
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 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
|
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_uint8s (); |
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 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
|
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_uint16s (); |
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 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
|
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_uint32s (); |
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 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
|
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_uint64s (); |
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 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4482 |
5900 | 4483 // Data setters. |
4484 void | |
4485 mxSetPr (mxArray *ptr, double *pr) | |
4486 { | |
7172 | 4487 ptr->set_data (maybe_unmark (pr)); |
5900 | 4488 } |
4489 | |
4490 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
|
4491 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
|
4492 { |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4493 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
|
4494 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4495 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4496 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
|
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 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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 #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
|
4557 /* 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
|
4558 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
|
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 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
|
4561 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4562 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4563 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 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
|
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_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
|
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 #endif |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4598 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4599 void |
5900 | 4600 mxSetPi (mxArray *ptr, double *pi) |
4601 { | |
7172 | 4602 ptr->set_imag_data (maybe_unmark (pi)); |
5864 | 4603 } |
4604 | |
5900 | 4605 void |
4606 mxSetImagData (mxArray *ptr, void *pi) | |
4607 { | |
7172 | 4608 ptr->set_imag_data (maybe_unmark (pi)); |
5900 | 4609 } |
4610 | |
4611 // Classes. | |
4612 mxClassID | |
4613 mxGetClassID (const mxArray *ptr) | |
4614 { | |
4615 return ptr->get_class_id (); | |
4616 } | |
4617 | |
4618 const char * | |
4619 mxGetClassName (const mxArray *ptr) | |
4620 { | |
4621 return ptr->get_class_name (); | |
4622 } | |
4623 | |
4624 void | |
4625 mxSetClassName (mxArray *ptr, const char *name) | |
4626 { | |
4627 ptr->set_class_name (name); | |
4628 } | |
4629 | |
23893
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4630 void |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4631 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
|
4632 const mxArray *property_value) |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4633 { |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4634 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
|
4635 } |
75eff5b667b3
new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents:
23891
diff
changeset
|
4636 |
23891
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4637 mxArray * |
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4638 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
|
4639 { |
23891
142a9c7e403a
Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents:
23884
diff
changeset
|
4640 return ptr->get_property (idx, property_name); |
23884
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4641 } |
bd9e719f04cc
new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
4642 |
5900 | 4643 // Cell support. |
4644 mxArray * | |
6686 | 4645 mxGetCell (const mxArray *ptr, mwIndex idx) |
5900 | 4646 { |
4647 return ptr->get_cell (idx); | |
4648 } | |
4649 | |
4650 void | |
6686 | 4651 mxSetCell (mxArray *ptr, mwIndex idx, mxArray *val) |
5900 | 4652 { |
4653 ptr->set_cell (idx, val); | |
4654 } | |
4655 | |
4656 // Sparse support. | |
6686 | 4657 mwIndex * |
5900 | 4658 mxGetIr (const mxArray *ptr) |
4659 { | |
4660 return ptr->get_ir (); | |
4661 } | |
4662 | |
6686 | 4663 mwIndex * |
5900 | 4664 mxGetJc (const mxArray *ptr) |
4665 { | |
4666 return ptr->get_jc (); | |
4667 } | |
4668 | |
6686 | 4669 mwSize |
5900 | 4670 mxGetNzmax (const mxArray *ptr) |
4671 { | |
4672 return ptr->get_nzmax (); | |
4673 } | |
4674 | |
4675 void | |
6686 | 4676 mxSetIr (mxArray *ptr, mwIndex *ir) |
5900 | 4677 { |
19739
3fa35defe495
Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
4678 ptr->set_ir (static_cast<mwIndex *> (maybe_unmark (ir))); |
5900 | 4679 } |
4680 | |
4681 void | |
6686 | 4682 mxSetJc (mxArray *ptr, mwIndex *jc) |
5900 | 4683 { |
7172 | 4684 ptr->set_jc (static_cast<mwIndex *> (maybe_unmark (jc))); |
5900 | 4685 } |
4686 | |
4687 void | |
6686 | 4688 mxSetNzmax (mxArray *ptr, mwSize nzmax) |
5900 | 4689 { |
4690 ptr->set_nzmax (nzmax); | |
4691 } | |
4692 | |
4693 // Structure support. | |
4694 int | |
4695 mxAddField (mxArray *ptr, const char *key) | |
4696 { | |
4697 return ptr->add_field (key); | |
4698 } | |
4699 | |
4700 void | |
4701 mxRemoveField (mxArray *ptr, int key_num) | |
4702 { | |
4703 ptr->remove_field (key_num); | |
4704 } | |
5864 | 4705 |
4706 mxArray * | |
6686 | 4707 mxGetField (const mxArray *ptr, mwIndex index, const char *key) |
5900 | 4708 { |
4709 int key_num = mxGetFieldNumber (ptr, key); | |
4710 return mxGetFieldByNumber (ptr, index, key_num); | |
4711 } | |
4712 | |
4713 mxArray * | |
6686 | 4714 mxGetFieldByNumber (const mxArray *ptr, mwIndex index, int key_num) |
5864 | 4715 { |
5900 | 4716 return ptr->get_field_by_number (index, key_num); |
5864 | 4717 } |
4718 | |
5900 | 4719 void |
6686 | 4720 mxSetField (mxArray *ptr, mwIndex index, const char *key, mxArray *val) |
5900 | 4721 { |
4722 int key_num = mxGetFieldNumber (ptr, key); | |
4723 mxSetFieldByNumber (ptr, index, key_num, val); | |
4724 } | |
5864 | 4725 |
4726 void | |
6686 | 4727 mxSetFieldByNumber (mxArray *ptr, mwIndex index, int key_num, mxArray *val) |
5864 | 4728 { |
5900 | 4729 ptr->set_field_by_number (index, key_num, val); |
4730 } | |
4731 | |
4732 int | |
4733 mxGetNumberOfFields (const mxArray *ptr) | |
4734 { | |
4735 return ptr->get_number_of_fields (); | |
5864 | 4736 } |
4737 | |
5900 | 4738 const char * |
4739 mxGetFieldNameByNumber (const mxArray *ptr, int key_num) | |
5864 | 4740 { |
5900 | 4741 return ptr->get_field_name_by_number (key_num); |
4742 } | |
4743 | |
4744 int | |
4745 mxGetFieldNumber (const mxArray *ptr, const char *key) | |
4746 { | |
4747 return ptr->get_field_number (key); | |
5864 | 4748 } |
4749 | |
5900 | 4750 int |
6686 | 4751 mxGetString (const mxArray *ptr, char *buf, mwSize buflen) |
5900 | 4752 { |
4753 return ptr->get_string (buf, buflen); | |
4754 } | |
4755 | |
4756 char * | |
4757 mxArrayToString (const mxArray *ptr) | |
5864 | 4758 { |
5900 | 4759 return ptr->array_to_string (); |
4760 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
4761 |
6686 | 4762 mwIndex |
4763 mxCalcSingleSubscript (const mxArray *ptr, mwSize nsubs, mwIndex *subs) | |
5900 | 4764 { |
4765 return ptr->calc_single_subscript (nsubs, subs); | |
5864 | 4766 } |
5900 | 4767 |
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
|
4768 std::size_t |
5900 | 4769 mxGetElementSize (const mxArray *ptr) |
4770 { | |
4771 return ptr->get_element_size (); | |
4772 } | |
4773 | |
4774 // ------------------------------------------------------------------ | |
5864 | 4775 |
4776 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
|
4777 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
|
4778 F77_INT& nrhs, mxArray **prhs); |
5864 | 4779 |
4780 octave_value_list | |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4781 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
|
4782 int nargout_arg) |
5864 | 4783 { |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4784 octave_quit (); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4785 |
5900 | 4786 // Use at least 1 for nargout since even for zero specified args, |
4787 // still want to be able to return an ans. | |
5864 | 4788 |
8806 | 4789 volatile int nargout = nargout_arg; |
4790 | |
5864 | 4791 int nargin = args.length (); |
5900 | 4792 OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin); |
5864 | 4793 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
|
4794 argin[i] = nullptr; |
5864 | 4795 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
4796 int nout = (nargout == 0 ? 1 : nargout); |
5900 | 4797 OCTAVE_LOCAL_BUFFER (mxArray *, argout, nout); |
5864 | 4798 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
|
4799 argout[i] = nullptr; |
5864 | 4800 |
5905 | 4801 // Save old mex pointer. |
28823
26cfccfee9a0
Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents:
28370
diff
changeset
|
4802 octave::unwind_protect_var<mex *> restore_var (mex_context); |
5905 | 4803 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4804 mex context (mex_fcn); |
5900 | 4805 |
5864 | 4806 for (int i = 0; i < nargin; i++) |
4807 argin[i] = context.make_value (args(i)); | |
4808 | |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4809 mex_context = &context; |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4810 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4811 void *mex_fcn_ptr = mex_fcn.mex_fcn_ptr (); |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4812 |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4813 if (mex_fcn.is_fmex ()) |
5864 | 4814 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4815 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
|
4816 |
23498
647705ffb110
use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
4817 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
|
4818 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
|
4819 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4820 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
|
4821 } |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4822 else |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4823 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23498
diff
changeset
|
4824 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
|
4825 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4826 fcn (nargout, argout, nargin, argin); |
5864 | 4827 } |
4828 | |
4829 // Convert returned array entries back into octave values. | |
4830 | |
4831 octave_value_list retval; | |
4832 | |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4833 if (nargout == 0 && argout[0]) |
5864 | 4834 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4835 // We have something for ans. |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4836 nargout = 1; |
5864 | 4837 } |
4838 | |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4839 retval.resize (nargout); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4840 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4841 // 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
|
4842 // 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
|
4843 // 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
|
4844 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4845 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
|
4846 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
|
4847 |
5864 | 4848 return retval; |
4849 } | |
4850 | |
4851 // C interface to mex functions: | |
4852 | |
4853 const char * | |
4854 mexFunctionName (void) | |
4855 { | |
5900 | 4856 return mex_context ? mex_context->function_name () : "unknown"; |
4857 } | |
4858 | |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4859 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
|
4860 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
|
4861 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4862 // 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
|
4863 // 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
|
4864 // 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
|
4865 // 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
|
4866 // 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
|
4867 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4868 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
|
4869 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4870 #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
|
4871 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4872 // 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
|
4873 // 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
|
4874 // 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
|
4875 // 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
|
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::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
|
4878 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
|
4879 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4880 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4881 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4882 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
|
4883 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
|
4884 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4885 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
|
4886 } |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4887 |
5900 | 4888 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
|
4889 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
|
4890 mxArray *argin[], const char *fname) |
5900 | 4891 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
4892 octave_value_list args = mx_to_ov_args (nargin, argin); |
5900 | 4893 |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4894 octave::interpreter& interp = octave::__get_interpreter__ ("mexCallMATLAB"); |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4895 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4896 bool execution_error = false; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4897 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4898 octave_value_list retval; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4899 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4900 try |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4901 { |
29172
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4902 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
|
4903 |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4904 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
|
4905 ([&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
|
4906 { |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4907 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
|
4908 }, tw.lvalue_list ()); |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4909 |
32fdcf67a683
don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
4910 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
|
4911 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
4912 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
|
4913 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4914 catch (const octave::execution_exception&) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4915 { |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4916 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
|
4917 { |
27471 | 4918 // FIXME: is there a way to indicate what error occurred? |
4919 // Should the error message be displayed here? Do we need to | |
4920 // save the exception info for lasterror? | |
4921 | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4922 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
|
4923 |
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4924 execution_error = true; |
2fb86778f78d
Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents:
22449
diff
changeset
|
4925 } |
20771
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4926 else |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4927 { |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4928 args.resize (0); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4929 retval.resize (0); |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4930 |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4931 throw; |
ed708a7ce0a2
simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
4932 } |
5900 | 4933 } |
4934 | |
4935 int num_to_copy = retval.length (); | |
4936 | |
4937 if (nargout < retval.length ()) | |
4938 num_to_copy = nargout; | |
4939 | |
4940 for (int i = 0; i < num_to_copy; i++) | |
4941 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4942 // FIXME: it would be nice to avoid copying the value here, |
5900 | 4943 // but there is no way to steal memory from a matrix, never mind |
4944 // that matrix memory is allocated by new[] and mxArray memory | |
4945 // 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
|
4946 argout[i] = mex_context->make_value (retval(i)); |
5900 | 4947 } |
4948 | |
4949 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
|
4950 argout[num_to_copy++] = nullptr; |
5900 | 4951 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4952 return execution_error ? 1 : 0; |
5900 | 4953 } |
4954 | |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4955 mxArray * |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4956 mexCallMATLABWithTrap (int nargout, mxArray *argout[], int nargin, |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4957 mxArray *argin[], const char *fname) |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4958 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
4959 mxArray *mx = nullptr; |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4960 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
4961 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
|
4962 mexSetTrapFlag (1); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4963 if (mexCallMATLAB (nargout, argout, nargin, argin, fname)) |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4964 { |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4965 const char *field_names[] = {"identifier", "message", "case", "stack"}; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4966 mx = mxCreateStructMatrix (1, 1, 4, field_names); |
22451
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4967 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX")); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4968 std::string msg = "mexCallMATLABWithTrap: function call <" |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4969 + std::string (fname) + "> failed"; |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4970 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ())); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4971 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
|
4972 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
|
4973 } |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4974 mexSetTrapFlag (old_flag); |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4975 |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4976 return mx; |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4977 } |
ad5439817753
Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents:
22450
diff
changeset
|
4978 |
5900 | 4979 void |
4980 mexSetTrapFlag (int flag) | |
4981 { | |
4982 if (mex_context) | |
4983 mex_context->trap_feval_error = flag; | |
4984 } | |
4985 | |
4986 int | |
4987 mexEvalString (const char *s) | |
4988 { | |
4989 int retval = 0; | |
4990 | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4991 octave::interpreter& interp = octave::__get_interpreter__ ("mexEvalString"); |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4992 |
5900 | 4993 int parse_status; |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
4994 bool execution_error = false; |
5900 | 4995 |
4996 octave_value_list ret; | |
4997 | |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
4998 try |
5900 | 4999 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25922
diff
changeset
|
5000 ret = interp.eval_string (std::string (s), false, parse_status, 0); |
5900 | 5001 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5002 catch (const octave::execution_exception&) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5003 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5004 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
|
5005 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5006 execution_error = true; |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5007 } |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5008 |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5009 if (parse_status || execution_error) |
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20527
diff
changeset
|
5010 retval = 1; |
5864 | 5011 |
5012 return retval; | |
5013 } | |
5014 | |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5015 mxArray * |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5016 mexEvalStringWithTrap (const char *s) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5017 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5018 mxArray *mx = nullptr; |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5019 |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5020 octave::interpreter& interp = octave::__get_interpreter__ ("mexEvalString"); |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5021 |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5022 int parse_status; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5023 bool execution_error = false; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5024 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5025 octave_value_list ret; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5026 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5027 try |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5028 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25922
diff
changeset
|
5029 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
|
5030 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5031 catch (const octave::execution_exception&) |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5032 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5033 interp.recover_from_exception (); |
22454
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5034 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5035 execution_error = true; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5036 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5037 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5038 if (parse_status || execution_error) |
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 const char *field_names[] = {"identifier", "message", "case", "stack"}; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5041 mx = mxCreateStructMatrix (1, 1, 4, field_names); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5042 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX")); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5043 std::string msg = "mexEvalStringWithTrap: eval of <" |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5044 + std::string (s) + "> failed"; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5045 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ())); |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5046 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
|
5047 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
|
5048 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5049 |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5050 return mx; |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5051 } |
8445f67a8123
Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents:
22452
diff
changeset
|
5052 |
5864 | 5053 void |
5054 mexErrMsgTxt (const char *s) | |
5055 { | |
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
|
5056 std::size_t len; |
25751
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5057 |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5058 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
|
5059 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5060 if (s[len - 1] == '\n') |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5061 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5062 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
|
5063 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
|
5064 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5065 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5066 error ("%s: %s", mexFunctionName (), s); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5067 } |
5864 | 5068 else |
16851
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5069 { |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5070 // 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
|
5071 // 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
|
5072 error (" "); |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5073 } |
5864 | 5074 } |
5075 | |
5879 | 5076 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
|
5077 mexErrMsgIdAndTxt (const char *id, const char *fmt, ...) |
5879 | 5078 { |
6338 | 5079 if (fmt && strlen (fmt) > 0) |
5080 { | |
5081 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
|
5082 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1; |
6338 | 5083 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); |
5084 sprintf (tmpfmt, "%s: %s", fname, fmt); | |
5085 va_list args; | |
5086 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
|
5087 verror_with_id (id, tmpfmt, args); |
6338 | 5088 va_end (args); |
5089 } | |
5879 | 5090 else |
16851
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5091 { |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5092 // 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
|
5093 // 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
|
5094 error (" "); |
209f0db3c32b
mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents:
16708
diff
changeset
|
5095 } |
5879 | 5096 } |
5097 | |
5098 void | |
5099 mexWarnMsgTxt (const char *s) | |
5100 { | |
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
|
5101 std::size_t len; |
25751
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5102 |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5103 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
|
5104 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5105 if (s[len - 1] == '\n') |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5106 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5107 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
|
5108 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
|
5109 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5110 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5111 warning ("%s", s); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5112 } |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5113 else |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5114 { |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5115 // 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
|
5116 // 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
|
5117 warning (" "); |
4bd60c9c6169
Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents:
25688
diff
changeset
|
5118 } |
5879 | 5119 } |
5120 | |
5121 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
|
5122 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...) |
5879 | 5123 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5124 // 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
|
5125 // an empty string? |
6338 | 5126 |
5127 if (fmt && strlen (fmt) > 0) | |
5128 { | |
5129 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
|
5130 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1; |
6338 | 5131 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); |
5132 sprintf (tmpfmt, "%s: %s", fname, fmt); | |
5133 va_list args; | |
5134 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
|
5135 vwarning_with_id (id, tmpfmt, args); |
6338 | 5136 va_end (args); |
5137 } | |
5879 | 5138 } |
5864 | 5139 |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5140 int |
5864 | 5141 mexPrintf (const char *fmt, ...) |
5142 { | |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5143 int retval; |
5864 | 5144 va_list args; |
5145 va_start (args, fmt); | |
25646
4d565baa475e
move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25452
diff
changeset
|
5146 retval = octave::vformat (octave_stdout, fmt, args); |
5864 | 5147 va_end (args); |
10127
f21fdff5c906
Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents:
10126
diff
changeset
|
5148 return retval; |
5864 | 5149 } |
5150 | |
5151 mxArray * | |
5879 | 5152 mexGetVariable (const char *space, const char *name) |
5864 | 5153 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5154 mxArray *retval = nullptr; |
5864 | 5155 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5156 octave_value val; |
5864 | 5157 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5158 octave::interpreter& interp = octave::__get_interpreter__ ("mexGetVariable"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5159 |
5864 | 5160 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
|
5161 val = interp.global_varval (name); |
5864 | 5162 else |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5163 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5164 // 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
|
5165 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
5166 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
|
5167 |
7901 | 5168 bool caller = ! strcmp (space, "caller"); |
5169 bool base = ! strcmp (space, "base"); | |
5170 | |
5171 if (caller || base) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5172 { |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5173 // 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
|
5174 // 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
|
5175 |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5176 if (base) |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5177 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5178 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
|
5179 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5180 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
|
5181 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
|
5182 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5183 tw.goto_base_frame (); |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5184 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5185 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5186 val = interp.varval (name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5187 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7577
diff
changeset
|
5188 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5189 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
|
5190 } |
7336 | 5191 |
5192 if (val.is_defined ()) | |
5864 | 5193 { |
7336 | 5194 retval = mex_context->make_value (val); |
5195 | |
5196 retval->set_name (name); | |
5864 | 5197 } |
5198 | |
5199 return retval; | |
5200 } | |
5201 | |
5879 | 5202 const mxArray * |
5203 mexGetVariablePtr (const char *space, const char *name) | |
5864 | 5204 { |
5879 | 5205 return mexGetVariable (space, name); |
5864 | 5206 } |
5207 | |
5900 | 5208 int |
15353
5f3a69a309a7
fix decl of mexPutVariable
John W. Eaton <jwe@octave.org>
parents:
15351
diff
changeset
|
5209 mexPutVariable (const char *space, const char *name, const mxArray *ptr) |
5864 | 5210 { |
5900 | 5211 if (! ptr) |
5212 return 1; | |
5213 | |
5214 if (! name) | |
5215 return 1; | |
5216 | |
5217 if (name[0] == '\0') | |
5218 name = ptr->get_name (); | |
5219 | |
5220 if (! name || name[0] == '\0') | |
5221 return 1; | |
5222 | |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5223 octave::interpreter& interp = octave::__get_interpreter__ ("mexPutVariable"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5224 |
5900 | 5225 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
|
5226 { |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5227 #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
|
5228 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5229 // 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
|
5230 // 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
|
5231 // 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
|
5232 // 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
|
5233 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5234 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
|
5235 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
|
5236 #endif |
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 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
|
5239 } |
5900 | 5240 else |
5241 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5242 // FIXME: should this be in variables.cc? |
7336 | 5243 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
5244 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
|
5245 |
7901 | 5246 bool caller = ! strcmp (space, "caller"); |
5247 bool base = ! strcmp (space, "base"); | |
5248 | |
5249 if (caller || base) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5250 { |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5251 // 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
|
5252 // 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
|
5253 |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5254 if (base) |
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5255 { |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5256 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
|
5257 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29173
diff
changeset
|
5258 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
|
5259 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
|
5260 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27083
diff
changeset
|
5261 tw.goto_base_frame (); |
16708
08f0f274de36
use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
5262 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5263 |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5264 #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
|
5265 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5266 // 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
|
5267 // 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
|
5268 // 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
|
5269 // 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
|
5270 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5271 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
|
5272 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
|
5273 &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
|
5274 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5275 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26438
diff
changeset
|
5276 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
|
5277 } |
5900 | 5278 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5279 mexErrMsgTxt ("mexPutVariable: symbol table does not exist"); |
5900 | 5280 } |
5281 | |
5282 return 0; | |
5864 | 5283 } |
5284 | |
5285 void | |
5900 | 5286 mexMakeArrayPersistent (mxArray *ptr) |
5864 | 5287 { |
7172 | 5288 maybe_unmark_array (ptr); |
5864 | 5289 } |
5879 | 5290 |
5864 | 5291 void |
5900 | 5292 mexMakeMemoryPersistent (void *ptr) |
5864 | 5293 { |
7172 | 5294 maybe_unmark (ptr); |
5864 | 5295 } |
5296 | |
5900 | 5297 int |
6068 | 5298 mexAtExit (void (*f) (void)) |
5864 | 5299 { |
6068 | 5300 if (mex_context) |
5301 { | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5302 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
|
5303 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5304 curr_mex_fcn.atexit (f); |
6068 | 5305 } |
5306 | |
5900 | 5307 return 0; |
5864 | 5308 } |
5309 | |
5900 | 5310 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
|
5311 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
|
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 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
|
5314 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5315 octave_value ret |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5316 = 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
|
5317 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5318 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
|
5319 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
|
5320 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5321 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
|
5322 } |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5323 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
5324 const mxArray * |
6595 | 5325 mexGet (double handle, const char *property) |
5864 | 5326 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
5327 mxArray *m = nullptr; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5328 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5329 octave_value ret |
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5330 = octave::get_property_from_handle (handle, property, "mexGet"); |
6595 | 5331 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
5332 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
|
5333 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
|
5334 |
6595 | 5335 return m; |
5864 | 5336 } |
5337 | |
5900 | 5338 int |
5339 mexIsGlobal (const mxArray *ptr) | |
5864 | 5340 { |
5900 | 5341 return mxIsFromGlobalWS (ptr); |
5864 | 5342 } |
5343 | |
5900 | 5344 int |
5345 mexIsLocked (void) | |
5864 | 5346 { |
5900 | 5347 int retval = 0; |
5348 | |
5349 if (mex_context) | |
5350 { | |
5351 const char *fname = mexFunctionName (); | |
5352 | |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5353 octave::interpreter& interp = octave::__get_interpreter__ ("mexIsLocked"); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5354 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5355 retval = interp.mislocked (fname); |
5900 | 5356 } |
5357 | |
5358 return retval; | |
5864 | 5359 } |
5360 | |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30349
diff
changeset
|
5361 std::map<std::string, int> mex_lock_count; |
5900 | 5362 |
5363 void | |
5364 mexLock (void) | |
5864 | 5365 { |
5900 | 5366 if (mex_context) |
5864 | 5367 { |
5900 | 5368 const char *fname = mexFunctionName (); |
5369 | |
5370 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
|
5371 mex_lock_count[fname] = 1; |
5900 | 5372 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5373 mex_lock_count[fname]++; |
5900 | 5374 |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5375 octave::interpreter& interp = octave::__get_interpreter__ ("mexLock"); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5376 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5377 interp.mlock (); |
5864 | 5378 } |
5379 } | |
5380 | |
5900 | 5381 int |
6595 | 5382 mexSet (double handle, const char *property, mxArray *val) |
5900 | 5383 { |
30770
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5384 #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
|
5385 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5386 // 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
|
5387 // 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
|
5388 // 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
|
5389 // 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
|
5390 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5391 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
|
5392 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
|
5393 |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5394 #endif |
2aff9dda08f1
avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents:
30769
diff
changeset
|
5395 |
29993
b5fae48ad807
move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29870
diff
changeset
|
5396 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
|
5397 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
|
5398 "mexSet"); |
6595 | 5399 return (ret ? 0 : 1); |
5900 | 5400 } |
5401 | |
5402 void | |
5403 mexUnlock (void) | |
5864 | 5404 { |
5900 | 5405 if (mex_context) |
5864 | 5406 { |
5900 | 5407 const char *fname = mexFunctionName (); |
5408 | |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
5409 auto p = mex_lock_count.find (fname); |
5905 | 5410 |
6062 | 5411 if (p != mex_lock_count.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5412 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5413 int count = --mex_lock_count[fname]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5414 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5415 if (count == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10225
diff
changeset
|
5416 { |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5417 octave::interpreter& interp |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5418 = octave::__get_interpreter__ ("mexUnLock"); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5419 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
5420 interp.munlock (fname); |
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 mex_lock_count.erase (p); |
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 } |
5864 | 5425 } |
5426 } |