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