annotate libinterp/corefcn/mex.cc @ 29655:32f4357ac8d9

maint: merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 12 May 2021 19:28:54 +0200
parents aef11bb4e6d1 d13d090cb03a
children 5411391a4cc0
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
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
367 class mxArray_octave_value : public mxArray_base
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
368 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
369 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
370
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
371 mxArray_octave_value (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
372 : mxArray_base (interleaved), val (ov), mutate_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
373 id (mxUNKNOWN_CLASS), class_name (nullptr), ndims (-1), dims (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
374 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
375
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
376 // 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
377 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
378
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
379 mxArray_octave_value& operator = (const mxArray_octave_value&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
380
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
381 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
382
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
383 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
384 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
385 mxArray *retval = 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
386
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
387 // 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
388 // 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
389
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 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
391 {
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 // 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
393 // 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
394
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 // 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
396 // 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
397
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 if (class_name)
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 {
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 retval->set_class_name (class_name);
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
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
402 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
403 }
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
404
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
405 if (dims)
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
406 {
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 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
408
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
409 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
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 retval->set_dimensions (dims, ndims);
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
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
413 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
414 }
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
415 }
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
416
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
417 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
418 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
419
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
420 ~mxArray_octave_value (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
421 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
422 mxFree (class_name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
423 mxFree (dims);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
424 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
425
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
426 bool is_octave_value (void) const { return true; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
427
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23553
diff changeset
428 int iscell (void) const { return val.iscell (); }
5900
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 int is_char (void) const { return val.is_string (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
431
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23579
diff changeset
432 int is_complex (void) const { return val.iscomplex (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
433
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
434 int is_double (void) const { return val.is_double_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
435
11100
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
436 int is_function_handle (void) const { return val.is_function_handle (); }
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
437
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
438 int is_int16 (void) const { return val.is_int16_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
439
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
440 int is_int32 (void) const { return val.is_int32_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
441
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
442 int is_int64 (void) const { return val.is_int64_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
443
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
444 int is_int8 (void) const { return val.is_int8_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
445
23579
c20a0fa91c0c maint: Deprecate is_bool_type and replace with islogical.
Rik <rik@octave.org>
parents: 23577
diff changeset
446 int is_logical (void) const { return val.islogical (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
447
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23584
diff changeset
448 int is_numeric (void) const { return val.isnumeric (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
449
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
450 int is_single (void) const { return val.is_single_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
451
23583
b7747a2c88b2 maint: Deprecate is_sparse_type and replace with issparse.
Rik <rik@octave.org>
parents: 23582
diff changeset
452 int is_sparse (void) const { return val.issparse (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
453
23584
7ed6b258db91 maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents: 23583
diff changeset
454 int is_struct (void) const { return val.isstruct (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
455
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
456 int is_uint16 (void) const { return val.is_uint16_type (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
457
6069
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 6068
diff changeset
458 int is_uint32 (void) const { return val.is_uint32_type (); }
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 6068
diff changeset
459
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 6068
diff changeset
460 int is_uint64 (void) const { return val.is_uint64_type (); }
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 6068
diff changeset
461
67b1a61a85ce [project @ 2006-10-21 14:33:53 by jwe]
jwe
parents: 6068
diff changeset
462 int is_uint8 (void) const { return val.is_uint8_type (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
463
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
464 int is_range (void) const { return val.is_range (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
465
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
466 int isreal (void) const { return val.isreal (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
467
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
468 int is_logical_scalar_true (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
469 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
470 return (is_logical_scalar () && val.is_true ());
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
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
473 mwSize get_m (void) const { return val.rows (); }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
474
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
475 mwSize get_n (void) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
476 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
477 mwSize n = 1;
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
478
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
479 // Force dims and 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
480 get_dimensions ();
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
481
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
482 for (mwIndex i = ndims - 1; i > 0; i--)
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
483 n *= dims[i];
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
484
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
485 return n;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
486 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
487
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
488 mwSize * get_dimensions (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
489 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
490 if (! dims)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
491 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
492 ndims = val.ndims ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
493
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
494 dims = static_cast<mwSize *> (mxArray::malloc (ndims
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
495 * sizeof (mwSize)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
496
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
497 dim_vector dv = val.dims ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
498
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
499 for (mwIndex i = 0; i < ndims; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
500 dims[i] = dv(i);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
501 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
502
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
503 return dims;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
504 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
505
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
506 mwSize get_number_of_dimensions (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
507 {
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
508 // Force dims and ndims to be cached.
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
509 get_dimensions ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
510
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
511 return ndims;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
512 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
513
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
514 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
515 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
516
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
517 MUTATION_METHOD (int, set_dimensions, (mwSize *, mwSize), 0)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
518
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
519 mwSize get_number_of_elements (void) const { return val.numel (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
520
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
521 int isempty (void) const { return val.isempty (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
522
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
523 bool is_scalar (void) const
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
524 {
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
525 // Force dims and ndims to be cached.
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
526 get_dimensions ();
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
527
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
528 return ndims == 2 && dims[0] == 1 && dims[1] == 1;
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22480
diff changeset
529 }
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
530
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
531 mxClassID get_class_id (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
532 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
533 id = mxUNKNOWN_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
534
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
535 std::string cn = val.class_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
536
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
537 if (cn == "double")
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
538 id = mxDOUBLE_CLASS;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
539 else if (cn == "single")
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
540 id = mxSINGLE_CLASS;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
541 else if (cn == "char")
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
542 id = mxCHAR_CLASS;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
543 else if (cn == "logical")
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
544 id = mxLOGICAL_CLASS;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
545 else if (cn == "cell")
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
546 id = mxCELL_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
547 else if (cn == "struct")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
548 id = mxSTRUCT_CLASS;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
549 else if (cn == "function_handle")
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
550 id = mxFUNCTION_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
551 else if (cn == "int8")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
552 id = mxINT8_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
553 else if (cn == "uint8")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
554 id = mxUINT8_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
555 else if (cn == "int16")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
556 id = mxINT16_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
557 else if (cn == "uint16")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
558 id = mxUINT16_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
559 else if (cn == "int32")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
560 id = mxINT32_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
561 else if (cn == "uint32")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
562 id = mxUINT32_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
563 else if (cn == "int64")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
564 id = mxINT64_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
565 else if (cn == "uint64")
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
566 id = mxUINT64_CLASS;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
567
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
568 return id;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
569 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
570
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
571 const char * get_class_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
572 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
573 if (! class_name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
574 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
575 std::string s = val.class_name ();
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
576 class_name = mxArray::strsave (s.c_str ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
577 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
578
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
579 return class_name;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
580 }
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 // 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
583 VOID_MUTATION_METHOD (set_class_name, (const char *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
584
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
585 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
586 {
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
587 mxArray *retval = nullptr;
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
588
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
589 if (val.is_classdef_object ())
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 octave_classdef *ov_cdef = val.classdef_object_value ();
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
592
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
593 if (ov_cdef)
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
594 {
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
595 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
596
23898
a490e729f2f2 correctly return NULL for unknown properties in mxGetProperty (bug #51725)
John W. Eaton <jwe@octave.org>
parents: 23893
diff changeset
597 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
598 retval = new mxArray (m_interleaved, pval);
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
599 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
600 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
601
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
602 return retval;
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
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
605 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
606 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
607 if (val.is_classdef_object ())
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
608 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
609 octave_classdef *ov_cdef = val.classdef_object_value ();
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
610
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
611 if (ov_cdef)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
612 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
613 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
614 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
615 err_invalid_type ("set_property");
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
616 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
617
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
618 CONST_MUTATION_METHOD (mxArray *, get_cell, (mwIndex), nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
619
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
620 // 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
621 VOID_MUTATION_METHOD (set_cell, (mwIndex, mxArray *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
622
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
623 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
624 {
23583
b7747a2c88b2 maint: Deprecate is_sparse_type and replace with issparse.
Rik <rik@octave.org>
parents: 23582
diff changeset
625 if (val.issparse ())
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
626 {
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22480
diff changeset
627 // For sparse arrays, return the first non-zero value.
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
628 void *data = val.mex_get_data ();
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
629 if (data == nullptr)
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
630 return 0.0;
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
631
23579
c20a0fa91c0c maint: Deprecate is_bool_type and replace with islogical.
Rik <rik@octave.org>
parents: 23577
diff changeset
632 if (val.islogical ())
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
633 return *static_cast<bool *> (data);
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
634 else if (val.isreal ())
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
635 return *static_cast<double *> (data);
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
636 else // Complex type, only return real part
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
637 return *static_cast<double *> (data);
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
638 }
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
639 else
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
640 return val.scalar_value (true);
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
641 }
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
642
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
643 void * get_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
644 {
9358
d4b1314a7c31 mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
645 void *retval = val.mex_get_data ();
d4b1314a7c31 mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
646
d4b1314a7c31 mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
647 if (retval)
d4b1314a7c31 mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
648 maybe_mark_foreign (retval);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
649 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
650 request_mutation ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
651
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
652 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
653 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
654
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
655 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
656 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
657 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
658 T *retval = static_cast<T *> (val.mex_get_data (class_id, complexity));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
659
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
660 if (retval)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
661 maybe_mark_foreign (retval);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
662 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
663 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
664
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
665 return retval;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
666 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
667
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
668 CONST_MUTATION_METHOD (mxDouble *, get_doubles, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
669
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
670 CONST_MUTATION_METHOD (mxSingle *, get_singles, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
671
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
672 CONST_MUTATION_METHOD (mxInt8 *, get_int8s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
673
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
674 CONST_MUTATION_METHOD (mxInt16 *, get_int16s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
675
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
676 CONST_MUTATION_METHOD (mxInt32 *, get_int32s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
677
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
678 CONST_MUTATION_METHOD (mxInt64 *, get_int64s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
679
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
680 CONST_MUTATION_METHOD (mxUint8 *, get_uint8s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
681
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
682 CONST_MUTATION_METHOD (mxUint16 *, get_uint16s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
683
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
684 CONST_MUTATION_METHOD (mxUint32 *, get_uint32s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
685
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
686 CONST_MUTATION_METHOD (mxUint64 *, get_uint64s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
687
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
688 CONST_MUTATION_METHOD (mxComplexDouble *, get_complex_doubles, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
689 CONST_MUTATION_METHOD (mxComplexSingle *, get_complex_singles, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
690
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
691 #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
692 /* 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
693 CONST_MUTATION_METHOD (mxComplexInt8 *, get_complex_int8s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
694
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
695 CONST_MUTATION_METHOD (mxComplexInt16 *, get_complex_int16s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
696
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
697 CONST_MUTATION_METHOD (mxComplexInt32 *, get_complex_int32s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
698
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
699 CONST_MUTATION_METHOD (mxComplexInt64 *, get_complex_int64s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
700
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
701 CONST_MUTATION_METHOD (mxComplexUint8 *, get_complex_uint8s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
702
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
703 CONST_MUTATION_METHOD (mxComplexUint16 *, get_complex_uint16s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
704
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
705 CONST_MUTATION_METHOD (mxComplexUint32 *, get_complex_uint32s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
706
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
707 CONST_MUTATION_METHOD (mxComplexUint64 *, get_complex_uint64s, (void), nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
708 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
709
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
710 void * get_imag_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
711 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
712 void *retval = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
713
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
714 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
715 retval = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
716 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
717 request_mutation ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
718
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
719 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
720 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
721
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
722 // 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
723 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
724
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
725 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
726 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
727 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
728 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
729 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
730 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
731 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
732 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
733 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
734 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
735
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_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
737 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
738 #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
739 /* 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
740 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
741 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
742 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
743 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
744 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
745 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
746 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
747 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
748 #endif
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
749
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
750 // 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
751 VOID_MUTATION_METHOD (set_imag_data, (void *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
752
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
753 mwIndex * get_ir (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
754 {
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
755 return static_cast<mwIndex *> (maybe_mark_foreign (val.mex_get_ir ()));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
756 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
757
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
758 mwIndex * get_jc (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
759 {
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
760 return static_cast<mwIndex *> (maybe_mark_foreign (val.mex_get_jc ()));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
761 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
762
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
763 mwSize get_nzmax (void) const { return val.nzmax (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
764
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
765 // 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
766 VOID_MUTATION_METHOD (set_ir, (mwIndex *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
767
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
768 // 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
769 VOID_MUTATION_METHOD (set_jc, (mwIndex *))
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 // 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
772 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
773
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
774 // 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
775 MUTATION_METHOD (int, add_field, (const char *), 0)
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 (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
779
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
780 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
781
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
782 // 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
783 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
784
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
785 int get_number_of_fields (void) const { return val.nfields (); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
786
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 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
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 (int, get_field_number, (const char *), 0)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
790
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
791 int get_string (char *buf, mwSize buflen) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
792 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
793 int retval = 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
794
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
795 mwSize nel = get_number_of_elements ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
796
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
797 if (val.is_string () && nel < buflen)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
798 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
799 charNDArray tmp = val.char_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
800
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
801 const char *p = tmp.data ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
802
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
803 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
804 buf[i] = p[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
805
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
806 buf[nel] = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
807
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
808 retval = 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
809 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
810
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
811 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
812 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
813
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
814 char * array_to_string (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
815 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
816 // 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
817
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
818 char *buf = nullptr;
5900
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 if (val.is_string ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
821 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
822 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
823
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
824 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
825
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
826 if (buf)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
827 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
828 charNDArray tmp = val.char_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
829
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
830 const char *p = tmp.data ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
831
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
832 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
833 buf[i] = p[i];
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 buf[nel] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
836 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
837 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
838
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
839 return buf;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
840 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
841
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
842 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
843 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
844 // Force ndims, dims to be cached.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
845 get_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
846
7357
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
847 return calc_single_subscript_internal (ndims, dims, nsubs, subs);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
848 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
849
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
850 std::size_t get_element_size (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
851 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
852 // Force id to be cached.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
853 get_class_id ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
854
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
855 switch (id)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
856 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
857 case mxCELL_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
858 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
859 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
860 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
861 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
862 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
863 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
864 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
865 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
866 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
867 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
868 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
869 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
870 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
871 case mxFUNCTION_CLASS: return 0;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
872 // 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
873 // What should they return, size of pointer?
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
874 default: return 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
875 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
876 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
877
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
878 bool mutation_needed (void) const { return mutate_flag; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
879
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
880 void request_mutation (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
881 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
882 if (mutate_flag)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
883 panic_impossible ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
884
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
885 mutate_flag = true;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
886 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
887
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
888 mxArray * mutate (void) const { return as_mxArray (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
889
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
890 octave_value as_octave_value (void) const { return val; }
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
891
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
892 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
893
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
894 mxArray_octave_value (const mxArray_octave_value& arg)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
895 : mxArray_base (arg), val (arg.val), mutate_flag (arg.mutate_flag),
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
896 id (arg.id), class_name (mxArray::strsave (arg.class_name)),
93dff6435fe1 tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents: 15353
diff changeset
897 ndims (arg.ndims),
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
898 dims (ndims > 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
899 ? static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize)))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
900 : nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
901 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
902 if (dims)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
903 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
904 for (mwIndex i = 0; i < ndims; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
905 dims[i] = arg.dims[i];
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
906 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
907 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
908
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
909 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
910
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
911 octave_value val;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
912
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
913 mutable bool mutate_flag;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
914
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
915 // 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
916 // 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
917 // Matlab-style mxArray object.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
918
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
919 mutable mxClassID id;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
920 mutable char *class_name;
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
921 mutable mwSize ndims;
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
922 mutable mwSize *dims;
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
925 // 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
926 // things that are common to all Matlab-style objects.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
927
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
928 class mxArray_matlab : public mxArray_base
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
929 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
930 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
931
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
932 mxArray_matlab (bool interleaved, mxClassID id_arg = mxUNKNOWN_CLASS)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
933 : mxArray_base (interleaved), class_name (nullptr), id (id_arg), ndims (0),
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
934 dims (nullptr)
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
935 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
936
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
937 mxArray_matlab (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
938 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
939 : mxArray_base (interleaved), class_name (nullptr), id (id_arg),
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
940 ndims (ndims_arg < 2 ? 2 : ndims_arg),
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
941 dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
942 {
20362
b9bd8786d310 fix incompatibility in mxCreateNumericArray (bug #45319)
John W. Eaton <jwe@octave.org>
parents: 20261
diff changeset
943 if (ndims_arg == 0)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
944 {
20261
2691947f5409 Change mxCreateNumericArray to be Matlab compatible for ndims < 2 (bug #45319).
Rik <rik@octave.org>
parents: 19739
diff changeset
945 dims[0] = 0;
2691947f5409 Change mxCreateNumericArray to be Matlab compatible for ndims < 2 (bug #45319).
Rik <rik@octave.org>
parents: 19739
diff changeset
946 dims[1] = 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
947 }
20362
b9bd8786d310 fix incompatibility in mxCreateNumericArray (bug #45319)
John W. Eaton <jwe@octave.org>
parents: 20261
diff changeset
948 else if (ndims_arg < 2)
b9bd8786d310 fix incompatibility in mxCreateNumericArray (bug #45319)
John W. Eaton <jwe@octave.org>
parents: 20261
diff changeset
949 {
b9bd8786d310 fix incompatibility in mxCreateNumericArray (bug #45319)
John W. Eaton <jwe@octave.org>
parents: 20261
diff changeset
950 dims[0] = 1;
b9bd8786d310 fix incompatibility in mxCreateNumericArray (bug #45319)
John W. Eaton <jwe@octave.org>
parents: 20261
diff changeset
951 dims[1] = 1;
b9bd8786d310 fix incompatibility in mxCreateNumericArray (bug #45319)
John W. Eaton <jwe@octave.org>
parents: 20261
diff changeset
952 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
953
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
954 for (mwIndex i = 0; i < ndims_arg; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
955 dims[i] = dims_arg[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
956
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
957 for (mwIndex i = ndims - 1; i > 1; i--)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
958 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
959 if (dims[i] == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
960 ndims--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
961 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
962 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
963 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
964 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
965
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
966 mxArray_matlab (bool interleaved, mxClassID id_arg, 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
967 : mxArray_base (interleaved), class_name (nullptr), id (id_arg),
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21301
diff changeset
968 ndims (dv.ndims ()),
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
969 dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
970 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
971 for (mwIndex i = 0; i < ndims; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
972 dims[i] = dv(i);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
973
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
974 for (mwIndex i = ndims - 1; i > 1; i--)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
975 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
976 if (dims[i] == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
977 ndims--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
978 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
979 break;
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 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
982
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
983 mxArray_matlab (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
984 : mxArray_base (interleaved), class_name (nullptr), id (id_arg), ndims (2),
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
985 dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
986 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
987 dims[0] = m;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
988 dims[1] = n;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
989 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
990
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
991 mxArray_matlab (const mxArray_matlab& val)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
992 : mxArray_base (val), class_name (mxArray::strsave (val.class_name)),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
993 id (val.id), ndims (val.ndims),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
994 dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
995 {
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
996 for (mwIndex i = 0; i < ndims; i++)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
997 dims[i] = val.dims[i];
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
998 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
999
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1000 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1001
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1002 // No assignment!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1003 // FIXME: should this be implemented?
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1004 // Note that we *do* have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1005
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1006 mxArray_matlab& operator = (const mxArray_matlab&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1007
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1008 ~mxArray_matlab (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1009 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1010 mxFree (class_name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1011 mxFree (dims);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1012 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1013
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23553
diff changeset
1014 int iscell (void) const { return id == mxCELL_CLASS; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1015
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1016 int is_char (void) const { return id == mxCHAR_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1017
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1018 int is_complex (void) const { return 0; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1019
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1020 int is_double (void) const { return id == mxDOUBLE_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1021
11100
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
1022 int is_function_handle (void) const { return id == mxFUNCTION_CLASS; }
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
1023
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1024 int is_int16 (void) const { return id == mxINT16_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1025
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1026 int is_int32 (void) const { return id == mxINT32_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1027
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1028 int is_int64 (void) const { return id == mxINT64_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1029
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1030 int is_int8 (void) const { return id == mxINT8_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1031
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1032 int is_logical (void) const { return id == mxLOGICAL_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1033
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1034 int is_numeric (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1035 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1036 return (id == mxDOUBLE_CLASS || id == mxSINGLE_CLASS
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1037 || id == mxINT8_CLASS || id == mxUINT8_CLASS
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1038 || id == mxINT16_CLASS || id == mxUINT16_CLASS
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1039 || id == mxINT32_CLASS || id == mxUINT32_CLASS
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1040 || id == mxINT64_CLASS || id == mxUINT64_CLASS);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1041 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1042
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1043 int is_single (void) const { return id == mxSINGLE_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1044
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1045 int is_sparse (void) const { return 0; }
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 int is_struct (void) const { return id == mxSTRUCT_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1048
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1049 int is_uint16 (void) const { return id == mxUINT16_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1050
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1051 int is_uint32 (void) const { return id == mxUINT32_CLASS; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1052
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1053 int is_uint64 (void) const { return id == mxUINT64_CLASS; }
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 int is_uint8 (void) const { return id == mxUINT8_CLASS; }
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 int is_logical_scalar_true (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1058 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1059 return (is_logical_scalar ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1060 && static_cast<mxLogical *> (get_data ())[0] != 0);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1061 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1062
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1063 mwSize get_m (void) const { return dims[0]; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1064
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1065 mwSize get_n (void) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1066 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1067 mwSize n = 1;
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1068
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1069 for (mwSize i = ndims - 1 ; i > 0 ; i--)
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1070 n *= dims[i];
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1071
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1072 return n;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1073 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1074
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1075 mwSize * get_dimensions (void) const { return dims; }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1076
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1077 mwSize get_number_of_dimensions (void) const { return ndims; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1078
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1079 void set_m (mwSize m) { dims[0] = m; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1080
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1081 void set_n (mwSize n) { dims[1] = n; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1082
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1083 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
1084 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1085 ndims = ndims_arg;
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1086
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1087 mxFree (dims);
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1088
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1089 if (ndims > 0)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1090 {
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1091 dims
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1092 = static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize)));
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22480
diff changeset
1093
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
1094 if (dims == nullptr)
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1095 return 1;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1096
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1097 for (int i = 0; i < ndims; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1098 dims[i] = dims_arg[i];
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1099
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1100 return 0;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1101 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1102 else
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1103 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
1104 dims = nullptr;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1105 return 0;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1106 }
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
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1109 mwSize get_number_of_elements (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1110 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1111 mwSize retval = dims[0];
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1112
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1113 for (mwIndex i = 1; i < ndims; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1114 retval *= dims[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1115
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1116 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1117 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1118
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
1119 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
1120
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1121 bool is_scalar (void) const
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1122 {
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1123 return ndims == 2 && dims[0] == 1 && dims[1] == 1;
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1124 }
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1125
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1126 mxClassID get_class_id (void) const { return id; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1127
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1128 const char * get_class_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1129 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1130 switch (id)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1131 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1132 case mxDOUBLE_CLASS: return "double";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1133 case mxSINGLE_CLASS: return "single";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1134 case mxCHAR_CLASS: return "char";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1135 case mxLOGICAL_CLASS: return "logical";
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1136 case mxCELL_CLASS: return "cell";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1137 case mxSTRUCT_CLASS: return "struct";
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1138 case mxFUNCTION_CLASS: return "function_handle";
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1139 case mxINT8_CLASS: return "int8";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1140 case mxUINT8_CLASS: return "uint8";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1141 case mxINT16_CLASS: return "int16";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1142 case mxUINT16_CLASS: return "uint16";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1143 case mxINT32_CLASS: return "int32";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1144 case mxUINT32_CLASS: return "uint32";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1145 case mxINT64_CLASS: return "int64";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1146 case mxUINT64_CLASS: return "uint64";
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1147 case mxUNKNOWN_CLASS: return "unknown";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1148 // 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
1149 default: return "unknown";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1150 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1151 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1152
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1153 void set_class_name (const char *name_arg)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1154 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1155 mxFree (class_name);
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
1156 class_name = static_cast<char *> (mxArray::malloc (strlen (name_arg) + 1));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1157 strcpy (class_name, name_arg);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1158 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1159
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1160 mxArray * get_cell (mwIndex /*idx*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1161 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1162 err_invalid_type ("get_cell");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1163 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1164
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1165 void set_cell (mwIndex /*idx*/, mxArray * /*val*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1166 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1167 err_invalid_type ("set_cell");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1168 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1169
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1170 double get_scalar (void) const
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1171 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1172 err_invalid_type ("get_scalar");
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1173 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1174
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1175 void * get_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1176 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1177 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1180 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
1181 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1182 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
1183 }
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 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
1186 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1187 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
1188 }
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 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
1191 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1192 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
1193 }
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 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
1196 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1197 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
1198 }
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 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
1201 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1202 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
1203 }
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 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
1206 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1207 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
1208 }
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 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
1211 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1212 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
1213 }
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 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
1216 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1217 err_invalid_type ("get_uint16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1218 }
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 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
1221 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1222 err_invalid_type ("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
1223 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1224
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1225 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
1226 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1227 err_invalid_type ("get_uint64s");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1228 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1229
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1230 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
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 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
1233 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1234
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1235 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
1236 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1237 err_invalid_type ("get_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
1238 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1239
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1240 #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
1241 /* 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
1242 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
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 ("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
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 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
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 ("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
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 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
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 ("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
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 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
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 ("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
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 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
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 ("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
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 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
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 ("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
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 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
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 ("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
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 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
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 ("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
1280 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1281 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1282
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1283 void * get_imag_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1284 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1285 err_invalid_type ("get_imag_data");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1286 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1287
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1288 void set_data (void * /*pr*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1289 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1290 err_invalid_type ("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
1291 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1292
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1293 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
1294 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1295 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
1296 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1297
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1298 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
1299 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1300 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
1301 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1302
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1303 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
1304 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1305 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
1306 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1307
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1308 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
1309 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1310 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
1311 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1312
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1313 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
1314 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1315 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
1316 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1317
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1318 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
1319 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1320 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
1321 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1322
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1323 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
1324 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1325 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
1326 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1327
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1328 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
1329 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1330 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
1331 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1332
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1333 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
1334 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1335 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
1336 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1337
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1338 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
1339 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1340 err_invalid_type ("set_uint64s");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1341 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1342
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1343 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
1344 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1345 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
1346 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1347
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1348 int set_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
1349 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1350 err_invalid_type ("set_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
1351 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1352
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1353 #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
1354 /* 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
1355 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
1356 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1357 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
1358 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1359
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1360 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
1361 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1362 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
1363 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1364
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1365 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
1366 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1367 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
1368 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1369
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1370 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
1371 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1372 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
1373 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1374
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1375 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
1376 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1377 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
1378 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1379
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1380 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
1381 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1382 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
1383 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1384
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1385 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
1386 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1387 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
1388 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1389
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1390 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
1391 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1392 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
1393 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1394 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1395
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1396 void set_imag_data (void * /*pi*/)
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 ("set_imag_data");
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
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1401 mwIndex * get_ir (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1402 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1403 err_invalid_type ("get_ir");
5900
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
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1406 mwIndex * get_jc (void) 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_jc");
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
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1411 mwSize get_nzmax (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 ("get_nzmax");
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
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1416 void set_ir (mwIndex * /*ir*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1417 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1418 err_invalid_type ("set_ir");
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
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1421 void set_jc (mwIndex * /*jc*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1422 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1423 err_invalid_type ("set_jc");
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
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1426 void set_nzmax (mwSize /*nzmax*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1427 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1428 err_invalid_type ("set_nzmax");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1429 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1430
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1431 int add_field (const char * /*key*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1432 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1433 err_invalid_type ("add_field");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1434 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1435
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1436 void remove_field (int /*key_num*/)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1437 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1438 err_invalid_type ("remove_field");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1439 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1440
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1441 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
1442 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1443 err_invalid_type ("get_field_by_number");
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
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1446 void set_field_by_number (mwIndex /*index*/, int /*key_num*/,
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1447 mxArray * /*val*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1448 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1449 err_invalid_type ("set_field_by_number");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1450 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1451
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1452 int get_number_of_fields (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1453 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1454 err_invalid_type ("get_number_of_fields");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1455 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1456
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1457 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
1458 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1459 err_invalid_type ("get_field_name_by_number");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1460 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1461
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1462 int get_field_number (const char * /*key*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1463 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1464 return -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1465 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1466
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1467 int get_string (char * /*buf*/, mwSize /*buflen*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1468 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1469 err_invalid_type ("get_string");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1470 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1471
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1472 char * array_to_string (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1473 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1474 err_invalid_type ("array_to_string");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1475 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1476
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1477 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
1478 {
7357
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
1479 return calc_single_subscript_internal (ndims, dims, nsubs, subs);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1480 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1481
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
1482 std::size_t get_element_size (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1483 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1484 switch (id)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1485 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1486 case mxCELL_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1487 case mxSTRUCT_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1488 case mxLOGICAL_CLASS: return sizeof (mxLogical);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1489 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
1490 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
1491 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
1492 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
1493 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
1494 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
1495 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
1496 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
1497 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
1498 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
1499 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
1500 case mxFUNCTION_CLASS: return 0;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1501 // 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
1502 // What should they return, size of pointer?
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1503 default: return 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1504 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1505 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1506
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1507 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1508
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1509 dim_vector
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1510 dims_to_dim_vector (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1511 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1512 mwSize nd = get_number_of_dimensions ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1513
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1514 mwSize *d = get_dimensions ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1515
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1516 dim_vector dv;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1517 dv.resize (nd);
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 for (mwIndex i = 0; i < nd; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1520 dv(i) = d[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1521
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1522 return dv;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1523 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1524
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1525 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1526
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1527 char *class_name;
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 mxClassID id;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1530
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1531 mwSize ndims;
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1532 mwSize *dims;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1533 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1534
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1535
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1536 // Matlab-style numeric, character, and logical data.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1537
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1538 #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
1539 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
1540 { \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1541 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
1542 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
1543 \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1544 return static_cast<TYPE> (pr); \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1545 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1546
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1547 #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
1548 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
1549 { \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1550 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
1551 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
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 pr = d; \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1554 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
1555 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1556
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1557 class mxArray_number : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1558 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1559 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1560
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 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
1562 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
1563 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
1564 : 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
1565 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
1566 pr (init
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1567 ? 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
1568 : 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
1569 pi (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
1570 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1571 : (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
1572 ? (init
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1573 ? 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
1574 : 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
1575 : nullptr))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1576 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1577
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1578 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
1579 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
1580 : mxArray_matlab (interleaved, id_arg, dv), m_complex (flag == mxCOMPLEX),
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
1581 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1582 pi (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
1583 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1584 : (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
1585 ? 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
1586 : nullptr))
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1587 { }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1588
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1589 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
1590 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
1591 : 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
1592 pr (init
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1593 ? 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
1594 : 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
1595 pi (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
1596 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1597 : (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
1598 ? (init
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1599 ? 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
1600 : 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
1601 : nullptr))
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1602 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1603
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1604 mxArray_number (bool interleaved, mxClassID id_arg, double val)
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1605 : mxArray_matlab (interleaved, id_arg, 1, 1), m_complex (false),
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
1606 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
1607 pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1608 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1609 double *dpr = static_cast<double *> (pr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1610 dpr[0] = val;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1611 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1612
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1613 mxArray_number (bool interleaved, mxClassID id_arg, mxLogical val)
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1614 : mxArray_matlab (interleaved, id_arg, 1, 1), m_complex (false),
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
1615 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
1616 pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1617 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1618 mxLogical *lpr = static_cast<mxLogical *> (pr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1619 lpr[0] = val;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1620 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1621
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1622 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
1623 : 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
1624 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
1625 str ? strlen (str) : 0),
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1626 m_complex (false),
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1627 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1628 pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1629 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1630 mxChar *cpr = static_cast<mxChar *> (pr);
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1631 mwSize nel = get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1632 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1633 cpr[i] = str[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1634 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1635
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17810
diff changeset
1636 // 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
1637 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
1638 : 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
1639 m_complex (false),
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
1640 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
1641 pi (nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1642 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1643 mxChar *cpr = static_cast<mxChar *> (pr);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1644
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1645 mwSize *dv = get_dimensions ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1646
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1647 mwSize nc = dv[1];
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1648
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1649 for (mwIndex j = 0; j < m; j++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1650 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1651 const char *ptr = str[j];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1652
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
1653 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
1654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1655 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
1656 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
1657
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
1658 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
1659 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
1660 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1661 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1662
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1663 protected:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1664
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1665 mxArray_number (const mxArray_number& val)
28370
27ef5f83682c initialize m_complex in all mxArray_number constructors
John W. Eaton <jwe@octave.org>
parents: 28126
diff changeset
1666 : mxArray_matlab (val), m_complex (val.m_complex),
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1667 pr (mxArray::malloc (get_number_of_elements () * get_element_size ())),
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1668 pi (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
1669 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1670 : (val.pi
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1671 ? 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
1672 : nullptr))
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1673 {
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
1674 std::size_t nbytes = get_number_of_elements () * get_element_size ();
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1675
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1676 if (pr)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1677 memcpy (pr, val.pr, nbytes);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1678
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1679 if (pi)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1680 memcpy (pi, val.pi, nbytes);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1681 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1682
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1683 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1684
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1685 // 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
1686 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1687
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1688 mxArray_number& operator = (const mxArray_number&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1689
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1690 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
1691 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1692 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
1693 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1694
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1695 ~mxArray_number (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1696 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1697 mxFree (pr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1698 mxFree (pi);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1699 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1700
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1701 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
1702 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1703 return m_interleaved ? m_complex : (pi != nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1704 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1705
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1706 double get_scalar (void) const
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1707 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1708 // 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
1709
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1710 double retval = 0;
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1711
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1712 switch (get_class_id ())
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1713 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1714 case mxDOUBLE_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1715 retval = *(static_cast<double *> (pr));
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1716 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1717
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1718 case mxSINGLE_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1719 retval = *(static_cast<float *> (pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1720 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1721
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1722 case mxCHAR_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1723 retval = *(static_cast<mxChar *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1724 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1725
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1726 case mxLOGICAL_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1727 retval = *(static_cast<bool *> (pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1728 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1729
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1730 case mxINT8_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1731 retval = *(static_cast<int8_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1732 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1733
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1734 case mxUINT8_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1735 retval = *(static_cast<uint8_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1736 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1737
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1738 case mxINT16_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1739 retval = *(static_cast<int16_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1740 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1741
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1742 case mxUINT16_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1743 retval = *(static_cast<uint16_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1744 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1745
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1746 case mxINT32_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1747 retval = *(static_cast<int32_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1748 break;
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 case mxUINT32_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1751 retval = *(static_cast<uint32_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1752 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1753
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1754 case mxINT64_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1755 retval = *(static_cast<int64_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1756 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1757
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1758 case mxUINT64_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1759 retval = *(static_cast<uint64_t *> (pr));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1760 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1761
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1762 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1763 panic_impossible ();
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1764 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1765
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1766 return retval;
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1767 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1768
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1769 void * get_data (void) const { return pr; }
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1770
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1771 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
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 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
1774 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
1775
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1776 return pi;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1777 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1778
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1779 void set_data (void *pr_arg) { pr = pr_arg; }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1780
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1781 void set_imag_data (void *pi_arg)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1782 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1783 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
1784 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
1785
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1786 pi = pi_arg;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1787 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1788
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 (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
1790 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
1791 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
1792 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
1793 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
1794 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
1795 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
1796 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
1797 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
1798 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
1799
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_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
1801 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
1802 #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
1803 /* 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
1804 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
1805 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
1806 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
1807 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
1808 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
1809 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
1810 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
1811 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
1812 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1813
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 (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
1815 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
1816 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
1817 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
1818 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
1819 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
1820 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
1821 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
1822 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
1823 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
1824
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1825 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
1826 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
1827 #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
1828 /* 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
1829 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
1830 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
1831 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
1832 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
1833 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
1834 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
1835 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
1836 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
1837 #endif
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1838
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1839 int get_string (char *buf, mwSize buflen) const
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1840 {
13753
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1841 int retval = 0;
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1842
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1843 mwSize nel = get_number_of_elements ();
6493
5fa513371dde [project @ 2007-04-05 14:53:49 by jwe]
jwe
parents: 6400
diff changeset
1844
13753
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1845 if (! (nel < buflen))
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1846 {
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1847 retval = 1;
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1848 if (buflen > 0)
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1849 nel = buflen-1;
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1850 }
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
1851
6493
5fa513371dde [project @ 2007-04-05 14:53:49 by jwe]
jwe
parents: 6400
diff changeset
1852 if (nel < buflen)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1853 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1854 mxChar *ptr = static_cast<mxChar *> (pr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1855
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1856 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1857 buf[i] = static_cast<char> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1858
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1859 buf[nel] = 0;
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1860 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1861
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1862 return retval;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1863 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1864
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1865 char * array_to_string (void) const
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1866 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1867 // 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
1868
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1869 mwSize nel = get_number_of_elements ();
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1870
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
1871 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
1872
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1873 if (buf)
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1874 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1875 mxChar *ptr = static_cast<mxChar *> (pr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1876
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1877 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1878 buf[i] = static_cast<char> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1879
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1880 buf[nel] = '\0';
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1881 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1882
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1883 return buf;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1884 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1885
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1886 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1887 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1888 octave_value retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1889
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1890 dim_vector dv = dims_to_dim_vector ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1891
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1892 switch (get_class_id ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1893 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1894 case mxDOUBLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1895 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1896 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1897
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1898 if (is_complex ())
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1899 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1900 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
1901 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1902 Complex *ppr = static_cast<Complex *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1903
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1904 ComplexNDArray val (dv);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1905 Complex *ptr = val.fortran_vec ();
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] = 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
1909
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1910 retval = val;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1911 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1912 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1913 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1914 double *ppr = static_cast<double *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1915
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1916 ComplexNDArray val (dv);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1917
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1918 Complex *ptr = val.fortran_vec ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1919
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1920 double *ppi = static_cast<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
1921
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1922 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
1923 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
1924
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1925 retval = val;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1926 }
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1927 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1928 else
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1929 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1930 double *ppr = static_cast<double *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1931
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1932 NDArray val (dv);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1933
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1934 double *ptr = val.fortran_vec ();
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1935
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1936 for (mwIndex i = 0; i < nel; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1937 ptr[i] = ppr[i];
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1938
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1939 retval = val;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1940 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1941 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1942 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1943
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1944 case mxSINGLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1945 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1946 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1947
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1948 if (is_complex ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1949 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1950 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
1951 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1952 FloatComplex *ppr = static_cast<FloatComplex *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1953
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1954 FloatComplexNDArray val (dv);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1955 FloatComplex *ptr = val.fortran_vec ();
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] = 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
1959
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1960 retval = val;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1961 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1962 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1963 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1964 float *ppr = static_cast<float *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1965
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1966 FloatComplexNDArray val (dv);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1967
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1968 FloatComplex *ptr = val.fortran_vec ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1969
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1970 float *ppi = static_cast<float *> (pi);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1971
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1972 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
1973 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
1974
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1975 retval = val;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1976 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1977 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1978 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1979 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1980 float *ppr = static_cast<float *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1981
11132
6ed521ed2d6a Stop converting single valued output from mex files to doubles.
Gunnar Farneback <gunnar@lysator.liu.se>
parents: 11100
diff changeset
1982 FloatNDArray val (dv);
6ed521ed2d6a Stop converting single valued output from mex files to doubles.
Gunnar Farneback <gunnar@lysator.liu.se>
parents: 11100
diff changeset
1983
6ed521ed2d6a Stop converting single valued output from mex files to doubles.
Gunnar Farneback <gunnar@lysator.liu.se>
parents: 11100
diff changeset
1984 float *ptr = val.fortran_vec ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1985
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1986 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1987 ptr[i] = ppr[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1988
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1989 retval = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1990 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1991 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1992 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1993
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1994 case mxCHAR_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1995 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1996 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1997
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1998 mxChar *ppr = static_cast<mxChar *> (pr);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1999
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2000 charNDArray val (dv);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2001
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2002 char *ptr = val.fortran_vec ();
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2003
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2004 for (mwIndex i = 0; i < nel; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2005 ptr[i] = static_cast<char> (ppr[i]);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2006
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2007 retval = val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2008 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2009 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2010
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2011 case mxLOGICAL_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2012 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
2013 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2014
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2015 case mxINT8_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2016 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
2017 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2018
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2019 case mxUINT8_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2020 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
2021 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2022
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2023 case mxINT16_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2024 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
2025 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2026
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2027 case mxUINT16_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2028 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
2029 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2030
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2031 case mxINT32_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2032 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
2033 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2034
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2035 case mxUINT32_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2036 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
2037 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2038
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2039 case mxINT64_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2040 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
2041 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2042
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2043 case mxUINT64_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2044 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
2045 break;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2046
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2047 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2048 panic_impossible ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2049 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2050
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2051 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2052 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2053
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2054 protected:
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2055
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2056 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
2057 octave_value
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2058 int_to_ov (const dim_vector& dv) const
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2059 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2060 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
2061 error ("complex integer types are not supported");
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2062
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2063 mwSize nel = get_number_of_elements ();
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2064
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2065 ELT_T *ppr = static_cast<ELT_T *> (pr);
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2066
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
2067 ARRAY_T val (dv);
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2068
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2069 ARRAY_ELT_T *ptr = val.fortran_vec ();
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2070
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2071 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
2072 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
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 return octave_value (val);
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2075 }
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2076
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2077 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2078
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2079 // 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
2080 // 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
2081 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
2082
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2083 // 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
2084 // (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
2085 // real part of the data.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2086 void *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
2087
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2088 // 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
2089 // the imaginary part of the data. Othrwise is is always nullptr.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2090 void *pi;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2091 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2092
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2093 // Matlab-style sparse arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2094
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2095 class mxArray_sparse : public mxArray_matlab
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2096 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2097 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2098
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2099 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
2100 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
2101 : 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
2102
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2103 nzmax (nzmax_arg > 0 ? nzmax_arg : 1),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2104 pr (mxArray::calloc (nzmax, 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
2105 pi (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
2106 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2107 : (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
2108 ? mxArray::calloc (nzmax, 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
2109 : nullptr)),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2110 ir (static_cast<mwIndex *> (mxArray::calloc (nzmax, sizeof (mwIndex)))),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2111 jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex))))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2112 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2113
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2114 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2115
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2116 mxArray_sparse (const mxArray_sparse& val)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2117 : mxArray_matlab (val), nzmax (val.nzmax),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2118 pr (mxArray::malloc (nzmax * get_element_size ())),
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2119 pi (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
2120 ? nullptr
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2121 : (val.pi
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2122 ? mxArray::malloc (nzmax * 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
2123 : nullptr)),
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2124 ir (static_cast<mwIndex *> (mxArray::malloc (nzmax * sizeof (mwIndex)))),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2125 jc (static_cast<mwIndex *> (mxArray::malloc (nzmax * sizeof (mwIndex))))
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2126 {
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
2127 std::size_t nbytes = nzmax * get_element_size ();
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2128
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2129 if (pr)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2130 memcpy (pr, val.pr, nbytes);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2131
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2132 if (pi)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2133 memcpy (pi, val.pi, nbytes);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2134
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2135 if (ir)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2136 memcpy (ir, val.ir, nzmax * sizeof (mwIndex));
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2137
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2138 if (jc)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2139 memcpy (jc, val.jc, (val.get_n () + 1) * sizeof (mwIndex));
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2140 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2141
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2142 public:
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 // 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
2145 // do have a copy constructor.
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 mxArray_sparse& operator = (const mxArray_sparse&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2148
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2149 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
2150 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2151 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
2152 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2153
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2154 ~mxArray_sparse (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2155 {
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2156 mxFree (pr);
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2157 mxFree (pi);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2158 mxFree (ir);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2159 mxFree (jc);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2160 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2161
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2162 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
2163 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2164 return m_interleaved ? m_complex : (pi != nullptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2165 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2166
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2167 int is_sparse (void) const { return 1; }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2168
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2169 void * get_data (void) const { return pr; }
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2170
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2171 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
2172 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2173 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
2174 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
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 return pi;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2177 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2178
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2179 void set_data (void *pr_arg) { pr = pr_arg; }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2180
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2181 void set_imag_data (void *pi_arg)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2182 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2183 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
2184 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
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 pi = pi_arg;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2187 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2188
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2189 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
2190 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
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_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
2193 TYPED_SET_METHOD (mxComplexDouble *, set_complex_doubles)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2194
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2195 mwIndex * get_ir (void) const { return ir; }
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2196
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2197 mwIndex * get_jc (void) const { return jc; }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2198
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2199 mwSize get_nzmax (void) const { return nzmax; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2200
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2201 void set_ir (mwIndex *ir_arg) { ir = ir_arg; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2202
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2203 void set_jc (mwIndex *jc_arg) { jc = jc_arg; }
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2204
27083
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2205 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
2206 {
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2207 /* Require storage for at least 1 element */
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2208 nzmax = (nzmax_arg > 0 ? nzmax_arg : 1);
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2209 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2210
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2211 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2212 {
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2213 octave_value retval;
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2214
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2215 dim_vector dv = dims_to_dim_vector ();
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2216
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2217 switch (get_class_id ())
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2218 {
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2219 case mxDOUBLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2220 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2221 if (is_complex ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2222 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2223 if (m_interleaved)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2224 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2225 Complex *ppr = static_cast<Complex *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2226
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2227 SparseComplexMatrix val (get_m (), get_n (),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2228 static_cast<octave_idx_type> (nzmax));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2229
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2230 for (mwIndex i = 0; i < nzmax; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2231 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2232 val.xdata (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
2233 val.xridx (i) = ir[i];
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2234 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2235
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2236 for (mwIndex i = 0; i < get_n () + 1; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2237 val.xcidx (i) = jc[i];
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 retval = val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2240 }
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2241 else
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2242 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2243 double *ppr = static_cast<double *> (pr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2244 double *ppi = static_cast<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
2245
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2246 SparseComplexMatrix val (get_m (), get_n (),
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2247 static_cast<octave_idx_type> (nzmax));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2248
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2249 for (mwIndex i = 0; i < nzmax; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2250 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2251 val.xdata (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
2252 val.xridx (i) = ir[i];
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2253 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2254
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2255 for (mwIndex i = 0; i < get_n () + 1; i++)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2256 val.xcidx (i) = jc[i];
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 retval = val;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2259 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2260 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2261 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2262 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2263 double *ppr = static_cast<double *> (pr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2264
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2265 SparseMatrix val (get_m (), get_n (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2266 static_cast<octave_idx_type> (nzmax));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2267
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2268 for (mwIndex i = 0; i < nzmax; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2269 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2270 val.xdata (i) = ppr[i];
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2271 val.xridx (i) = ir[i];
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2272 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2273
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2274 for (mwIndex i = 0; i < get_n () + 1; i++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2275 val.xcidx (i) = jc[i];
10315
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 retval = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2278 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2279 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2280 break;
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2281
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2282 case mxLOGICAL_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2283 {
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2284 bool *ppr = static_cast<bool *> (pr);
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2285
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2286 SparseBoolMatrix val (get_m (), get_n (),
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2287 static_cast<octave_idx_type> (nzmax));
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2288
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2289 for (mwIndex i = 0; i < nzmax; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2290 {
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2291 val.xdata (i) = ppr[i];
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2292 val.xridx (i) = ir[i];
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2293 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2294
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2295 for (mwIndex i = 0; i < get_n () + 1; i++)
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2296 val.xcidx (i) = jc[i];
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 retval = val;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2299 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2300 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2301
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2302 case mxSINGLE_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2303 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
2304
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2305 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2306 panic_impossible ();
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2307 }
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2308
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2309 return retval;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2310 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2311
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2312 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2313
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2314 // 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
2315 // 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
2316 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
2317
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2318 // Maximun number of nonzero elements.
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2319 mwSize nzmax;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2320
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2321 // 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
2322 // (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
2323 // real part of the data.
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2324 void *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
2325
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2326 // 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
2327 // the imaginary part of the data. Othrwise is is always nullptr.
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2328 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
2329
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2330 // Sparse storage indexing arrays.
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2331 mwIndex *ir;
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2332 mwIndex *jc;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2333 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2334
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2335 // Matlab-style struct arrays.
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 class mxArray_struct : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2338 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2339 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2340
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2341 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
2342 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
2343 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, ndims_arg, dims_arg),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2344 nfields (num_keys_arg),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2345 fields (static_cast<char **> (mxArray::calloc (nfields,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2346 sizeof (char *)))),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2347 data (static_cast<mxArray **> (mxArray::calloc (nfields *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2348 get_number_of_elements (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2349 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2350 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2351 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2352 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2353
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2354 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
2355 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
2356 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, dv), nfields (num_keys_arg),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2357 fields (static_cast<char **> (mxArray::calloc (nfields,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2358 sizeof (char *)))),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2359 data (static_cast<mxArray **> (mxArray::calloc (nfields *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2360 get_number_of_elements (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2361 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2362 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2363 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2364 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2365
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2366 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
2367 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
2368 : mxArray_matlab (interleaved, mxSTRUCT_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
2369 nfields (num_keys_arg),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2370 fields (static_cast<char **> (mxArray::calloc (nfields,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2371 sizeof (char *)))),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2372 data (static_cast<mxArray **> (mxArray::calloc (nfields *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2373 get_number_of_elements (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2374 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2375 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2376 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2377 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2378
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2379 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2380
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2381 mxArray_struct (const mxArray_struct& val)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2382 : mxArray_matlab (val), nfields (val.nfields),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2383 fields (static_cast<char **> (mxArray::malloc (nfields
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2384 * sizeof (char *)))),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2385 data (static_cast<mxArray **> (mxArray::malloc (nfields *
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2386 get_number_of_elements ()
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2387 * sizeof (mxArray *))))
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2388 {
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2389 for (int i = 0; i < nfields; i++)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2390 fields[i] = mxArray::strsave (val.fields[i]);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2391
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2392 mwSize nel = get_number_of_elements ();
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2393
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2394 for (mwIndex i = 0; i < nel * nfields; i++)
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 mxArray *ptr = val.data[i];
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2397 data[i] = (ptr ? ptr->dup () : nullptr);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2398 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2399 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2400
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2401 public:
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 // 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
2404 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2405
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2406 mxArray_struct& operator = (const mxArray_struct& val);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2407
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2408 void init (const char **keys)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2409 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2410 for (int i = 0; i < nfields; i++)
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
2411 fields[i] = mxArray::strsave (keys[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2412 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2413
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2414 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
2415
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2416 ~mxArray_struct (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2417 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2418 for (int i = 0; i < nfields; i++)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2419 mxFree (fields[i]);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2420
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2421 mxFree (fields);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2422
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2423 mwSize ntot = nfields * get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2424
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2425 for (mwIndex i = 0; i < ntot; i++)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
2426 delete data[i];
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2427
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2428 mxFree (data);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2429 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2430
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2431 int add_field (const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2432 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2433 int retval = -1;
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 if (valid_key (key))
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2436 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2437 nfields++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2438
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2439 fields = static_cast<char **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2440 (mxRealloc (fields, nfields * sizeof (char *)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2441
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2442 if (fields)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2443 {
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
2444 fields[nfields-1] = mxArray::strsave (key);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2445
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2446 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2447
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2448 mwSize ntot = nfields * nel;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2449
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2450 mxArray **new_data;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2451 new_data = static_cast<mxArray **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2452 (mxArray::malloc (ntot * sizeof (mxArray *)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2453
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2454 if (new_data)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2455 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2456 mwIndex j = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2457 mwIndex k = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2458 mwIndex n = 0;
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 for (mwIndex i = 0; i < ntot; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2461 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2462 if (++n == nfields)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2463 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2464 new_data[j++] = nullptr;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2465 n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2466 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2467 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2468 new_data[j++] = data[k++];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2469 }
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 mxFree (data);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2472
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2473 data = new_data;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2474
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2475 retval = nfields - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2476 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2477 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2478 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2479
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2480 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2481 }
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 void remove_field (int key_num)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2484 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2485 if (key_num >= 0 && key_num < nfields)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2486 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2487 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2488
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2489 mwSize ntot = nfields * nel;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2490
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2491 int new_nfields = nfields - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2492
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2493 char **new_fields = static_cast<char **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2494 (mxArray::malloc (new_nfields * sizeof (char *)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2495
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2496 mxArray **new_data = static_cast<mxArray **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2497 (mxArray::malloc (new_nfields * nel
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2498 * sizeof (mxArray *)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2499
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2500 for (int i = 0; i < key_num; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2501 new_fields[i] = fields[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2502
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2503 for (int i = key_num + 1; i < nfields; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2504 new_fields[i-1] = fields[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2505
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2506 if (new_nfields > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2507 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2508 mwIndex j = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2509 mwIndex k = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2510 mwIndex n = 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 for (mwIndex i = 0; i < ntot; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2513 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2514 if (n == key_num)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2515 k++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2516 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2517 new_data[j++] = data[k++];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2518
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2519 if (++n == nfields)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2520 n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2521 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2522 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2523
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2524 nfields = new_nfields;
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 mxFree (fields);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2527 mxFree (data);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2528
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2529 fields = new_fields;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2530 data = new_data;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2531 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2532 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2533
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2534 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
2535 {
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
2536 return key_num >= 0 && key_num < nfields
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2537 ? data[nfields * index + key_num] : nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2538 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2539
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2540 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
2541
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2542 int get_number_of_fields (void) const { return nfields; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2543
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2544 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
2545 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2546 return key_num >= 0 && key_num < nfields ? fields[key_num] : nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2547 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2548
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2549 int get_field_number (const char *key) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2550 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2551 int retval = -1;
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 for (int i = 0; i < nfields; i++)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2554 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2555 if (! strcmp (key, fields[i]))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2556 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2557 retval = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2558 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2559 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2560 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2561
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2562 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2563 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2564
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2565 void * get_data (void) const { return data; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2566
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2567 void set_data (void *data_arg) { data = static_cast<mxArray **> (data_arg); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2568
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2569 octave_value as_octave_value (void) const
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2570 {
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2571 dim_vector dv = dims_to_dim_vector ();
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2572
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2573 string_vector keys (fields, nfields);
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2574
25922
34e82a829fdd Create scalar structs of size 1x1 with MEX interface (bug #54799).
Rik <rik@octave.org>
parents: 25751
diff changeset
2575 octave_map m (dv);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2576
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2577 mwSize ntot = nfields * get_number_of_elements ();
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2578
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2579 for (int i = 0; i < nfields; i++)
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2580 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2581 Cell c (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2582
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2583 octave_value *p = c.fortran_vec ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2584
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2585 mwIndex k = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2586 for (mwIndex j = i; j < ntot; j += nfields)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2587 p[k++] = mxArray::as_octave_value (data[j]);
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 m.assign (keys[i], c);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2590 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2591
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2592 return m;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2593 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2594
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2595 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2596
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2597 int nfields;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2598
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2599 char **fields;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2600
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2601 mxArray **data;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2602 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2603
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2604 // Matlab-style cell arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2605
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2606 class mxArray_cell : public mxArray_matlab
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 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2609
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2610 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
2611 : mxArray_matlab (interleaved, mxCELL_CLASS, ndims_arg, dims_arg),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2612 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2613 sizeof (mxArray *)))) { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2614
28126
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_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
2616 : mxArray_matlab (interleaved, mxCELL_CLASS, dv),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2617 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2618 sizeof (mxArray *)))) { }
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, 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
2621 : mxArray_matlab (interleaved, mxCELL_CLASS, m, n),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2622 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2623 sizeof (mxArray *)))) { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2624
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2625 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2626
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2627 mxArray_cell (const mxArray_cell& val)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2628 : mxArray_matlab (val),
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2629 data (static_cast<mxArray **> (mxArray::malloc (get_number_of_elements ()
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2630 * sizeof (mxArray *))))
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2631 {
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2632 mwSize nel = get_number_of_elements ();
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2633
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2634 for (mwIndex i = 0; i < nel; i++)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2635 {
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2636 mxArray *ptr = val.data[i];
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2637 data[i] = (ptr ? ptr->dup () : nullptr);
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 }
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 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2642
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2643 // 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
2644 // do have a copy constructor.
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 mxArray_cell& operator = (const mxArray_cell&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2647
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2648 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
2649
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2650 ~mxArray_cell (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2651 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2652 mwSize nel = get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2653
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
2654 for (mwIndex i = 0; i < nel; i++)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
2655 delete data[i];
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 mxFree (data);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2658 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2659
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2660 mxArray * get_cell (mwIndex idx) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
2661 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2662 return idx >= 0 && idx < get_number_of_elements () ? data[idx] : nullptr;
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
2663 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2664
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2665 void set_cell (mwIndex idx, mxArray *val);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2666
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2667 void * get_data (void) const { return data; }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2668
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2669 void set_data (void *data_arg) { data = static_cast<mxArray **> (data_arg); }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2670
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2671 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2672 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2673 dim_vector dv = dims_to_dim_vector ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2674
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2675 Cell c (dv);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2676
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2677 mwSize nel = get_number_of_elements ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2678
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2679 octave_value *p = c.fortran_vec ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2680
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2681 for (mwIndex i = 0; i < nel; i++)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2682 p[i] = mxArray::as_octave_value (data[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2683
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2684 return c;
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2687 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2688
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2689 mxArray **data;
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
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
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2694 mxArray::mxArray (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
2695 : rep (create_rep (interleaved, ov)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2696 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2697
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2698 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
2699 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
2700 : rep (create_rep (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
2701 name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2702 { }
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 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
2705 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
2706 : rep (create_rep (interleaved, id, dv, flag)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2707 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2708
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2709 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
2710 mxComplexity flag, bool 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
2711 : rep (create_rep (interleaved, id, m, n, flag, init)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2712 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2713
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2714 mxArray::mxArray (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
2715 : rep (create_rep (interleaved, id, val)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2716 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2717
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2718 mxArray::mxArray (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
2719 : rep (create_rep (interleaved, id, val)), name (nullptr)
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2722 mxArray::mxArray (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
2723 : rep (create_rep (interleaved, str)), name (nullptr)
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2726 mxArray::mxArray (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
2727 : rep (create_rep (interleaved, m, str)), name (nullptr)
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2730 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
2731 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
2732 : rep (create_rep (interleaved, id, m, n, nzmax, flag)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2733 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2734
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2735 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
2736 int num_keys,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2737 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
2738 : rep (new mxArray_struct (interleaved, ndims, dims, 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
2739 name (nullptr)
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, 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
2743 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
2744 : rep (new mxArray_struct (interleaved, dv, num_keys, keys)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2745 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2746
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2747 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
2748 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
2749 : rep (new mxArray_struct (interleaved, 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
2750 name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2751 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2752
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2753 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
2754 : rep (new mxArray_cell (interleaved, ndims, dims)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2755 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2756
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2757 mxArray::mxArray (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
2758 : rep (new mxArray_cell (interleaved, dv)), name (nullptr)
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2761 mxArray::mxArray (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
2762 : rep (new mxArray_cell (interleaved, m, n)), name (nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2763 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2764
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2765 mxArray::~mxArray (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2766 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2767 mxFree (name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2768
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2769 delete rep;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2770 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2771
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2772 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2773 mxArray::set_name (const char *name_arg)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2774 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2775 mxFree (name);
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
2776 name = mxArray::strsave (name_arg);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2777 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2778
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2779 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
2780 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
2781 {
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
2782 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
2783
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
2784 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
2785 ? 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
2786 : (null_is_empty ? empty_matrix : octave_value ()));
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2787 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2788
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2789 octave_value
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2790 mxArray::as_octave_value (void) const
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2791 {
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2792 return rep->as_octave_value ();
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2793 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2794
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2795 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
2796 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
2797 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2798 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
2799 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2800
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2801 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
2802 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
2803 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
2804 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2805 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
2806 }
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 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
2809 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
2810 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
2811 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2812 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
2813 }
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 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
2816 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
2817 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
2818 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2819 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
2820 }
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 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
2823 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
2824 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2825 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2828 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
2829 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
2830 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2831 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2834 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
2835 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
2836 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2837 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2840 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
2841 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
2842 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2843 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2846 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
2847 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
2848 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
2849 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2850 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
2851 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2852
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2853 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2854 mxArray::maybe_mutate (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2855 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2856 if (rep->is_octave_value ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2857 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2858 // 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
2859 // 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
2860 // 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
2861
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2862 mxArray *new_val = rep->mutate ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2863
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2864 if (new_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2865 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2866 delete rep;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2867 rep = new_val->rep;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2868 new_val->rep = nullptr;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2869 delete new_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2870 }
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 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2873
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2874 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2875
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2876 // 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
2877 // management.
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2878
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2879 class mex
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2880 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2881 public:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2882
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2883 mex (octave_mex_function& f)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
2884 : curr_mex_fcn (f), memlist (), arraylist (), fname (nullptr) { }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2885
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2886 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2887
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2888 mex (const mex&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2889
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2890 mex& operator = (const mex&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2891
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2892 ~mex (void)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2893 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2894 // We can't use mex::free here because it modifies memlist.
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2895 while (! memlist.empty ())
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2896 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
2897 auto p = memlist.begin ();
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2898 xfree (*p);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2899 memlist.erase (p);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2900 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2901
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_value here because it modifies arraylist.
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2903 while (! arraylist.empty ())
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2904 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
2905 auto p = arraylist.begin ();
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2906 delete *p;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
2907 arraylist.erase (p);
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 if (! (memlist.empty () && arraylist.empty ()))
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
2911 error ("mex: %s: cleanup failed", function_name ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2912
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2913 mxFree (fname);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2914 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2915
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2916 const char * function_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2917 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2918 if (! fname)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2919 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
2920 octave::tree_evaluator& tw
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
2921 = 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
2922
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
2923 octave_function *fcn = tw.current_function ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2924
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2925 if (fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2926 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2927 std::string nm = fcn->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2928 fname = mxArray::strsave (nm.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2929 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2930 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2931 fname = mxArray::strsave ("unknown");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2932 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2933
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2934 return fname;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2935 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2936
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2937 // 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
2938 void * malloc_unmarked (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2939 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2940 void *ptr = std::malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2941
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2942 if (! ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2943 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2944 // 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
2945 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
2946 function_name (), n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2947 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2948
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2949 global_mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2950
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2951 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2952 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2953
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2954 // 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
2955 void * malloc (std::size_t n)
5900
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 void *ptr = malloc_unmarked (n);
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 mark (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 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2962 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2963
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2964 // 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
2965 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
2966 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2967 void *ptr = malloc_unmarked (n*t);
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 memset (ptr, 0, n*t);
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 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2972 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2973
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
2974 // 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
2975 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
2976 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2977 void *ptr = calloc_unmarked (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 mark (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 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2982 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2983
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21743
diff changeset
2984 // 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
2985 // 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
2986 // 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
2987 void * realloc (void *ptr, std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2988 {
10225
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
2989 void *v;
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
2990
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
2991 if (ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2992 {
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
2993 auto p_local = memlist.find (ptr);
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
2994 auto p_global = global_memlist.find (ptr);
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
2995
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2996 v = std::realloc (ptr, n);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2997
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
2998 if (v)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2999 {
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3000 if (p_local != memlist.end ())
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3001 {
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3002 memlist.erase (p_local);
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3003 memlist.insert (v);
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3004 }
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3005
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3006 if (p_global != global_memlist.end ())
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3007 {
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3008 global_memlist.erase (p_global);
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3009 global_memlist.insert (v);
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3010 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3011 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3012 }
10225
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3013 else
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3014 v = malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3015
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3016 return v;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3017 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3018
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3019 // Free a pointer obtained from malloc or calloc.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3020 void free (void *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3021 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3022 if (ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3023 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3024 unmark (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3025
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
3026 auto p = global_memlist.find (ptr);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3027
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3028 if (p != global_memlist.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3029 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3030 global_memlist.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3031
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3032 xfree (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3033 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3034 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3035 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3036 p = foreign_memlist.find (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3037
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3038 if (p != foreign_memlist.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3039 foreign_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3040 #if defined (DEBUG)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3041 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3042 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
3043 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3044 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3045 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3046 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3047
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3048 // Mark a pointer to be freed on exit.
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3049 void mark (void *ptr)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3050 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3051 #if defined (DEBUG)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3052 if (memlist.find (ptr) != memlist.end ())
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3053 warning ("%s: double registration ignored", function_name ());
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3054 #endif
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3055
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3056 memlist.insert (ptr);
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3057 }
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3058
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3059 // 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
3060 // made persistent, or because it was already freed.
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3061 void unmark (void *ptr)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3062 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
3063 auto p = memlist.find (ptr);
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3064
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3065 if (p != memlist.end ())
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3066 memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3067 #if defined (DEBUG)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3068 else
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3069 warning ("%s: value not marked", function_name ());
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3070 #endif
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3071 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3072
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3073 mxArray * mark_array (mxArray *ptr)
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3074 {
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3075 arraylist.insert (ptr);
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3076 return ptr;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3077 }
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3078
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3079 void unmark_array (mxArray *ptr)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3080 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
3081 auto p = arraylist.find (ptr);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3082
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3083 if (p != arraylist.end ())
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3084 arraylist.erase (p);
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3085 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3086
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3087 // Mark a pointer as one we allocated.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3088 void mark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3089 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3090 #if defined (DEBUG)
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3091 if (foreign_memlist.find (ptr) != foreign_memlist.end ())
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3092 warning ("%s: double registration ignored", function_name ());
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3093 #endif
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3094
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3095 foreign_memlist.insert (ptr);
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3096 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3097
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3098 // Unmark a pointer as one we allocated.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3099 void unmark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3100 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
3101 auto p = foreign_memlist.find (ptr);
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3102
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3103 if (p != foreign_memlist.end ())
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3104 foreign_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3105 #if defined (DEBUG)
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3106 else
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3107 warning ("%s: value not marked", function_name ());
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3108 #endif
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3109
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3110 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3111
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3112 // 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
3113 // 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
3114 mxArray * make_value (const octave_value& ov)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3115 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3116 bool interleaved = curr_mex_fcn.use_interleaved_complex ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3117
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3118 return mark_array (new mxArray (interleaved, ov));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3119 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3120
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3121 // Free an array and its contents.
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3122 bool free_value (mxArray *ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3123 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3124 bool inlist = false;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3125
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
3126 auto p = arraylist.find (ptr);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3127
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3128 if (p != arraylist.end ())
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3129 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3130 inlist = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3131 arraylist.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3132 delete ptr;
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3133 }
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3134 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3135 else
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3136 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
3137 #endif
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3138
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3139 return inlist;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3140 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3141
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3142 octave_mex_function& current_mex_function (void) const
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3143 {
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3144 return curr_mex_fcn;
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3145 }
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3146
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3147 // 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
3148 int trap_feval_error = 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3149
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3150 private:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3151
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3152 // Pointer to the mex function that corresponds to this mex context.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3153 octave_mex_function& curr_mex_fcn;
6068
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 // List of memory resources that need to be freed upon exit.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3156 std::set<void *> memlist;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3157
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3158 // List of mxArray objects that need to be freed upon exit.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3159 std::set<mxArray *> arraylist;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3160
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3161 // List of memory resources we know about, but that were allocated
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3162 // elsewhere.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3163 std::set<void *> foreign_memlist;
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3164
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3165 // The name of the currently executing function.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3166 mutable char *fname;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3167
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3168 // List of memory resources we allocated.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3169 static std::set<void *> global_memlist;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3170
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3171 // Mark 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_mark (void *ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3173 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3174 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3175 if (global_memlist.find (ptr) != global_memlist.end ())
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3176 warning ("%s: double registration ignored", function_name ());
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3177 #endif
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3178
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3179 global_memlist.insert (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3180 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3181
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3182 // Unmark a pointer as one we allocated.
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3183 void global_unmark (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3184 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
3185 auto p = global_memlist.find (ptr);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3186
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3187 if (p != global_memlist.end ())
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3188 global_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3189 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3190 else
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3191 warning ("%s: value not marked", function_name ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3192 #endif
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3193 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3194 };
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3195
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3196 // List of memory resources we allocated.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3197 std::set<void *> mex::global_memlist;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3198
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3199 // Current context.
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
3200 mex *mex_context = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3201
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3202 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
3203 mxArray::malloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3204 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3205 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
3206 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3207
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3208 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
3209 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
3210 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3211 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
3212 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3213
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3214 static inline void *
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3215 maybe_mark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3216 {
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3217 if (mex_context)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3218 mex_context->mark_foreign (ptr);
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3219
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3220 return ptr;
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3221 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3222
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3223 static inline mxArray *
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3224 maybe_unmark_array (mxArray *ptr)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3225 {
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3226 if (mex_context)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3227 mex_context->unmark_array (ptr);
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3228
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3229 return ptr;
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3230 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3231
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3232 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
3233 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
3234 maybe_unmark (T *ptr)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3235 {
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3236 if (mex_context)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3237 mex_context->unmark (ptr);
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3238
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3239 return ptr;
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3240 }
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3241
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3242 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3243 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
3244 {
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
3245 if (key_num >= 0 && key_num < nfields)
25450
66b72fbf2845 Backed out changeset 97e64c23fd07 (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25445
diff changeset
3246 data[nfields * index + key_num] = maybe_unmark_array (val);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3247 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3248
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3249 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3250 mxArray_cell::set_cell (mwIndex idx, mxArray *val)
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3251 {
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
3252 if (idx >= 0 && idx < get_number_of_elements ())
25450
66b72fbf2845 Backed out changeset 97e64c23fd07 (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25445
diff changeset
3253 data[idx] = maybe_unmark_array (val);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3254 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3255
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3256 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3257
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3258 // C interface to mxArray objects:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3259
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3260 // Floating point predicates.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3261
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3262 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3263 mxIsFinite (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3264 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3265 return lo_ieee_finite (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3266 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3267
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3268 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3269 mxIsInf (const double v)
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 return lo_ieee_isinf (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3272 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3273
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3274 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3275 mxIsNaN (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3276 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3277 return lo_ieee_isnan (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3278 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3279
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3280 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3281 mxGetEps (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3282 {
15220
61822c866ba1 use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
3283 return std::numeric_limits<double>::epsilon ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3284 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3285
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3286 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3287 mxGetInf (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3288 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3289 return lo_ieee_inf_value ();
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3292 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3293 mxGetNaN (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3294 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3295 return lo_ieee_nan_value ();
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3298 // Memory management.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3299 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
3300 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
3301 {
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
3302 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
3303 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3304
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3305 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
3306 mxMalloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3307 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3308 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
3309 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3310
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3311 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
3312 mxRealloc (void *ptr, std::size_t size)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3313 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3314 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
3315 : std::realloc (ptr, size);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3316 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3317
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3318 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3319 mxFree (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3320 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3321 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3322 mex_context->free (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3323 else
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3324 xfree (ptr);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3325 }
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3326
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3327 static inline mxArray *
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3328 maybe_mark_array (mxArray *ptr)
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3329 {
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3330 return mex_context ? mex_context->mark_array (ptr) : ptr;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3331 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3332
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3333 // Constructors.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3334 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
3335 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
3336 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3337 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
3338 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3339
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3340 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3341 mxCreateCellArray (mwSize ndims, const mwSize *dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3342 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3343 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
3344 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3345
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3346 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3347 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
3348 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3349 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
3350 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3351
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3352 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3353 mxCreateCellMatrix (mwSize m, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3354 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3355 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
3356 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3357
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3358 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3359 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
3360 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3361 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
3362 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3363
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3364 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3365 mxCreateCharArray (mwSize ndims, const mwSize *dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3366 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3367 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3370 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3371 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
3372 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3373 return maybe_mark_array (new mxArray (true, m, str));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3374 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3375
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3376 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3377 mxCreateCharMatrixFromStrings (mwSize m, const char **str)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3378 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3379 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3382 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3383 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
3384 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3385 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
3386 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3387
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3388 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3389 mxCreateDoubleMatrix (mwSize m, mwSize n, mxComplexity flag)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3390 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3391 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3394 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3395 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
3396 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3397 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, val));
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3400 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3401 mxCreateDoubleScalar (double val)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3402 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3403 return maybe_mark_array (new mxArray (false, mxDOUBLE_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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3406 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3407 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
3408 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3409 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
3410 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3411
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3412 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3413 mxCreateLogicalArray (mwSize ndims, const mwSize *dims)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3414 {
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 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3418 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3419 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
3420 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3421 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
3422 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3423
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3424 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3425 mxCreateLogicalMatrix (mwSize m, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3426 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3427 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3430 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3431 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
3432 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3433 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
3434 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3435
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3436 mxArray *
7577
ba8fcc115fee mex.cc: arg to mxCreateLogicalScalar is now mxLogical
John W. Eaton <jwe@octave.org>
parents: 7357
diff changeset
3437 mxCreateLogicalScalar (mxLogical val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3438 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3439 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3442 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3443 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
3444 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
3445 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3446 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
3447 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3448
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3449 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
3450 mxCreateNumericArray (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
3451 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
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 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
3454 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3455
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3456 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3457 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
3458 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
3459 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3460 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
3461 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3462
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3463 mxArray *
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3464 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
3465 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
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 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
3468 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3469
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3470 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3471 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
3472 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
3473 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3474 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
3475 false));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3476 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3477
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3478 mxArray *
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3479 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
3480 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
3481 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3482 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
3483 false));
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3486 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3487 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
3488 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
3489 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3490 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
3491 }
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3492
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3493 mxArray *
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3494 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
3495 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
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 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
3498 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3499
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3500 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3501 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
3502 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3503 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
3504 flag));
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3505 }
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3506
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3507 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3508 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
3509 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3510 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
3511 flag));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3512 }
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 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3515 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
3516 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3517 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
3518 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3519
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3520 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3521 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3522 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3523 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3526 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3527 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
3528 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3529 return maybe_mark_array (new mxArray (true, str));
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3532 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3533 mxCreateString (const char *str)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3534 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3535 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3538 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3539 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
3540 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
3541 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3542 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
3543 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3544
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3545 mxArray *
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3546 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys,
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3547 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
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 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
3550 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3551
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3552 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
3553 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
3554 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
3555 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3556 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
3557 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3558
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3559 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3560 mxCreateStructMatrix (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
3561 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
3562 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3563 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
3564 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3565
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3566 // Copy constructor.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3567 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3568 mxDuplicateArray (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3569 {
11277
7d5351fc575a mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents: 11276
diff changeset
3570 return maybe_mark_array (ptr->dup ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3571 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3572
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3573 // Destructor.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3574 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3575 mxDestroyArray (mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3576 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3577 if (! (mex_context && mex_context->free_value (ptr)))
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3578 delete ptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3579 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3580
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3581 // 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
3582 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3583 mxIsCell (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3584 {
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23553
diff changeset
3585 return ptr->iscell ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3586 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3587
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3588 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3589 mxIsChar (const mxArray *ptr)
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 return ptr->is_char ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3592 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3593
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3594 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3595 mxIsClass (const mxArray *ptr, const char *name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3596 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3597 return ptr->is_class (name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3598 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3599
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3600 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3601 mxIsComplex (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3602 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3603 return ptr->is_complex ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3604 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3605
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3606 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3607 mxIsDouble (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3608 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3609 return ptr->is_double ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3610 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3611
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3612 bool
11100
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3613 mxIsFunctionHandle (const mxArray *ptr)
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3614 {
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3615 return ptr->is_function_handle ();
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3616 }
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
3617
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3618 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3619 mxIsInt16 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3620 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3621 return ptr->is_int16 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3622 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3623
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3624 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3625 mxIsInt32 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3626 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3627 return ptr->is_int32 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3628 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3629
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3630 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3631 mxIsInt64 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3632 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3633 return ptr->is_int64 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3634 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3635
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3636 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3637 mxIsInt8 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3638 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3639 return ptr->is_int8 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3640 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3641
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3642 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3643 mxIsLogical (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3644 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3645 return ptr->is_logical ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3646 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3647
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3648 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3649 mxIsNumeric (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3650 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3651 return ptr->is_numeric ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3652 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3653
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3654 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3655 mxIsSingle (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3656 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3657 return ptr->is_single ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3658 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3659
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3660 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3661 mxIsSparse (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3662 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3663 return ptr->is_sparse ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3664 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3665
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3666 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3667 mxIsStruct (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3668 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3669 return ptr->is_struct ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3670 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3671
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3672 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3673 mxIsUint16 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3674 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3675 return ptr->is_uint16 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3676 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3677
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3678 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3679 mxIsUint32 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3680 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3681 return ptr->is_uint32 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3682 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3683
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3684 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3685 mxIsUint64 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3686 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3687 return ptr->is_uint64 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3688 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3689
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3690 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3691 mxIsUint8 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3692 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3693 return ptr->is_uint8 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3694 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3695
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3696 // 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
3697 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3698 mxIsLogicalScalar (const mxArray *ptr)
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 return ptr->is_logical_scalar ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3701 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3702
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3703 // 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
3704 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3705 mxIsLogicalScalarTrue (const mxArray *ptr)
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 return ptr->is_logical_scalar_true ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3708 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3709
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3710 // 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
3711 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3712 mxIsEmpty (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3713 {
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
3714 return ptr->isempty ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3715 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3716
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3717 bool
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3718 mxIsScalar (const mxArray *ptr)
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3719 {
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3720 return ptr->is_scalar ();
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3721 }
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
3722
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
3723 // 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
3724 // 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
3725 bool
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
3726 mxIsFromGlobalWS (const mxArray * /*ptr*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3727 {
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
3728 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
3729
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3730 return 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3731 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3732
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3733 // 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
3734 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3735 mxGetM (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3736 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3737 return ptr->get_m ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3738 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3739
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3740 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3741 mxGetN (const mxArray *ptr)
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 return ptr->get_n ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3744 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3745
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3746 const mwSize *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3747 mxGetDimensions (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3748 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3749 return ptr->get_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3750 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3751
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3752 mwSize
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3753 mxGetNumberOfDimensions (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3754 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3755 return ptr->get_number_of_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3756 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3757
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
3758 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3759 mxGetNumberOfElements (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3760 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3761 return ptr->get_number_of_elements ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3762 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3763
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3764 // Dimension setters.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3765 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3766 mxSetM (mxArray *ptr, mwSize m)
5900
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 ptr->set_m (m);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3769 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3770
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3771 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3772 mxSetN (mxArray *ptr, mwSize n)
5900
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 ptr->set_n (n);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3775 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3776
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3777 int
10126
8687ce1c56da Change signature of mxSetDimensions.
David Grundberg <davidg@cs.umu.se>
parents: 10066
diff changeset
3778 mxSetDimensions (mxArray *ptr, const mwSize *dims, mwSize ndims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3779 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3780 return (ptr->set_dimensions (static_cast<mwSize *>
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3781 (maybe_unmark (const_cast<mwSize *> (dims))),
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3782 ndims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3783 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3784
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3785 // Data extractors.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3786 double *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3787 mxGetPr (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3788 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3789 return static_cast<double *> (ptr->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3790 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3791
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3792 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3793 mxGetScalar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3794 {
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
3795 return ptr->get_scalar ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3796 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3797
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3798 mxChar *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3799 mxGetChars (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3800 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3801 if (mxIsChar (ptr))
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3802 return static_cast<mxChar *> (ptr->get_data ());
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
3803 else
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
3804 return nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3805 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3806
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3807 mxLogical *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3808 mxGetLogicals (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3809 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3810 return static_cast<mxLogical *> (ptr->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3811 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3812
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3813 void *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3814 mxGetData (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3815 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3816 return ptr->get_data ();
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
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3819 double *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3820 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
3821 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3822 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
3823 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3824
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3825 void *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3826 mxGetImagData (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3827 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3828 return ptr->get_imag_data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3829 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3830
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3831 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
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 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3836 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
3837 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3838 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
3839 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3840
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3841 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
3842 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3843 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
3844 }
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 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
3847 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3848 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
3849 }
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 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
3852 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3853 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
3854 }
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 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
3857 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3858 return 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
3859 }
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 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
3862 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3863 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
3864 }
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 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
3867 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3868 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
3869 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3870
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3871 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
3872 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3873 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
3874 }
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 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
3877 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3878 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
3879 }
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 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
3882 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3883 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
3884 }
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 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
3887 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3888 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
3889 }
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 #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
3892 /* 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
3893 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
3894 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3895 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
3896 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3897
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3898 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
3899 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3900 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3903 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
3904 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3905 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
3906 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3907
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3908 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
3909 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3910 return 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
3911 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3912
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3913 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
3914 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3915 return 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
3916 }
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 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
3919 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3920 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
3921 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3922
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3923 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
3924 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3925 return 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
3926 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3927
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3928 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
3929 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3930 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
3931 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3932 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3933
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3934 // Data setters.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3935 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3936 mxSetPr (mxArray *ptr, double *pr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3937 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3938 ptr->set_data (maybe_unmark (pr));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3939 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3940
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3941 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
3942 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
3943 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3944 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
3945 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3946
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3947 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
3948 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3949 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
3950 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3951
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3952 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
3953 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3954 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
3955 }
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 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
3958 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3959 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
3960 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3961
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3962 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
3963 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3964 return 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
3965 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3966
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3967 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
3968 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3969 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
3970 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3971
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3972 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
3973 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3974 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
3975 }
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 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
3978 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3979 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
3980 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3981
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3982 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
3983 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3984 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
3985 }
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 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
3988 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3989 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
3990 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3991
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3992 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
3993 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3994 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
3995 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3996
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3997 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
3998 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3999 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
4000 }
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 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
4003 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4004 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
4005 }
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 #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
4008 /* 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
4009 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
4010 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4011 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
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
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4014 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
4015 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4016 return 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
4017 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4018
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4019 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
4020 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4021 return 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
4022 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4023
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4024 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
4025 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4026 return 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
4027 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4028
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4029 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
4030 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4031 return 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
4032 }
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 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
4035 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4036 return 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
4037 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4038
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4039 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
4040 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4041 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
4042 }
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 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
4045 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4046 return 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
4047 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4048 #endif
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 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4051 mxSetPi (mxArray *ptr, double *pi)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4052 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4053 ptr->set_imag_data (maybe_unmark (pi));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4054 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4055
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4056 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4057 mxSetImagData (mxArray *ptr, void *pi)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4058 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4059 ptr->set_imag_data (maybe_unmark (pi));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4060 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4061
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4062 // Classes.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4063 mxClassID
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4064 mxGetClassID (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4065 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4066 return ptr->get_class_id ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4067 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4068
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4069 const char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4070 mxGetClassName (const mxArray *ptr)
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 return ptr->get_class_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4073 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4074
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4075 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4076 mxSetClassName (mxArray *ptr, const char *name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4077 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4078 ptr->set_class_name (name);
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
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4081 void
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4082 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
4083 const mxArray *property_value)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4084 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4085 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
4086 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4087
23891
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4088 mxArray *
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4089 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
4090 {
23891
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4091 return ptr->get_property (idx, property_name);
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4092 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4093
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4094 // Cell support.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4095 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4096 mxGetCell (const mxArray *ptr, mwIndex idx)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4097 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4098 return ptr->get_cell (idx);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4099 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4100
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4101 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4102 mxSetCell (mxArray *ptr, mwIndex idx, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4103 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4104 ptr->set_cell (idx, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4105 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4106
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4107 // Sparse support.
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4108 mwIndex *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4109 mxGetIr (const mxArray *ptr)
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 return ptr->get_ir ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4112 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4113
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4114 mwIndex *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4115 mxGetJc (const mxArray *ptr)
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 return ptr->get_jc ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4118 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4119
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4120 mwSize
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4121 mxGetNzmax (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4122 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4123 return ptr->get_nzmax ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4124 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4125
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4126 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4127 mxSetIr (mxArray *ptr, mwIndex *ir)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4128 {
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
4129 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
4130 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4131
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4132 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4133 mxSetJc (mxArray *ptr, mwIndex *jc)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4134 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4135 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
4136 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4137
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4138 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4139 mxSetNzmax (mxArray *ptr, mwSize nzmax)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4140 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4141 ptr->set_nzmax (nzmax);
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4144 // Structure support.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4145 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4146 mxAddField (mxArray *ptr, const char *key)
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 return ptr->add_field (key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4149 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4150
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4151 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4152 mxRemoveField (mxArray *ptr, int key_num)
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 ptr->remove_field (key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4155 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4156
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4157 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4158 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
4159 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4160 int key_num = mxGetFieldNumber (ptr, key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4161 return mxGetFieldByNumber (ptr, index, key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4162 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4163
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4164 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4165 mxGetFieldByNumber (const mxArray *ptr, mwIndex index, int key_num)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4166 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4167 return ptr->get_field_by_number (index, key_num);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4168 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4169
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4170 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4171 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
4172 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4173 int key_num = mxGetFieldNumber (ptr, key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4174 mxSetFieldByNumber (ptr, index, key_num, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4175 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4176
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4177 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4178 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
4179 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4180 ptr->set_field_by_number (index, key_num, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4181 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4182
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4183 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4184 mxGetNumberOfFields (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4185 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4186 return ptr->get_number_of_fields ();
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
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4189 const char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4190 mxGetFieldNameByNumber (const mxArray *ptr, int key_num)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4191 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4192 return ptr->get_field_name_by_number (key_num);
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4195 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4196 mxGetFieldNumber (const mxArray *ptr, const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4197 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4198 return ptr->get_field_number (key);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4199 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4200
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4201 int
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4202 mxGetString (const mxArray *ptr, char *buf, mwSize buflen)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4203 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4204 return ptr->get_string (buf, buflen);
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4207 char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4208 mxArrayToString (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4209 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4210 return ptr->array_to_string ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4211 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
4212
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4213 mwIndex
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4214 mxCalcSingleSubscript (const mxArray *ptr, mwSize nsubs, mwIndex *subs)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4215 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4216 return ptr->calc_single_subscript (nsubs, subs);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4217 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4218
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
4219 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4220 mxGetElementSize (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4221 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4222 return ptr->get_element_size ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4223 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4224
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4225 // ------------------------------------------------------------------
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4226
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4227 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
4228 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
4229 F77_INT& nrhs, mxArray **prhs);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4230
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4231 octave_value_list
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4232 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
4233 int nargout_arg)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4234 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4235 octave_quit ();
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4236
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4237 // 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
4238 // still want to be able to return an ans.
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4239
8806
c7864bb74914 avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
4240 volatile int nargout = nargout_arg;
c7864bb74914 avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
4241
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4242 int nargin = args.length ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4243 OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4244 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
4245 argin[i] = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4246
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
4247 int nout = (nargout == 0 ? 1 : nargout);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4248 OCTAVE_LOCAL_BUFFER (mxArray *, argout, nout);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4249 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
4250 argout[i] = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4251
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4252 // Save old mex pointer.
28823
26cfccfee9a0 Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents: 28370
diff changeset
4253 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
4254
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4255 mex context (mex_fcn);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4256
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4257 for (int i = 0; i < nargin; i++)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4258 argin[i] = context.make_value (args(i));
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4259
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4260 mex_context = &context;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4261
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4262 void *mex_fcn_ptr = mex_fcn.mex_fcn_ptr ();
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4263
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4264 if (mex_fcn.is_fmex ())
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4265 {
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4266 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
4267
23498
647705ffb110 use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
4268 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
4269 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
4270
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4271 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
4272 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4273 else
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4274 {
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4275 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
4276
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4277 fcn (nargout, argout, nargin, argin);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4278 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4279
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4280 // Convert returned array entries back into octave values.
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4281
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4282 octave_value_list retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4283
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4284 if (nargout == 0 && argout[0])
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4285 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4286 // We have something for ans.
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4287 nargout = 1;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4288 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4289
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4290 retval.resize (nargout);
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4291
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4292 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
4293 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
4294
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4295 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4296 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4297
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4298 // C interface to mex functions:
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 const char *
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4301 mexFunctionName (void)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4302 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4303 return mex_context ? mex_context->function_name () : "unknown";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4304 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4305
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4306 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
4307 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
4308 mxArray *argin[], const char *fname)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4309 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4310 octave_value_list args;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4311
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4312 // 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
4313 // 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
4314 // 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
4315 // handling is implemented.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4316
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
4317 // 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
4318 // Can this code be re-factored?
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4319 args.resize (nargin);
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 for (int i = 0; i < nargin; i++)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
4322 args(i) = mxArray::as_octave_value (argin[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4323
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4324 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
4325
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4326 bool execution_error = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4327
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4328 octave_value_list retval;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4329
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4330 try
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4331 {
29172
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4332 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
4333
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4334 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
4335 ([&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
4336 {
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4337 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
4338 }, tw.lvalue_list ());
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4339
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4340 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
4341
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23052
diff changeset
4342 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
4343 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
4344 catch (const octave::execution_exception&)
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4345 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4346 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
4347 {
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4348 // FIXME: is there a way to indicate what error occurred?
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4349 // 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
4350 // save the exception info for lasterror?
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4351
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4352 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
4353
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4354 execution_error = true;
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4355 }
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4356 else
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4357 {
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4358 args.resize (0);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4359 retval.resize (0);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4360
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4361 throw;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4362 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4363 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4364
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4365 int num_to_copy = retval.length ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4366
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4367 if (nargout < retval.length ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4368 num_to_copy = nargout;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4369
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4370 for (int i = 0; i < num_to_copy; i++)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4371 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4372 // 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
4373 // 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
4374 // 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
4375 // 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
4376 argout[i] = mex_context->make_value (retval(i));
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4379 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
4380 argout[num_to_copy++] = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4381
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4382 return execution_error ? 1 : 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4383 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4384
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4385 mxArray *
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4386 mexCallMATLABWithTrap (int nargout, mxArray *argout[], int nargin,
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4387 mxArray *argin[], const char *fname)
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4388 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4389 mxArray *mx = nullptr;
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4390
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
4391 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
4392 mexSetTrapFlag (1);
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4393 if (mexCallMATLAB (nargout, argout, nargin, argin, fname))
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4394 {
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4395 const char *field_names[] = {"identifier", "message", "case", "stack"};
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4396 mx = mxCreateStructMatrix (1, 1, 4, field_names);
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4397 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX"));
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4398 std::string msg = "mexCallMATLABWithTrap: function call <"
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4399 + std::string (fname) + "> failed";
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4400 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ()));
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4401 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
4402 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
4403 }
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4404 mexSetTrapFlag (old_flag);
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4405
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4406 return mx;
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4407 }
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4408
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4409 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4410 mexSetTrapFlag (int flag)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4411 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4412 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4413 mex_context->trap_feval_error = flag;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4414 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4415
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4416 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4417 mexEvalString (const char *s)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4418 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4419 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4420
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4421 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
4422
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4423 int parse_status;
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4424 bool execution_error = false;
5900
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 octave_value_list ret;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4427
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4428 try
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4429 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 25922
diff changeset
4430 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
4431 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
4432 catch (const octave::execution_exception&)
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4433 {
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4434 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
4435
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4436 execution_error = true;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4437 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4438
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4439 if (parse_status || execution_error)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4440 retval = 1;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4441
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4442 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4443 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4444
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4445 mxArray *
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4446 mexEvalStringWithTrap (const char *s)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4447 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4448 mxArray *mx = nullptr;
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4449
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4450 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
4451
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4452 int parse_status;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4453 bool execution_error = false;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4455 octave_value_list ret;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4456
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4457 try
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4458 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 25922
diff changeset
4459 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
4460 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4461 catch (const octave::execution_exception&)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4462 {
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4463 interp.recover_from_exception ();
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4464
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4465 execution_error = true;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4466 }
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 if (parse_status || execution_error)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4469 {
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4470 const char *field_names[] = {"identifier", "message", "case", "stack"};
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4471 mx = mxCreateStructMatrix (1, 1, 4, field_names);
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4472 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX"));
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4473 std::string msg = "mexEvalStringWithTrap: eval of <"
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4474 + std::string (s) + "> failed";
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4475 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ()));
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4476 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
4477 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
4478 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4479
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4480 return mx;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4481 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4482
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4483 void
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4484 mexErrMsgTxt (const char *s)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4485 {
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
4486 std::size_t len;
25751
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4487
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4488 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
4489 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4490 if (s[len - 1] == '\n')
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4491 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4492 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
4493 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
4494 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4495 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4496 error ("%s: %s", mexFunctionName (), s);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4497 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4498 else
16851
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4499 {
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4500 // 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
4501 // 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
4502 error (" ");
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4503 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4504 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4505
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4506 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4507 mexErrMsgIdAndTxt (const char *id, const char *fmt, ...)
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4508 {
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4509 if (fmt && strlen (fmt) > 0)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4510 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4511 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
4512 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
4513 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4514 sprintf (tmpfmt, "%s: %s", fname, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4515 va_list args;
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4516 va_start (args, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4517 verror_with_id (id, tmpfmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4518 va_end (args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4519 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4520 else
16851
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4521 {
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4522 // 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
4523 // 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
4524 error (" ");
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
4525 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4526 }
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4527
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4528 void
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4529 mexWarnMsgTxt (const char *s)
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4530 {
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
4531 std::size_t len;
25751
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4532
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4533 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
4534 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4535 if (s[len - 1] == '\n')
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4536 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4537 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
4538 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
4539 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4540 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4541 warning ("%s", s);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4542 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4543 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4544 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4545 // 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
4546 // 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
4547 warning (" ");
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
4548 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4549 }
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4550
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4551 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4552 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...)
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4553 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4554 // 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
4555 // an empty string?
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4556
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4557 if (fmt && strlen (fmt) > 0)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4558 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4559 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
4560 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
4561 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4562 sprintf (tmpfmt, "%s: %s", fname, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4563 va_list args;
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4564 va_start (args, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4565 vwarning_with_id (id, tmpfmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4566 va_end (args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
4567 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4568 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4569
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
4570 int
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4571 mexPrintf (const char *fmt, ...)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4572 {
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
4573 int retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4574 va_list args;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4575 va_start (args, fmt);
25646
4d565baa475e move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25452
diff changeset
4576 retval = octave::vformat (octave_stdout, fmt, args);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4577 va_end (args);
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
4578 return retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4579 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4580
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4581 mxArray *
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4582 mexGetVariable (const char *space, const char *name)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4583 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4584 mxArray *retval = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4585
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
4586 octave_value val;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4587
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4588 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
4589
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4590 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
4591 val = interp.global_varval (name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4592 else
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
4593 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4594 // 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
4595
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
4596 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
4597
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4598 bool caller = ! strcmp (space, "caller");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4599 bool base = ! strcmp (space, "base");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4600
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4601 if (caller || base)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4602 {
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4603 // 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
4604 // 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
4605
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4606 if (base)
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4607 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4608 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
4609
29253
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
4610 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
4611 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
4612
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4613 tw.goto_base_frame ();
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4614 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4615
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4616 val = interp.varval (name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4617 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
4618 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4619 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
4620 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4621
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4622 if (val.is_defined ())
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4623 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4624 retval = mex_context->make_value (val);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4625
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4626 retval->set_name (name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4627 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4628
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4629 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4630 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4631
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4632 const mxArray *
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4633 mexGetVariablePtr (const char *space, const char *name)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4634 {
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4635 return mexGetVariable (space, name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4636 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4637
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4638 int
15353
5f3a69a309a7 fix decl of mexPutVariable
John W. Eaton <jwe@octave.org>
parents: 15351
diff changeset
4639 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
4640 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4641 if (! ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4642 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4643
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4644 if (! name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4645 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4646
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4647 if (name[0] == '\0')
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4648 name = ptr->get_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4649
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4650 if (! name || name[0] == '\0')
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4651 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4652
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4653 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
4654
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4655 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
4656 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
4657 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4658 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4659 // FIXME: should this be in variables.cc?
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
4660
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
4661 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
4662
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4663 bool caller = ! strcmp (space, "caller");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4664 bool base = ! strcmp (space, "base");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4665
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
4666 if (caller || base)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4667 {
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4668 // 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
4669 // 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
4670
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4671 if (base)
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4672 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4673 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
4674
29253
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
4675 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
4676 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
4677
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
4678 tw.goto_base_frame ();
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
4679 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4680
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
4681 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
4682 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4683 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4684 mexErrMsgTxt ("mexPutVariable: symbol table does not exist");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4685 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4686
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4687 return 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4688 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4689
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4690 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4691 mexMakeArrayPersistent (mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4692 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4693 maybe_unmark_array (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4694 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
4695
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4696 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4697 mexMakeMemoryPersistent (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4698 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4699 maybe_unmark (ptr);
5864
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
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4702 int
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4703 mexAtExit (void (*f) (void))
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4704 {
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4705 if (mex_context)
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4706 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4707 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
4708
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4709 curr_mex_fcn.atexit (f);
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4710 }
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
4711
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4712 return 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4713 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4714
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4715 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
4716 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
4717 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4718 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
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 octave_value ret = get_property_from_handle (handle, property, "mexGet");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4721
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4722 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
4723 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
4724
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4725 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
4726 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4727
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4728 const mxArray *
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4729 mexGet (double handle, const char *property)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4730 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4731 mxArray *m = nullptr;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4732
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4733 octave_value ret = get_property_from_handle (handle, property, "mexGet");
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4734
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4735 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
4736 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
4737
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4738 return m;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4739 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4740
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4741 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4742 mexIsGlobal (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4743 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4744 return mxIsFromGlobalWS (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4745 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4746
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4747 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4748 mexIsLocked (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4749 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4750 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4751
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4752 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4753 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4754 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4755
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4756 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
4757
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4758 retval = interp.mislocked (fname);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4759 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4760
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4761 return retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4762 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4763
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4764 std::map<std::string,int> mex_lock_count;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4765
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4766 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4767 mexLock (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4768 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4769 if (mex_context)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4770 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4771 const char *fname = mexFunctionName ();
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 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
4774 mex_lock_count[fname] = 1;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4775 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4776 mex_lock_count[fname]++;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4777
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4778 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
4779
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4780 interp.mlock ();
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4781 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4782 }
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 int
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4785 mexSet (double handle, const char *property, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4786 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
4787 bool ret
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
4788 = set_property_in_handle (handle, property, mxArray::as_octave_value (val),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
4789 "mexSet");
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
4790 return (ret ? 0 : 1);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4791 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4792
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4793 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4794 mexUnlock (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4795 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4796 if (mex_context)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4797 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4798 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4799
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
4800 auto p = mex_lock_count.find (fname);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4801
6062
a813714cb04b [project @ 2006-10-18 23:30:22 by jwe]
jwe
parents: 6018
diff changeset
4802 if (p != mex_lock_count.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4803 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4804 int count = --mex_lock_count[fname];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4805
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4806 if (count == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4807 {
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4808 octave::interpreter& interp
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4809 = octave::__get_interpreter__ ("mexUnLock");
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4810
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
4811 interp.munlock (fname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4812
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4813 mex_lock_count.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4814 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
4815 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4816 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4817 }