annotate libinterp/corefcn/mex.cc @ 30129:b7c04a5036d3

maint: use "m_" prefix for member variables in file mex.cc. * mex.cc: use "m_" prefix for member variables.
author Rik <rik@octave.org>
date Mon, 06 Sep 2021 13:51:03 -0700
parents 8418f99cfcd0
children c27b9ba4c9bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
29
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
30 #include <cstdarg>
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
31 #include <cstdlib>
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
32 #include <cstring>
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
33 #include <cctype>
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
39
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
40 #include "f77-fcn.h"
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
51 #include "mexproto.h"
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
56 #include "ov-mex-fcn.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
57 #include "ov-usr-fcn.h"
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
58 #include "pager.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
59 #include "parse.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
60 #include "unwind-prot.h"
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
61 #include "utils.h"
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
62 #include "variables.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
63 #include "graphics.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
256 // #define DEBUG 1
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
257
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
258 static void
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
259 xfree (void *ptr)
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
260 {
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
261 ::free (ptr);
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
262 }
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
263
6806
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
264 static mwSize
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
265 max_str_len (mwSize m, const char **str)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
266 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
267 int max_len = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
268
6806
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
269 for (mwSize i = 0; i < m; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
270 {
6806
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
271 mwSize tmp = strlen (str[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
272
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
275 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
276
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
277 return max_len;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
278 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
279
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
280 static int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
281 valid_key (const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
282 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
283 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
284
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
285 int nel = strlen (key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
286
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
287 if (nel > 0)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
288 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
299 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
300
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
301 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
302 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
303
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
304 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
310 static mwIndex
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
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
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
313 {
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
314 mwIndex retval = 0;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
315
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
316 switch (nsubs)
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
317 {
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
318 case 0:
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
319 break;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
320
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
321 case 1:
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
322 retval = subs[0];
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
323 break;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
324
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
325 default:
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
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
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
335 }
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
336 break;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
337 }
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
338
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
339 return retval;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
340 }
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
341
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
342 // The object that handles values pass to MEX files from Octave. Some
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
343 // methods in this class may set mutate_flag to TRUE to tell the
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
344 // mxArray class to convert to the Matlab-style representation and
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
345 // then invoke the method on that object instead (for example, getting
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
346 // a pointer to real or imaginary data from a complex object requires
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
347 // a mutation but getting a pointer to real data from a real object
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
348 // does not). Changing the representation causes a copy so we try to
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
349 // avoid it unless it is really necessary. Once the conversion
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
350 // happens, we delete this representation, so the conversion can only
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
351 // happen once per call to a MEX file.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
370 class mxArray_octave_value : public mxArray_base
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
371 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
372 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
423
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
424 ~mxArray_octave_value (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
428 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
429
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
430 bool is_octave_value (void) const { return true; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
471
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
472 int is_logical_scalar_true (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
475 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
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
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
480 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
481 mwSize n = 1;
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
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
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
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
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
488
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
489 return n;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
490 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
505 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
508 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
509
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
510 mwSize get_number_of_dimensions (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
513 get_dimensions ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
514
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
515 return m_ndims;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
516 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
535 mxClassID get_class_id (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
573 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
581 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
584 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
585
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
623
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
659 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
725 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
726 request_mutation ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
727
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
728 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
729 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
730
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
758
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
765 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
770 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
773
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
776
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
779
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
785
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
790
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
799
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
800 int get_string (char *buf, mwSize buflen) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
801 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
802 int retval = 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
803
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
804 mwSize nel = get_number_of_elements ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
818 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
819
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
820 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
821 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
846 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
847
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
848 return buf;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
849 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
850
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
851 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
854 get_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
857 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
862 get_class_id ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
865 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
866 case mxCELL_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
883 default: return 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
884 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
885 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
888
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
889 void request_mutation (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
892 panic_impossible ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
895 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
901 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
902
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
915 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
916 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
917
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
918 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
923
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
924 // Caching these does not cost much or lead to much duplicated
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
925 // code. For other things, we just request mutation to a
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
926 // Matlab-style mxArray object.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
932 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
933
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
934 // The base class for the Matlab-style representation, used to handle
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
935 // things that are common to all Matlab-style objects.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
936
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
937 class mxArray_matlab : public mxArray_base
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
938 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
939 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
947 ~mxArray_matlab (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
951 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
952
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
953 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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
956
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
957 int is_complex (void) const { return 0; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
972
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
973 int is_numeric (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
980 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
983
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
984 int is_sparse (void) const { return 0; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
995
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
996 int is_logical_scalar_true (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
997 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1000 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1003
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1004 mwSize get_n (void) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1005 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1006 mwSize n = 1;
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
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
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1010
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1011 return n;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1012 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1021
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1022 int set_dimensions (mwSize *dims_arg, mwSize ndims_arg)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1023 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1024 m_ndims = ndims_arg;
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++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1037 m_dims[i] = dims_arg[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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1046 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1047
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1048 mwSize get_number_of_elements (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1054
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1055 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1056 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1075 case mxCELL_CLASS: return "cell";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1078 case mxINT8_CLASS: return "int8";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1079 case mxUINT8_CLASS: return "uint8";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1080 case mxINT16_CLASS: return "int16";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1081 case mxUINT16_CLASS: return "uint16";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1082 case mxINT32_CLASS: return "int32";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1083 case mxUINT32_CLASS: return "uint32";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1084 case mxINT64_CLASS: return "int64";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1088 default: return "unknown";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1089 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1090 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1091
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1092 void set_class_name (const char *name_arg)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1095 m_class_name = static_cast<char *> (mxArray::malloc (strlen (name_arg) + 1));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1096 strcpy (m_class_name, name_arg);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1097 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1102 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1103
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1104 void set_cell (mwIndex /*idx*/, mxArray * /*m_val*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1107 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1108
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1109 double get_scalar (void) const
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
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
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1112 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1167 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1225 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1226
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1227 void set_data (void * /*m_pr*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1280 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1335 void set_imag_data (void * /*m_pi*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1338 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1343 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1348 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1349
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1350 mwSize get_nzmax (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1353 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1354
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1355 void set_ir (mwIndex * /*m_ir*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1358 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1359
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1360 void set_jc (mwIndex * /*m_jc*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1363 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1364
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1365 void set_nzmax (mwSize /*m_nzmax*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1368 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1373 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1374
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1375 void remove_field (int /*key_num*/)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1378 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1383 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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*/,
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1386 mxArray * /*m_val*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1389 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1390
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1391 int get_number_of_fields (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1394 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1399 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1402 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1403 return -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1404 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1409 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1414 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1415
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1416 mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1419 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1424 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1425 case mxCELL_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1426 case mxSTRUCT_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1427 case mxLOGICAL_CLASS: return sizeof (mxLogical);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1442 default: return 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1443 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1444 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1445
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1446 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1447
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1448 mxArray_matlab (bool interleaved, mxClassID id_arg = mxUNKNOWN_CLASS)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1449 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id_arg), m_ndims (0),
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
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1453 mxArray_matlab (bool interleaved, mxClassID id_arg, mwSize ndims_arg,
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1454 const mwSize *dims_arg)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1455 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id_arg),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1456 m_ndims (ndims_arg < 2 ? 2 : ndims_arg),
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 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1459 if (ndims_arg == 0)
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 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1464 else if (ndims_arg < 2)
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
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1470 for (mwIndex i = 0; i < ndims_arg; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1471 m_dims[i] = dims_arg[i];
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
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1482 mxArray_matlab (bool interleaved, mxClassID id_arg, const dim_vector& dv)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1483 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id_arg),
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
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1499 mxArray_matlab (bool interleaved, mxClassID id_arg, mwSize m, mwSize n)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1500 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id_arg), m_ndims (2),
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
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1507 mxArray_matlab (const mxArray_matlab& m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1508 : mxArray_base (m_val), m_class_name (mxArray::strsave (m_val.m_class_name)),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1509 m_id (m_val.m_id), m_ndims (m_val.m_ndims),
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++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1513 m_dims[i] = m_val.m_dims[i];
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1516 dim_vector
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1517 dims_to_dim_vector (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1518 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1519 mwSize nd = get_number_of_dimensions ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1520
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1521 mwSize *d = get_dimensions ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1522
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1523 dim_vector dv;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1524 dv.resize (nd);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1525
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1526 for (mwIndex i = 0; i < nd; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1527 dv(i) = d[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1528
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1529 return dv;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1530 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1531
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1532 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1540 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1543 // Matlab-style numeric, character, and logical data.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1544
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1545 #define TYPED_GET_METHOD(TYPE, FCN_NAME) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1546 TYPE FCN_NAME (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
1547 { \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1548 if (! m_interleaved) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1549 panic_impossible (); \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1550 \
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1551 return static_cast<TYPE> (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
1552 }
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 #define TYPED_SET_METHOD(TYPE, FCN_NAME) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1555 int FCN_NAME (TYPE d) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1556 { \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1557 if (! m_interleaved) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1558 panic_impossible (); \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1559 \
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1560 m_pr = d; \
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1561 return 0; \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1562 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1563
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1564 class mxArray_number : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1565 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1566 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1567
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1568 mxArray_number (bool interleaved, mxClassID id_arg, mwSize ndims_arg,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1569 const mwSize *dims_arg, mxComplexity flag = mxREAL,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1570 bool init = true)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1571 : mxArray_matlab (interleaved, id_arg, ndims_arg, dims_arg),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1572 m_complex (flag == mxCOMPLEX),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1573 m_pr (init
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1574 ? mxArray::calloc (get_number_of_elements (), get_element_size ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1575 : mxArray::malloc (get_number_of_elements () * get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1576 m_pi (m_interleaved
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1577 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1578 : (m_complex
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1579 ? (init
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1580 ? mxArray::calloc (get_number_of_elements (), get_element_size ())
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1581 : mxArray::malloc (get_number_of_elements () * get_element_size ()))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1582 : nullptr))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1583 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1584
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1585 mxArray_number (bool interleaved, mxClassID id_arg, const dim_vector& dv,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1586 mxComplexity flag = mxREAL)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1587 : mxArray_matlab (interleaved, id_arg, dv), m_complex (flag == mxCOMPLEX),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1588 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1589 m_pi (m_interleaved
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1590 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1591 : (m_complex
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1592 ? mxArray::calloc (get_number_of_elements (), get_element_size ())
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1593 : nullptr))
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1594 { }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1595
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_number (bool interleaved, mxClassID id_arg, mwSize m, mwSize n,
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1597 mxComplexity flag = mxREAL, bool init = true)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1598 : mxArray_matlab (interleaved, id_arg, m, n), m_complex (flag == mxCOMPLEX),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1599 m_pr (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
1600 ? mxArray::calloc (get_number_of_elements (), get_element_size ())
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1601 : mxArray::malloc (get_number_of_elements () * get_element_size ())),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1602 m_pi (m_interleaved
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1603 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1604 : (m_complex
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1605 ? (init
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1606 ? mxArray::calloc (get_number_of_elements (), get_element_size ())
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1607 : mxArray::malloc (get_number_of_elements () * get_element_size ()))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1608 : nullptr))
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1609 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1610
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1611 mxArray_number (bool interleaved, mxClassID id_arg, double m_val)
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1612 : mxArray_matlab (interleaved, id_arg, 1, 1), m_complex (false),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1613 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1614 m_pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1615 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1616 double *dpr = static_cast<double *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1617 dpr[0] = m_val;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1618 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1619
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1620 mxArray_number (bool interleaved, mxClassID id_arg, mxLogical m_val)
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1621 : mxArray_matlab (interleaved, id_arg, 1, 1), m_complex (false),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1622 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1623 m_pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1624 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1625 mxLogical *lpr = static_cast<mxLogical *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1626 lpr[0] = m_val;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1627 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1628
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1629 mxArray_number (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
1630 : 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
1631 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
1632 str ? strlen (str) : 0),
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1633 m_complex (false),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1634 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1635 m_pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1636 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1637 mxChar *cpr = static_cast<mxChar *> (m_pr);
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1638 mwSize nel = get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1639 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1640 cpr[i] = str[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1641 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1642
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17810
diff changeset
1643 // FIXME: ???
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1644 mxArray_number (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
1645 : mxArray_matlab (interleaved, mxCHAR_CLASS, m, max_str_len (m, str)),
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1646 m_complex (false),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1647 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1648 m_pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1649 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1650 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
1651
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1652 mwSize *dv = get_dimensions ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1653
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1654 mwSize nc = dv[1];
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1655
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1656 for (mwIndex j = 0; j < m; j++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1657 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1658 const char *ptr = str[j];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1659
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
1660 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
1661
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1662 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
1663 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
1664
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
1665 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
1666 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
1667 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1668 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1669
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1670 // 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
1671 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1672
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1673 mxArray_number& operator = (const mxArray_number&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1674
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1675 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
1676 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1677 return new mxArray_number (*this);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1678 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1679
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1680 ~mxArray_number (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1681 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1682 mxFree (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1683 mxFree (m_pi);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1684 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1685
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1686 int is_complex (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
1687 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1688 return m_interleaved ? m_complex : (m_pi != 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
1689 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1690
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1691 double get_scalar (void) const
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1692 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1693 // 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
1694
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1695 double retval = 0;
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1696
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1697 switch (get_class_id ())
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1698 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1699 case mxDOUBLE_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1700 retval = *(static_cast<double *> (m_pr));
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1701 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1702
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1703 case mxSINGLE_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1704 retval = *(static_cast<float *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1705 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1706
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1707 case mxCHAR_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1708 retval = *(static_cast<mxChar *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1709 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1710
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1711 case mxLOGICAL_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1712 retval = *(static_cast<bool *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1713 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1714
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1715 case mxINT8_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1716 retval = *(static_cast<int8_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1717 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1718
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1719 case mxUINT8_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1720 retval = *(static_cast<uint8_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1721 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1722
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1723 case mxINT16_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1724 retval = *(static_cast<int16_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1725 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1726
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1727 case mxUINT16_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1728 retval = *(static_cast<uint16_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1729 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1730
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1731 case mxINT32_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1732 retval = *(static_cast<int32_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1733 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1734
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1735 case mxUINT32_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1736 retval = *(static_cast<uint32_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1737 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1738
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1739 case mxINT64_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1740 retval = *(static_cast<int64_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1741 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1742
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1743 case mxUINT64_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1744 retval = *(static_cast<uint64_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1745 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1746
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1747 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1748 panic_impossible ();
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1749 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1750
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1751 return retval;
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1752 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1753
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1754 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
1755
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1756 void * get_imag_data (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
1757 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1758 if (m_interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1759 panic_impossible ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1760
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1761 return m_pi;
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1762 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1763
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1764 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
1765
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1766 void set_imag_data (void *pi)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1767 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1768 if (m_interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1769 panic_impossible ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1770
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1771 m_pi = pi;
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1772 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1773
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1774 TYPED_GET_METHOD (mxDouble *, 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
1775 TYPED_GET_METHOD (mxSingle *, 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
1776 TYPED_GET_METHOD (mxInt8 *, 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
1777 TYPED_GET_METHOD (mxInt16 *, 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
1778 TYPED_GET_METHOD (mxInt32 *, 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
1779 TYPED_GET_METHOD (mxInt64 *, 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
1780 TYPED_GET_METHOD (mxUint8 *, 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
1781 TYPED_GET_METHOD (mxUint16 *, 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
1782 TYPED_GET_METHOD (mxUint32 *, 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
1783 TYPED_GET_METHOD (mxUint64 *, 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
1784
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1785 TYPED_GET_METHOD (mxComplexDouble *, 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
1786 TYPED_GET_METHOD (mxComplexSingle *, 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
1787 #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
1788 /* 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
1789 TYPED_GET_METHOD (mxComplexInt8 *, 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
1790 TYPED_GET_METHOD (mxComplexInt16 *, 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
1791 TYPED_GET_METHOD (mxComplexInt32 *, 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
1792 TYPED_GET_METHOD (mxComplexInt64 *, 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
1793 TYPED_GET_METHOD (mxComplexUint8 *, 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
1794 TYPED_GET_METHOD (mxComplexUint16 *, 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
1795 TYPED_GET_METHOD (mxComplexUint32 *, 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
1796 TYPED_GET_METHOD (mxComplexUint64 *, 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
1797 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1798
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1799 TYPED_SET_METHOD (mxDouble *, 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
1800 TYPED_SET_METHOD (mxSingle *, 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
1801 TYPED_SET_METHOD (mxInt8 *, 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
1802 TYPED_SET_METHOD (mxInt16 *, 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
1803 TYPED_SET_METHOD (mxInt32 *, 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
1804 TYPED_SET_METHOD (mxInt64 *, 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
1805 TYPED_SET_METHOD (mxUint8 *, 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
1806 TYPED_SET_METHOD (mxUint16 *, 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
1807 TYPED_SET_METHOD (mxUint32 *, 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
1808 TYPED_SET_METHOD (mxUint64 *, set_uint64s)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1809
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1810 TYPED_SET_METHOD (mxComplexDouble *, 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
1811 TYPED_SET_METHOD (mxComplexSingle *, 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
1812 #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
1813 /* 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
1814 TYPED_SET_METHOD (mxComplexInt8 *, 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
1815 TYPED_SET_METHOD (mxComplexInt16 *, 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
1816 TYPED_SET_METHOD (mxComplexInt32 *, 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
1817 TYPED_SET_METHOD (mxComplexInt64 *, 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
1818 TYPED_SET_METHOD (mxComplexUint8 *, 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
1819 TYPED_SET_METHOD (mxComplexUint16 *, 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
1820 TYPED_SET_METHOD (mxComplexUint32 *, 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
1821 TYPED_SET_METHOD (mxComplexUint64 *, 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
1822 #endif
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1823
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1824 int get_string (char *buf, mwSize buflen) const
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1825 {
13753
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1826 int retval = 0;
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1827
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1828 mwSize nel = get_number_of_elements ();
6493
5fa513371dde [project @ 2007-04-05 14:53:49 by jwe]
jwe
parents: 6400
diff changeset
1829
13753
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1830 if (! (nel < buflen))
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1831 {
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1832 retval = 1;
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1833 if (buflen > 0)
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1834 nel = buflen-1;
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1835 }
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1836
6493
5fa513371dde [project @ 2007-04-05 14:53:49 by jwe]
jwe
parents: 6400
diff changeset
1837 if (nel < buflen)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1838 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1839 mxChar *ptr = static_cast<mxChar *> (m_pr);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1840
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1841 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1842 buf[i] = static_cast<char> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1843
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1844 buf[nel] = 0;
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1845 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1846
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1847 return retval;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1848 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1849
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1850 char * array_to_string (void) const
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1851 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1852 // FIXME: this is supposed to handle multi-byte character strings.
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1853
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1854 mwSize nel = get_number_of_elements ();
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1855
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
1856 char *buf = static_cast<char *> (mxArray::malloc (nel + 1));
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1857
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1858 if (buf)
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1859 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1860 mxChar *ptr = static_cast<mxChar *> (m_pr);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1861
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1862 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1863 buf[i] = static_cast<char> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1864
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1865 buf[nel] = '\0';
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1866 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1867
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1868 return buf;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1869 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1870
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1871 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1872 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1873 octave_value retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1874
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1875 dim_vector dv = dims_to_dim_vector ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1876
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1877 switch (get_class_id ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1878 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1879 case mxDOUBLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1880 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1881 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1882
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1883 if (is_complex ())
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1884 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1885 if (m_interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1886 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1887 Complex *ppr = static_cast<Complex *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1888
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1889 ComplexNDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1890 Complex *ptr = m_val.fortran_vec ();
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1891
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1892 for (mwIndex i = 0; i < nel; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1893 ptr[i] = ppr[i];
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1894
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1895 retval = m_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
1896 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1897 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1898 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1899 double *ppr = static_cast<double *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1900
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1901 ComplexNDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1902
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1903 Complex *ptr = m_val.fortran_vec ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1904
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1905 double *ppi = static_cast<double *> (m_pi);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1906
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1907 for (mwIndex i = 0; i < nel; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1908 ptr[i] = Complex (ppr[i], ppi[i]);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1909
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1910 retval = m_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
1911 }
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1912 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1913 else
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1914 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1915 double *ppr = static_cast<double *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1916
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1917 NDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1918
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1919 double *ptr = m_val.fortran_vec ();
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1920
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1921 for (mwIndex i = 0; i < nel; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1922 ptr[i] = ppr[i];
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1923
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1924 retval = m_val;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1925 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1926 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1927 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1928
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1929 case mxSINGLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1930 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1931 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1932
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1933 if (is_complex ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1934 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1935 if (m_interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1936 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1937 FloatComplex *ppr = static_cast<FloatComplex *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1938
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1939 FloatComplexNDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1940 FloatComplex *ptr = m_val.fortran_vec ();
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1941
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1942 for (mwIndex i = 0; i < nel; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1943 ptr[i] = ppr[i];
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1944
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1945 retval = m_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
1946 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1947 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1948 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1949 float *ppr = static_cast<float *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1950
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1951 FloatComplexNDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1952
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1953 FloatComplex *ptr = m_val.fortran_vec ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1954
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1955 float *ppi = static_cast<float *> (m_pi);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1956
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1957 for (mwIndex i = 0; i < nel; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1958 ptr[i] = FloatComplex (ppr[i], ppi[i]);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1959
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1960 retval = m_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
1961 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1962 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1963 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1964 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1965 float *ppr = static_cast<float *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1966
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1967 FloatNDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1968
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1969 float *ptr = m_val.fortran_vec ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1970
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1971 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1972 ptr[i] = ppr[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1973
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1974 retval = m_val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1975 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1976 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1977 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1978
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1979 case mxCHAR_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1980 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1981 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1982
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1983 mxChar *ppr = static_cast<mxChar *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1984
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1985 charNDArray m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1986
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1987 char *ptr = m_val.fortran_vec ();
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1988
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1989 for (mwIndex i = 0; i < nel; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1990 ptr[i] = static_cast<char> (ppr[i]);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1991
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1992 retval = m_val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1993 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1994 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1995
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1996 case mxLOGICAL_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1997 retval = int_to_ov<mxLogical, boolNDArray, bool> (dv);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1998 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1999
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2000 case mxINT8_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2001 retval = int_to_ov<int8_t, int8NDArray, octave_int8> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2002 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2003
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2004 case mxUINT8_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2005 retval = int_to_ov<uint8_t, uint8NDArray, octave_uint8> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2006 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2007
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2008 case mxINT16_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2009 retval = int_to_ov<int16_t, int16NDArray, octave_int16> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2010 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2011
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2012 case mxUINT16_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2013 retval = int_to_ov<uint16_t, uint16NDArray, octave_uint16> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2014 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2015
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2016 case mxINT32_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2017 retval = int_to_ov<int32_t, int32NDArray, octave_int32> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2018 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2019
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2020 case mxUINT32_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2021 retval = int_to_ov<uint32_t, uint32NDArray, octave_uint32> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2022 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2023
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2024 case mxINT64_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2025 retval = int_to_ov<int64_t, int64NDArray, octave_int64> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2026 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2027
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2028 case mxUINT64_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2029 retval = int_to_ov<uint64_t, uint64NDArray, octave_uint64> (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2030 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2031
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2032 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2033 panic_impossible ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2034 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2035
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2036 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2037 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2038
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2039 protected:
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2040
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2041 mxArray_number (const mxArray_number& m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2042 : mxArray_matlab (m_val), m_complex (m_val.m_complex),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2043 m_pr (mxArray::malloc (get_number_of_elements () * get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2044 m_pi (m_interleaved
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2045 ? nullptr
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2046 : (m_val.m_pi
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2047 ? mxArray::malloc (get_number_of_elements () * get_element_size ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2048 : nullptr))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2049 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2050 std::size_t nbytes = get_number_of_elements () * get_element_size ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2051
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2052 if (m_pr)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2053 memcpy (m_pr, m_val.m_pr, nbytes);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2054
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2055 if (m_pi)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2056 memcpy (m_pi, m_val.m_pi, nbytes);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2057 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2058
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2059 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
2060 octave_value
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2061 int_to_ov (const dim_vector& dv) const
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2062 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2063 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
2064 error ("complex integer types are not supported");
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2065
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2066 mwSize nel = get_number_of_elements ();
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2067
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2068 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
2069
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2070 ARRAY_T m_val (dv);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2071
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2072 ARRAY_ELT_T *ptr = m_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
2073
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2074 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
2075 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
2076
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2077 return octave_value (m_val);
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2078 }
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2079
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2080 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2081
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2082 // Flag to identify complex object if using interleaved data and PI is
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2083 // always nullptr.
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2084 bool m_complex;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2085
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2086 // 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
2087 // (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
2088 // 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
2089 void *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
2090
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2091 // If using non-interleaved complex storage, this is the pointer to
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2092 // the imaginary part of the data. Othrwise is is always nullptr.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2093 void *m_pi;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2094 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2095
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2096 // Matlab-style sparse arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2097
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2098 class mxArray_sparse : public mxArray_matlab
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2099 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2100 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2101
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2102 mxArray_sparse (bool interleaved, mxClassID id_arg, 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
2103 mwSize nzmax_arg, mxComplexity flag = mxREAL)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2104 : mxArray_matlab (interleaved, id_arg, m, n), m_complex (flag == mxCOMPLEX),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2105
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2106 m_nzmax (nzmax_arg > 0 ? nzmax_arg : 1),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2107 m_pr (mxArray::calloc (m_nzmax, get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2108 m_pi (m_interleaved
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2109 ? nullptr
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2110 : (m_complex
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2111 ? mxArray::calloc (m_nzmax, get_element_size ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2112 : nullptr)),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2113 m_ir (static_cast<mwIndex *> (mxArray::calloc (m_nzmax, sizeof (mwIndex)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2114 m_jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex))))
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2115 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2116
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2117 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2118
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2119 mxArray_sparse (const mxArray_sparse& m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2120 : mxArray_matlab (m_val), m_nzmax (m_val.m_nzmax),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2121 m_pr (mxArray::malloc (m_nzmax * get_element_size ())),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2122 m_pi (m_interleaved
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2123 ? nullptr
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2124 : (m_val.m_pi
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2125 ? mxArray::malloc (m_nzmax * get_element_size ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2126 : nullptr)),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2127 m_ir (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2128 m_jc (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex))))
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2129 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2130 std::size_t nbytes = m_nzmax * get_element_size ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2131
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2132 if (m_pr)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2133 memcpy (m_pr, m_val.m_pr, nbytes);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2134
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2135 if (m_pi)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2136 memcpy (m_pi, m_val.m_pi, nbytes);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2137
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2138 if (m_ir)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2139 memcpy (m_ir, m_val.m_ir, m_nzmax * sizeof (mwIndex));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2140
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2141 if (m_jc)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2142 memcpy (m_jc, m_val.m_jc, (m_val.get_n () + 1) * sizeof (mwIndex));
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2143 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2144
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2145 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2146
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2147 // 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
2148 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2149
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2150 mxArray_sparse& operator = (const mxArray_sparse&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2151
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2152 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
2153 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2154 return new mxArray_sparse (*this);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2155 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2156
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2157 ~mxArray_sparse (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2158 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2159 mxFree (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2160 mxFree (m_pi);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2161 mxFree (m_ir);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2162 mxFree (m_jc);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2163 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2164
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2165 int is_complex (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
2166 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2167 return m_interleaved ? m_complex : (m_pi != 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
2168 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2169
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2170 int is_sparse (void) const { return 1; }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2171
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2172 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
2173
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2174 void * get_imag_data (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
2175 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2176 if (m_interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2177 panic_impossible ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2178
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2179 return m_pi;
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2180 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2181
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2182 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
2183
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2184 void set_imag_data (void *pi)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2185 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2186 if (m_interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2187 panic_impossible ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2188
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2189 m_pi = pi;
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2190 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2191
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2192 TYPED_GET_METHOD (mxDouble *, 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
2193 TYPED_GET_METHOD (mxComplexDouble *, 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
2194
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2195 TYPED_SET_METHOD (mxDouble *, 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
2196 TYPED_SET_METHOD (mxComplexDouble *, set_complex_doubles)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2197
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2198 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
2199
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2200 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
2201
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2202 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
2203
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2204 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
2205
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2206 void set_jc (mwIndex *jc) { m_jc = jc; }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2207
27083
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2208 void set_nzmax (mwSize nzmax_arg)
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2209 {
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2210 /* Require storage for at least 1 element */
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2211 m_nzmax = (nzmax_arg > 0 ? nzmax_arg : 1);
27083
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2212 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2213
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2214 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2215 {
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2216 octave_value retval;
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2217
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2218 dim_vector dv = dims_to_dim_vector ();
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2219
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2220 switch (get_class_id ())
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2221 {
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2222 case mxDOUBLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2223 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2224 if (is_complex ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2225 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2226 if (m_interleaved)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2227 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2228 Complex *ppr = static_cast<Complex *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2229
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2230 SparseComplexMatrix m_val (get_m (), get_n (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2231 static_cast<octave_idx_type> (m_nzmax));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2232
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2233 for (mwIndex i = 0; i < m_nzmax; i++)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2234 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2235 m_val.xdata (i) = ppr[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2236 m_val.xridx (i) = m_ir[i];
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2237 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2238
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2239 for (mwIndex i = 0; i < get_n () + 1; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2240 m_val.xcidx (i) = m_jc[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2241
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2242 retval = m_val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2243 }
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2244 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2245 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2246 double *ppr = static_cast<double *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2247 double *ppi = static_cast<double *> (m_pi);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2248
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2249 SparseComplexMatrix m_val (get_m (), get_n (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2250 static_cast<octave_idx_type> (m_nzmax));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2251
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2252 for (mwIndex i = 0; i < m_nzmax; i++)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2253 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2254 m_val.xdata (i) = Complex (ppr[i], ppi[i]);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2255 m_val.xridx (i) = m_ir[i];
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2256 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2257
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2258 for (mwIndex i = 0; i < get_n () + 1; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2259 m_val.xcidx (i) = m_jc[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2260
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2261 retval = m_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
2262 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2263 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2264 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2265 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2266 double *ppr = static_cast<double *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2267
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2268 SparseMatrix m_val (get_m (), get_n (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2269 static_cast<octave_idx_type> (m_nzmax));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2270
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2271 for (mwIndex i = 0; i < m_nzmax; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2272 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2273 m_val.xdata (i) = ppr[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2274 m_val.xridx (i) = m_ir[i];
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2275 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2276
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2277 for (mwIndex i = 0; i < get_n () + 1; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2278 m_val.xcidx (i) = m_jc[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2279
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2280 retval = m_val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2281 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2282 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2283 break;
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2284
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2285 case mxLOGICAL_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2286 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2287 bool *ppr = static_cast<bool *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2288
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2289 SparseBoolMatrix m_val (get_m (), get_n (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2290 static_cast<octave_idx_type> (m_nzmax));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2291
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2292 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
2293 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2294 m_val.xdata (i) = ppr[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2295 m_val.xridx (i) = m_ir[i];
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2296 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2297
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2298 for (mwIndex i = 0; i < get_n () + 1; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2299 m_val.xcidx (i) = m_jc[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2300
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2301 retval = m_val;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2302 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2303 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2304
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2305 case mxSINGLE_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2306 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
2307
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2308 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2309 panic_impossible ();
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2310 }
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2311
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2312 return retval;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2313 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2314
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2315 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2316
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2317 // Flag to identify complex object if using interleaved data and PI is
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2318 // always nullptr.
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2319 bool m_complex;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2320
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2321 // Maximun number of nonzero elements.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2322 mwSize m_nzmax;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2323
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2324 // 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
2325 // (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
2326 // 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
2327 void *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
2328
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2329 // If using non-interleaved complex storage, this is the pointer to
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2330 // the imaginary part of the data. Othrwise is is always nullptr.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2331 void *m_pi;
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2332
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2333 // Sparse storage indexing arrays.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2334 mwIndex *m_ir;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2335 mwIndex *m_jc;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2336 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2337
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2338 // Matlab-style struct arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2339
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2340 class mxArray_struct : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2341 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2342 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2343
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2344 mxArray_struct (bool interleaved, mwSize ndims_arg, const mwSize *dims_arg,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2345 int num_keys_arg, 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
2346 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, ndims_arg, dims_arg),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2347 m_nfields (num_keys_arg),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2348 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
2349 sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2350 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
2351 get_number_of_elements (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2352 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2353 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2354 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2355 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2356
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2357 mxArray_struct (bool interleaved, const dim_vector& dv, int num_keys_arg,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2358 const char **keys)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2359 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, dv),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2360 m_nfields (num_keys_arg),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2361 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
2362 sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2363 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
2364 get_number_of_elements (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2365 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2366 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2367 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2368 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2369
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2370 mxArray_struct (bool interleaved, mwSize m, mwSize n, int num_keys_arg,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2371 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
2372 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, m, n),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2373 m_nfields (num_keys_arg),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2374 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
2375 sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2376 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
2377 get_number_of_elements (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2378 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2379 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2380 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2381 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2382
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2383 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2384
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2385 mxArray_struct (const mxArray_struct& m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2386 : mxArray_matlab (m_val), m_nfields (m_val.m_nfields),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2387 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
2388 * sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2389 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
2390 get_number_of_elements ()
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2391 * sizeof (mxArray *))))
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2392 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2393 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
2394 m_fields[i] = mxArray::strsave (m_val.m_fields[i]);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2395
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2396 mwSize nel = get_number_of_elements ();
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2397
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2398 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
2399 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2400 mxArray *ptr = m_val.m_data[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2401 m_data[i] = (ptr ? ptr->dup () : nullptr);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2402 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2403 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2404
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2405 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2406
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2407 // 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
2408 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2409
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2410 mxArray_struct& operator = (const mxArray_struct& m_val);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2411
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2412 void init (const char **keys)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2413 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2414 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
2415 m_fields[i] = mxArray::strsave (keys[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2416 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2417
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2418 mxArray_base * dup (void) const { return new mxArray_struct (*this); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2419
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2420 ~mxArray_struct (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2421 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2422 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
2423 mxFree (m_fields[i]);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2424
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2425 mxFree (m_fields);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2426
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2427 mwSize ntot = m_nfields * get_number_of_elements ();
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2428
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2429 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
2430 delete m_data[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2431
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2432 mxFree (m_data);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2433 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2434
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2435 int add_field (const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2436 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2437 int retval = -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2438
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2439 if (valid_key (key))
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2440 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2441 m_nfields++;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2442
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2443 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
2444 (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
2445
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2446 if (m_fields)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2447 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2448 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
2449
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2450 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2451
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2452 mwSize ntot = m_nfields * nel;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2453
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2454 mxArray **new_data;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2455 new_data = static_cast<mxArray **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2456 (mxArray::malloc (ntot * sizeof (mxArray *)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2457
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2458 if (new_data)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2459 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2460 mwIndex j = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2461 mwIndex k = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2462 mwIndex n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2463
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2464 for (mwIndex i = 0; i < ntot; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2465 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2466 if (++n == m_nfields)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2467 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2468 new_data[j++] = nullptr;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2469 n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2470 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2471 else
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2472 new_data[j++] = m_data[k++];
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2473 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2474
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2475 mxFree (m_data);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2476
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2477 m_data = new_data;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2478
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2479 retval = m_nfields - 1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2480 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2481 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2482 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2483
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2484 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2485 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2486
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2487 void remove_field (int key_num)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2488 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2489 if (key_num >= 0 && key_num < m_nfields)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2490 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2491 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2492
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2493 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
2494
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2495 int new_nfields = m_nfields - 1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2496
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2497 char **new_fields = static_cast<char **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2498 (mxArray::malloc (new_nfields * sizeof (char *)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2499
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2500 mxArray **new_data = static_cast<mxArray **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2501 (mxArray::malloc (new_nfields * nel
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2502 * sizeof (mxArray *)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2503
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2504 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
2505 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
2506
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2507 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
2508 new_fields[i-1] = m_fields[i];
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2509
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2510 if (new_nfields > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2511 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2512 mwIndex j = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2513 mwIndex k = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2514 mwIndex n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2515
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2516 for (mwIndex i = 0; i < ntot; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2517 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2518 if (n == key_num)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2519 k++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2520 else
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2521 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
2522
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2523 if (++n == m_nfields)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2524 n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2525 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2526 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2527
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2528 m_nfields = new_nfields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2529
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2530 mxFree (m_fields);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2531 mxFree (m_data);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2532
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2533 m_fields = new_fields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2534 m_data = new_data;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2535 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2536 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2537
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2538 mxArray * get_field_by_number (mwIndex index, int key_num) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2539 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2540 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
2541 ? m_data[m_nfields * index + key_num] : nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2542 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2543
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2544 void set_field_by_number (mwIndex index, int key_num, mxArray *val);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2545
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2546 int get_number_of_fields (void) const { return m_nfields; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2547
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2548 const char * get_field_name_by_number (int key_num) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2549 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2550 return key_num >= 0 && key_num < m_nfields ? m_fields[key_num] : nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2551 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2552
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2553 int get_field_number (const char *key) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2554 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2555 int retval = -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2556
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2557 for (int i = 0; i < m_nfields; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2558 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2559 if (! strcmp (key, m_fields[i]))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2560 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2561 retval = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2562 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2563 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2564 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2565
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2566 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2567 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2568
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2569 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
2570
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2571 void set_data (void *data) { m_data = static_cast<mxArray **> (data); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2572
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2573 octave_value as_octave_value (void) const
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2574 {
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2575 dim_vector dv = dims_to_dim_vector ();
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2576
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2577 string_vector keys (m_fields, m_nfields);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2578
25922
34e82a829fdd Create scalar structs of size 1x1 with MEX interface (bug #54799).
Rik <rik@octave.org>
parents: 25751
diff changeset
2579 octave_map m (dv);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2580
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2581 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
2582
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2583 for (int i = 0; i < m_nfields; i++)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2584 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2585 Cell c (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2586
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2587 octave_value *p = c.fortran_vec ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2588
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2589 mwIndex k = 0;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2590 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
2591 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
2592
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2593 m.assign (keys[i], c);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2594 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2595
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2596 return m;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2597 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2598
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2599 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2600
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2601 int m_nfields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2602
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2603 char **m_fields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2604
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2605 mxArray **m_data;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2606 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2607
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2608 // Matlab-style cell arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2609
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2610 class mxArray_cell : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2611 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2612 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2613
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2614 mxArray_cell (bool interleaved, mwSize ndims_arg, const mwSize *dims_arg)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2615 : mxArray_matlab (interleaved, mxCELL_CLASS, ndims_arg, dims_arg),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2616 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
2617 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
2618 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2619
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2620 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
2621 : 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
2622 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
2623 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
2624 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2625
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2626 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
2627 : 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
2628 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
2629 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
2630 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2631
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2632 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2633
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2634 mxArray_cell (const mxArray_cell& m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2635 : mxArray_matlab (m_val),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2636 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
2637 mxArray::malloc (get_number_of_elements () * sizeof (mxArray *))))
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2638 {
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2639 mwSize nel = get_number_of_elements ();
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2640
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2641 for (mwIndex i = 0; i < nel; i++)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2642 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2643 mxArray *ptr = m_val.m_data[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2644 m_data[i] = (ptr ? ptr->dup () : nullptr);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2645 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2646 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2647
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2648 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2649
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2650 // 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
2651 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2652
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2653 mxArray_cell& operator = (const mxArray_cell&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2654
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2655 mxArray_base * dup (void) const { return new mxArray_cell (*this); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2656
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2657 ~mxArray_cell (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2658 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2659 mwSize nel = get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2660
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
2661 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
2662 delete m_data[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2663
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2664 mxFree (m_data);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2665 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2666
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2667 mxArray * get_cell (mwIndex idx) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
2668 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2669 return idx >= 0 && idx < get_number_of_elements () ? m_data[idx] : nullptr;
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
2670 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2671
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2672 void set_cell (mwIndex idx, mxArray *m_val);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2673
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2674 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
2675
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2676 void set_data (void *data) { m_data = static_cast<mxArray **> (data); }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2677
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2678 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2679 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2680 dim_vector dv = dims_to_dim_vector ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2681
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2682 Cell c (dv);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2683
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2684 mwSize nel = get_number_of_elements ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2685
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2686 octave_value *p = c.fortran_vec ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2687
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2688 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
2689 p[i] = mxArray::as_octave_value (m_data[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2690
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2691 return c;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2692 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2693
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2694 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2695
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2696 mxArray **m_data;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2697 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2698
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2699 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2700
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2701 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
2702 : 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
2703 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2704
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2705 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
2706 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
2707 : 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
2708 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
2709 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2710
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2711 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
2712 mxComplexity flag)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2713 : 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
2714 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2715
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2716 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
2717 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
2718 : 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
2719 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2720
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2721 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
2722 : 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
2723 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2724
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2725 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
2726 : 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
2727 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2728
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2729 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
2730 : 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
2731 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2732
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2733 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
2734 : 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
2735 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2736
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2737 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
2738 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
2739 : 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
2740 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2741
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2742 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
2743 int num_keys,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2744 const char **keys)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2745 : 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
2746 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
2747 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2748
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2749 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
2750 const char **keys)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2751 : 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
2752 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
2753 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2754
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2755 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
2756 const char **keys)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2757 : 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
2758 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
2759 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2760
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2761 mxArray::mxArray (bool interleaved, mwSize m_ndims, const mwSize *m_dims)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2762 : m_rep (new mxArray_cell (interleaved, m_ndims, m_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
2763 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2764
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2765 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
2766 : 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
2767 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2768
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2769 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
2770 : 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
2771 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2772
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2773 mxArray::~mxArray (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2774 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2775 mxFree (m_name);
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2776
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2777 delete m_rep;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2778 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2779
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2780 void
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2781 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
2782 {
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2783 mxFree (m_name);
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2784 m_name = mxArray::strsave (name);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2785 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2786
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2787 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
2788 mxArray::as_octave_value (const mxArray *ptr, bool null_is_empty)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2789 {
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
2790 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
2791
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
2792 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
2793 ? 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
2794 : (null_is_empty ? empty_matrix : octave_value ()));
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2795 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2796
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2797 octave_value
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2798 mxArray::as_octave_value (void) const
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2799 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2800 return m_rep->as_octave_value ();
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2801 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2802
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2803 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
2804 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
2805 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2806 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
2807 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2808
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2809 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
2810 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
2811 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
2812 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2813 return new mxArray_number (interleaved, id, ndims, dims, flag, init);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2814 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2815
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2816 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
2817 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
2818 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
2819 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2820 return new mxArray_number (interleaved, id, dv, flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2821 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2822
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2823 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
2824 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
2825 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
2826 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2827 return new mxArray_number (interleaved, id, m, n, flag, init);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2828 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2829
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2830 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
2831 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
2832 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2833 return new mxArray_number (interleaved, id, val);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2834 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2835
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2836 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
2837 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
2838 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2839 return new mxArray_number (interleaved, id, val);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2840 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2841
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2842 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
2843 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
2844 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2845 return new mxArray_number (interleaved, str);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2846 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2847
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2848 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
2849 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
2850 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2851 return new mxArray_number (interleaved, 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
2852 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2853
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2854 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
2855 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
2856 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
2857 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2858 return new mxArray_sparse (interleaved, id, m, n, nzmax, flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2859 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2860
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2861 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2862 mxArray::maybe_mutate (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2863 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2864 if (m_rep->is_octave_value ())
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2865 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2866 // The mutate function returns a pointer to a complete new
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2867 // mxArray object (or 0, if no mutation happened). We just want
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2868 // to replace the existing rep with the rep from the new object.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2869
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2870 mxArray *new_val = m_rep->mutate ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2871
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2872 if (new_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2873 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2874 delete m_rep;
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
2875 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
2876 new_val->m_rep = nullptr;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2877 delete new_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2878 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2879 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2880 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2881
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2882 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2883
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2884 // A class to manage calls to MEX functions. Mostly deals with memory
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2885 // management.
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2886
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2887 class mex
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2888 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2889 public:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2890
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2891 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
2892 : m_curr_mex_fcn (f), m_memlist (), m_arraylist (), m_fname (nullptr) { }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2893
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2894 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2895
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2896 mex (const mex&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2897
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2898 mex& operator = (const mex&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2899
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2900 ~mex (void)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2901 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2902 // 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
2903 while (! m_memlist.empty ())
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2904 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2905 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
2906 xfree (*p);
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2907 m_memlist.erase (p);
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2908 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2909
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2910 // 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
2911 while (! m_arraylist.empty ())
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2912 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2913 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
2914 delete *p;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2915 m_arraylist.erase (p);
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2916 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2917
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2918 if (! (m_memlist.empty () && m_arraylist.empty ()))
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
2919 error ("mex: %s: cleanup failed", function_name ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2920
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2921 mxFree (m_fname);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2922 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2923
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2924 const char * function_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2925 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2926 if (! m_fname)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2927 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
2928 octave::tree_evaluator& tw
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
2929 = 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
2930
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
2931 octave_function *fcn = tw.current_function ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2932
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2933 if (fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2934 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2935 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
2936 m_fname = mxArray::strsave (nm.c_str ());
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 else
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2939 m_fname = mxArray::strsave ("unknown");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2940 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2941
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2942 return m_fname;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2943 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2944
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2945 // 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
2946 void * malloc_unmarked (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2947 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2948 void *ptr = std::malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2949
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2950 if (! ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2951 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2952 // 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
2953 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
2954 function_name (), n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2955 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2956
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2957 global_mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2958
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2959 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2960 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2961
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2962 // 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
2963 void * malloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2964 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2965 void *ptr = malloc_unmarked (n);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2966
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2967 mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2968
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2969 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2970 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2971
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2972 // 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
2973 void * calloc_unmarked (std::size_t n, std::size_t t)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2974 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2975 void *ptr = malloc_unmarked (n*t);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2976
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2977 memset (ptr, 0, n*t);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2978
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2979 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2980 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2981
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2982 // 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
2983 void * calloc (std::size_t n, std::size_t t)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2984 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2985 void *ptr = calloc_unmarked (n, t);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2986
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2987 mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2988
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2989 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2990 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2991
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21743
diff changeset
2992 // 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
2993 // 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
2994 // 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
2995 void * realloc (void *ptr, std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2996 {
10225
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
2997 void *v;
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
2998
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
2999 if (ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3000 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3001 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
3002 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
3003
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3004 v = std::realloc (ptr, n);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3005
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3006 if (v)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3007 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3008 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
3009 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3010 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
3011 m_memlist.insert (v);
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3012 }
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3013
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3014 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
3015 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3016 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
3017 s_global_memlist.insert (v);
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3018 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3019 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3020 }
10225
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3021 else
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3022 v = malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3023
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3024 return v;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3025 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3026
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3027 // Free a pointer obtained from malloc or calloc.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3028 void free (void *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3029 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3030 if (ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3031 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3032 unmark (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3033
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3034 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
3035
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3036 if (p != s_global_memlist.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3037 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3038 s_global_memlist.erase (p);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3039
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3040 xfree (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3041 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3042 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3043 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3044 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
3045
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3046 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
3047 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
3048 #if defined (DEBUG)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3049 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3050 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
3051 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3052 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3053 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3054 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3055
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3056 // Mark a pointer to be freed on exit.
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3057 void mark (void *ptr)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3058 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3059 #if defined (DEBUG)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3060 if (m_memlist.find (ptr) != m_memlist.end ())
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3061 warning ("%s: double registration ignored", function_name ());
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3062 #endif
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3063
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3064 m_memlist.insert (ptr);
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3065 }
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3066
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3067 // Unmark a pointer to be freed on exit, either because it was
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3068 // made persistent, or because it was already freed.
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3069 void unmark (void *ptr)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3070 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3071 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
3072
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3073 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
3074 m_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3075 #if defined (DEBUG)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3076 else
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3077 warning ("%s: value not marked", function_name ());
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3078 #endif
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3079 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3080
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3081 mxArray * mark_array (mxArray *ptr)
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3082 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3083 m_arraylist.insert (ptr);
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3084 return ptr;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3085 }
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3086
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3087 void unmark_array (mxArray *ptr)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3088 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3089 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
3090
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3091 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
3092 m_arraylist.erase (p);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3093 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3094
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3095 // Mark a pointer as one we allocated.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3096 void mark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3097 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3098 #if defined (DEBUG)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3099 if (m_foreign_memlist.find (ptr) != m_foreign_memlist.end ())
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3100 warning ("%s: double registration ignored", function_name ());
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3101 #endif
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3102
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3103 m_foreign_memlist.insert (ptr);
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3104 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3105
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3106 // Unmark a pointer as one we allocated.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3107 void unmark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3108 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3109 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
3110
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3111 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
3112 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
3113 #if defined (DEBUG)
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3114 else
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3115 warning ("%s: value not marked", function_name ());
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3116 #endif
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3117
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3118 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3119
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3120 // Make a new array value and initialize from an octave value; it will be
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3121 // 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
3122 mxArray * make_value (const octave_value& ov)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3123 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3124 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
3125
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3126 return mark_array (new mxArray (interleaved, ov));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3127 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3128
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3129 // Free an array and its contents.
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3130 bool free_value (mxArray *ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3131 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3132 bool inlist = false;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3133
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3134 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
3135
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3136 if (p != m_arraylist.end ())
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3137 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3138 inlist = true;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3139 m_arraylist.erase (p);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3140 delete ptr;
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3141 }
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3142 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3143 else
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3144 warning ("mex::free_value: skipping memory not allocated by mex::make_value");
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3145 #endif
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3146
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3147 return inlist;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3148 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3149
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3150 octave_mex_function& current_mex_function (void) const
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3151 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3152 return m_curr_mex_fcn;
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3153 }
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3154
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3155 // 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
3156 int trap_feval_error = 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3157
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3158 private:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3159
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3160 // Mark a pointer as one we allocated.
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3161 void global_mark (void *ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3162 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3163 #if defined (DEBUG)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3164 if (s_global_memlist.find (ptr) != s_global_memlist.end ())
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3165 warning ("%s: double registration ignored", function_name ());
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3166 #endif
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3167
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3168 s_global_memlist.insert (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3169 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3170
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3171 // Unmark a pointer as one we allocated.
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3172 void global_unmark (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3173 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3174 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
3175
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3176 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
3177 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
3178 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3179 else
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3180 warning ("%s: value not marked", function_name ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3181 #endif
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3182 }
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3183
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3184 //--------
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3185
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3186 // 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
3187 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
3188
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3189 // 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
3190 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
3191
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3192 // 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
3193 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
3194
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3195 // 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
3196 // elsewhere.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3197 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
3198
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3199 // 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
3200 mutable char *m_fname;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3201
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3202 // 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
3203 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
3204
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3205 };
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3206
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3207 // 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
3208 std::set<void *> mex::s_global_memlist;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3209
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3210 // Current context.
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
3211 mex *mex_context = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3212
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3213 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
3214 mxArray::malloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3215 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3216 return mex_context ? mex_context->malloc_unmarked (n) : std::malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3217 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3218
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3219 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
3220 mxArray::calloc (std::size_t n, std::size_t t)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3221 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3222 return mex_context ? mex_context->calloc_unmarked (n, t) : ::calloc (n, t);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3223 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3224
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3225 static inline void *
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3226 maybe_mark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3227 {
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3228 if (mex_context)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3229 mex_context->mark_foreign (ptr);
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3230
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3231 return ptr;
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3232 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3233
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3234 static inline mxArray *
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3235 maybe_unmark_array (mxArray *ptr)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3236 {
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3237 if (mex_context)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3238 mex_context->unmark_array (ptr);
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3239
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3240 return ptr;
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3241 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3242
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3243 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
3244 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
3245 maybe_unmark (T *ptr)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3246 {
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3247 if (mex_context)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3248 mex_context->unmark (ptr);
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3249
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3250 return ptr;
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3251 }
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3252
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3253 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3254 mxArray_struct::set_field_by_number (mwIndex index, int key_num, mxArray *val)
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3255 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3256 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
3257 m_data[m_nfields * index + key_num] = maybe_unmark_array (val);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3258 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3259
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3260 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3261 mxArray_cell::set_cell (mwIndex idx, mxArray *val)
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3262 {
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
3263 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
3264 m_data[idx] = maybe_unmark_array (val);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3265 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3266
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3267 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3268
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3269 // C interface to mxArray objects:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3270
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3271 // Floating point predicates.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3272
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3273 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3274 mxIsFinite (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3275 {
30088
fca57eaad2d4 maint: deprecate lo_ieee_finite and replace with lo_ieee_isfinite.
Rik <rik@octave.org>
parents: 29993
diff changeset
3276 return lo_ieee_isfinite (v) != 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3277 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3278
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3279 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3280 mxIsInf (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3281 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3282 return lo_ieee_isinf (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3283 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3284
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3285 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3286 mxIsNaN (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3287 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3288 return lo_ieee_isnan (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3289 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3290
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3291 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3292 mxGetEps (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3293 {
15220
61822c866ba1 use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
3294 return std::numeric_limits<double>::epsilon ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3295 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3296
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3297 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3298 mxGetInf (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3299 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3300 return lo_ieee_inf_value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3301 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3302
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3303 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3304 mxGetNaN (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3305 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3306 return lo_ieee_nan_value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3307 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3308
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3309 // Memory management.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3310 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
3311 mxCalloc (std::size_t n, std::size_t size)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3312 {
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
3313 return mex_context ? mex_context->calloc (n, size) : ::calloc (n, size);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3314 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3315
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3316 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
3317 mxMalloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3318 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3319 return mex_context ? mex_context->malloc (n) : std::malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3320 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3321
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3322 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
3323 mxRealloc (void *ptr, std::size_t size)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3324 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3325 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
3326 : std::realloc (ptr, size);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3327 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3328
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3329 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3330 mxFree (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3331 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3332 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3333 mex_context->free (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3334 else
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3335 xfree (ptr);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3336 }
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3337
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3338 static inline mxArray *
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3339 maybe_mark_array (mxArray *ptr)
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3340 {
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3341 return mex_context ? mex_context->mark_array (ptr) : ptr;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3342 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3343
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3344 // Constructors.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3345 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
3346 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
3347 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3348 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
3349 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3350
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3351 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3352 mxCreateCellArray (mwSize ndims, const mwSize *dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3353 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3354 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
3355 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3356
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3357 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3358 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
3359 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3360 return maybe_mark_array (new mxArray (true, m, n));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3361 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3362
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3363 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3364 mxCreateCellMatrix (mwSize m, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3365 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3366 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
3367 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3368
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3369 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3370 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
3371 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3372 return maybe_mark_array (new mxArray (true, mxCHAR_CLASS, ndims, dims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3373 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3374
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3375 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3376 mxCreateCharArray (mwSize ndims, const mwSize *dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3377 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3378 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
3379 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3380
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3381 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3382 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
3383 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3384 return maybe_mark_array (new mxArray (true, m, str));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3385 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3386
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3387 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3388 mxCreateCharMatrixFromStrings (mwSize m, const char **str)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3389 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3390 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
3391 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3392
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3393 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3394 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
3395 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3396 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, flag));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3397 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3398
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3399 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3400 mxCreateDoubleMatrix (mwSize m, mwSize n, mxComplexity flag)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3401 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3402 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
3403 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3404
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3405 mxArray *
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3406 mxCreateDoubleScalar_interleaved (double m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3407 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3408 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m_val));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3409 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3410
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3411 mxArray *
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3412 mxCreateDoubleScalar (double m_val)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3413 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3414 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, m_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
3415 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3416
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3417 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3418 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
3419 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3420 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, ndims, dims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3421 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3422
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3423 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3424 mxCreateLogicalArray (mwSize ndims, const mwSize *dims)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3425 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3426 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
3427 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3428
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3429 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3430 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
3431 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3432 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3433 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3434
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3435 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3436 mxCreateLogicalMatrix (mwSize m, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3437 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3438 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
3439 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3440
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3441 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3442 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
3443 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3444 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, val));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3445 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3446
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3447 mxArray *
7577
ba8fcc115fee mex.cc: arg to mxCreateLogicalScalar is now mxLogical
John W. Eaton <jwe@octave.org>
parents: 7357
diff changeset
3448 mxCreateLogicalScalar (mxLogical val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3449 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3450 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
3451 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3452
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3453 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3454 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
3455 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
3456 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3457 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3458 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3459
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3460 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
3461 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
3462 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
3463 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3464 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
3465 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3466
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3467 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3468 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
3469 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
3470 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3471 return maybe_mark_array (new mxArray (true, class_id, m, n, flag));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3472 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3473
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3474 mxArray *
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3475 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
3476 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
3477 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3478 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
3479 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3480
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3481 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3482 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
3483 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
3484 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3485 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
3486 false));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3487 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3488
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3489 mxArray *
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3490 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
3491 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
3492 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3493 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
3494 false));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3495 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3496
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3497 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3498 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
3499 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
3500 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3501 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
3502 }
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3503
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3504 mxArray *
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3505 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
3506 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
3507 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3508 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
3509 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3510
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3511 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3512 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
3513 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3514 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
3515 flag));
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3516 }
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3517
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3518 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3519 mxCreateSparse (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3520 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3521 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
3522 flag));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3523 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3524
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3525 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3526 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
3527 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3528 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n, nzmax));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3529 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3530
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3531 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3532 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3533 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3534 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
3535 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3536
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3537 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3538 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
3539 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3540 return maybe_mark_array (new mxArray (true, str));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3541 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3542
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3543 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3544 mxCreateString (const char *str)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3545 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3546 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
3547 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3548
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3549 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3550 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
3551 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
3552 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3553 return maybe_mark_array (new mxArray (true, ndims, dims, num_keys, keys));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3554 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3555
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3556 mxArray *
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3557 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
3558 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
3559 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3560 return maybe_mark_array (new mxArray (false, ndims, dims, num_keys, keys));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3561 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3562
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3563 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
3564 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
3565 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
3566 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3567 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
3568 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3569
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3570 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3571 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
3572 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
3573 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3574 return maybe_mark_array (new mxArray (false, m, n, num_keys, keys));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3575 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3576
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3577 // Copy constructor.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3578 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3579 mxDuplicateArray (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3580 {
11277
7d5351fc575a mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents: 11276
diff changeset
3581 return maybe_mark_array (ptr->dup ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3582 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3583
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3584 // Destructor.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3585 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3586 mxDestroyArray (mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3587 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3588 if (! (mex_context && mex_context->free_value (ptr)))
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3589 delete ptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3590 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3591
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3592 // 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
3593 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3594 mxIsCell (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3595 {
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23553
diff changeset
3596 return ptr->iscell ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3597 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3598
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3599 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3600 mxIsChar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3601 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3602 return ptr->is_char ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3603 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3604
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3605 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3606 mxIsClass (const mxArray *ptr, const char *name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3607 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3608 return ptr->is_class (name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3609 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3610
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3611 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3612 mxIsComplex (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3613 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3614 return ptr->is_complex ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3615 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3616
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3617 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3618 mxIsDouble (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3619 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3620 return ptr->is_double ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3621 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3622
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3623 bool
11100
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3624 mxIsFunctionHandle (const mxArray *ptr)
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3625 {
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3626 return ptr->is_function_handle ();
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3627 }
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3628
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3629 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3630 mxIsInt16 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3631 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3632 return ptr->is_int16 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3633 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3634
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3635 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3636 mxIsInt32 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3637 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3638 return ptr->is_int32 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3639 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3640
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3641 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3642 mxIsInt64 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3643 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3644 return ptr->is_int64 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3645 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3646
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3647 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3648 mxIsInt8 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3649 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3650 return ptr->is_int8 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3651 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3652
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3653 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3654 mxIsLogical (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3655 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3656 return ptr->is_logical ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3657 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3658
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3659 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3660 mxIsNumeric (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3661 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3662 return ptr->is_numeric ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3663 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3664
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3665 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3666 mxIsSingle (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3667 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3668 return ptr->is_single ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3669 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3670
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3671 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3672 mxIsSparse (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3673 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3674 return ptr->is_sparse ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3675 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3676
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3677 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3678 mxIsStruct (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3679 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3680 return ptr->is_struct ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3681 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3682
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3683 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3684 mxIsUint16 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3685 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3686 return ptr->is_uint16 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3687 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3688
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3689 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3690 mxIsUint32 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3691 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3692 return ptr->is_uint32 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3693 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3694
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3695 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3696 mxIsUint64 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3697 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3698 return ptr->is_uint64 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3699 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3700
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3701 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3702 mxIsUint8 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3703 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3704 return ptr->is_uint8 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3705 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3706
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3707 // 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
3708 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3709 mxIsLogicalScalar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3710 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3711 return ptr->is_logical_scalar ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3712 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3713
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3714 // 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
3715 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3716 mxIsLogicalScalarTrue (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3717 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3718 return ptr->is_logical_scalar_true ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3719 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3720
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3721 // 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
3722 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3723 mxIsEmpty (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3724 {
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
3725 return ptr->isempty ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3726 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3727
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3728 bool
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3729 mxIsScalar (const mxArray *ptr)
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3730 {
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3731 return ptr->is_scalar ();
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3732 }
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3733
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
3734 // 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
3735 // 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
3736 bool
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
3737 mxIsFromGlobalWS (const mxArray * /*ptr*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3738 {
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
3739 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
3740
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3741 return 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3742 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3743
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3744 // 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
3745 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3746 mxGetM (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3747 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3748 return ptr->get_m ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3749 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3750
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
3751 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3752 mxGetN (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3753 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3754 return ptr->get_n ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3755 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3756
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3757 const mwSize *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3758 mxGetDimensions (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3759 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3760 return ptr->get_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3761 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3762
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3763 mwSize
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3764 mxGetNumberOfDimensions (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3765 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3766 return ptr->get_number_of_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3767 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3768
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
3769 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3770 mxGetNumberOfElements (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3771 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3772 return ptr->get_number_of_elements ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3773 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3774
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3775 // Dimension setters.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3776 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3777 mxSetM (mxArray *ptr, mwSize m)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3778 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3779 ptr->set_m (m);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3780 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3781
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3782 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3783 mxSetN (mxArray *ptr, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3784 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3785 ptr->set_n (n);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3786 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3787
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3788 int
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3789 mxSetDimensions (mxArray *ptr, const mwSize *m_dims, mwSize m_ndims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3790 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3791 return (ptr->set_dimensions (static_cast<mwSize *>
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3792 (maybe_unmark (const_cast<mwSize *> (m_dims))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3793 m_ndims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3794 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3795
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3796 // Data extractors.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3797 double *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3798 mxGetPr (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3799 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3800 return static_cast<double *> (ptr->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3801 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3802
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3803 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3804 mxGetScalar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3805 {
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
3806 return ptr->get_scalar ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3807 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3808
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3809 mxChar *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3810 mxGetChars (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3811 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3812 if (mxIsChar (ptr))
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3813 return static_cast<mxChar *> (ptr->get_data ());
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3814 else
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
3815 return nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3816 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3817
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3818 mxLogical *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3819 mxGetLogicals (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3820 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3821 return static_cast<mxLogical *> (ptr->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3822 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3823
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3824 void *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3825 mxGetData (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3826 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3827 return ptr->get_data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3828 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3829
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3830 double *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3831 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
3832 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3833 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
3834 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3835
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3836 void *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3837 mxGetImagData (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3838 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3839 return ptr->get_imag_data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3840 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3841
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3842 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
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 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
3845 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3846
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3847 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
3848 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3849 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3852 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
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 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
3855 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3856
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3857 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
3858 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3859 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
3860 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3861
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3862 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
3863 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3864 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3867 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
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 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
3870 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3871
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3872 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
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 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
3875 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3876
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3877 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
3878 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3879 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3882 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
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 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
3885 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3886
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3887 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
3888 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3889 return 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
3890 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3891
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3892 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
3893 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3894 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
3895 }
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 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
3898 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3899 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3902 #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
3903 /* 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
3904 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
3905 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3906 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
3907 }
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 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
3910 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3911 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3914 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
3915 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3916 return 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
3917 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3918
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3919 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
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 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
3922 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3923
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3924 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
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 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
3927 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3928
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3929 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
3930 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3931 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
3932 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3933
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3934 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
3935 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3936 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
3937 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3938
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3939 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
3940 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3941 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
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 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3944
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3945 // Data setters.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3946 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3947 mxSetPr (mxArray *ptr, double *pr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3948 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3949 ptr->set_data (maybe_unmark (pr));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3950 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3951
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3952 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
3953 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
3954 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3955 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
3956 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3957
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3958 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
3959 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3960 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
3961 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3962
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3963 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
3964 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3965 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
3966 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3967
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3968 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
3969 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3970 return 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
3971 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3972
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3973 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
3974 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3975 return 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
3976 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3977
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3978 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
3979 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3980 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
3981 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3982
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3983 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
3984 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3985 return 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
3986 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3987
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3988 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
3989 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3990 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
3991 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3992
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3993 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
3994 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3995 return 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
3996 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3997
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3998 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
3999 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4000 return 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
4001 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4002
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4003 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
4004 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4005 return 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
4006 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4007
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4008 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
4009 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4010 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
4011 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4012
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4013 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
4014 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4015 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
4016 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4017
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4018 #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
4019 /* 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
4020 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
4021 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4022 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
4023 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4024
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4025 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
4026 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4027 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
4028 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4029
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4030 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
4031 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4032 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
4033 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4034
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4035 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
4036 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4037 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
4038 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4039
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4040 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
4041 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4042 return 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
4043 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4044
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4045 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
4046 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4047 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
4048 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4049
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4050 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
4051 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4052 return 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
4053 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4054
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4055 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
4056 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4057 return 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
4058 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4059 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4060
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4061 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4062 mxSetPi (mxArray *ptr, double *pi)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4063 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4064 ptr->set_imag_data (maybe_unmark (pi));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4065 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4066
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4067 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4068 mxSetImagData (mxArray *ptr, void *pi)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4069 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4070 ptr->set_imag_data (maybe_unmark (pi));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4071 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4072
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4073 // Classes.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4074 mxClassID
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4075 mxGetClassID (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4076 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4077 return ptr->get_class_id ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4078 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4079
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4080 const char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4081 mxGetClassName (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4082 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4083 return ptr->get_class_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4084 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4085
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4086 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4087 mxSetClassName (mxArray *ptr, const char *name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4088 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4089 ptr->set_class_name (name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4090 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4091
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4092 void
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4093 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
4094 const mxArray *property_value)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4095 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4096 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
4097 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4098
23891
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4099 mxArray *
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4100 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
4101 {
23891
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4102 return ptr->get_property (idx, property_name);
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4103 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4104
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4105 // Cell support.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4106 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4107 mxGetCell (const mxArray *ptr, mwIndex idx)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4108 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4109 return ptr->get_cell (idx);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4110 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4111
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4112 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4113 mxSetCell (mxArray *ptr, mwIndex idx, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4114 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4115 ptr->set_cell (idx, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4116 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4117
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4118 // Sparse support.
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4119 mwIndex *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4120 mxGetIr (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4121 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4122 return ptr->get_ir ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4123 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4124
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4125 mwIndex *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4126 mxGetJc (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4127 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4128 return ptr->get_jc ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4129 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4130
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4131 mwSize
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4132 mxGetNzmax (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4133 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4134 return ptr->get_nzmax ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4135 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4136
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4137 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4138 mxSetIr (mxArray *ptr, mwIndex *ir)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4139 {
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
4140 ptr->set_ir (static_cast<mwIndex *> (maybe_unmark (ir)));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4141 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4142
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4143 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4144 mxSetJc (mxArray *ptr, mwIndex *jc)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4145 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4146 ptr->set_jc (static_cast<mwIndex *> (maybe_unmark (jc)));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4147 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4148
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4149 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4150 mxSetNzmax (mxArray *ptr, mwSize nzmax)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4151 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4152 ptr->set_nzmax (nzmax);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4153 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4154
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4155 // Structure support.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4156 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4157 mxAddField (mxArray *ptr, const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4158 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4159 return ptr->add_field (key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4160 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4161
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4162 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4163 mxRemoveField (mxArray *ptr, int key_num)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4164 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4165 ptr->remove_field (key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4166 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4167
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4168 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4169 mxGetField (const mxArray *ptr, mwIndex index, const char *key)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4170 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4171 int key_num = mxGetFieldNumber (ptr, key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4172 return mxGetFieldByNumber (ptr, index, key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4173 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4174
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4175 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4176 mxGetFieldByNumber (const mxArray *ptr, mwIndex index, int key_num)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4177 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4178 return ptr->get_field_by_number (index, key_num);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4179 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4180
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4181 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4182 mxSetField (mxArray *ptr, mwIndex index, const char *key, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4183 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4184 int key_num = mxGetFieldNumber (ptr, key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4185 mxSetFieldByNumber (ptr, index, key_num, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4186 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4187
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4188 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4189 mxSetFieldByNumber (mxArray *ptr, mwIndex index, int key_num, mxArray *val)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4190 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4191 ptr->set_field_by_number (index, key_num, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4192 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4193
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4194 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4195 mxGetNumberOfFields (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4196 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4197 return ptr->get_number_of_fields ();
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4198 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4199
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4200 const char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4201 mxGetFieldNameByNumber (const mxArray *ptr, int key_num)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4202 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4203 return ptr->get_field_name_by_number (key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4204 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4205
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4206 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4207 mxGetFieldNumber (const mxArray *ptr, const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4208 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4209 return ptr->get_field_number (key);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4210 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4211
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4212 int
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4213 mxGetString (const mxArray *ptr, char *buf, mwSize buflen)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4214 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4215 return ptr->get_string (buf, buflen);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4216 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4217
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4218 char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4219 mxArrayToString (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4220 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4221 return ptr->array_to_string ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4222 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
4223
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4224 mwIndex
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4225 mxCalcSingleSubscript (const mxArray *ptr, mwSize nsubs, mwIndex *subs)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4226 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4227 return ptr->calc_single_subscript (nsubs, subs);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4228 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4229
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
4230 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4231 mxGetElementSize (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4232 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4233 return ptr->get_element_size ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4234 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4235
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4236 // ------------------------------------------------------------------
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4237
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4238 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
4239 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
4240 F77_INT& nrhs, mxArray **prhs);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4241
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4242 octave_value_list
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4243 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
4244 int nargout_arg)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4245 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4246 octave_quit ();
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4247
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4248 // Use at least 1 for nargout since even for zero specified args,
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4249 // still want to be able to return an ans.
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4250
8806
c7864bb74914 avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
4251 volatile int nargout = nargout_arg;
c7864bb74914 avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
4252
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4253 int nargin = args.length ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4254 OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4255 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
4256 argin[i] = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4257
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
4258 int nout = (nargout == 0 ? 1 : nargout);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4259 OCTAVE_LOCAL_BUFFER (mxArray *, argout, nout);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4260 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
4261 argout[i] = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4262
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4263 // Save old mex pointer.
28823
26cfccfee9a0 Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents: 28370
diff changeset
4264 octave::unwind_protect_var<mex *> restore_var (mex_context);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4265
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4266 mex context (mex_fcn);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4267
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4268 for (int i = 0; i < nargin; i++)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4269 argin[i] = context.make_value (args(i));
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4270
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4271 mex_context = &context;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4272
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4273 void *mex_fcn_ptr = mex_fcn.mex_fcn_ptr ();
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4274
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4275 if (mex_fcn.is_fmex ())
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4276 {
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4277 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
4278
23498
647705ffb110 use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
4279 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
4280 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
4281
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4282 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
4283 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4284 else
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4285 {
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4286 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
4287
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4288 fcn (nargout, argout, nargin, argin);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4289 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4290
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4291 // Convert returned array entries back into octave values.
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4292
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4293 octave_value_list retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4294
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4295 if (nargout == 0 && argout[0])
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4296 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4297 // We have something for ans.
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4298 nargout = 1;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4299 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4300
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4301 retval.resize (nargout);
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4302
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4303 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
4304 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
4305
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4306 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4307 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4308
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4309 // C interface to mex functions:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4310
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4311 const char *
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4312 mexFunctionName (void)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4313 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4314 return mex_context ? mex_context->function_name () : "unknown";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4315 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4316
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4317 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
4318 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
4319 mxArray *argin[], const char *fname)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4320 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4321 octave_value_list args;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4322
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4323 // FIXME: do we need unwind protect to clean up args? Off hand, I
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4324 // would say that this problem is endemic to Octave and we will
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4325 // 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
4326 // handling is implemented.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4327
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
4328 // 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
4329 // Can this code be re-factored?
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4330 args.resize (nargin);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4331
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4332 for (int i = 0; i < nargin; i++)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
4333 args(i) = mxArray::as_octave_value (argin[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4334
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4335 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
4336
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4337 bool execution_error = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4338
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4339 octave_value_list retval;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4340
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4341 try
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4342 {
29172
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4343 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
4344
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4345 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
4346 ([&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
4347 {
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4348 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
4349 }, tw.lvalue_list ());
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4350
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4351 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
4352
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23052
diff changeset
4353 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
4354 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
4355 catch (const octave::execution_exception&)
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4356 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4357 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
4358 {
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4359 // FIXME: is there a way to indicate what error occurred?
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4360 // Should the error message be displayed here? Do we need to
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4361 // save the exception info for lasterror?
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4362
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4363 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
4364
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4365 execution_error = true;
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4366 }
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4367 else
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4368 {
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4369 args.resize (0);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4370 retval.resize (0);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4371
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4372 throw;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4373 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4374 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4375
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4376 int num_to_copy = retval.length ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4377
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4378 if (nargout < retval.length ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4379 num_to_copy = nargout;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4380
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4381 for (int i = 0; i < num_to_copy; i++)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4382 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4383 // FIXME: it would be nice to avoid copying the value here,
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4384 // but there is no way to steal memory from a matrix, never mind
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4385 // that matrix memory is allocated by new[] and mxArray memory
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4386 // 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
4387 argout[i] = mex_context->make_value (retval(i));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4388 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4389
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4390 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
4391 argout[num_to_copy++] = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4392
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4393 return execution_error ? 1 : 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4394 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4395
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4396 mxArray *
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4397 mexCallMATLABWithTrap (int nargout, mxArray *argout[], int nargin,
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4398 mxArray *argin[], const char *fname)
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4399 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4400 mxArray *mx = nullptr;
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4401
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
4402 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
4403 mexSetTrapFlag (1);
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4404 if (mexCallMATLAB (nargout, argout, nargin, argin, fname))
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4405 {
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4406 const char *field_names[] = {"identifier", "message", "case", "stack"};
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4407 mx = mxCreateStructMatrix (1, 1, 4, field_names);
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4408 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX"));
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4409 std::string msg = "mexCallMATLABWithTrap: function call <"
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4410 + std::string (fname) + "> failed";
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4411 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ()));
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4412 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
4413 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
4414 }
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4415 mexSetTrapFlag (old_flag);
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4416
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4417 return mx;
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4418 }
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4419
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4420 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4421 mexSetTrapFlag (int flag)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4422 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4423 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4424 mex_context->trap_feval_error = flag;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4425 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4426
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4427 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4428 mexEvalString (const char *s)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4429 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4430 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4431
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4432 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
4433
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4434 int parse_status;
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4435 bool execution_error = false;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4436
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4437 octave_value_list ret;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4438
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4439 try
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4440 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 25922
diff changeset
4441 ret = interp.eval_string (std::string (s), false, parse_status, 0);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4442 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
4443 catch (const octave::execution_exception&)
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4444 {
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4445 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
4446
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4447 execution_error = true;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4448 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4449
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4450 if (parse_status || execution_error)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4451 retval = 1;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4452
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4453 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4454 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4455
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4456 mxArray *
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4457 mexEvalStringWithTrap (const char *s)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4458 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4459 mxArray *mx = nullptr;
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4460
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4461 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
4462
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4463 int parse_status;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4464 bool execution_error = false;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4465
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4466 octave_value_list ret;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4467
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4468 try
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4469 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 25922
diff changeset
4470 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
4471 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4472 catch (const octave::execution_exception&)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4473 {
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4474 interp.recover_from_exception ();
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4475
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4476 execution_error = true;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4477 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4478
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4479 if (parse_status || execution_error)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4480 {
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4481 const char *field_names[] = {"identifier", "message", "case", "stack"};
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4482 mx = mxCreateStructMatrix (1, 1, 4, field_names);
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4483 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX"));
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4484 std::string msg = "mexEvalStringWithTrap: eval of <"
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4485 + std::string (s) + "> failed";
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4486 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ()));
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4487 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
4488 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
4489 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4490
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4491 return mx;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4492 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4493
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4494 void
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4495 mexErrMsgTxt (const char *s)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4496 {
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
4497 std::size_t len;
25751
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4498
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4499 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
4500 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4501 if (s[len - 1] == '\n')
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4502 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4503 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
4504 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
4505 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4506 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4507 error ("%s: %s", mexFunctionName (), s);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4508 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4509 else
16851
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4510 {
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4511 // 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
4512 // 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
4513 error (" ");
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4514 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4515 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4516
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4517 void
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4518 mexErrMsgIdAndTxt (const char *m_id, const char *fmt, ...)
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4519 {
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4520 if (fmt && strlen (fmt) > 0)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4521 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4522 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
4523 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4524 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4525 sprintf (tmpfmt, "%s: %s", fname, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4526 va_list args;
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4527 va_start (args, fmt);
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4528 verror_with_id (m_id, tmpfmt, args);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4529 va_end (args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4530 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4531 else
16851
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4532 {
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4533 // 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
4534 // 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
4535 error (" ");
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4536 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4537 }
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4538
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4539 void
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4540 mexWarnMsgTxt (const char *s)
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4541 {
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
4542 std::size_t len;
25751
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4543
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4544 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
4545 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4546 if (s[len - 1] == '\n')
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4547 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4548 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
4549 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
4550 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4551 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4552 warning ("%s", s);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4553 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4554 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4555 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4556 // 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
4557 // 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
4558 warning (" ");
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4559 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4560 }
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4561
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4562 void
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4563 mexWarnMsgIdAndTxt (const char *m_id, const char *fmt, ...)
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4564 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4565 // 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
4566 // an empty string?
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4567
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4568 if (fmt && strlen (fmt) > 0)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4569 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4570 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
4571 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4572 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4573 sprintf (tmpfmt, "%s: %s", fname, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4574 va_list args;
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4575 va_start (args, fmt);
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4576 vwarning_with_id (m_id, tmpfmt, args);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4577 va_end (args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4578 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4579 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4580
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
4581 int
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4582 mexPrintf (const char *fmt, ...)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4583 {
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
4584 int retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4585 va_list args;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4586 va_start (args, fmt);
25646
4d565baa475e move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25452
diff changeset
4587 retval = octave::vformat (octave_stdout, fmt, args);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4588 va_end (args);
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
4589 return retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4590 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4591
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4592 mxArray *
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4593 mexGetVariable (const char *space, const char *name)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4594 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4595 mxArray *retval = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4596
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
4597 octave_value val;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4598
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4599 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
4600
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4601 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
4602 val = interp.global_varval (name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4603 else
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
4604 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4605 // 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
4606
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
4607 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
4608
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4609 bool caller = ! strcmp (space, "caller");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4610 bool base = ! strcmp (space, "base");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4611
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4612 if (caller || base)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4613 {
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4614 // 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
4615 // 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
4616
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4617 if (base)
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4618 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4619 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
4620
29253
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
4621 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
4622 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
4623
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4624 tw.goto_base_frame ();
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4625 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4626
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4627 val = interp.varval (name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4628 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
4629 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4630 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
4631 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4632
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4633 if (val.is_defined ())
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4634 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4635 retval = mex_context->make_value (val);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4636
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4637 retval->set_name (name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4638 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4639
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4640 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4641 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4642
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4643 const mxArray *
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4644 mexGetVariablePtr (const char *space, const char *name)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4645 {
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4646 return mexGetVariable (space, name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4647 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4648
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4649 int
15353
5f3a69a309a7 fix decl of mexPutVariable
John W. Eaton <jwe@octave.org>
parents: 15351
diff changeset
4650 mexPutVariable (const char *space, const char *name, const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4651 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4652 if (! ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4653 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4654
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4655 if (! name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4656 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4657
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4658 if (name[0] == '\0')
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4659 name = ptr->get_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4660
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4661 if (! name || name[0] == '\0')
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4662 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4663
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4664 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
4665
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4666 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
4667 interp.global_assign (name, mxArray::as_octave_value (ptr));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4668 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4669 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4670 // FIXME: should this be in variables.cc?
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4671
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
4672 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
4673
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4674 bool caller = ! strcmp (space, "caller");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4675 bool base = ! strcmp (space, "base");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4676
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4677 if (caller || base)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4678 {
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4679 // 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
4680 // 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
4681
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4682 if (base)
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4683 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4684 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
4685
29253
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
4686 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
4687 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
4688
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4689 tw.goto_base_frame ();
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4690 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4691
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4692 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
4693 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4694 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4695 mexErrMsgTxt ("mexPutVariable: symbol table does not exist");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4696 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4697
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4698 return 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4699 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4700
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4701 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4702 mexMakeArrayPersistent (mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4703 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4704 maybe_unmark_array (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4705 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4706
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4707 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4708 mexMakeMemoryPersistent (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4709 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4710 maybe_unmark (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4711 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4712
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4713 int
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4714 mexAtExit (void (*f) (void))
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4715 {
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4716 if (mex_context)
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4717 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4718 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
4719
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4720 curr_mex_fcn.atexit (f);
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4721 }
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4722
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4723 return 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4724 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4725
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4726 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
4727 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
4728 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4729 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
4730
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
4731 octave_value ret
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
4732 = 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
4733
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4734 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
4735 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
4736
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4737 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
4738 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4739
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4740 const mxArray *
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4741 mexGet (double handle, const char *property)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4742 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4743 mxArray *m = nullptr;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4744
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
4745 octave_value ret
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
4746 = octave::get_property_from_handle (handle, property, "mexGet");
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4747
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4748 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
4749 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
4750
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4751 return m;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4752 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4753
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4754 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4755 mexIsGlobal (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4756 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4757 return mxIsFromGlobalWS (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4758 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4759
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4760 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4761 mexIsLocked (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4762 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4763 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4764
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4765 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4766 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4767 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4768
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4769 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
4770
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4771 retval = interp.mislocked (fname);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4772 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4773
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4774 return retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4775 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4776
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4777 std::map<std::string,int> mex_lock_count;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4778
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4779 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4780 mexLock (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4781 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4782 if (mex_context)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4783 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4784 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4785
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4786 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
4787 mex_lock_count[fname] = 1;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4788 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4789 mex_lock_count[fname]++;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4790
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4791 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
4792
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4793 interp.mlock ();
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4794 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4795 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4796
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4797 int
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4798 mexSet (double handle, const char *property, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4799 {
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
4800 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
4801 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
4802 "mexSet");
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4803 return (ret ? 0 : 1);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4804 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4805
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4806 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4807 mexUnlock (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4808 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4809 if (mex_context)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4810 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4811 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4812
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
4813 auto p = mex_lock_count.find (fname);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4814
6062
a813714cb04b [project @ 2006-10-18 23:30:22 by jwe]
jwe
parents: 6018
diff changeset
4815 if (p != mex_lock_count.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4816 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4817 int count = --mex_lock_count[fname];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4818
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4819 if (count == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4820 {
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4821 octave::interpreter& interp
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4822 = octave::__get_interpreter__ ("mexUnLock");
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4823
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4824 interp.munlock (fname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4825
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4826 mex_lock_count.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4827 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4828 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4829 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4830 }