annotate libinterp/corefcn/mex.cc @ 31362:4e12be13186d

build: Silence unused function compilation warning in mex.cc (bug #63210) * mex.cc (maybe_disown_ptr): Surround use of maybe_disown_ptr() prototype and function definition with "#if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)".
author Rik <rik@octave.org>
date Sat, 29 Oct 2022 17:57:56 -0700
parents 670a0d878af1
children 8dc9508b8364
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30501
diff changeset
3 // Copyright (C) 2006-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
7016
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
30501
79a7f3e3cf54 Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30494
diff changeset
30 // #define DEBUG 1
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
31
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
32 #if defined (DEBUG)
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
33 # include <iostream>
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
34 #endif
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
35
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
36 #include <cstdarg>
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
37 #include <cstdlib>
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
38 #include <cstring>
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
39 #include <cctype>
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
40
23455
73ff72d3d603 maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents: 23450
diff changeset
41 #include <limits>
73ff72d3d603 maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents: 23450
diff changeset
42 #include <map>
30501
79a7f3e3cf54 Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30494
diff changeset
43 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
30494
ba5370c670d5 make use of <memory_resource> conditional on HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR
John W. Eaton <jwe@octave.org>
parents: 30488
diff changeset
44 # include <memory_resource>
ba5370c670d5 make use of <memory_resource> conditional on HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR
John W. Eaton <jwe@octave.org>
parents: 30488
diff changeset
45 #endif
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
46 #include <set>
23455
73ff72d3d603 maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents: 23450
diff changeset
47 #include <string>
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
48
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
49 // Needed to instantiate Array objects with custom allocator.
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
50 #include "Array.cc"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
51 #include "f77-fcn.h"
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
52 #include "lo-ieee.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7901
diff changeset
53 #include "oct-locbuf.h"
23455
73ff72d3d603 maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents: 23450
diff changeset
54 #include "quit.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
55
15149
62a35ae7d6a2 use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents: 15096
diff changeset
56 #include "Cell.h"
21151
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
57 #include "error.h"
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23499
diff changeset
58 #include "interpreter-private.h"
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 22091
diff changeset
59 #include "interpreter.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
60 // mxArray must be declared as a class before including mexproto.h.
15149
62a35ae7d6a2 use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents: 15096
diff changeset
61 #include "mxarray.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
62 #include "mexproto.h"
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
63 #include "oct-map.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20771
diff changeset
64 #include "ovl.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
65 #include "ov.h"
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
66 #include "ov-classdef.h"
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
67 #include "ov-mex-fcn.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
68 #include "ov-usr-fcn.h"
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
69 #include "pager.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
70 #include "parse.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
71 #include "unwind-prot.h"
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
72 #include "utils.h"
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
73 #include "variables.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
74 #include "graphics.h"
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
75
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
76 // These must be declared extern "C" but may be omitted from the set of
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
77 // symbols declared in mexproto.h, so we declare them here as well.
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
78
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
79 extern "C"
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
80 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
81 extern OCTINTERP_API const mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
82 mexGet_interleaved (double handle, const char *property);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
83
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
84 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
85 mxCreateCellArray (mwSize ndims, const mwSize *dims);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
86
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
87 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
88 mxCreateCellMatrix (mwSize m, mwSize n);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
89
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
90 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
91 mxCreateCharArray (mwSize ndims, const mwSize *dims);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
92
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
93 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
94 mxCreateCharMatrixFromStrings (mwSize m, const char **str);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
95
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
96 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
97 mxCreateDoubleMatrix (mwSize nr, mwSize nc, mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
98
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
99 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
100 mxCreateDoubleScalar (double val);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
101
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
102 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
103 mxCreateLogicalArray (mwSize ndims, const mwSize *dims);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
104
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
105 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
106 mxCreateLogicalMatrix (mwSize m, mwSize n);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
107
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
108 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
109 mxCreateLogicalScalar (mxLogical val);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
110
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
111 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
112 mxCreateNumericArray (mwSize ndims, const mwSize *dims, mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
113 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
114
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
115 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
116 mxCreateNumericMatrix (mwSize m, mwSize n, mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
117 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
118
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
119 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
120 mxCreateUninitNumericArray (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
121 mxClassID class_id, mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
122
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
123 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
124 mxCreateUninitNumericMatrix (mwSize m, mwSize n, mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
125 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
127 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
128 mxCreateSparse (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
129
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
130 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
131 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
132
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
133 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
134 mxCreateString (const char *str);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
135
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
136 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
137 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
138 const char **keys);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
139
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
140 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
141 mxCreateStructMatrix (mwSize rows, mwSize cols, int num_keys,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
142 const char **keys);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
143
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
144 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
145 mxCreateCellArray_interleaved (mwSize ndims, const mwSize *dims);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
146
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
147 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
148 mxCreateCellMatrix_interleaved (mwSize m, mwSize n);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
149
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
150 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
151 mxCreateCharArray_interleaved (mwSize ndims, const mwSize *dims);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
152
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
153 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
154 mxCreateCharMatrixFromStrings_interleaved (mwSize m, const char **str);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
155
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
156 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
157 mxCreateDoubleMatrix_interleaved (mwSize nr, mwSize nc, mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
158
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
159 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
160 mxCreateDoubleScalar_interleaved (double val);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
161
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
162 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
163 mxCreateLogicalArray_interleaved (mwSize ndims, const mwSize *dims);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
164
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
165 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
166 mxCreateLogicalMatrix_interleaved (mwSize m, mwSize n);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
167
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
168 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
169 mxCreateLogicalScalar_interleaved (mxLogical val);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
170
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
171 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
172 mxCreateNumericArray_interleaved (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
173 mxClassID class_id, mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
174
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
175 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
176 mxCreateNumericMatrix_interleaved (mwSize m, mwSize n, mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
177 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
178
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
179 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
180 mxCreateUninitNumericArray_interleaved (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
181 mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
182 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
183
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
184 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
185 mxCreateUninitNumericMatrix_interleaved (mwSize m, mwSize n,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
186 mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
187 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
188
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
189 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
190 mxCreateSparse_interleaved (mwSize m, mwSize n, mwSize nzmax,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
191 mxComplexity flag);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
192
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
193 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
194 mxCreateSparseLogicalMatrix_interleaved (mwSize m, mwSize n, mwSize nzmax);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
195
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
196 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
197 mxCreateString_interleaved (const char *str);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
198
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
199 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
200 mxCreateStructArray_interleaved (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
201 int num_keys, const char **keys);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
202
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
203 extern OCTINTERP_API mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
204 mxCreateStructMatrix_interleaved (mwSize rows, mwSize cols, int num_keys,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
205 const char **keys);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
206
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
207 extern OCTINTERP_API int mxMakeArrayReal (mxArray *ptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
208 extern OCTINTERP_API int mxMakeArrayComplex (mxArray *ptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
209
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
210 extern OCTINTERP_API mxDouble * mxGetDoubles (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
211 extern OCTINTERP_API mxSingle * mxGetSingles (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
212 extern OCTINTERP_API mxInt8 * mxGetInt8s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
213 extern OCTINTERP_API mxInt16 * mxGetInt16s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
214 extern OCTINTERP_API mxInt32 * mxGetInt32s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
215 extern OCTINTERP_API mxInt64 * mxGetInt64s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
216 extern OCTINTERP_API mxUint8 * mxGetUint8s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
217 extern OCTINTERP_API mxUint16 * mxGetUint16s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
218 extern OCTINTERP_API mxUint32 * mxGetUint32s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
219 extern OCTINTERP_API mxUint64 * mxGetUint64s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
220
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
221 extern OCTINTERP_API mxComplexDouble * mxGetComplexDoubles (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
222 extern OCTINTERP_API mxComplexSingle * mxGetComplexSingles (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
223 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
224 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
225 extern OCTINTERP_API mxComplexInt8 * mxGetComplexInt8s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
226 extern OCTINTERP_API mxComplexInt16 * mxGetComplexInt16s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
227 extern OCTINTERP_API mxComplexInt32 * mxGetComplexInt32s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
228 extern OCTINTERP_API mxComplexInt64 * mxGetComplexInt64s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
229 extern OCTINTERP_API mxComplexUint8 * mxGetComplexUint8s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
230 extern OCTINTERP_API mxComplexUint16 * mxGetComplexUint16s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
231 extern OCTINTERP_API mxComplexUint32 * mxGetComplexUint32s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
232 extern OCTINTERP_API mxComplexUint64 * mxGetComplexUint64s (const mxArray *p);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
233 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
234
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
235 extern OCTINTERP_API double * mxGetPi (const mxArray *ptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
236 extern OCTINTERP_API void * mxGetImagData (const mxArray *ptr);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
237
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
238 extern OCTINTERP_API int mxSetDoubles (mxArray *p, mxDouble *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
239 extern OCTINTERP_API int mxSetSingles (mxArray *p, mxSingle *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
240 extern OCTINTERP_API int mxSetInt8s (mxArray *p, mxInt8 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
241 extern OCTINTERP_API int mxSetInt16s (mxArray *p, mxInt16 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
242 extern OCTINTERP_API int mxSetInt32s (mxArray *p, mxInt32 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
243 extern OCTINTERP_API int mxSetInt64s (mxArray *p, mxInt64 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
244 extern OCTINTERP_API int mxSetUint8s (mxArray *p, mxUint8 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
245 extern OCTINTERP_API int mxSetUint16s (mxArray *p, mxUint16 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
246 extern OCTINTERP_API int mxSetUint32s (mxArray *p, mxUint32 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
247 extern OCTINTERP_API int mxSetUint64s (mxArray *p, mxUint64 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
248
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
249 extern OCTINTERP_API int mxSetComplexDoubles (mxArray *p, mxComplexDouble *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
250 extern OCTINTERP_API int mxSetComplexSingles (mxArray *p, mxComplexSingle *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
251 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
252 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
253 extern OCTINTERP_API int mxSetComplexInt8s (mxArray *p, mxComplexInt8 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
254 extern OCTINTERP_API int mxSetComplexInt16s (mxArray *p, mxComplexInt16 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
255 extern OCTINTERP_API int mxSetComplexInt32s (mxArray *p, mxComplexInt32 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
256 extern OCTINTERP_API int mxSetComplexInt64s (mxArray *p, mxComplexInt64 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
257 extern OCTINTERP_API int mxSetComplexUint8s (mxArray *p, mxComplexUint8 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
258 extern OCTINTERP_API int mxSetComplexUint16s (mxArray *p, mxComplexUint16 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
259 extern OCTINTERP_API int mxSetComplexUint32s (mxArray *p, mxComplexUint32 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
260 extern OCTINTERP_API int mxSetComplexUint64s (mxArray *p, mxComplexUint64 *d);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
261 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
262
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
263 extern OCTINTERP_API void mxSetPi (mxArray *ptr, double *pi);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
264 extern OCTINTERP_API void mxSetImagData (mxArray *ptr, void *pi);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
265 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
266
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
267 static void *
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
268 xmalloc (size_t n)
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
269 {
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
270 void *ptr = std::malloc (n);
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
271
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
272 #if defined (DEBUG)
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
273 std::cerr << "xmalloc (" << n << ") = " << ptr << std::endl;
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
274 #endif
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
275
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
276 return ptr;
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
277 }
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
278
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
279 static void *
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
280 xrealloc (void *ptr, size_t n)
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
281 {
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
282 void *newptr = std::realloc (ptr, n);
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
283
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
284 #if defined (DEBUG)
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
285 std::cerr << "xrealloc (" << ptr << ", " << n << ") = " << newptr
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
286 << std::endl;
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
287 #endif
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
288
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
289 return newptr;
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
290 }
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
291
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
292 static void
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
293 xfree (void *ptr)
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
294 {
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
295 #if defined (DEBUG)
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
296 std::cerr << "xfree (" << ptr << ")" << std::endl;
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
297 #endif
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
298
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
299 std::free (ptr);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
300 }
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
301
6806
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
302 static mwSize
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
303 max_str_len (mwSize m, const char **str)
5900
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 int max_len = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
306
6806
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
307 for (mwSize i = 0; i < m; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
308 {
6806
afa9123c5faa [project @ 2007-07-30 18:36:01 by jwe]
jwe
parents: 6787
diff changeset
309 mwSize tmp = strlen (str[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
310
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
311 if (tmp > max_len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
312 max_len = tmp;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
313 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
314
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
315 return max_len;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
316 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
317
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
318 // FIXME: Is there a better/standard way to do this job?
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
319
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
320 template <typename T>
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
321 class fp_type_traits
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
322 {
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
323 public:
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
324 static const bool is_complex = false;
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
325 };
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
326
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
327 template <>
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
328 class fp_type_traits<Complex>
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
329 {
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
330 public:
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
331 static const bool is_complex = true;
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
332 };
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
333
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
334 template <>
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
335 class fp_type_traits <FloatComplex>
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
336 {
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
337 public:
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
338 static const bool is_complex = true;
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
339 };
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
340
30501
79a7f3e3cf54 Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30494
diff changeset
341 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
342
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
343 class mx_deleting_memory_resource : public std::pmr::memory_resource
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
344 {
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
345 private:
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
346
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
347 void * do_allocate (std::size_t bytes, size_t /*alignment*/)
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
348 {
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
349 void *ptr = xmalloc (bytes);
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
350
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
351 if (! ptr)
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
352 throw std::bad_alloc ();
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
353
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
354 return ptr;
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
355 }
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
356
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
357 void do_deallocate (void* ptr, std::size_t /*bytes*/,
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
358 std::size_t /*alignment*/)
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
359 {
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
360 xfree (ptr);
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
361 }
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
362
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
363 bool do_is_equal (const std::pmr::memory_resource& other) const noexcept
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
364 {
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
365 return this == dynamic_cast<const mx_deleting_memory_resource *> (&other);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
366 }
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
367 };
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
368
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
369 class mx_preserving_memory_resource : public std::pmr::memory_resource
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
370 {
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
371 private:
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
372
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
373 void * do_allocate (std::size_t bytes, size_t /*alignment*/)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
374 {
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
375 void *ptr = xmalloc (bytes);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
376
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
377 if (! ptr)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
378 throw std::bad_alloc ();
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
379
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
380 return ptr;
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
381 }
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
382
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
383 void do_deallocate (void* /*ptr*/, std::size_t /*bytes*/,
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
384 std::size_t /*alignment*/)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
385 { }
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
386
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
387 bool do_is_equal (const std::pmr::memory_resource& other) const noexcept
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
388 {
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
389 return this == dynamic_cast<const mx_preserving_memory_resource *> (&other);
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
390 }
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
391 };
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
392
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
393 // FIXME: Is it OK for the memory resource object to be defined this
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
394 // way?
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
395 static mx_deleting_memory_resource the_mx_deleting_memory_resource;
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
396 static mx_preserving_memory_resource the_mx_preserving_memory_resource;
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
397
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
398 static std::pmr::memory_resource *current_mx_memory_resource = &the_mx_deleting_memory_resource;
30494
ba5370c670d5 make use of <memory_resource> conditional on HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR
John W. Eaton <jwe@octave.org>
parents: 30488
diff changeset
399
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
400 #endif
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
401
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
402 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
403
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
404 mxArray_base::mxArray_base (bool interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
405 : m_interleaved (interleaved)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
406 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
407
7357
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
408 static mwIndex
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
409 calc_single_subscript_internal (mwSize ndims, const mwSize *dims,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
410 mwSize nsubs, const mwIndex *subs)
7357
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
411 {
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
412 mwIndex retval = 0;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
413
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
414 switch (nsubs)
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
415 {
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
416 case 0:
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
417 break;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
418
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
419 case 1:
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
420 retval = subs[0];
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
421 break;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
422
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
423 default:
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
424 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
425 // Both nsubs and ndims should be at least 2 here.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
426
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
427 mwSize n = (nsubs <= ndims ? nsubs : ndims);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
428
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
429 retval = subs[--n];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
430
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
431 while (--n >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
432 retval = dims[n] * retval + subs[n];
7357
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
433 }
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
434 break;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
435 }
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
436
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
437 return retval;
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
438 }
3a1e5a965815 [project @ 2008-01-10 19:28:38 by jwe]
jwe
parents: 7336
diff changeset
439
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
440 // 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
441 // 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
442 // 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
443 // 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
444 // 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
445 // 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
446 // 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
447 // 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
448 // 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
449 // happen once per call to a MEX file.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
450
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
451 static inline void * maybe_mark_foreign (void *ptr);
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
452
31362
4e12be13186d build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents: 31105
diff changeset
453 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
454 static inline void maybe_disown_ptr (void *ptr);
31362
4e12be13186d build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents: 31105
diff changeset
455 #endif
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
456
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
457 #define VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
458 void FCN_NAME ARG_LIST { request_mutation (); }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
459
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
460 #define CONST_VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
461 void FCN_NAME ARG_LIST const { request_mutation (); }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
462
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
463 #define MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
464 RET_TYPE FCN_NAME ARG_LIST { request_mutation (); return RET_VAL; }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
465
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
466 #define CONST_MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
467 RET_TYPE FCN_NAME ARG_LIST const { request_mutation (); return RET_VAL; }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
468
29869
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
469 #define GET_DATA_METHOD(RT, FCN_NAME, ID, COMPLEXITY) \
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
470 RT * FCN_NAME (void) const { return get_data<RT> (ID, COMPLEXITY); }
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
471
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
472 class mxArray_octave_value : public mxArray_base
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
473 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
474 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
475
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
476 mxArray_octave_value (bool interleaved, const octave_value& ov)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
477 : mxArray_base (interleaved), m_val (ov), m_mutate_flag (false),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
478 m_id (mxUNKNOWN_CLASS), m_class_name (nullptr), m_ndims (-1),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
479 m_dims (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
480 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
481
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
482 // No assignment! FIXME: should this be implemented? Note that we
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
483 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
484
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
485 mxArray_octave_value& operator = (const mxArray_octave_value&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
486
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
487 mxArray_base * dup (void) const { return new mxArray_octave_value (*this); }
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
488
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
489 mxArray * as_mxArray (void) const
12331
f39436e14734 mex.cc (mxArray_octave_value::dup): if value can't be converted to mxArray object, create a clone of the mxArray_octave_value container
John W. Eaton <jwe@octave.org>
parents: 12123
diff changeset
490 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
491 mxArray *retval = m_val.as_mxArray (m_interleaved);
17810
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
492
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
493 // RETVAL is assumed to be an mxArray_matlab object. Should we
30723
08b08b7f05b2 Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents: 30565
diff changeset
494 // error_unless that condition here?
17810
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
495
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
496 if (retval)
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
497 {
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
498 // Preserve cached values of class name and dimensions in case
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
499 // they will be used after we mutate.
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
500
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
501 // set_class_name will handle deleting class name that comes
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
502 // from as_mxArray conversion function.
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
503
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
504 if (m_class_name)
17810
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
505 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
506 retval->set_class_name (m_class_name);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
507
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
508 m_class_name = nullptr;
17810
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
509 }
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
510
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
511 if (m_dims)
17810
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
512 {
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
513 mwSize *xdims = retval->get_dimensions ();
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
514
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
515 mxFree (xdims);
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
516
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
517 retval->set_dimensions (m_dims, m_ndims);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
518
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
519 m_dims = nullptr;
17810
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
520 }
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
521 }
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
522
6da521da1c70 preserve cached mxArray_octave_value data while it's still in use (bug #40429)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
523 return retval;
12331
f39436e14734 mex.cc (mxArray_octave_value::dup): if value can't be converted to mxArray object, create a clone of the mxArray_octave_value container
John W. Eaton <jwe@octave.org>
parents: 12123
diff changeset
524 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
525
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
526 ~mxArray_octave_value (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
527 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
528 mxFree (m_class_name);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
529 mxFree (m_dims);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
530 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
531
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
532 bool is_octave_value (void) const { return true; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
533
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
534 int iscell (void) const { return m_val.iscell (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
535
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
536 int is_char (void) const { return m_val.is_string (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
537
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
538 int is_complex (void) const { return m_val.iscomplex (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
539
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
540 int is_double (void) const { return m_val.is_double_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
541
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
542 int is_function_handle (void) const { return m_val.is_function_handle (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
543
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
544 int is_int16 (void) const { return m_val.is_int16_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
545
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
546 int is_int32 (void) const { return m_val.is_int32_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
547
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
548 int is_int64 (void) const { return m_val.is_int64_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
549
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
550 int is_int8 (void) const { return m_val.is_int8_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
551
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
552 int is_logical (void) const { return m_val.islogical (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
553
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
554 int is_numeric (void) const { return m_val.isnumeric (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
555
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
556 int is_single (void) const { return m_val.is_single_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
557
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
558 int is_sparse (void) const { return m_val.issparse (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
559
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
560 int is_struct (void) const { return m_val.isstruct (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
561
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
562 int is_uint16 (void) const { return m_val.is_uint16_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
563
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
564 int is_uint32 (void) const { return m_val.is_uint32_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
565
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
566 int is_uint64 (void) const { return m_val.is_uint64_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
567
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
568 int is_uint8 (void) const { return m_val.is_uint8_type (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
569
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
570 int is_range (void) const { return m_val.is_range (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
571
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
572 int isreal (void) const { return m_val.isreal (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
573
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
574 int is_logical_scalar_true (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
575 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
576 return (is_logical_scalar () && m_val.is_true ());
5900
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
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
579 mwSize get_m (void) const { return m_val.rows (); }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
580
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
581 mwSize get_n (void) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
582 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
583 mwSize n = 1;
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
584
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
585 // Force m_dims and m_ndims to be cached.
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14840
diff changeset
586 get_dimensions ();
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
587
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
588 for (mwIndex i = m_ndims - 1; i > 0; i--)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
589 n *= m_dims[i];
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
590
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
591 return n;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
592 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
593
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
594 mwSize * get_dimensions (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
595 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
596 if (! m_dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
597 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
598 m_ndims = m_val.ndims ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
599
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
600 m_dims = static_cast<mwSize *> (mxArray::malloc (m_ndims
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
601 * sizeof (mwSize)));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
602
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
603 dim_vector dv = m_val.dims ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
604
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
605 for (mwIndex i = 0; i < m_ndims; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
606 m_dims[i] = dv(i);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
607 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
608
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
609 return m_dims;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
610 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
611
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
612 mwSize get_number_of_dimensions (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
613 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
614 // Force m_dims and m_ndims to be cached.
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
615 get_dimensions ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
616
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
617 return m_ndims;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
618 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
619
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
620 VOID_MUTATION_METHOD (set_m, (mwSize))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
621 VOID_MUTATION_METHOD (set_n, (mwSize))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
622
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
623 MUTATION_METHOD (int, set_dimensions, (mwSize *, mwSize), 0)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
624
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
625 mwSize get_number_of_elements (void) const { return m_val.numel (); }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
626
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
627 int isempty (void) const { return m_val.isempty (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
628
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
629 bool is_scalar (void) const
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
630 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
631 // Force m_dims and m_ndims to be cached.
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
632 get_dimensions ();
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
633
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
634 return m_ndims == 2 && m_dims[0] == 1 && m_dims[1] == 1;
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22480
diff changeset
635 }
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
636
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
637 mxClassID get_class_id (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
638 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
639 m_id = mxUNKNOWN_CLASS;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
640
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
641 std::string cn = m_val.class_name ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
642
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
643 if (cn == "double")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
644 m_id = mxDOUBLE_CLASS;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
645 else if (cn == "single")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
646 m_id = mxSINGLE_CLASS;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
647 else if (cn == "char")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
648 m_id = mxCHAR_CLASS;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
649 else if (cn == "logical")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
650 m_id = mxLOGICAL_CLASS;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
651 else if (cn == "cell")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
652 m_id = mxCELL_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
653 else if (cn == "struct")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
654 m_id = mxSTRUCT_CLASS;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
655 else if (cn == "function_handle")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
656 m_id = mxFUNCTION_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
657 else if (cn == "int8")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
658 m_id = mxINT8_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
659 else if (cn == "uint8")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
660 m_id = mxUINT8_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
661 else if (cn == "int16")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
662 m_id = mxINT16_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
663 else if (cn == "uint16")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
664 m_id = mxUINT16_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
665 else if (cn == "int32")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
666 m_id = mxINT32_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
667 else if (cn == "uint32")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
668 m_id = mxUINT32_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
669 else if (cn == "int64")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
670 m_id = mxINT64_CLASS;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
671 else if (cn == "uint64")
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
672 m_id = mxUINT64_CLASS;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
673
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
674 return m_id;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
675 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
676
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
677 const char * get_class_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
678 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
679 if (! m_class_name)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
680 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
681 std::string s = m_val.class_name ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
682 m_class_name = mxArray::strsave (s.c_str ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
683 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
684
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
685 return m_class_name;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
686 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
687
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
688 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
689 VOID_MUTATION_METHOD (set_class_name, (const char *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
690
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
691 mxArray * get_property (mwIndex idx, const char *pname) const
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
692 {
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
693 mxArray *retval = nullptr;
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
694
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
695 if (m_val.is_classdef_object ())
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
696 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
697 octave_classdef *ov_cdef = m_val.classdef_object_value ();
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
698
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
699 if (ov_cdef)
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
700 {
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
701 octave_value pval = ov_cdef->get_property (idx, pname);
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
702
23898
a490e729f2f2 correctly return NULL for unknown properties in mxGetProperty (bug #51725)
John W. Eaton <jwe@octave.org>
parents: 23893
diff changeset
703 if (pval.is_defined())
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
704 retval = new mxArray (m_interleaved, pval);
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
705 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
706 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
707
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
708 return retval;
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
709 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
710
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
711 void set_property (mwIndex idx, const char *pname, const mxArray *pval)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
712 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
713 if (m_val.is_classdef_object ())
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
714 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
715 octave_classdef *ov_cdef = m_val.classdef_object_value ();
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
716
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
717 if (ov_cdef)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
718 ov_cdef->set_property (idx, pname, pval->as_octave_value ());
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
719 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
720 else
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
721 err_invalid_type ("set_property");
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
722 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
723
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
724 CONST_MUTATION_METHOD (mxArray *, get_cell, (mwIndex), nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
725
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
726 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
727 VOID_MUTATION_METHOD (set_cell, (mwIndex, mxArray *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
728
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
729 double get_scalar (void) const
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
730 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
731 if (m_val.issparse ())
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
732 {
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22480
diff changeset
733 // For sparse arrays, return the first non-zero value.
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
734 const void *m_data = m_val.mex_get_data ();
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
735 if (m_data == nullptr)
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
736 return 0.0;
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
737
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
738 if (m_val.islogical ())
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
739 return *static_cast<const bool *> (m_data);
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
740 else if (m_val.isreal ())
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
741 return *static_cast<const double *> (m_data);
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
742 else // Complex type, only return real part
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
743 return *static_cast<const double *> (m_data);
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
744 }
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
745 else
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
746 return m_val.scalar_value (true);
22480
9263b2889003 Change mxGetScalar to return the first non-zero element of sparse array.
Rik <rik@octave.org>
parents: 22471
diff changeset
747 }
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
748
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
749 void * get_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
750 {
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
751 // Casting away const required for MEX interface.
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
752
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
753 void *retval = const_cast<void *> (m_val.mex_get_data ());
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
754
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
755 if (retval && (m_val.isreal () || m_interleaved))
29870
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
756 {
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
757 maybe_mark_foreign (retval);
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
758 return retval;
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
759 }
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
760
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
761 request_mutation ();
79fe39e852db mxArray_octave_value::get_data: fix mutation for non-interleaved complex data
John W. Eaton <jwe@octave.org>
parents: 29869
diff changeset
762 return nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
763 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
764
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
765 template <typename T>
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
766 T * get_data (mxClassID class_id, mxComplexity complexity) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
767 {
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
768 // Casting away const required for MEX interface.
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
769
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
770 void *ptr = const_cast<void *> (m_val.mex_get_data (class_id, complexity));
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
771
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
772 T *retval = static_cast<T *> (ptr);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
773
29869
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
774 if (retval && (complexity == mxREAL || m_interleaved))
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
775 {
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
776 maybe_mark_foreign (retval);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
777 return retval;
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
778 }
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
779
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
780 request_mutation ();
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
781 return nullptr;
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
782 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
783
29869
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
784 GET_DATA_METHOD (mxDouble, get_doubles, mxDOUBLE_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
785
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
786 GET_DATA_METHOD (mxSingle, get_singles, mxSINGLE_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
787
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
788 GET_DATA_METHOD (mxInt8, get_int8s, mxINT8_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
789
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
790 GET_DATA_METHOD (mxInt16, get_int16s, mxINT16_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
791
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
792 GET_DATA_METHOD (mxInt32, get_int32s, mxINT32_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
793
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
794 GET_DATA_METHOD (mxInt64, get_int64s, mxINT64_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
795
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
796 GET_DATA_METHOD (mxUint8, get_uint8s, mxUINT8_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
797
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
798 GET_DATA_METHOD (mxUint16, get_uint16s, mxUINT16_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
799
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
800 GET_DATA_METHOD (mxUint32, get_uint32s, mxUINT32_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
801
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
802 GET_DATA_METHOD (mxUint64, get_uint64s, mxUINT64_CLASS, mxREAL);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
803
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
804 GET_DATA_METHOD (mxComplexDouble, get_complex_doubles,
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
805 mxDOUBLE_CLASS, mxCOMPLEX);
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
806
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
807 GET_DATA_METHOD (mxComplexSingle, get_complex_singles,
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
808 mxDOUBLE_CLASS, mxCOMPLEX);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
809
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
810 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
811 /* We don't have these yet. */
29869
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
812 GET_DATA_METHOD (mxComplexInt8 *, get_complex_int8s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
813
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
814 GET_DATA_METHOD (mxComplexInt16 *, get_complex_int16s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
815
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
816 GET_DATA_METHOD (mxComplexInt32 *, get_complex_int32s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
817
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
818 GET_DATA_METHOD (mxComplexInt64 *, get_complex_int64s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
819
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
820 GET_DATA_METHOD (mxComplexUint8 *, get_complex_uint8s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
821
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
822 GET_DATA_METHOD (mxComplexUint16 *, get_complex_uint16s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
823
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
824 GET_DATA_METHOD (mxComplexUint32 *, get_complex_uint32s, (void), nullptr);
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
825
5411391a4cc0 allow typed mx get data functions to work without mutation in more cases
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
826 GET_DATA_METHOD (mxComplexUint64 *, get_complex_uint64s, (void), nullptr);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
827 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
828
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
829 void * get_imag_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
830 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
831 void *retval = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
832
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
833 if (is_numeric () && isreal ())
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
834 retval = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
835 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
836 request_mutation ();
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 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
839 }
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 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
842 VOID_MUTATION_METHOD (set_data, (void *))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
843
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
844 MUTATION_METHOD (int, set_doubles, (mxDouble *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
845 MUTATION_METHOD (int, set_singles, (mxSingle *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
846 MUTATION_METHOD (int, set_int8s, (mxInt8 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
847 MUTATION_METHOD (int, set_int16s, (mxInt16 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
848 MUTATION_METHOD (int, set_int32s, (mxInt32 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
849 MUTATION_METHOD (int, set_int64s, (mxInt64 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
850 MUTATION_METHOD (int, set_uint8s, (mxUint8 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
851 MUTATION_METHOD (int, set_uint16s, (mxUint16 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
852 MUTATION_METHOD (int, set_uint32s, (mxUint32 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
853 MUTATION_METHOD (int, set_uint64s, (mxUint64 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
854
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
855 MUTATION_METHOD (int, set_complex_doubles, (mxComplexDouble *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
856 MUTATION_METHOD (int, set_complex_singles, (mxComplexSingle *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
857 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
858 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
859 MUTATION_METHOD (int, set_complex_int8s, (mxComplexInt8 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
860 MUTATION_METHOD (int, set_complex_int16s, (mxComplexInt16 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
861 MUTATION_METHOD (int, set_complex_int32s, (mxComplexInt32 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
862 MUTATION_METHOD (int, set_complex_int64s, (mxComplexInt64 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
863 MUTATION_METHOD (int, set_complex_uint8s, (mxComplexUint8 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
864 MUTATION_METHOD (int, set_complex_uint16s, (mxComplexUint16 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
865 MUTATION_METHOD (int, set_complex_uint32s, (mxComplexUint32 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
866 MUTATION_METHOD (int, set_complex_uint64s, (mxComplexUint64 *), 0)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
867 #endif
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
868
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
869 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
870 VOID_MUTATION_METHOD (set_imag_data, (void *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
871
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
872 mwIndex * get_ir (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
873 {
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
874 // Casting away const required for MEX interface.
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
875
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
876 octave_idx_type *ptr = const_cast<octave_idx_type *> (m_val.mex_get_ir ());
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
877 return static_cast<mwIndex *> (maybe_mark_foreign (ptr));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
878 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
879
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
880 mwIndex * get_jc (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
881 {
30232
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
882 // Casting away const required for MEX interface.
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
883
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
884 octave_idx_type *ptr = const_cast<octave_idx_type *> (m_val.mex_get_jc ());
a2936935c7c8 attempt to limit possible const_cast damage
John W. Eaton <jwe@octave.org>
parents: 30227
diff changeset
885 return static_cast<mwIndex *> (maybe_mark_foreign (ptr));
5900
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
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
888 mwSize get_nzmax (void) const { return m_val.nzmax (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
889
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
890 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
891 VOID_MUTATION_METHOD (set_ir, (mwIndex *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
892
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
893 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
894 VOID_MUTATION_METHOD (set_jc, (mwIndex *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
895
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
896 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
897 VOID_MUTATION_METHOD (set_nzmax, (mwSize))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
898
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
899 // Not allowed.
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
900 MUTATION_METHOD (int, add_field, (const char *), 0)
5900
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 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
903 VOID_MUTATION_METHOD (remove_field, (int))
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
904
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
905 CONST_MUTATION_METHOD (mxArray *, get_field_by_number, (mwIndex, int), nullptr)
5900
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 // Not allowed.
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
908 VOID_MUTATION_METHOD (set_field_by_number, (mwIndex, int, mxArray *))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
909
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
910 int get_number_of_fields (void) const { return m_val.nfields (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
911
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
912 CONST_MUTATION_METHOD (const char *, get_field_name_by_number, (int), nullptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
913
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
914 CONST_MUTATION_METHOD (int, get_field_number, (const char *), 0)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
915
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
916 int get_string (char *buf, mwSize buflen) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
917 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
918 int retval = 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
919
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
920 mwSize nel = get_number_of_elements ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
921
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
922 if (m_val.is_string () && nel < buflen)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
923 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
924 charNDArray tmp = m_val.char_array_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
925
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
926 const char *p = tmp.data ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
927
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
928 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
929 buf[i] = p[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
930
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
931 buf[nel] = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
932
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
933 retval = 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
934 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
935
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
936 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
937 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
938
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
939 char * array_to_string (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
940 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
941 // FIXME: this is supposed to handle multi-byte character strings.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
942
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
943 char *buf = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
944
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
945 if (m_val.is_string ())
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
946 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
947 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
948
15354
93dff6435fe1 tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents: 15353
diff changeset
949 buf = static_cast<char *> (mxArray::malloc (nel + 1));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
950
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
951 if (buf)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
952 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
953 charNDArray tmp = m_val.char_array_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
954
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
955 const char *p = tmp.data ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
956
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
957 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
958 buf[i] = p[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
959
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
960 buf[nel] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
961 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
962 }
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 return buf;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
965 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
966
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
967 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
968 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
969 // Force m_ndims, n_dims to be cached.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
970 get_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
971
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
972 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
973 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
974
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
975 std::size_t get_element_size (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
976 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
977 // Force m_id to be cached.
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
978 get_class_id ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
979
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
980 switch (m_id)
5900
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 case mxCELL_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
983 case mxSTRUCT_CLASS: return sizeof (mxArray *);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
984 case mxLOGICAL_CLASS: return sizeof (mxLogical);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
985 case mxCHAR_CLASS: return sizeof (mxChar);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
986 case mxDOUBLE_CLASS: return get_numeric_element_size (sizeof (mxDouble));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
987 case mxSINGLE_CLASS: return get_numeric_element_size (sizeof (mxSingle));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
988 case mxINT8_CLASS: return get_numeric_element_size (sizeof (mxInt8));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
989 case mxUINT8_CLASS: return get_numeric_element_size (sizeof (mxUint8));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
990 case mxINT16_CLASS: return get_numeric_element_size (sizeof (mxInt16));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
991 case mxUINT16_CLASS: return get_numeric_element_size (sizeof (mxUint16));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
992 case mxINT32_CLASS: return get_numeric_element_size (sizeof (mxInt32));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
993 case mxUINT32_CLASS: return get_numeric_element_size (sizeof (mxUint32));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
994 case mxINT64_CLASS: return get_numeric_element_size (sizeof (mxInt64));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
995 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64));
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
996 case mxFUNCTION_CLASS: return 0;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
997 // FIXME: user-defined objects need their own class ID.
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
998 // What should they return, size of pointer?
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
999 default: return 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1000 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1001 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1002
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1003 bool mutation_needed (void) const { return m_mutate_flag; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1004
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1005 void request_mutation (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1006 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1007 if (m_mutate_flag)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1008 panic_impossible ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1009
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1010 m_mutate_flag = true;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1011 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1012
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1013 mxArray * mutate (void) const { return as_mxArray (); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1014
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1015 octave_value as_octave_value (void) const { return m_val; }
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
1016
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1017 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1018
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1019 mxArray_octave_value (const mxArray_octave_value& arg)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1020 : mxArray_base (arg), m_val (arg.m_val), m_mutate_flag (arg.m_mutate_flag),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1021 m_id (arg.m_id), m_class_name (mxArray::strsave (arg.m_class_name)),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1022 m_ndims (arg.m_ndims),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1023 m_dims (m_ndims > 0
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1024 ? static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1025 : nullptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1026 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1027 if (m_dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1028 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1029 for (mwIndex i = 0; i < m_ndims; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1030 m_dims[i] = arg.m_dims[i];
5900
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 }
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 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1035
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1036 octave_value m_val;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1037
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1038 mutable bool m_mutate_flag;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1039
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1040 // 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
1041 // 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
1042 // Matlab-style mxArray object.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1043
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1044 mutable mxClassID m_id;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1045 mutable char *m_class_name;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1046 mutable mwSize m_ndims;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1047 mutable mwSize *m_dims;
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1050 // 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
1051 // things that are common to all Matlab-style objects.
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 class mxArray_matlab : public mxArray_base
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 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1056
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1057 // No assignment!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1058 // FIXME: should this be implemented?
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1059 // Note that we *do* have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1060
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1061 mxArray_matlab& operator = (const mxArray_matlab&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1062
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1063 ~mxArray_matlab (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1064 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1065 mxFree (m_class_name);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1066 mxFree (m_dims);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1067 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1068
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1069 int iscell (void) const { return m_id == mxCELL_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1070
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1071 int is_char (void) const { return m_id == mxCHAR_CLASS; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1072
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1073 int is_complex (void) const { return 0; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1074
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1075 int is_double (void) const { return m_id == mxDOUBLE_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1076
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1077 int is_function_handle (void) const { return m_id == mxFUNCTION_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1078
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1079 int is_int16 (void) const { return m_id == mxINT16_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1080
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1081 int is_int32 (void) const { return m_id == mxINT32_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1082
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1083 int is_int64 (void) const { return m_id == mxINT64_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1084
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1085 int is_int8 (void) const { return m_id == mxINT8_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1086
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1087 int is_logical (void) const { return m_id == mxLOGICAL_CLASS; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1088
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1089 int is_numeric (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1090 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1091 return (m_id == mxDOUBLE_CLASS || m_id == mxSINGLE_CLASS
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1092 || m_id == mxINT8_CLASS || m_id == mxUINT8_CLASS
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1093 || m_id == mxINT16_CLASS || m_id == mxUINT16_CLASS
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1094 || m_id == mxINT32_CLASS || m_id == mxUINT32_CLASS
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1095 || m_id == mxINT64_CLASS || m_id == mxUINT64_CLASS);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1096 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1097
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1098 int is_single (void) const { return m_id == mxSINGLE_CLASS; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1099
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1100 int is_sparse (void) const { return 0; }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1101
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1102 int is_struct (void) const { return m_id == mxSTRUCT_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1103
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1104 int is_uint16 (void) const { return m_id == mxUINT16_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1105
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1106 int is_uint32 (void) const { return m_id == mxUINT32_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1107
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1108 int is_uint64 (void) const { return m_id == mxUINT64_CLASS; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1109
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1110 int is_uint8 (void) const { return m_id == mxUINT8_CLASS; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1111
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1112 int is_logical_scalar_true (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1113 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1114 return (is_logical_scalar ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1115 && static_cast<mxLogical *> (get_data ())[0] != 0);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1116 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1117
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1118 mwSize get_m (void) const { return m_dims[0]; }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1119
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1120 mwSize get_n (void) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1121 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1122 mwSize n = 1;
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1123
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1124 for (mwSize i = m_ndims - 1 ; i > 0 ; i--)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1125 n *= m_dims[i];
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1126
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1127 return n;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
1128 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1129
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1130 mwSize * get_dimensions (void) const { return m_dims; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1131
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1132 mwSize get_number_of_dimensions (void) const { return m_ndims; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1133
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1134 void set_m (mwSize m) { m_dims[0] = m; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1135
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1136 void set_n (mwSize n) { m_dims[1] = n; }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1137
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1138 int set_dimensions (mwSize *dims, mwSize ndims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1139 {
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1140 m_ndims = ndims;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1141
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1142 mxFree (m_dims);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1143
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1144 if (m_ndims > 0)
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1145 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1146 m_dims
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1147 = static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize)));
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1148
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1149 if (m_dims == nullptr)
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1150 return 1;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1151
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1152 for (int i = 0; i < m_ndims; i++)
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1153 m_dims[i] = dims[i];
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1154
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1155 return 0;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1156 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1157 else
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1158 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1159 m_dims = nullptr;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1160 return 0;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1161 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1162 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1163
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1164 mwSize get_number_of_elements (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1165 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1166 mwSize retval = m_dims[0];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1167
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1168 for (mwIndex i = 1; i < m_ndims; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1169 retval *= m_dims[i];
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1170
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1171 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1172 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1173
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
1174 int isempty (void) const { return get_number_of_elements () == 0; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1175
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1176 bool is_scalar (void) const
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1177 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1178 return m_ndims == 2 && m_dims[0] == 1 && m_dims[1] == 1;
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1179 }
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
1180
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1181 mxClassID get_class_id (void) const { return m_id; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1182
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1183 const char * get_class_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1184 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1185 switch (m_id)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1186 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1187 case mxDOUBLE_CLASS: return "double";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1188 case mxSINGLE_CLASS: return "single";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1189 case mxCHAR_CLASS: return "char";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1190 case mxLOGICAL_CLASS: return "logical";
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1191 case mxCELL_CLASS: return "cell";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1192 case mxSTRUCT_CLASS: return "struct";
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1193 case mxFUNCTION_CLASS: return "function_handle";
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1194 case mxINT8_CLASS: return "int8";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1195 case mxUINT8_CLASS: return "uint8";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1196 case mxINT16_CLASS: return "int16";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1197 case mxUINT16_CLASS: return "uint16";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1198 case mxINT32_CLASS: return "int32";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1199 case mxUINT32_CLASS: return "uint32";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1200 case mxINT64_CLASS: return "int64";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1201 case mxUINT64_CLASS: return "uint64";
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1202 case mxUNKNOWN_CLASS: return "unknown";
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1203 // FIXME: should return the classname of user-defined objects
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1204 default: return "unknown";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1205 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1206 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1207
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1208 void set_class_name (const char *name)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1209 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1210 mxFree (m_class_name);
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1211 m_class_name = static_cast<char *> (mxArray::malloc (strlen (name) + 1));
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1212 strcpy (m_class_name, name);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1213 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1214
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1215 mxArray * get_cell (mwIndex /*idx*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1216 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1217 err_invalid_type ("get_cell");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1218 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1219
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1220 void set_cell (mwIndex /*idx*/, mxArray * /*val*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1221 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1222 err_invalid_type ("set_cell");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1223 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1224
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1225 double get_scalar (void) const
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1226 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1227 err_invalid_type ("get_scalar");
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1228 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1229
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1230 void * get_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1231 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1232 err_invalid_type ("get_data");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1233 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1234
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1235 mxDouble * get_doubles (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1236 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1237 err_invalid_type ("get_doubles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1238 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1239
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1240 mxSingle * get_singles (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1241 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1242 err_invalid_type ("get_singles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1243 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1244
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1245 mxInt8 * get_int8s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1246 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1247 err_invalid_type ("get_int8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1248 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1249
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1250 mxInt16 * get_int16s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1251 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1252 err_invalid_type ("get_int16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1253 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1254
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1255 mxInt32 * get_int32s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1256 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1257 err_invalid_type ("get_int32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1258 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1259
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1260 mxInt64 * get_int64s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1261 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1262 err_invalid_type ("get_int64s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1263 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1264
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1265 mxUint8 * get_uint8s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1266 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1267 err_invalid_type ("get_uint8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1268 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1269
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1270 mxUint16 * get_uint16s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1271 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1272 err_invalid_type ("get_uint16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1273 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1274
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1275 mxUint32 * get_uint32s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1276 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1277 err_invalid_type ("get_uint32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1278 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1279
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1280 mxUint64 * get_uint64s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1281 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1282 err_invalid_type ("get_uint64s");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1283 }
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 mxComplexDouble * get_complex_doubles (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1286 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1287 err_invalid_type ("get_complex_doubles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1288 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1289
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1290 mxComplexSingle * get_complex_singles (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1291 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1292 err_invalid_type ("get_complex_singles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1293 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1294
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1295 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1296 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1297 mxComplexInt8 * get_complex_int8s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1298 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1299 err_invalid_type ("get_complex_int8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1300 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1301
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1302 mxComplexInt16 * get_complex_int16s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1303 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1304 err_invalid_type ("get_complex_int16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1305 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1306
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1307 mxComplexInt32 * get_complex_int32s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1308 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1309 err_invalid_type ("get_complex_int32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1310 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1311
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1312 mxComplexInt64 * get_complex_int64s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1313 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1314 err_invalid_type ("get_complex_int64s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1315 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1316
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1317 mxComplexUint8 * get_complex_uint8s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1318 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1319 err_invalid_type ("get_complex_uint8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1320 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1321
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1322 mxComplexUint16 * get_complex_uint16s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1323 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1324 err_invalid_type ("get_complex_uint16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1325 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1326
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1327 mxComplexUint32 * get_complex_uint32s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1328 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1329 err_invalid_type ("get_complex_uint32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1330 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1331
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1332 mxComplexUint64 * get_complex_uint64s (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1333 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1334 err_invalid_type ("get_complex_uint64s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1335 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1336 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1337
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1338 void * get_imag_data (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1339 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1340 err_invalid_type ("get_imag_data");
5900
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
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1343 void set_data (void * /*pr*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1344 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1345 err_invalid_type ("set_data");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1346 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1347
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1348 int set_doubles (mxDouble *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1349 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1350 err_invalid_type ("set_doubles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1351 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1352
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1353 int set_singles (mxSingle *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1354 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1355 err_invalid_type ("set_singles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1356 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1357
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1358 int set_int8s (mxInt8 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1359 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1360 err_invalid_type ("set_int8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1361 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1362
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1363 int set_int16s (mxInt16 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1364 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1365 err_invalid_type ("set_int16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1366 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1367
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1368 int set_int32s (mxInt32 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1369 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1370 err_invalid_type ("set_int32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1371 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1372
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1373 int set_int64s (mxInt64 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1374 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1375 err_invalid_type ("set_int64s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1376 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1377
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1378 int set_uint8s (mxUint8 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1379 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1380 err_invalid_type ("set_uint8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1381 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1382
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1383 int set_uint16s (mxUint16 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1384 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1385 err_invalid_type ("set_uint16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1386 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1387
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1388 int set_uint32s (mxUint32 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1389 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1390 err_invalid_type ("set_uint32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1391 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1392
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1393 int set_uint64s (mxUint64 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1394 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1395 err_invalid_type ("set_uint64s");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1396 }
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 int set_complex_doubles (mxComplexDouble *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1399 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1400 err_invalid_type ("set_complex_doubles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1401 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1402
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1403 int set_complex_singles (mxComplexSingle *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1404 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1405 err_invalid_type ("set_complex_singles");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1406 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1407
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1408 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1409 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1410 int set_complex_int8s (mxComplexInt8 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1411 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1412 err_invalid_type ("set_complex_int8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1413 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1414
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1415 int set_complex_int16s (mxComplexInt16 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1416 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1417 err_invalid_type ("set_complex_int16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1418 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1419
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1420 int set_complex_int32s (mxComplexInt32 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1421 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1422 err_invalid_type ("set_complex_int32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1423 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1424
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1425 int set_complex_int64s (mxComplexInt64 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1426 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1427 err_invalid_type ("set_complex_int64s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1428 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1429
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1430 int set_complex_uint8s (mxComplexUint8 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1431 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1432 err_invalid_type ("set_complex_uint8s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1433 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1434
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1435 int set_complex_uint16s (mxComplexUint16 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1436 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1437 err_invalid_type ("set_complex_uint16s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1438 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1439
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1440 int set_complex_uint32s (mxComplexUint32 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1441 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1442 err_invalid_type ("set_complex_uint32s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1443 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1444
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1445 int set_complex_uint64s (mxComplexUint64 *)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1446 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1447 err_invalid_type ("set_complex_uint64s");
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1448 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1449 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1450
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1451 void set_imag_data (void * /*pi*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1452 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1453 err_invalid_type ("set_imag_data");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1454 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1455
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1456 mwIndex * get_ir (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1457 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1458 err_invalid_type ("get_ir");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1459 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1460
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1461 mwIndex * get_jc (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1462 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1463 err_invalid_type ("get_jc");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1464 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1465
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1466 mwSize get_nzmax (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1467 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1468 err_invalid_type ("get_nzmax");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1469 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1470
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1471 void set_ir (mwIndex * /*ir*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1472 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1473 err_invalid_type ("set_ir");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1474 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1475
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1476 void set_jc (mwIndex * /*jc*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1477 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1478 err_invalid_type ("set_jc");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1479 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1480
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1481 void set_nzmax (mwSize /*nzmax*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1482 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1483 err_invalid_type ("set_nzmax");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1484 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1485
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1486 int add_field (const char * /*key*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1487 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1488 err_invalid_type ("add_field");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1489 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1490
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1491 void remove_field (int /*key_num*/)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1492 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1493 err_invalid_type ("remove_field");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1494 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1495
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1496 mxArray * get_field_by_number (mwIndex /*index*/, int /*key_num*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1497 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1498 err_invalid_type ("get_field_by_number");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1499 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1500
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1501 void set_field_by_number (mwIndex /*index*/, int /*key_num*/,
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1502 mxArray * /*val*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1503 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1504 err_invalid_type ("set_field_by_number");
5900
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 int get_number_of_fields (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1508 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1509 err_invalid_type ("get_number_of_fields");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1510 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1511
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1512 const char * get_field_name_by_number (int /*key_num*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1513 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1514 err_invalid_type ("get_field_name_by_number");
5900
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
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1517 int get_field_number (const char * /*key*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1518 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1519 return -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1520 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1521
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
1522 int get_string (char * /*buf*/, mwSize /*buflen*/) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1523 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1524 err_invalid_type ("get_string");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1525 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1526
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1527 char * array_to_string (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1528 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1529 err_invalid_type ("array_to_string");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1530 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1531
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1532 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
1533 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1534 return calc_single_subscript_internal (m_ndims, m_dims, nsubs, subs);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1535 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1536
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1537 std::size_t get_element_size (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1538 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1539 switch (m_id)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1540 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1541 case mxCELL_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1542 case mxSTRUCT_CLASS: return sizeof (mxArray *);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1543 case mxLOGICAL_CLASS: return sizeof (mxLogical);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1544 case mxCHAR_CLASS: return sizeof (mxChar);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1545 case mxDOUBLE_CLASS: return get_numeric_element_size (sizeof (mxDouble));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1546 case mxSINGLE_CLASS: return get_numeric_element_size (sizeof (mxSingle));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1547 case mxINT8_CLASS: return get_numeric_element_size (sizeof (mxInt8));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1548 case mxUINT8_CLASS: return get_numeric_element_size (sizeof (mxUint8));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1549 case mxINT16_CLASS: return get_numeric_element_size (sizeof (mxInt16));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1550 case mxUINT16_CLASS: return get_numeric_element_size (sizeof (mxUint16));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1551 case mxINT32_CLASS: return get_numeric_element_size (sizeof (mxInt32));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1552 case mxUINT32_CLASS: return get_numeric_element_size (sizeof (mxUint32));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1553 case mxINT64_CLASS: return get_numeric_element_size (sizeof (mxInt64));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1554 case mxUINT64_CLASS: return get_numeric_element_size (sizeof (mxUint64));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1555 case mxFUNCTION_CLASS: return 0;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1556 // FIXME: user-defined objects need their own class ID.
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1557 // What should they return, size of pointer?
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1558 default: return 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1559 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1560 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1561
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1562 protected:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1563
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1564 mxArray_matlab (bool interleaved, mxClassID id = mxUNKNOWN_CLASS)
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
1565 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id),
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
1566 m_ndims (0), m_dims (nullptr)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1567 { }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1568
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1569 mxArray_matlab (bool interleaved, mxClassID id, mwSize ndims,
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1570 const mwSize *dims)
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1571 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id),
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1572 m_ndims (ndims < 2 ? 2 : ndims),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1573 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1574 {
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1575 if (ndims == 0)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1576 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1577 m_dims[0] = 0;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1578 m_dims[1] = 0;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1579 }
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1580 else if (ndims < 2)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1581 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1582 m_dims[0] = 1;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1583 m_dims[1] = 1;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1584 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1585
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1586 for (mwIndex i = 0; i < ndims; i++)
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1587 m_dims[i] = dims[i];
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1588
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1589 for (mwIndex i = m_ndims - 1; i > 1; i--)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1590 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1591 if (m_dims[i] == 1)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1592 m_ndims--;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1593 else
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1594 break;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1595 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1596 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1597
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1598 mxArray_matlab (bool interleaved, mxClassID id, const dim_vector& dv)
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1599 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1600 m_ndims (dv.ndims ()),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1601 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1602 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1603 for (mwIndex i = 0; i < m_ndims; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1604 m_dims[i] = dv(i);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1605
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1606 for (mwIndex i = m_ndims - 1; i > 1; i--)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1607 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1608 if (m_dims[i] == 1)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1609 m_ndims--;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1610 else
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1611 break;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1612 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1613 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1614
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1615 mxArray_matlab (bool interleaved, mxClassID id, mwSize m, mwSize n)
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
1616 : mxArray_base (interleaved), m_class_name (nullptr), m_id (id),
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30232
diff changeset
1617 m_ndims (2),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1618 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1619 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1620 m_dims[0] = m;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1621 m_dims[1] = n;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1622 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1623
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1624 mxArray_matlab (const mxArray_matlab& val)
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1625 : mxArray_base (val), m_class_name (mxArray::strsave (val.m_class_name)),
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1626 m_id (val.m_id), m_ndims (val.m_ndims),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1627 m_dims (static_cast<mwSize *> (mxArray::malloc (m_ndims * sizeof (mwSize))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1628 {
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1629 for (mwIndex i = 0; i < m_ndims; i++)
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1630 m_dims[i] = val.m_dims[i];
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1631 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1632
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1633 dim_vector
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1634 dims_to_dim_vector (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1635 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1636 mwSize nd = get_number_of_dimensions ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1637
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1638 mwSize *d = get_dimensions ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1639
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1640 dim_vector dv;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1641 dv.resize (nd);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1642
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1643 for (mwIndex i = 0; i < nd; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1644 dv(i) = d[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1645
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1646 return dv;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1647 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1648
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1649 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1650
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1651 char *m_class_name;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1652
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1653 mxClassID m_id;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1654
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1655 mwSize m_ndims;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1656 mwSize *m_dims;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1657 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1658
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1659
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1660 // Matlab-style numeric, character, and logical data.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1661
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1662 class mxArray_base_full : public mxArray_matlab
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1663 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1664 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1665
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1666 mxArray_base_full (bool interleaved, mxClassID id, mwSize ndims,
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1667 const mwSize *dims, bool init = true)
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
1668 : mxArray_matlab (interleaved, id, ndims, dims),
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1669 m_pr (mxArray::alloc (init, get_number_of_elements (), get_element_size ()))
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1670 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1671
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1672 mxArray_base_full (bool interleaved, mxClassID id, const dim_vector& dv)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1673 : mxArray_matlab (interleaved, id, dv),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1674 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ()))
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1675 { }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1676
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1677 mxArray_base_full (bool interleaved, mxClassID id, mwSize m, mwSize n,
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1678 bool init = true)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1679 : mxArray_matlab (interleaved, id, m, n),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1680 m_pr (mxArray::alloc (init, get_number_of_elements (), get_element_size ()))
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
1681 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1682
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1683 mxArray_base_full (bool interleaved, mxClassID id, double val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1684 : mxArray_matlab (interleaved, id, 1, 1),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1685 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ()))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1686 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1687 double *dpr = static_cast<double *> (m_pr);
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1688 dpr[0] = val;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1689 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1690
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1691 mxArray_base_full (bool interleaved, mxClassID id, mxLogical val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1692 : mxArray_matlab (interleaved, id, 1, 1),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1693 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ()))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1694 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1695 mxLogical *lpr = static_cast<mxLogical *> (m_pr);
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
1696 lpr[0] = val;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1697 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1698
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1699 mxArray_base_full (bool interleaved, const char *str)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1700 : mxArray_matlab (interleaved, mxCHAR_CLASS,
10853
c3813056f94f mxArray_number (const char *): create empty string if given NULL arg
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
1701 str ? (strlen (str) ? 1 : 0) : 0,
c3813056f94f mxArray_number (const char *): create empty string if given NULL arg
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
1702 str ? strlen (str) : 0),
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1703 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ()))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1704 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1705 mxChar *cpr = static_cast<mxChar *> (m_pr);
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1706 mwSize nel = get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1707 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1708 cpr[i] = str[i];
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1709 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1710
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17810
diff changeset
1711 // FIXME: ???
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1712 mxArray_base_full (bool interleaved, mwSize m, const char **str)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1713 : mxArray_matlab (interleaved, mxCHAR_CLASS, m, max_str_len (m, str)),
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
1714 m_pr (mxArray::calloc (get_number_of_elements (), get_element_size ()))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1715 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1716 mxChar *cpr = static_cast<mxChar *> (m_pr);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1717
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1718 mwSize *dv = get_dimensions ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1719
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1720 mwSize nc = dv[1];
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1721
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
1722 for (mwIndex j = 0; j < m; j++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1723 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1724 const char *ptr = str[j];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1725
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1726 std::size_t tmp_len = strlen (ptr);
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1727
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1728 for (std::size_t i = 0; i < tmp_len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1729 cpr[m*i+j] = static_cast<mxChar> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1730
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1731 for (std::size_t i = tmp_len; i < static_cast<std::size_t> (nc); i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1732 cpr[m*i+j] = static_cast<mxChar> (' ');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1733 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1734 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1735
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1736 // No assignment! FIXME: should this be implemented? Note that we
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1737 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1738
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1739 mxArray_base_full& operator = (const mxArray_base_full&);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
1740
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1741 mxArray_base * dup (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1742 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1743 return new mxArray_base_full (*this);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1744 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1745
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
1746 ~mxArray_base_full (void)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
1747 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1748 mxFree (m_pr);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1749 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
1750
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1751 double get_scalar (void) const
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1752 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1753 // FIXME: how does this work for interleaved complex arrays?
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1754
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1755 double retval = 0;
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1756
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1757 switch (get_class_id ())
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1758 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1759 case mxDOUBLE_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1760 retval = *(static_cast<double *> (m_pr));
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1761 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1762
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1763 case mxSINGLE_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1764 retval = *(static_cast<float *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1765 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1766
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1767 case mxCHAR_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1768 retval = *(static_cast<mxChar *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1769 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1770
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
1771 case mxLOGICAL_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1772 retval = *(static_cast<bool *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1773 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1774
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1775 case mxINT8_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1776 retval = *(static_cast<int8_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1777 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1778
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1779 case mxUINT8_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1780 retval = *(static_cast<uint8_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1781 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1782
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1783 case mxINT16_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1784 retval = *(static_cast<int16_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1785 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1786
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1787 case mxUINT16_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1788 retval = *(static_cast<uint16_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1789 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1790
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1791 case mxINT32_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1792 retval = *(static_cast<int32_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1793 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1794
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1795 case mxUINT32_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1796 retval = *(static_cast<uint32_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1797 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1798
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1799 case mxINT64_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1800 retval = *(static_cast<int64_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1801 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1802
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1803 case mxUINT64_CLASS:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1804 retval = *(static_cast<uint64_t *> (m_pr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1805 break;
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1806
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1807 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
1808 panic_impossible ();
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1809 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1810
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1811 return retval;
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1812 }
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
1813
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1814 void * get_data (void) const { return m_pr; }
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1815
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1816 void set_data (void *pr) { m_pr = pr; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
1817
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1818 // The typed get and set functions only work for interleaved data but
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1819 // they are defined here because this class owns PR. There are
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1820 // definitions in the mxArray_separate_full class that override these
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1821 // functions.
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1822
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1823 mxDouble * get_doubles (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1824 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1825 return static_cast<mxDouble *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1826 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1827
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1828 mxSingle * get_singles (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1829 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1830 return static_cast<mxSingle *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1831 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1832
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1833 mxInt8 * get_int8s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1834 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1835 return static_cast<mxInt8 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1836 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1837
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1838 mxInt16 * get_int16s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1839 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1840 return static_cast<mxInt16 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1841 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1842
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1843 mxInt32 * get_int32s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1844 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1845 return static_cast<mxInt32 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1846 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1847
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1848 mxInt64 * get_int64s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1849 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1850 return static_cast<mxInt64 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1851 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1852
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1853 mxUint8 * get_uint8s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1854 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1855 return static_cast<mxUint8 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1856 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1857
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1858 mxUint16 * get_uint16s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1859 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1860 return static_cast<mxUint16 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1861 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1862
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1863 mxUint32 * get_uint32s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1864 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1865 return static_cast<mxUint32 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1866 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1867
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1868 mxUint64 * get_uint64s (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1869 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1870 return static_cast<mxUint64 *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1871 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1872
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1873 mxComplexDouble * get_complex_doubles (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1874 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1875 return static_cast<mxComplexDouble *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1876 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1877
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1878 mxComplexSingle * get_complex_singles (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1879 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1880 return static_cast<mxComplexSingle *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1881 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1882
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1883 #if 0
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1884 // We don't have these data types.
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1885
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1886 int get_complex_int8s (mxComplexInt8 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1887 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1888 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1889 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1890 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1891
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1892 int get_complex_int16s (mxComplexInt16 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1893 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1894 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1895 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1896 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1897
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1898 int get_complex_int32s (mxComplexInt32 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1899 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1900 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1901 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1902 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1903
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1904 int get_complex_int64s (mxComplexInt64 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1905 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1906 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1907 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1908 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1909
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1910 int get_complex_uint8s (mxComplexUint8 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1911 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1912 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1913 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1914 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1915
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1916 int get_complex_uint16s (mxComplexUint16 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1917 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1918 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1919 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1920 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1921
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1922 int get_complex_uint32s (mxComplexUint32 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1923 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1924 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1925 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1926 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1927
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1928 int get_complex_uint64s (mxComplexUint64 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1929 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1930 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1931 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1932 }
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1933 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1934
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1935 int set_doubles (mxDouble *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1936 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1937 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1938 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1939 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1940
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1941 int set_singles (mxSingle *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1942 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1943 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1944 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1945 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1946
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1947 int set_int8s (mxInt8 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1948 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1949 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1950 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1951 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1952
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1953 int set_int16s (mxInt16 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1954 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1955 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1956 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1957 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1958
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1959 int set_int32s (mxInt32 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1960 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1961 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1962 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1963 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1964
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1965 int set_int64s (mxInt64 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1966 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1967 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1968 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1969 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1970
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1971 int set_uint8s (mxUint8 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1972 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1973 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1974 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1975 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1976
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1977 int set_uint16s (mxUint16 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1978 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1979 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1980 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1981 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1982
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1983 int set_uint32s (mxUint32 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1984 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1985 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1986 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1987 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1988
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1989 int set_uint64s (mxUint64 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1990 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1991 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1992 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1993 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1994
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1995 int set_complex_doubles (mxComplexDouble *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1996 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1997 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1998 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
1999 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2000
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2001 int set_complex_singles (mxComplexSingle *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2002 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2003 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2004 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2005 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2006
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2007 #if 0
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2008 // We don't have these data types.
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2009
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2010 int set_complex_int8s (mxComplexInt8 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2011 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2012 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2013 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2014 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2015
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2016 int set_complex_int16s (mxComplexInt16 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2017 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2018 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2019 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2020 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2021
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2022 int set_complex_int32s (mxComplexInt32 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2023 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2024 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2025 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2026 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2027
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2028 int set_complex_int64s (mxComplexInt64 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2029 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2030 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2031 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2032 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2033
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2034 int set_complex_uint8s (mxComplexUint8 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2035 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2036 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2037 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2038 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2039
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2040 int set_complex_uint16s (mxComplexUint16 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2041 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2042 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2043 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2044 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2045
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2046 int set_complex_uint32s (mxComplexUint32 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2047 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2048 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2049 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2050 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2051
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2052 int set_complex_uint64s (mxComplexUint64 *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2053 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2054 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2055 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2056 }
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2057 #endif
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2058
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2059 int get_string (char *buf, mwSize buflen) const
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2060 {
13753
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2061 int retval = 0;
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2062
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2063 mwSize nel = get_number_of_elements ();
6493
5fa513371dde [project @ 2007-04-05 14:53:49 by jwe]
jwe
parents: 6400
diff changeset
2064
13753
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2065 if (! (nel < buflen))
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2066 {
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2067 retval = 1;
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2068 if (buflen > 0)
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2069 nel = buflen-1;
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2070 }
ab4238b0b09b Change return value of mxGetString to match Matlab (Bug #34546)
Rik <octave@nomad.inbox5.com>
parents: 12472
diff changeset
2071
6493
5fa513371dde [project @ 2007-04-05 14:53:49 by jwe]
jwe
parents: 6400
diff changeset
2072 if (nel < buflen)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2073 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2074 mxChar *ptr = static_cast<mxChar *> (m_pr);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2075
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2076 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2077 buf[i] = static_cast<char> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2078
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2079 buf[nel] = 0;
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2080 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2081
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2082 return retval;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2083 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2084
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2085 char * array_to_string (void) const
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2086 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2087 // FIXME: this is supposed to handle multi-byte character strings.
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2088
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2089 mwSize nel = get_number_of_elements ();
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2090
15354
93dff6435fe1 tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents: 15353
diff changeset
2091 char *buf = static_cast<char *> (mxArray::malloc (nel + 1));
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2092
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2093 if (buf)
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2094 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2095 mxChar *ptr = static_cast<mxChar *> (m_pr);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2096
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2097 for (mwIndex i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2098 buf[i] = static_cast<char> (ptr[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2099
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2100 buf[nel] = '\0';
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2101 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2102
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2103 return buf;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2104 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2105
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2106 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2107 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2108 octave_value retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2109
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2110 dim_vector dv = dims_to_dim_vector ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2111
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2112 switch (get_class_id ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2113 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2114 case mxDOUBLE_CLASS:
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2115 return (is_complex ()
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2116 ? fp_to_ov<Complex> (dv) : fp_to_ov<double> (dv));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2117
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2118 case mxSINGLE_CLASS:
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2119 return (is_complex ()
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2120 ? fp_to_ov<FloatComplex> (dv) : fp_to_ov<float> (dv));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2121
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2122 case mxCHAR_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2123 return int_to_ov<mxChar, charNDArray, char> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2124
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2125 case mxLOGICAL_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2126 return int_to_ov<mxLogical, boolNDArray, bool> (dv);
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2127
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2128 case mxINT8_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2129 return int_to_ov<int8_t, int8NDArray, octave_int8> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2130
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2131 case mxUINT8_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2132 return int_to_ov<uint8_t, uint8NDArray, octave_uint8> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2133
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2134 case mxINT16_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2135 return int_to_ov<int16_t, int16NDArray, octave_int16> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2136
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2137 case mxUINT16_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2138 return int_to_ov<uint16_t, uint16NDArray, octave_uint16> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2139
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2140 case mxINT32_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2141 return int_to_ov<int32_t, int32NDArray, octave_int32> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2142
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2143 case mxUINT32_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2144 return int_to_ov<uint32_t, uint32NDArray, octave_uint32> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2145
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2146 case mxINT64_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2147 return int_to_ov<int64_t, int64NDArray, octave_int64> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2148
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2149 case mxUINT64_CLASS:
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2150 return int_to_ov<uint64_t, uint64NDArray, octave_uint64> (dv);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2151
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2152 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2153 panic_impossible ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2154 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2155
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2156 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2157 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2158
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2159 protected:
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2160
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2161 mxArray_base_full (const mxArray_base_full& val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2162 : mxArray_matlab (val),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2163 m_pr (mxArray::malloc (get_number_of_elements () * get_element_size ()))
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2164 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2165 if (m_pr)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2166 memcpy (m_pr, val.m_pr, get_number_of_elements () * get_element_size ());
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2167 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2168
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2169 template <typename ELT_T>
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2170 octave_value
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2171 fp_to_ov (const dim_vector& dv) const
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2172 {
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2173 octave_value retval;
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2174
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2175 ELT_T *ppr = static_cast<ELT_T *> (m_pr);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2176
30501
79a7f3e3cf54 Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30494
diff changeset
2177 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2178
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2179 if (current_mx_memory_resource == &the_mx_deleting_memory_resource)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2180 {
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2181 octave::unwind_action act ([=] () { maybe_disown_ptr (m_pr); });
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2182
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2183 return octave_value (Array<ELT_T> (ppr, dv, current_mx_memory_resource));
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2184 }
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2185 else
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2186 return octave_value (Array<ELT_T> (ppr, dv, current_mx_memory_resource));
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2187
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2188 #else
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2189
30769
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2190 // Copy data instead of allowing the octave_value object to borrow
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2191 // the mxArray object data.
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2192
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2193 Array<ELT_T> val (dv);
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2194
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2195 ELT_T *ptr = val.fortran_vec ();
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2196
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2197 mwSize nel = get_number_of_elements ();
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2198
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2199 for (mwIndex i = 0; i < nel; i++)
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2200 ptr[i] = ppr[i];
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2201
822649f5f193 don't mix operator new and free (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30768
diff changeset
2202 return octave_value (val);
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2203
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2204 #endif
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2205 }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2206
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2207 template <typename ELT_T, typename ARRAY_T, typename ARRAY_ELT_T>
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2208 octave_value
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2209 int_to_ov (const dim_vector& dv) const
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2210 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2211 if (is_complex ())
21151
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2212 error ("complex integer types are not supported");
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2213
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2214 ELT_T *ppr = static_cast<ELT_T *> (m_pr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2215
30501
79a7f3e3cf54 Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30494
diff changeset
2216 #if 0 && defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2217
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2218 // FIXME: Currently not allowed because we don't have the necessary
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2219 // constructors for integer arrays.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2220
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2221 octave::unwind_action act ([=] () { maybe_disown_ptr (m_pr); });
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2222
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2223 return ARRAY_T (ppr, dv, current_mx_memory_resource);
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2224
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2225 #else
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2226
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2227 // Copy data instead of allowing the octave_value object to borrow
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
2228 // the mxArray object data.
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2229
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2230 ARRAY_T val (dv);
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2231
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2232 ARRAY_ELT_T *ptr = val.fortran_vec ();
21151
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2233
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2234 mwSize nel = get_number_of_elements ();
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2235
21151
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2236 for (mwIndex i = 0; i < nel; i++)
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2237 ptr[i] = ppr[i];
bfd5e48c41a1 Rename local error in mex I/F from invalid_type_error to err_invalid_type.
Rik <rik@octave.org>
parents: 20940
diff changeset
2238
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2239 return octave_value (val);
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2240
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2241 #endif
15351
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2242 }
a291f850743c modernize mxArray class hierarchy
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
2243
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2244 protected:
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2245
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2246 // If using interleaved complex storage, this is the pointer to data
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2247 // (real, complex, or logical). Otherwise, it is the pointer to the
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2248 // real part of the data.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2249 void *m_pr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2250 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2251
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2252 class mxArray_interleaved_full : public mxArray_base_full
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2253 {
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2254 public:
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2255
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2256 mxArray_interleaved_full (mxClassID id, mwSize ndims, const mwSize *dims,
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2257 mxComplexity flag = mxREAL, bool init = true)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2258 : mxArray_base_full (true, id, ndims, dims, init),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2259 m_complex (flag == mxCOMPLEX)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2260 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2261
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2262 mxArray_interleaved_full (mxClassID id, const dim_vector& dv,
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2263 mxComplexity flag = mxREAL)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2264 : mxArray_base_full (true, id, dv),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2265 m_complex (flag == mxCOMPLEX)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2266 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2267
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2268 mxArray_interleaved_full (mxClassID id, mwSize m, mwSize n,
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2269 mxComplexity flag = mxREAL, bool init = true)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2270 : mxArray_base_full (true, id, m, n, init),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2271 m_complex (flag == mxCOMPLEX)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2272 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2273
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2274 mxArray_interleaved_full (mxClassID id, double val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2275 : mxArray_base_full (true, id, val), m_complex (false)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2276 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2277
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2278 mxArray_interleaved_full (mxClassID id, mxLogical val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2279 : mxArray_base_full (true, id, val), m_complex (false)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2280 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2281
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2282 mxArray_interleaved_full (const char *str)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2283 : mxArray_base_full (true, str), m_complex (false)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2284 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2285
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2286 // FIXME: ???
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2287 mxArray_interleaved_full (mwSize m, const char **str)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2288 : mxArray_base_full (true, m, str), m_complex (false)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2289 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2290
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2291 // No assignment! FIXME: should this be implemented? Note that we
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2292 // do have a copy constructor.
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2293
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2294 mxArray_interleaved_full& operator = (const mxArray_interleaved_full&);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2295
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2296 mxArray_base * dup (void) const
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2297 {
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2298 return new mxArray_interleaved_full (*this);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2299 }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2300
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2301 ~mxArray_interleaved_full (void) = default;
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2302
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2303 int is_complex (void) const { return m_complex; }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2304
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2305 void * get_imag_data (void) const { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2306
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2307 void set_imag_data (void */*pi*/) { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2308
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2309 protected:
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2310
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2311 mxArray_interleaved_full (const mxArray_interleaved_full& val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2312 : mxArray_base_full (val), m_complex (val.m_complex)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2313 { }
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2314
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2315 // Flag to identify complex object.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2316 bool m_complex;
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2317 };
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2318
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2319 class mxArray_separate_full : public mxArray_base_full
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2320 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2321 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2322
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2323 mxArray_separate_full (mxClassID id, mwSize ndims, const mwSize *dims,
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2324 mxComplexity flag = mxREAL, bool init = true)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2325 : mxArray_base_full (false, id, ndims, dims, init),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2326 m_pi (flag == mxCOMPLEX
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2327 ? mxArray::alloc (init, get_number_of_elements (), get_element_size ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2328 : nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2329 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2330
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2331 mxArray_separate_full (mxClassID id, const dim_vector& dv,
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2332 mxComplexity flag = mxREAL)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2333 : mxArray_base_full (false, id, dv),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2334 m_pi (flag == mxCOMPLEX
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2335 ? mxArray::calloc (get_number_of_elements (), get_element_size ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2336 : nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2337 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2338
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2339 mxArray_separate_full (mxClassID id, mwSize m, mwSize n,
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2340 mxComplexity flag = mxREAL, bool init = true)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2341 : mxArray_base_full (false, id, m, n, init),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2342 m_pi (flag == mxCOMPLEX
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2343 ? (mxArray::alloc (init, get_number_of_elements (), get_element_size ()))
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2344 : nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2345 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2346
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2347 mxArray_separate_full (mxClassID id, double val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2348 : mxArray_base_full (false, id, val), m_pi (nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2349 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2350
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2351 mxArray_separate_full (mxClassID id, mxLogical val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2352 : mxArray_base_full (false, id, val), m_pi (nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2353 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2354
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2355 mxArray_separate_full (const char *str)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2356 : mxArray_base_full (false, str), m_pi (nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2357 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2358
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2359 // FIXME: ???
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2360 mxArray_separate_full (mwSize m, const char **str)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2361 : mxArray_base_full (false, m, str), m_pi (nullptr)
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2362 { }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2363
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2364 // No assignment! FIXME: should this be implemented? Note that we
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2365 // do have a copy constructor.
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2366
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2367 mxArray_separate_full& operator = (const mxArray_separate_full&);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2368
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2369 mxArray_base * dup (void) const
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2370 {
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2371 return new mxArray_separate_full (*this);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2372 }
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2373
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2374 ~mxArray_separate_full (void)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2375 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2376 mxFree (m_pi);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2377 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2378
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2379 int is_complex (void) const { return m_pi != nullptr; }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2380
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2381 void * get_imag_data (void) const { return m_pi; }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2382
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2383 void set_imag_data (void *pi) { m_pi = pi; }
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2384
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2385 mxDouble * get_doubles (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2386 mxSingle * get_singles (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2387 mxInt8 * get_int8s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2388 mxInt16 * get_int16s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2389 mxInt32 * get_int32s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2390 mxInt64 * get_int64s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2391 mxUint8 * get_uint8s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2392 mxUint16 * get_uint16s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2393 mxUint32 * get_uint32s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2394 mxUint64 * get_uint64s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2395
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2396 mxComplexDouble * get_complex_doubles (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2397 mxComplexSingle * get_complex_singles (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2398
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2399 // We don't have complex integer types, but for separate storage they
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2400 // still would not work.
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2401 mxComplexInt8 * get_complex_int8s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2402 mxComplexInt16 * get_complex_int16s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2403 mxComplexInt32 * get_complex_int32s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2404 mxComplexInt64 * get_complex_int64s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2405 mxComplexUint8 * get_complex_uint8s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2406 mxComplexUint16 * get_complex_uint16s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2407 mxComplexUint32 * get_complex_uint32s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2408 mxComplexUint64 * get_complex_uint64s (void) const { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2409
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2410 int set_doubles (mxDouble *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2411 int set_singles (mxSingle *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2412 int set_int8s (mxInt8 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2413 int set_int16s (mxInt16 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2414 int set_int32s (mxInt32 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2415 int set_int64s (mxInt64 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2416 int set_uint8s (mxUint8 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2417 int set_uint16s (mxUint16 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2418 int set_uint32s (mxUint32 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2419 int set_uint64s (mxUint64 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2420
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2421 int set_complex_doubles (mxComplexDouble *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2422 int set_complex_singles (mxComplexSingle *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2423
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2424 // We don't have complex integer types, but for separate storage they
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2425 // still would not work.
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2426 int set_complex_int8s (mxComplexInt8 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2427 int set_complex_int16s (mxComplexInt16 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2428 int set_complex_int32s (mxComplexInt32 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2429 int set_complex_int64s (mxComplexInt64 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2430 int set_complex_uint8s (mxComplexUint8 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2431 int set_complex_uint16s (mxComplexUint16 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2432 int set_complex_uint32s (mxComplexUint32 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2433 int set_complex_uint64s (mxComplexUint64 *) { panic_impossible (); }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2434
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2435 octave_value as_octave_value (void) const
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2436 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2437 if (! is_complex ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2438 return mxArray_base_full::as_octave_value ();
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2439
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2440 octave_value retval;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2441
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2442 dim_vector dv = dims_to_dim_vector ();
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2443
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2444 switch (get_class_id ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2445 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2446 case mxDOUBLE_CLASS:
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2447 return to_ov<double> (dv);
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2448
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2449 case mxSINGLE_CLASS:
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2450 return to_ov<float> (dv);
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2451
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2452 case mxLOGICAL_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2453 case mxINT8_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2454 case mxUINT8_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2455 case mxINT16_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2456 case mxUINT16_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2457 case mxINT32_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2458 case mxUINT32_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2459 case mxINT64_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2460 case mxUINT64_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2461 error ("complex integer types are not supported");
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2462
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2463 default:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2464 panic_impossible ();
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2465 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2466
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2467 return retval;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2468 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2469
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2470 protected:
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2471
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2472 mxArray_separate_full (const mxArray_separate_full& val)
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2473 : mxArray_base_full (val),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2474 m_pi (val.m_pi
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2475 ? mxArray::malloc (get_number_of_elements () * get_element_size ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2476 : nullptr)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2477 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2478 if (m_pi)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2479 memcpy (m_pi, val.m_pi, get_number_of_elements () * get_element_size ());
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2480 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2481
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2482 private:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2483
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2484 template <typename T>
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2485 octave_value
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2486 to_ov (const dim_vector& dv) const
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2487 {
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2488 mwSize nel = get_number_of_elements ();
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2489
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2490 T *ppr = static_cast<T *> (m_pr);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2491
30488
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2492 // We allocate in the Array<T> constructor and copy here, so we
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2493 // don't need the custom allocator for this object.
abb4823df535 with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents: 30428
diff changeset
2494
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2495 Array<std::complex<T>> val (dv);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2496
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2497 std::complex<T> *ptr = val.fortran_vec ();
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2498
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2499 T *ppi = static_cast<T *> (m_pi);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2500
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2501 for (mwIndex i = 0; i < nel; i++)
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2502 ptr[i] = std::complex<T> (ppr[i], ppi[i]);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2503
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2504 return octave_value (val);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2505 }
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2506
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2507 // Pointer to the imaginary part of the data.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2508 void *m_pi;
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2509 };
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2510
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2511 // Matlab-style sparse arrays.
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2512
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2513 class mxArray_base_sparse : public mxArray_matlab
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2514 {
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2515 public:
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2516
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2517 mxArray_base_sparse (bool interleaved, mxClassID id, mwSize m, mwSize n,
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2518 mwSize nzmax)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2519 : mxArray_matlab (interleaved, id, m, n),
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2520
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2521 m_nzmax (nzmax > 0 ? nzmax : 1),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2522 m_ir (static_cast<mwIndex *> (mxArray::calloc (m_nzmax, sizeof (mwIndex)))),
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2523 m_jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex)))),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2524 m_pr (mxArray::calloc (m_nzmax, get_element_size ()))
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2525 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2526
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2527 protected:
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2528
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2529 mxArray_base_sparse (const mxArray_base_sparse& val)
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2530 : mxArray_matlab (val), m_nzmax (val.m_nzmax),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2531 m_ir (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))),
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2532 m_jc (static_cast<mwIndex *> (mxArray::malloc (m_nzmax * sizeof (mwIndex)))),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2533 m_pr (mxArray::malloc (m_nzmax * get_element_size ()))
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2534 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2535 if (m_ir)
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2536 memcpy (m_ir, val.m_ir, m_nzmax * sizeof (mwIndex));
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2537
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2538 if (m_jc)
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2539 memcpy (m_jc, val.m_jc, (val.get_n () + 1) * sizeof (mwIndex));
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2540
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2541 if (m_pr)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2542 memcpy (m_pr, val.m_pr, m_nzmax * get_element_size ());
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2543 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2544
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2545 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2546
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2547 // No assignment! FIXME: should this be implemented? Note that we
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2548 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2549
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2550 mxArray_base_sparse& operator = (const mxArray_base_sparse&);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2551
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2552 mxArray_base * dup (void) const
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2553 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2554 return new mxArray_base_sparse (*this);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2555 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2556
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2557 ~mxArray_base_sparse (void)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2558 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2559 mxFree (m_ir);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2560 mxFree (m_jc);
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2561 mxFree (m_pr);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2562 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2563
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2564 int is_sparse (void) const { return 1; }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2565
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2566 void * get_data (void) const { return m_pr; }
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2567
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2568 void set_data (void *pr) { m_pr = pr; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2569
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2570 mxDouble * get_doubles (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2571 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2572 return static_cast<mxDouble *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2573 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2574
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2575 mxComplexDouble * get_complex_doubles (void) const
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2576 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2577 return static_cast<mxComplexDouble *> (m_pr);
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2578 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2579
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2580 int set_doubles (mxDouble *d)
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2581 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2582 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2583 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2584 }
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2585
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2586 int set_complex_doubles (mxComplexDouble *d)
30225
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2587 {
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2588 m_pr = d;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2589 return 0;
3a988323d5d7 refactor typed data get and set methods for mxArray objects
John W. Eaton <jwe@octave.org>
parents: 30224
diff changeset
2590 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2591
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2592 mwIndex * get_ir (void) const { return m_ir; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2593
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2594 mwIndex * get_jc (void) const { return m_jc; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2595
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2596 mwSize get_nzmax (void) const { return m_nzmax; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2597
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2598 void set_ir (mwIndex *ir) { m_ir = ir; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2599
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2600 void set_jc (mwIndex *jc) { m_jc = jc; }
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2601
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2602 void set_nzmax (mwSize nzmax)
27083
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2603 {
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2604 /* Require storage for at least 1 element */
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2605 m_nzmax = (nzmax > 0 ? nzmax : 1);
27083
23761e83756f Always reserve memory for 1-element in sparse mxArray matrices (bug #56232).
Rik <rik@octave.org>
parents: 26997
diff changeset
2606 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
2607
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2608 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2609 {
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2610 octave_value retval;
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2611
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2612 dim_vector dv = dims_to_dim_vector ();
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2613
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2614 switch (get_class_id ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2615 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2616 case mxDOUBLE_CLASS:
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2617 return is_complex () ? to_ov<Complex> (dv): to_ov<double> (dv);
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2618
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2619 case mxSINGLE_CLASS:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2620 error ("single precision sparse data type not supported");
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2621
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2622 case mxLOGICAL_CLASS:
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2623 return to_ov<bool> (dv);
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2624
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2625 default:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2626 panic_impossible ();
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2627 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2628
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2629 return retval;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2630 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2631
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2632 protected:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2633
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2634 template <typename ELT_T>
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2635 octave_value
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2636 to_ov (const dim_vector& dv) const
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2637 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2638 ELT_T *ppr = static_cast<ELT_T *> (m_pr);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2639
30792
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2640 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2641
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2642 if (current_mx_memory_resource == &the_mx_deleting_memory_resource)
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2643 {
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2644 octave::unwind_action act ([=] () {
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2645 maybe_disown_ptr (m_pr);
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2646 maybe_disown_ptr (m_ir);
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2647 maybe_disown_ptr (m_jc);
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2648 });
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2649
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2650 return octave_value
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2651 (Sparse<ELT_T> (dv, static_cast<octave_idx_type> (m_nzmax),
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2652 ppr, m_ir, m_jc, current_mx_memory_resource));
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2653 }
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2654 else
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2655 return octave_value
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2656 (Sparse<ELT_T> (dv, static_cast<octave_idx_type> (m_nzmax),
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2657 ppr, m_ir, m_jc, current_mx_memory_resource));
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2658 #else
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2659
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2660 // Copy data instead of allowing the octave_value object to borrow
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2661 // the mxArray object data.
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2662
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2663 octave_idx_type m = dv(0);
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2664 octave_idx_type n = dv(1);
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2665
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2666 Sparse<ELT_T> val (m, n, static_cast<octave_idx_type> (m_nzmax));
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2667
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2668 for (mwIndex i = 0; i < m_nzmax; i++)
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2669 {
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2670 val.xdata (i) = ppr[i];
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2671 val.xridx (i) = m_ir[i];
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2672 }
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2673
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2674 for (mwIndex i = 0; i < n + 1; i++)
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2675 val.xcidx (i) = m_jc[i];
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2676
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2677 return octave_value (val);
30792
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2678
4fc0b7269803 use allocators for sparse mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30770
diff changeset
2679 #endif
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2680 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2681
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2682 // Maximun number of nonzero elements.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2683 mwSize m_nzmax;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2684
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2685 // Sparse storage indexing arrays.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2686 mwIndex *m_ir;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2687 mwIndex *m_jc;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2688
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2689 // If using interleaved complex storage, this is the pointer to data
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2690 // (real, complex, or logical). Otherwise, it is the pointer to the
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2691 // real part of the data.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2692 void *m_pr;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2693 };
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2694
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2695 class mxArray_interleaved_sparse : public mxArray_base_sparse
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2696 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2697 public:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2698
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2699 mxArray_interleaved_sparse (mxClassID id, mwSize m, mwSize n, mwSize nzmax,
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2700 mxComplexity flag = mxREAL)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2701 : mxArray_base_sparse (true, id, m, n, nzmax),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2702 m_complex (flag == mxCOMPLEX)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2703 { }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2704
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2705 private:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2706
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2707 mxArray_interleaved_sparse (const mxArray_interleaved_sparse& val)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2708 : mxArray_base_sparse (val), m_complex (val.m_complex)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2709 { }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2710
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2711 public:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2712
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2713 // No assignment! FIXME: should this be implemented? Note that we
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2714 // do have a copy constructor.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2715
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2716 mxArray_interleaved_sparse& operator = (const mxArray_interleaved_sparse&);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2717
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2718 mxArray_base * dup (void) const
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2719 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2720 return new mxArray_interleaved_sparse (*this);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2721 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2722
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2723 ~mxArray_interleaved_sparse (void) = default;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2724
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2725 int is_complex (void) const { return m_complex; }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2726
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2727 void * get_imag_data (void) const { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2728
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2729 void set_imag_data (void */*pi*/) { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2730
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2731 private:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2732
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2733 // Flag to identify complex object if using interleaved data and PI is
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2734 // always nullptr.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2735 bool m_complex;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2736 };
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2737
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2738 class mxArray_separate_sparse : public mxArray_base_sparse
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2739 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2740 public:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2741
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2742 mxArray_separate_sparse (mxClassID id, mwSize m, mwSize n, mwSize nzmax,
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2743 mxComplexity flag = mxREAL)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2744 : mxArray_base_sparse (false, id, m, n, nzmax),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2745 m_pi (flag == mxCOMPLEX
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2746 ? mxArray::calloc (m_nzmax, get_element_size ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2747 : nullptr)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2748 { }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2749
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2750 private:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2751
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2752 mxArray_separate_sparse (const mxArray_separate_sparse& val)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2753 : mxArray_base_sparse (val),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2754 m_pi (val.m_pi
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2755 ? mxArray::malloc (m_nzmax * get_element_size ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2756 : nullptr)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2757 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2758 if (m_pi)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2759 memcpy (m_pi, val.m_pi, m_nzmax * get_element_size ());
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2760 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2761
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2762 public:
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2763
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2764 // No assignment! FIXME: should this be implemented? Note that we
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2765 // do have a copy constructor.
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2766
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2767 mxArray_separate_sparse& operator = (const mxArray_separate_sparse&);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2768
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2769 mxArray_base * dup (void) const
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2770 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2771 return new mxArray_separate_sparse (*this);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2772 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2773
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2774 ~mxArray_separate_sparse (void)
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2775 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2776 mxFree (m_pi);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2777 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2778
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2779 int is_complex (void) const
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2780 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2781 return m_pi != nullptr;
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2782 }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2783
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2784 void * get_imag_data (void) const { return m_pi; }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2785
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2786 void set_imag_data (void *pi) { m_pi = pi; }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2787
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2788 mxDouble * get_doubles (void) const { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2789 mxComplexDouble * get_complex_doubles (void) const { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2790
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2791 int set_doubles (mxDouble *) { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2792 int set_complex_doubles (mxComplexDouble *) { panic_impossible (); }
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2793
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2794 octave_value as_octave_value (void) const
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2795 {
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2796 if (! is_complex ())
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2797 return mxArray_base_sparse::as_octave_value ();
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2798
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2799 octave_value retval;
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2800
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2801 dim_vector dv = dims_to_dim_vector ();
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
2802
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2803 switch (get_class_id ())
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2804 {
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2805 case mxDOUBLE_CLASS:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2806 {
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2807 double *ppr = static_cast<double *> (m_pr);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2808 double *ppi = static_cast<double *> (m_pi);
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2809
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2810 SparseComplexMatrix val (get_m (), get_n (),
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2811 static_cast<octave_idx_type> (m_nzmax));
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2812
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2813 for (mwIndex i = 0; i < m_nzmax; i++)
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2814 {
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2815 val.xdata (i) = Complex (ppr[i], ppi[i]);
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2816 val.xridx (i) = m_ir[i];
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2817 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2818
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2819 for (mwIndex i = 0; i < get_n () + 1; i++)
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2820 val.xcidx (i) = m_jc[i];
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2821
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2822 retval = val;
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2823 }
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2824 break;
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2825
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2826 case mxSINGLE_CLASS:
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2827 error ("single precision sparse data type not supported");
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
2828
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2829 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2830 panic_impossible ();
5903
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2831 }
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2832
11bb9bf343a0 [project @ 2006-07-26 03:36:33 by jwe]
jwe
parents: 5902
diff changeset
2833 return retval;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2834 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2835
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2836 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2837
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
2838 // Pointer to the imaginary part of the data.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2839 void *m_pi;
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2840 };
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
2841
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2842 // Matlab-style struct arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2843
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2844 class mxArray_struct : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2845 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2846 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2847
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2848 mxArray_struct (bool interleaved, mwSize ndims, const mwSize *dims,
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2849 int num_keys, const char **keys)
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2850 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, ndims, dims),
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2851 m_nfields (num_keys),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2852 m_fields (static_cast<char **> (mxArray::calloc (m_nfields,
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2853 sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2854 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields *
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2855 get_number_of_elements (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2856 sizeof (mxArray *))))
5900
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 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2859 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2860
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2861 mxArray_struct (bool interleaved, const dim_vector& dv, int num_keys,
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2862 const char **keys)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2863 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, dv),
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2864 m_nfields (num_keys),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2865 m_fields (static_cast<char **> (mxArray::calloc (m_nfields,
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2866 sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2867 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields *
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2868 get_number_of_elements (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2869 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2870 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2871 init (keys);
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
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2874 mxArray_struct (bool interleaved, mwSize m, mwSize n, int num_keys,
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2875 const char **keys)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
2876 : mxArray_matlab (interleaved, mxSTRUCT_CLASS, m, n),
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
2877 m_nfields (num_keys),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2878 m_fields (static_cast<char **> (mxArray::calloc (m_nfields,
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2879 sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2880 m_data (static_cast<mxArray **> (mxArray::calloc (m_nfields *
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2881 get_number_of_elements (),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2882 sizeof (mxArray *))))
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2883 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2884 init (keys);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2885 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2886
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2887 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2888
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2889 mxArray_struct (const mxArray_struct& val)
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2890 : mxArray_matlab (val), m_nfields (val.m_nfields),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2891 m_fields (static_cast<char **> (mxArray::malloc (m_nfields
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2892 * sizeof (char *)))),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2893 m_data (static_cast<mxArray **> (mxArray::malloc (m_nfields *
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2894 get_number_of_elements ()
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2895 * sizeof (mxArray *))))
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2896 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2897 for (int i = 0; i < m_nfields; i++)
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2898 m_fields[i] = mxArray::strsave (val.m_fields[i]);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2899
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2900 mwSize nel = get_number_of_elements ();
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2901
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2902 for (mwIndex i = 0; i < nel * m_nfields; i++)
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2903 {
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2904 mxArray *ptr = val.m_data[i];
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2905 m_data[i] = (ptr ? ptr->dup () : nullptr);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2906 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2907 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2908
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2909 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2910
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2911 // No assignment! FIXME: should this be implemented? Note that we
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2912 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2913
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
2914 mxArray_struct& operator = (const mxArray_struct& val);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
2915
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2916 void init (const char **keys)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2917 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2918 for (int i = 0; i < m_nfields; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2919 m_fields[i] = mxArray::strsave (keys[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2920 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2921
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
2922 mxArray_base * dup (void) const { return new mxArray_struct (*this); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2923
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2924 ~mxArray_struct (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2925 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2926 for (int i = 0; i < m_nfields; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2927 mxFree (m_fields[i]);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2928
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2929 mxFree (m_fields);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2930
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2931 mwSize ntot = m_nfields * get_number_of_elements ();
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2932
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
2933 for (mwIndex i = 0; i < ntot; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2934 delete m_data[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2935
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2936 mxFree (m_data);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2937 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2938
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2939 int add_field (const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2940 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2941 int retval = -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2942
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2943 m_nfields++;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2944
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2945 m_fields = static_cast<char **>
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2946 (mxRealloc (m_fields, m_nfields * sizeof (char *)));
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2947
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2948 if (m_fields)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2949 {
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2950 m_fields[m_nfields-1] = mxArray::strsave (key);
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2951
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2952 mwSize nel = get_number_of_elements ();
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2953
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2954 mwSize ntot = m_nfields * nel;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2955
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2956 mxArray **new_data;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2957 new_data = static_cast<mxArray **>
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2958 (mxArray::malloc (ntot * sizeof (mxArray *)));
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2959
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2960 if (new_data)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2961 {
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2962 mwIndex j = 0;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2963 mwIndex k = 0;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2964 mwIndex n = 0;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2965
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2966 for (mwIndex i = 0; i < ntot; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2967 {
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2968 if (++n == m_nfields)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2969 {
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2970 new_data[j++] = nullptr;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2971 n = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2972 }
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2973 else
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2974 new_data[j++] = m_data[k++];
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2975 }
30349
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2976
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2977 mxFree (m_data);
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2978
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2979 m_data = new_data;
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2980
5c6c5c8bbefd mxAddField: Allow keys to contain any characters (bug #61537)
John W. Eaton <jwe@octave.org>
parents: 30232
diff changeset
2981 retval = m_nfields - 1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2982 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2983 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2984
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2985 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2986 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2987
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2988 void remove_field (int key_num)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2989 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2990 if (key_num >= 0 && key_num < m_nfields)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
2991 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2992 mwSize nel = get_number_of_elements ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2993
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2994 mwSize ntot = m_nfields * nel;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2995
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
2996 int new_nfields = m_nfields - 1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
2997
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2998 char **new_fields = static_cast<char **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2999 (mxArray::malloc (new_nfields * sizeof (char *)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3000
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3001 mxArray **new_data = static_cast<mxArray **>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3002 (mxArray::malloc (new_nfields * nel
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3003 * sizeof (mxArray *)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3004
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3005 for (int i = 0; i < key_num; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3006 new_fields[i] = m_fields[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3007
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3008 for (int i = key_num + 1; i < m_nfields; i++)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3009 new_fields[i-1] = m_fields[i];
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3010
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3011 if (new_nfields > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3012 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3013 mwIndex j = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3014 mwIndex k = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3015 mwIndex n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3016
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3017 for (mwIndex i = 0; i < ntot; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3018 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3019 if (n == key_num)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3020 k++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3021 else
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3022 new_data[j++] = m_data[k++];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3023
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3024 if (++n == m_nfields)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3025 n = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3026 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3027 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3028
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3029 m_nfields = new_nfields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3030
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3031 mxFree (m_fields);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3032 mxFree (m_data);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3033
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3034 m_fields = new_fields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3035 m_data = new_data;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3036 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3037 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3038
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3039 mxArray * get_field_by_number (mwIndex index, int key_num) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3040 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3041 return key_num >= 0 && key_num < m_nfields
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3042 ? m_data[m_nfields * index + key_num] : nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3043 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3044
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3045 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
3046
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3047 int get_number_of_fields (void) const { return m_nfields; }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3048
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3049 const char * get_field_name_by_number (int key_num) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3050 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3051 return key_num >= 0 && key_num < m_nfields ? m_fields[key_num] : nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3052 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3053
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3054 int get_field_number (const char *key) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3055 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3056 int retval = -1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3057
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3058 for (int i = 0; i < m_nfields; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3059 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3060 if (! strcmp (key, m_fields[i]))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3061 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3062 retval = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3063 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3064 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3065 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3066
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3067 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3068 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3069
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3070 void * get_data (void) const { return m_data; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3071
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3072 void set_data (void *data) { m_data = static_cast<mxArray **> (data); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3073
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3074 octave_value as_octave_value (void) const
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3075 {
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3076 dim_vector dv = dims_to_dim_vector ();
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3077
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3078 string_vector keys (m_fields, m_nfields);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3079
25922
34e82a829fdd Create scalar structs of size 1x1 with MEX interface (bug #54799).
Rik <rik@octave.org>
parents: 25751
diff changeset
3080 octave_map m (dv);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3081
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3082 mwSize ntot = m_nfields * get_number_of_elements ();
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3083
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3084 for (int i = 0; i < m_nfields; i++)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3085 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3086 Cell c (dv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3087
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3088 octave_value *p = c.fortran_vec ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3089
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3090 mwIndex k = 0;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3091 for (mwIndex j = i; j < ntot; j += m_nfields)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3092 p[k++] = mxArray::as_octave_value (m_data[j]);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3093
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3094 m.assign (keys[i], c);
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3095 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3096
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3097 return m;
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3098 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3099
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3100 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3101
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3102 int m_nfields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3103
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3104 char **m_fields;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3105
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3106 mxArray **m_data;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3107 };
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3108
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3109 // Matlab-style cell arrays.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3110
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3111 class mxArray_cell : public mxArray_matlab
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3112 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3113 public:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3114
30213
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
3115 mxArray_cell (bool interleaved, mwSize ndims, const mwSize *dims)
27791344a45c * mex.cc: Don't use _arg prefix for function argument names if possible.
John W. Eaton <jwe@octave.org>
parents: 30212
diff changeset
3116 : mxArray_matlab (interleaved, mxCELL_CLASS, ndims, dims),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3117 m_data (static_cast<mxArray **> (
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3118 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3119 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3120
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3121 mxArray_cell (bool interleaved, const dim_vector& dv)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3122 : mxArray_matlab (interleaved, mxCELL_CLASS, dv),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3123 m_data (static_cast<mxArray **> (
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3124 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3125 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3126
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3127 mxArray_cell (bool interleaved, mwSize m, mwSize n)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3128 : mxArray_matlab (interleaved, mxCELL_CLASS, m, n),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3129 m_data (static_cast<mxArray **> (
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3130 mxArray::calloc (get_number_of_elements (), sizeof (mxArray *))))
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3131 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3132
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3133 private:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3134
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3135 mxArray_cell (const mxArray_cell& val)
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3136 : mxArray_matlab (val),
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3137 m_data (static_cast<mxArray **> (
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3138 mxArray::malloc (get_number_of_elements () * sizeof (mxArray *))))
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3139 {
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3140 mwSize nel = get_number_of_elements ();
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3141
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3142 for (mwIndex i = 0; i < nel; i++)
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3143 {
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3144 mxArray *ptr = val.m_data[i];
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3145 m_data[i] = (ptr ? ptr->dup () : nullptr);
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3146 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3147 }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3148
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3149 public:
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3150
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3151 // No assignment! FIXME: should this be implemented? Note that we
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3152 // do have a copy constructor.
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3153
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3154 mxArray_cell& operator = (const mxArray_cell&);
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3155
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3156 mxArray_base * dup (void) const { return new mxArray_cell (*this); }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3157
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3158 ~mxArray_cell (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3159 {
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3160 mwSize nel = get_number_of_elements ();
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3161
22449
e337b8e3592c Fix double free causing segfault in mxSetDimensions (bug #49010).
Rik <rik@octave.org>
parents: 22407
diff changeset
3162 for (mwIndex i = 0; i < nel; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3163 delete m_data[i];
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3164
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3165 mxFree (m_data);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3166 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3167
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3168 mxArray * get_cell (mwIndex idx) const
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
3169 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3170 return idx >= 0 && idx < get_number_of_elements () ? m_data[idx] : nullptr;
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
3171 }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3172
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3173 void set_cell (mwIndex idx, mxArray *val);
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3174
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3175 void * get_data (void) const { return m_data; }
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3176
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3177 void set_data (void *data) { m_data = static_cast<mxArray **> (data); }
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3178
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3179 octave_value as_octave_value (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3180 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3181 dim_vector dv = dims_to_dim_vector ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3182
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3183 Cell c (dv);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3184
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3185 mwSize nel = get_number_of_elements ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3186
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3187 octave_value *p = c.fortran_vec ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3188
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3189 for (mwIndex i = 0; i < nel; i++)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3190 p[i] = mxArray::as_octave_value (m_data[i]);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3191
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3192 return c;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3193 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3194
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3195 private:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3196
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3197 mxArray **m_data;
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3200 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3201
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3202 mxArray::mxArray (bool interleaved, const octave_value& ov)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3203 : m_rep (create_rep (interleaved, ov)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3204 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3205
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3206 mxArray::mxArray (bool interleaved, mxClassID id, mwSize ndims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3207 const mwSize *dims, mxComplexity flag, bool init)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3208 : m_rep (create_rep (interleaved, id, ndims, dims, flag, init)),
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3209 m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3210 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3211
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3212 mxArray::mxArray (bool interleaved, mxClassID id, const dim_vector& dv,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3213 mxComplexity flag)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3214 : m_rep (create_rep (interleaved, id, dv, flag)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3215 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3216
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3217 mxArray::mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n,
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
3218 mxComplexity flag, bool init)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3219 : m_rep (create_rep (interleaved, id, m, n, flag, init)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3220 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3221
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3222 mxArray::mxArray (bool interleaved, mxClassID id, double val)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3223 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3224 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3225
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3226 mxArray::mxArray (bool interleaved, mxClassID id, mxLogical val)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3227 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3228 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3229
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3230 mxArray::mxArray (bool interleaved, const char *str)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3231 : m_rep (create_rep (interleaved, str)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3232 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3233
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3234 mxArray::mxArray (bool interleaved, mwSize m, const char **str)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3235 : m_rep (create_rep (interleaved, m, str)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3236 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3237
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3238 mxArray::mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3239 mwSize nzmax, mxComplexity flag)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3240 : m_rep (create_rep (interleaved, id, m, n, nzmax, flag)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3241 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3242
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3243 mxArray::mxArray (bool interleaved, mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3244 int num_keys,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3245 const char **keys)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3246 : m_rep (new mxArray_struct (interleaved, ndims, dims, num_keys, keys)),
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3247 m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3248 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3249
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3250 mxArray::mxArray (bool interleaved, const dim_vector& dv, int num_keys,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3251 const char **keys)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3252 : m_rep (new mxArray_struct (interleaved, dv, num_keys, keys)),
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3253 m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3254 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3255
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3256 mxArray::mxArray (bool interleaved, mwSize m, mwSize n, int num_keys,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3257 const char **keys)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3258 : m_rep (new mxArray_struct (interleaved, m, n, num_keys, keys)),
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3259 m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3260 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3261
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3262 mxArray::mxArray (bool interleaved, mwSize ndims, const mwSize *dims)
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3263 : m_rep (new mxArray_cell (interleaved, ndims, dims)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3264 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3265
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3266 mxArray::mxArray (bool interleaved, const dim_vector& dv)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3267 : m_rep (new mxArray_cell (interleaved, dv)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3268 { }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3269
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3270 mxArray::mxArray (bool interleaved, mwSize m, mwSize n)
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3271 : m_rep (new mxArray_cell (interleaved, m, n)), m_name (nullptr)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3272 { }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3273
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3274 mxArray::~mxArray (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3275 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3276 mxFree (m_name);
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3277
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3278 delete m_rep;
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3281 void
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3282 mxArray::set_name (const char *name)
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3283 {
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3284 mxFree (m_name);
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3285 m_name = mxArray::strsave (name);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3286 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3287
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3288 octave_value
25451
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
3289 mxArray::as_octave_value (const mxArray *ptr, bool null_is_empty)
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3290 {
25451
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
3291 static const octave_value empty_matrix = Matrix ();
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
3292
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
3293 return (ptr
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
3294 ? ptr->as_octave_value ()
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
3295 : (null_is_empty ? empty_matrix : octave_value ()));
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3296 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3297
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3298 octave_value
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3299 mxArray::as_octave_value (void) const
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3300 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3301 return m_rep->as_octave_value ();
5907
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3302 }
288c341438f9 [project @ 2006-07-27 03:21:02 by jwe]
jwe
parents: 5905
diff changeset
3303
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3304 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3305 mxArray::create_rep (bool interleaved, const octave_value& ov)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3306 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3307 return new mxArray_octave_value (interleaved, ov);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3308 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3309
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3310 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3311 mxArray::create_rep (bool interleaved, mxClassID id, mwSize ndims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3312 const mwSize *dims, mxComplexity flag, bool init)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3313 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3314 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3315 return new mxArray_interleaved_full (id, ndims, dims, flag, init);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3316 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3317 return new mxArray_separate_full (id, ndims, dims, flag, init);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3318 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3319
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3320 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3321 mxArray::create_rep (bool interleaved, mxClassID id, const dim_vector& dv,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3322 mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3323 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3324 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3325 return new mxArray_interleaved_full (id, dv, flag);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3326 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3327 return new mxArray_separate_full (id, dv, flag);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3328 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3329
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3330 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3331 mxArray::create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3332 mxComplexity flag, bool init)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3333 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3334 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3335 return new mxArray_interleaved_full (id, m, n, flag, init);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3336 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3337 return new mxArray_separate_full (id, m, n, flag, init);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3338 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3339
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3340 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3341 mxArray::create_rep (bool interleaved, mxClassID id, double val)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3342 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3343 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3344 return new mxArray_interleaved_full (id, val);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3345 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3346 return new mxArray_separate_full (id, val);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3347 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3348
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3349 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3350 mxArray::create_rep (bool interleaved, mxClassID id, mxLogical val)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3351 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3352 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3353 return new mxArray_interleaved_full (id, val);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3354 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3355 return new mxArray_separate_full (id, val);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3356 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3357
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3358 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3359 mxArray::create_rep (bool interleaved, const char *str)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3360 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3361 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3362 return new mxArray_interleaved_full (str);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3363 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3364 return new mxArray_separate_full (str);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3365 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3366
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3367 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3368 mxArray::create_rep (bool interleaved, mwSize m, const char **str)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3369 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3370 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3371 return new mxArray_interleaved_full (m, str);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3372 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3373 return new mxArray_separate_full (m, str);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3374 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3375
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3376 mxArray_base *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3377 mxArray::create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3378 mwSize nzmax, mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3379 {
30224
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3380 if (interleaved)
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3381 return new mxArray_interleaved_sparse (id, m, n, nzmax, flag);
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3382 else
8670f5165430 use distinct classes for interleaved and separate numeric mxarray objects
John W. Eaton <jwe@octave.org>
parents: 30223
diff changeset
3383 return new mxArray_separate_sparse (id, m, n, nzmax, flag);
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3384 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3385
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3386 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3387 mxArray::maybe_mutate (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3388 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3389 if (m_rep->is_octave_value ())
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3390 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3391 // 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
3392 // 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
3393 // 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
3394
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3395 mxArray *new_val = m_rep->mutate ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3396
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3397 if (new_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3398 {
30122
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3399 delete m_rep;
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3400 m_rep = new_val->m_rep;
8418f99cfcd0 maint: use "m_" prefix for member variables in class mxArray_base.
Rik <rik@octave.org>
parents: 30088
diff changeset
3401 new_val->m_rep = nullptr;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3402 delete new_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3403 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3404 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3405 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3406
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3407 // ------------------------------------------------------------------
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3408
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3409 // 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
3410 // management.
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3411
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3412 class mex
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3413 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3414 public:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3415
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3416 mex (octave_mex_function& f)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3417 : m_curr_mex_fcn (f), m_memlist (), m_arraylist (), m_fname (nullptr) { }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3418
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3419 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3420
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3421 mex (const mex&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3422
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3423 mex& operator = (const mex&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
3424
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3425 ~mex (void)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3426 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3427 // We can't use mex::free here because it modifies memlist.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3428 while (! m_memlist.empty ())
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3429 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3430 auto p = m_memlist.begin ();
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3431 xfree (*p);
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3432 m_memlist.erase (p);
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3433 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3434
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3435 // We can't use mex::free_value here because it modifies arraylist.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3436 while (! m_arraylist.empty ())
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3437 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3438 auto p = m_arraylist.begin ();
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3439 delete *p;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3440 m_arraylist.erase (p);
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3441 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
3442
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3443 if (! (m_memlist.empty () && m_arraylist.empty ()))
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3444 error ("mex: %s: cleanup failed", function_name ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3445
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3446 mxFree (m_fname);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3447 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3448
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3449 const char * function_name (void) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3450 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3451 if (! m_fname)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3452 {
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
3453 octave::tree_evaluator& tw = octave::__get_evaluator__ ();
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
3454
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
3455 octave_function *fcn = tw.current_function ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3456
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3457 if (fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3458 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3459 std::string nm = fcn->name ();
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3460 m_fname = mxArray::strsave (nm.c_str ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3461 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3462 else
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3463 m_fname = mxArray::strsave ("unknown");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3464 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3465
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3466 return m_fname;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3467 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3468
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3469 // Allocate memory.
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3470 void * malloc_unmarked (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3471 {
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3472 void *ptr = xmalloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3473
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3474 if (! ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3475 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3476 // FIXME: could use "octave_new_handler();" instead
26159
aa678451b758 Silence compiler warning about incorrect format specifier (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26113
diff changeset
3477 error ("%s: failed to allocate %zd bytes of memory",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3478 function_name (), n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3479 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3480
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3481 global_mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3482
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3483 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3484 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3485
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3486 // Allocate memory to be freed on exit.
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3487 void * malloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3488 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3489 void *ptr = malloc_unmarked (n);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3490
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3491 mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3492
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3493 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3494 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3495
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3496 // Allocate memory and initialize to 0.
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3497 void * calloc_unmarked (std::size_t n, std::size_t t)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3498 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3499 void *ptr = malloc_unmarked (n*t);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3500
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3501 memset (ptr, 0, n*t);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3502
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3503 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3504 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3505
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3506 // Allocate memory to be freed on exit and initialize to 0.
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3507 void * calloc (std::size_t n, std::size_t t)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3508 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3509 void *ptr = calloc_unmarked (n, t);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3510
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3511 mark (ptr);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3512
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3513 return ptr;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3514 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3515
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21743
diff changeset
3516 // Reallocate a pointer obtained from malloc or calloc.
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21743
diff changeset
3517 // If the pointer is NULL, allocate using malloc.
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21743
diff changeset
3518 // We don't need an "unmarked" version of this.
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3519 void * realloc (void *ptr, std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3520 {
10225
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3521 void *v;
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3522
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3523 if (ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3524 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3525 auto p_local = m_memlist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3526 auto p_global = s_global_memlist.find (ptr);
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3527
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3528 v = xrealloc (ptr, n);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3529
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3530 if (v)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3531 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3532 if (p_local != m_memlist.end ())
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3533 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3534 m_memlist.erase (p_local);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3535 m_memlist.insert (v);
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3536 }
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3537
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3538 if (p_global != s_global_memlist.end ())
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3539 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3540 s_global_memlist.erase (p_global);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3541 s_global_memlist.insert (v);
26438
c048a6ac0f79 mex.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
3542 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3543 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3544 }
10225
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3545 else
477d05b0a739 mxRealloc: Allocate new memory on NULL argument
David Grundberg <davidg@cs.umu.se>
parents: 10127
diff changeset
3546 v = malloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3547
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3548 return v;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3549 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3550
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3551 // Free a pointer obtained from malloc or calloc.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3552 void free (void *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3553 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3554 if (ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3555 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3556 unmark (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3557
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3558 auto p = s_global_memlist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3559
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3560 if (p != s_global_memlist.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3561 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3562 s_global_memlist.erase (p);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3563
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3564 xfree (ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3565 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3566 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3567 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3568 p = m_foreign_memlist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3569
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3570 if (p != m_foreign_memlist.end ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3571 m_foreign_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3572 #if defined (DEBUG)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3573 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3574 warning ("mxFree: skipping memory not allocated by mxMalloc, mxCalloc, or mxRealloc");
11276
475e90eb4ff1 mex::free: don't warn about skipping memory not allocated by mx{M,C,Re}alloc
John W. Eaton <jwe@octave.org>
parents: 11132
diff changeset
3575 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3576 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3577 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3578 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3579
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3580 // Mark a pointer to be freed on exit.
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3581 void mark (void *ptr)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3582 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3583 #if defined (DEBUG)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3584 if (m_memlist.find (ptr) != m_memlist.end ())
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3585 warning ("%s: double registration ignored", function_name ());
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3586 #endif
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3587
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3588 m_memlist.insert (ptr);
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3589 }
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3590
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3591 // 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
3592 // made persistent, or because it was already freed.
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3593 void unmark (void *ptr)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3594 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3595 auto p = m_memlist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3596
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3597 if (p != m_memlist.end ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3598 m_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3599 #if defined (DEBUG)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3600 else
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3601 warning ("%s: value not marked", function_name ());
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3602 #endif
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3603 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3604
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3605 mxArray * mark_array (mxArray *ptr)
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3606 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3607 m_arraylist.insert (ptr);
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3608 return ptr;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3609 }
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3610
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3611 void unmark_array (mxArray *ptr)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3612 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3613 auto p = m_arraylist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3614
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3615 if (p != m_arraylist.end ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3616 m_arraylist.erase (p);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3617 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3618
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3619 // Mark a pointer as one we allocated.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3620 void mark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3621 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3622 #if defined (DEBUG)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3623 if (m_foreign_memlist.find (ptr) != m_foreign_memlist.end ())
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3624 warning ("%s: double registration ignored", function_name ());
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3625 #endif
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3626
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3627 m_foreign_memlist.insert (ptr);
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3628 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3629
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3630 // Unmark a pointer as one we allocated.
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3631 void unmark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3632 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3633 auto p = m_foreign_memlist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3634
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3635 if (p != m_foreign_memlist.end ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3636 m_foreign_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3637 #if defined (DEBUG)
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3638 else
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3639 warning ("%s: value not marked", function_name ());
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3640 #endif
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3641
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3642 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3643
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3644 // 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
3645 // freed on exit unless marked as persistent.
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
3646 mxArray * make_value (const octave_value& ov)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3647 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3648 bool interleaved = m_curr_mex_fcn.use_interleaved_complex ();
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3649
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3650 return mark_array (new mxArray (interleaved, ov));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3651 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3652
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3653 // Free an array and its contents.
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3654 bool free_value (mxArray *ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3655 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3656 bool inlist = false;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3657
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3658 auto p = m_arraylist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3659
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3660 if (p != m_arraylist.end ())
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3661 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3662 inlist = true;
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3663 m_arraylist.erase (p);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
3664 delete ptr;
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3665 }
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3666 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3667 else
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3668 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
3669 #endif
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3670
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3671 return inlist;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3672 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3673
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3674 octave_mex_function& current_mex_function (void) const
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3675 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3676 return m_curr_mex_fcn;
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3677 }
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
3678
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3679 // 1 if error should be returned to MEX file, 0 if abort.
22452
3a8af9d517de Initialize MEX TrapFlag variable for Matlab compatibility.
Rik <rik@octave.org>
parents: 22451
diff changeset
3680 int trap_feval_error = 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3681
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3682 // Mark a pointer as one we allocated.
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3683 void global_mark (void *ptr)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3684 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3685 #if defined (DEBUG)
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3686 if (s_global_memlist.find (ptr) != s_global_memlist.end ())
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3687 warning ("%s: double registration ignored", function_name ());
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3688 #endif
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3689
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3690 s_global_memlist.insert (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3691 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3692
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3693 // Unmark a pointer as one we allocated.
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3694 void global_unmark (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3695 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3696 auto p = s_global_memlist.find (ptr);
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3697
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3698 if (p != s_global_memlist.end ())
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3699 s_global_memlist.erase (p);
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
3700 #if defined (DEBUG)
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3701 else
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
3702 warning ("%s: value not marked", function_name ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3703 #endif
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3704 }
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3705
30226
f3ffb4596bd8 move ptr to imag data in mxArray to separate_full and separate_sparse classes
John W. Eaton <jwe@octave.org>
parents: 30225
diff changeset
3706 private:
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3707
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3708 // Pointer to the mex function that corresponds to this mex context.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3709 octave_mex_function& m_curr_mex_fcn;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3710
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3711 // List of memory resources that need to be freed upon exit.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3712 std::set<void *> m_memlist;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3713
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3714 // List of mxArray objects that need to be freed upon exit.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3715 std::set<mxArray *> m_arraylist;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3716
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3717 // List of memory resources we know about, but that were allocated
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3718 // elsewhere.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3719 std::set<void *> m_foreign_memlist;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3720
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3721 // The name of the currently executing function.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3722 mutable char *m_fname;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3723
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3724 // List of memory resources we allocated.
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3725 static std::set<void *> s_global_memlist;
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3726
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3727 };
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3728
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3729 // List of memory resources we allocated.
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3730 std::set<void *> mex::s_global_memlist;
5900
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 // Current context.
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
3733 mex *mex_context = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3734
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3735 void *
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3736 mxArray::malloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3737 {
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3738 return mex_context ? mex_context->malloc_unmarked (n) : xmalloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3739 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3740
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3741 void *
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3742 mxArray::calloc (std::size_t n, std::size_t t)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3743 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3744 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
3745 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3746
30223
b8841fcd28c8 combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents: 30213
diff changeset
3747 void *
b8841fcd28c8 combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents: 30213
diff changeset
3748 mxArray::alloc (bool init, std::size_t n, std::size_t t)
b8841fcd28c8 combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents: 30213
diff changeset
3749 {
b8841fcd28c8 combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents: 30213
diff changeset
3750 return init ? mxArray::calloc (n, t) : mxArray::malloc (n * t);
b8841fcd28c8 combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents: 30213
diff changeset
3751 }
b8841fcd28c8 combine calls to mxArray::malloc and mxArray::calloc in wrapper function
John W. Eaton <jwe@octave.org>
parents: 30213
diff changeset
3752
7179
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3753 static inline void *
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3754 maybe_mark_foreign (void *ptr)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3755 {
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3756 if (mex_context)
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3757 mex_context->mark_foreign (ptr);
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3758
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3759 return ptr;
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3760 }
32abf21b21e9 [project @ 2007-11-15 02:44:05 by jwe]
jwe
parents: 7177
diff changeset
3761
31362
4e12be13186d build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents: 31105
diff changeset
3762 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
4e12be13186d build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents: 31105
diff changeset
3763
30227
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3764 static inline void
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3765 maybe_disown_ptr (void *ptr)
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3766 {
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3767 if (mex_context)
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3768 {
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3769 mex_context->unmark (ptr);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3770 mex_context->global_unmark (ptr);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3771 mex_context->mark_foreign (ptr);
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3772 }
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3773 }
b00ff462e0f2 improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents: 30226
diff changeset
3774
31362
4e12be13186d build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents: 31105
diff changeset
3775 #endif
4e12be13186d build: Silence unused function compilation warning in mex.cc (bug #63210)
Rik <rik@octave.org>
parents: 31105
diff changeset
3776
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3777 static inline mxArray *
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3778 maybe_unmark_array (mxArray *ptr)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3779 {
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3780 if (mex_context)
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3781 mex_context->unmark_array (ptr);
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3782
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3783 return ptr;
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3784 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3785
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3786 template <typename T>
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3787 static inline T *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3788 maybe_unmark (T *ptr)
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3789 {
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3790 if (mex_context)
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3791 mex_context->unmark (ptr);
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3792
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3793 return ptr;
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3794 }
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
3795
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3796 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3797 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
3798 {
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3799 if (key_num >= 0 && key_num < m_nfields)
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3800 m_data[m_nfields * index + key_num] = maybe_unmark_array (val);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3801 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3802
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3803 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3804 mxArray_cell::set_cell (mwIndex idx, mxArray *val)
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3805 {
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6071
diff changeset
3806 if (idx >= 0 && idx < get_number_of_elements ())
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
3807 m_data[idx] = maybe_unmark_array (val);
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3808 }
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3809
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3810 // ------------------------------------------------------------------
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 // C interface to mxArray objects:
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3813
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3814 // Floating point predicates.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3815
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3816 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3817 mxIsFinite (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3818 {
30088
fca57eaad2d4 maint: deprecate lo_ieee_finite and replace with lo_ieee_isfinite.
Rik <rik@octave.org>
parents: 29993
diff changeset
3819 return lo_ieee_isfinite (v) != 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3820 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3821
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3822 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3823 mxIsInf (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3824 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3825 return lo_ieee_isinf (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3826 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3827
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
3828 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3829 mxIsNaN (const double v)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3830 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3831 return lo_ieee_isnan (v) != 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3832 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3833
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3834 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3835 mxGetEps (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3836 {
15220
61822c866ba1 use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
3837 return std::numeric_limits<double>::epsilon ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3838 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3839
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3840 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3841 mxGetInf (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3842 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3843 return lo_ieee_inf_value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3844 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3845
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3846 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3847 mxGetNaN (void)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3848 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3849 return lo_ieee_nan_value ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3850 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3851
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3852 // Memory management.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3853 void *
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3854 mxCalloc (std::size_t n, std::size_t size)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3855 {
15354
93dff6435fe1 tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents: 15353
diff changeset
3856 return mex_context ? mex_context->calloc (n, size) : ::calloc (n, size);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3857 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3858
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3859 void *
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3860 mxMalloc (std::size_t n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3861 {
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3862 return mex_context ? mex_context->malloc (n) : xmalloc (n);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3863 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3864
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3865 void *
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3866 mxRealloc (void *ptr, std::size_t size)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3867 {
30428
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3868 return (mex_context
2ac26917bdec mex.cc: allow for tracing malloc/realloc/free calls
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3869 ? mex_context->realloc (ptr, size) : xrealloc (ptr, size));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3870 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3871
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3872 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3873 mxFree (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3874 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3875 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3876 mex_context->free (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3877 else
6071
950d8cb39617 [project @ 2006-10-23 19:30:28 by jwe]
jwe
parents: 6069
diff changeset
3878 xfree (ptr);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3879 }
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3880
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3881 static inline mxArray *
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3882 maybe_mark_array (mxArray *ptr)
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3883 {
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3884 return mex_context ? mex_context->mark_array (ptr) : ptr;
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
3885 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3886
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3887 // Constructors.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3888 mxArray *
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3889 mxCreateCellArray_interleaved (mwSize ndims, const mwSize *dims)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3890 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3891 return maybe_mark_array (new mxArray (true, ndims, dims));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3892 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3893
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3894 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3895 mxCreateCellArray (mwSize ndims, const mwSize *dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3896 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3897 return maybe_mark_array (new mxArray (false, ndims, dims));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3898 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3899
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3900 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3901 mxCreateCellMatrix_interleaved (mwSize m, mwSize n)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3902 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3903 return maybe_mark_array (new mxArray (true, m, n));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3904 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3905
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3906 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3907 mxCreateCellMatrix (mwSize m, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3908 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3909 return maybe_mark_array (new mxArray (false, m, n));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3910 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3911
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3912 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3913 mxCreateCharArray_interleaved (mwSize ndims, const mwSize *dims)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3914 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3915 return maybe_mark_array (new mxArray (true, mxCHAR_CLASS, ndims, dims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3916 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3917
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3918 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3919 mxCreateCharArray (mwSize ndims, const mwSize *dims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3920 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3921 return maybe_mark_array (new mxArray (false, mxCHAR_CLASS, ndims, dims));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3922 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3923
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3924 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3925 mxCreateCharMatrixFromStrings_interleaved (mwSize m, const char **str)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3926 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3927 return maybe_mark_array (new mxArray (true, m, str));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3928 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3929
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3930 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3931 mxCreateCharMatrixFromStrings (mwSize m, const char **str)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3932 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3933 return maybe_mark_array (new mxArray (false, m, str));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3934 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3935
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3936 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3937 mxCreateDoubleMatrix_interleaved (mwSize m, mwSize n, mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3938 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3939 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, flag));
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3942 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3943 mxCreateDoubleMatrix (mwSize m, mwSize n, mxComplexity flag)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3944 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3945 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, m, n, flag));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3946 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3947
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3948 mxArray *
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3949 mxCreateDoubleScalar_interleaved (double val)
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3950 {
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3951 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, val));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3952 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3953
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3954 mxArray *
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3955 mxCreateDoubleScalar (double val)
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3956 {
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
3957 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, val));
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3958 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3959
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3960 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3961 mxCreateLogicalArray_interleaved (mwSize ndims, const mwSize *dims)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3962 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3963 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, ndims, dims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3964 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3965
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3966 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3967 mxCreateLogicalArray (mwSize ndims, const mwSize *dims)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
3968 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3969 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, ndims, dims));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3970 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3971
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3972 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3973 mxCreateLogicalMatrix_interleaved (mwSize m, mwSize n)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3974 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3975 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3976 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3977
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3978 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
3979 mxCreateLogicalMatrix (mwSize m, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3980 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3981 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, m, n));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3982 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3983
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3984 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3985 mxCreateLogicalScalar_interleaved (mxLogical val)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3986 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3987 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, val));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3988 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3989
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3990 mxArray *
7577
ba8fcc115fee mex.cc: arg to mxCreateLogicalScalar is now mxLogical
John W. Eaton <jwe@octave.org>
parents: 7357
diff changeset
3991 mxCreateLogicalScalar (mxLogical val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
3992 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3993 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, val));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3994 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3995
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3996 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3997 mxCreateNumericArray_interleaved (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3998 mxClassID class_id, mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
3999 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4000 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4001 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4002
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4003 mxArray *
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4004 mxCreateNumericArray (mwSize ndims, const mwSize *dims,
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4005 mxClassID class_id, mxComplexity flag)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4006 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4007 return maybe_mark_array (new mxArray (false, class_id, ndims, dims, flag));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4008 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4009
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4010 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4011 mxCreateNumericMatrix_interleaved (mwSize m, mwSize n, mxClassID class_id,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4012 mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4013 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4014 return maybe_mark_array (new mxArray (true, class_id, m, n, flag));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4015 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4016
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4017 mxArray *
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4018 mxCreateNumericMatrix (mwSize m, mwSize n, mxClassID class_id,
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30349
diff changeset
4019 mxComplexity flag)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4020 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4021 return maybe_mark_array (new mxArray (false, class_id, m, n, flag));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4022 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4023
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4024 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4025 mxCreateUninitNumericArray_interleaved (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4026 mxClassID class_id, mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4027 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4028 return maybe_mark_array (new mxArray (true, class_id, ndims, dims, flag,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4029 false));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4030 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4031
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4032 mxArray *
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4033 mxCreateUninitNumericArray (mwSize ndims, const mwSize *dims,
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30349
diff changeset
4034 mxClassID class_id, mxComplexity flag)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4035 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4036 return maybe_mark_array (new mxArray (false, class_id, ndims, dims, flag,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4037 false));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4038 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4039
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4040 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4041 mxCreateUninitNumericMatrix_interleaved (mwSize m, mwSize n,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4042 mxClassID class_id, mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4043 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4044 return maybe_mark_array (new mxArray (true, class_id, m, n, flag, false));
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4045 }
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4046
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4047 mxArray *
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4048 mxCreateUninitNumericMatrix (mwSize m, mwSize n, mxClassID class_id,
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30349
diff changeset
4049 mxComplexity flag)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4050 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4051 return maybe_mark_array (new mxArray (false, class_id, m, n, flag, false));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4052 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4053
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4054 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4055 mxCreateSparse_interleaved (mwSize m, mwSize n, mwSize nzmax, mxComplexity flag)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4056 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4057 return maybe_mark_array (new mxArray (true, mxDOUBLE_CLASS, m, n, nzmax,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4058 flag));
22464
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4059 }
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4060
1d2960b5efe6 Add new MEX fcns mxCreateUninitNumericArray, mxCreateUninitNumericMatrix.
Rik <rik@octave.org>
parents: 22462
diff changeset
4061 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4062 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
4063 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4064 return maybe_mark_array (new mxArray (false, mxDOUBLE_CLASS, m, n, nzmax,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4065 flag));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4066 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4067
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4068 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4069 mxCreateSparseLogicalMatrix_interleaved (mwSize m, mwSize n, mwSize nzmax)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4070 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4071 return maybe_mark_array (new mxArray (true, mxLOGICAL_CLASS, m, n, nzmax));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4072 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4073
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4074 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4075 mxCreateSparseLogicalMatrix (mwSize m, mwSize n, mwSize nzmax)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4076 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4077 return maybe_mark_array (new mxArray (false, mxLOGICAL_CLASS, m, n, nzmax));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4078 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4079
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4080 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4081 mxCreateString_interleaved (const char *str)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4082 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4083 return maybe_mark_array (new mxArray (true, str));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4084 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4085
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4086 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4087 mxCreateString (const char *str)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4088 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4089 return maybe_mark_array (new mxArray (false, str));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4090 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4091
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4092 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4093 mxCreateStructArray_interleaved (mwSize ndims, const mwSize *dims,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4094 int num_keys, const char **keys)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4095 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4096 return maybe_mark_array (new mxArray (true, ndims, dims, num_keys, keys));
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4099 mxArray *
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4100 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys,
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4101 const char **keys)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4102 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4103 return maybe_mark_array (new mxArray (false, ndims, dims, num_keys, keys));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4104 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4105
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4106 mxArray *
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4107 mxCreateStructMatrix_interleaved (mwSize m, mwSize n, int num_keys,
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4108 const char **keys)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4109 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4110 return maybe_mark_array (new mxArray (true, m, n, num_keys, keys));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4111 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4112
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4113 mxArray *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4114 mxCreateStructMatrix (mwSize m, mwSize n, int num_keys,
30129
b7c04a5036d3 maint: use "m_" prefix for member variables in file mex.cc.
Rik <rik@octave.org>
parents: 30122
diff changeset
4115 const char **keys)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4116 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4117 return maybe_mark_array (new mxArray (false, m, n, num_keys, keys));
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4120 // Copy constructor.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4121 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4122 mxDuplicateArray (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4123 {
11277
7d5351fc575a mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents: 11276
diff changeset
4124 return maybe_mark_array (ptr->dup ());
5900
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
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4127 // Destructor.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4128 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4129 mxDestroyArray (mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4130 {
6065
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
4131 if (! (mex_context && mex_context->free_value (ptr)))
814f20da2cdb [project @ 2006-10-20 03:01:43 by jwe]
jwe
parents: 6062
diff changeset
4132 delete ptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4133 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4134
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4135 // Type Predicates.
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4136 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4137 mxIsCell (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4138 {
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23553
diff changeset
4139 return ptr->iscell ();
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
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4142 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4143 mxIsChar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4144 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4145 return ptr->is_char ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4146 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4147
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4148 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4149 mxIsClass (const mxArray *ptr, const char *name)
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 return ptr->is_class (name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4152 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4153
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4154 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4155 mxIsComplex (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4156 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4157 return ptr->is_complex ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4158 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4159
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4160 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4161 mxIsDouble (const mxArray *ptr)
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 return ptr->is_double ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4164 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4165
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4166 bool
11100
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
4167 mxIsFunctionHandle (const mxArray *ptr)
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
4168 {
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
4169 return ptr->is_function_handle ();
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
4170 }
cdf940db26a0 provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents: 11073
diff changeset
4171
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4172 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4173 mxIsInt16 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4174 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4175 return ptr->is_int16 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4176 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4177
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4178 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4179 mxIsInt32 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4180 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4181 return ptr->is_int32 ();
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
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4184 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4185 mxIsInt64 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4186 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4187 return ptr->is_int64 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4188 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4189
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4190 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4191 mxIsInt8 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4192 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4193 return ptr->is_int8 ();
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
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4196 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4197 mxIsLogical (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4198 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4199 return ptr->is_logical ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4200 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4201
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4202 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4203 mxIsNumeric (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4204 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4205 return ptr->is_numeric ();
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
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4208 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4209 mxIsSingle (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4210 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4211 return ptr->is_single ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4212 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4213
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4214 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4215 mxIsSparse (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4216 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4217 return ptr->is_sparse ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4218 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4219
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4220 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4221 mxIsStruct (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4222 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4223 return ptr->is_struct ();
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
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4226 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4227 mxIsUint16 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4228 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4229 return ptr->is_uint16 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4230 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4231
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4232 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4233 mxIsUint32 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4234 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4235 return ptr->is_uint32 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4236 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4237
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4238 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4239 mxIsUint64 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4240 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4241 return ptr->is_uint64 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4242 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4243
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4244 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4245 mxIsUint8 (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4246 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4247 return ptr->is_uint8 ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4248 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4249
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4250 // Odd type+size predicate.
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4251 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4252 mxIsLogicalScalar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4253 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4254 return ptr->is_logical_scalar ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4255 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4256
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4257 // Odd type+size+value predicate.
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4258 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4259 mxIsLogicalScalarTrue (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4260 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4261 return ptr->is_logical_scalar_true ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4262 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4263
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4264 // Size predicate.
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4265 bool
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4266 mxIsEmpty (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4267 {
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
4268 return ptr->isempty ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4269 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4270
22462
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
4271 bool
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
4272 mxIsScalar (const mxArray *ptr)
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
4273 {
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
4274 return ptr->is_scalar ();
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
4275 }
6cb7813e5b2f Add new mxIsScalar function for MEX API.
Rik <rik@octave.org>
parents: 22454
diff changeset
4276
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
4277 // FIXME: Just plain odd thing to ask of a value.
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
4278 // Still, Octave is incompatible because it does not implement this.
22465
6149f6b34cbc Change all mxIs* functions in MEX API to return bool rather than int.
Rik <rik@octave.org>
parents: 22464
diff changeset
4279 bool
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
4280 mxIsFromGlobalWS (const mxArray * /*ptr*/)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4281 {
20527
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
4282 mexErrMsgTxt ("mxIsFromGlobalWS() is unimplemented");
2d9ec16fa960 Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
Rik <rik@octave.org>
parents: 20362
diff changeset
4283
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4284 return 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4285 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4286
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4287 // Dimension extractors.
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
4288 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4289 mxGetM (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4290 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4291 return ptr->get_m ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4292 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4293
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
4294 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4295 mxGetN (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4296 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4297 return ptr->get_n ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4298 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4299
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
4300 const mwSize *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4301 mxGetDimensions (const mxArray *ptr)
5864
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 ptr->get_dimensions ();
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
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4306 mwSize
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4307 mxGetNumberOfDimensions (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4308 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4309 return ptr->get_number_of_dimensions ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4310 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4311
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
4312 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4313 mxGetNumberOfElements (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4314 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4315 return ptr->get_number_of_elements ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4316 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4317
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4318 // Dimension setters.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4319 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4320 mxSetM (mxArray *ptr, mwSize m)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4321 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4322 ptr->set_m (m);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4323 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4324
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4325 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4326 mxSetN (mxArray *ptr, mwSize n)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4327 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4328 ptr->set_n (n);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4329 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4330
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
4331 int
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
4332 mxSetDimensions (mxArray *ptr, const mwSize *dims, mwSize ndims)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4333 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
4334 return (ptr->set_dimensions (static_cast<mwSize *>
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
4335 (maybe_unmark (const_cast<mwSize *> (dims))),
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
4336 ndims));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4337 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
4338
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4339 // Data extractors.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4340 double *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4341 mxGetPr (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4342 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4343 return static_cast<double *> (ptr->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4344 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4345
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4346 double
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4347 mxGetScalar (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4348 {
6332
debb662eab07 [project @ 2007-02-20 20:41:35 by jwe]
jwe
parents: 6271
diff changeset
4349 return ptr->get_scalar ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4350 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4351
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4352 mxChar *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4353 mxGetChars (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4354 {
22471
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
4355 if (mxIsChar (ptr))
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
4356 return static_cast<mxChar *> (ptr->get_data ());
667d353d1ab8 Clean up MEX API prototypes to match Matlab.
Rik <rik@octave.org>
parents: 22465
diff changeset
4357 else
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4358 return nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4359 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4360
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4361 mxLogical *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4362 mxGetLogicals (const mxArray *ptr)
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 return static_cast<mxLogical *> (ptr->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4365 }
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 void *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4368 mxGetData (const mxArray *ptr)
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 return ptr->get_data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4371 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4372
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4373 double *
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4374 mxGetPi (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4375 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4376 return static_cast<double *> (ptr->get_imag_data ());
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4377 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4378
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4379 void *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4380 mxGetImagData (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4381 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4382 return ptr->get_imag_data ();
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
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4385 mxDouble * mxGetDoubles (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4386 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4387 return ptr->get_doubles ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4388 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4389
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4390 mxSingle * mxGetSingles (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4391 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4392 return ptr->get_singles ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4393 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4394
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4395 mxInt8 * mxGetInt8s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4396 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4397 return ptr->get_int8s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4398 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4399
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4400 mxInt16 * mxGetInt16s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4401 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4402 return ptr->get_int16s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4403 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4404
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4405 mxInt32 * mxGetInt32s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4406 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4407 return ptr->get_int32s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4408 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4409
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4410 mxInt64 * mxGetInt64s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4411 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4412 return ptr->get_int64s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4413 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4414
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4415 mxUint8 * mxGetUint8s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4416 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4417 return ptr->get_uint8s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4418 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4419
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4420 mxUint16 * mxGetUint16s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4421 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4422 return ptr->get_uint16s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4423 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4424
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4425 mxUint32 * mxGetUint32s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4426 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4427 return ptr->get_uint32s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4428 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4429
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4430 mxUint64 * mxGetUint64s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4431 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4432 return ptr->get_uint64s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4433 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4434
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4435 mxComplexDouble * mxGetComplexDoubles (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4436 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4437 return ptr->get_complex_doubles ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4438 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4439
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4440 mxComplexSingle * mxGetComplexSingles (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4441 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4442 return ptr->get_complex_singles ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4443 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4444
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4445 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4446 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4447 mxComplexInt8 * mxGetComplexInt8s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4448 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4449 return ptr->get_complex_int8s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4450 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4451
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4452 mxComplexInt16 * mxGetComplexInt16s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4453 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4454 return ptr->get_complex_int16s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4455 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4456
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4457 mxComplexInt32 * mxGetComplexInt32s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4458 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4459 return ptr->get_complex_int32s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4460 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4461
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4462 mxComplexInt64 * mxGetComplexInt64s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4463 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4464 return ptr->get_complex_int64s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4465 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4466
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4467 mxComplexUint8 * mxGetComplexUint8s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4468 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4469 return ptr->get_complex_uint8s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4470 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4471
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4472 mxComplexUint16 * mxGetComplexUint16s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4473 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4474 return ptr->get_complex_uint16s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4475 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4476
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4477 mxComplexUint32 * mxGetComplexUint32s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4478 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4479 return ptr->get_complex_uint32s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4480 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4481
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4482 mxComplexUint64 * mxGetComplexUint64s (const mxArray *ptr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4483 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4484 return ptr->get_complex_uint64s ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4485 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4486 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4487
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4488 // Data setters.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4489 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4490 mxSetPr (mxArray *ptr, double *pr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4491 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4492 ptr->set_data (maybe_unmark (pr));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4493 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4494
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4495 void
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4496 mxSetData (mxArray *ptr, void *pr)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4497 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4498 ptr->set_data (maybe_unmark (pr));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4499 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4500
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4501 int mxSetDoubles (mxArray *ptr, mxDouble *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4502 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4503 return ptr->set_doubles (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4504 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4505
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4506 int mxSetSingles (mxArray *ptr, mxSingle *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4507 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4508 return ptr->set_singles (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4509 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4510
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4511 int mxSetInt8s (mxArray *ptr, mxInt8 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4512 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4513 return ptr->set_int8s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4514 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4515
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4516 int mxSetInt16s (mxArray *ptr, mxInt16 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4517 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4518 return ptr->set_int16s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4519 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4520
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4521 int mxSetInt32s (mxArray *ptr, mxInt32 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4522 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4523 return ptr->set_int32s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4524 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4525
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4526 int mxSetInt64s (mxArray *ptr, mxInt64 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4527 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4528 return ptr->set_int64s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4529 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4530
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4531 int mxSetUint8s (mxArray *ptr, mxUint8 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4532 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4533 return ptr->set_uint8s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4534 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4535
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4536 int mxSetUint16s (mxArray *ptr, mxUint16 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4537 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4538 return ptr->set_uint16s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4539 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4540
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4541 int mxSetUint32s (mxArray *ptr, mxUint32 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4542 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4543 return ptr->set_uint32s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4544 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4545
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4546 int mxSetUint64s (mxArray *ptr, mxUint64 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4547 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4548 return ptr->set_uint64s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4549 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4550
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4551 int mxSetComplexDoubles (mxArray *ptr, mxComplexDouble *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4552 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4553 return ptr->set_complex_doubles (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4554 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4555
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4556 int mxSetComplexSingles (mxArray *ptr, mxComplexSingle *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4557 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4558 return ptr->set_complex_singles (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4559 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4560
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4561 #if 0
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4562 /* We don't have these yet. */
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4563 int mxSetComplexInt8s (mxArray *ptr, mxComplexInt8 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4564 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4565 return ptr->set_complex_int8s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4566 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4567
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4568 int mxSetComplexInt16s (mxArray *ptr, mxComplexInt16 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4569 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4570 return ptr->set_complex_int16s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4571 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4572
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4573 int mxSetComplexInt32s (mxArray *ptr, mxComplexInt32 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4574 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4575 return ptr->set_complex_int32s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4576 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4577
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4578 int mxSetComplexInt64s (mxArray *ptr, mxComplexInt64 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4579 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4580 return ptr->set_complex_int64s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4581 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4582
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4583 int mxSetComplexUint8s (mxArray *ptr, mxComplexUint8 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4584 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4585 return ptr->set_complex_uint8s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4586 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4587
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4588 int mxSetComplexUint16s (mxArray *ptr, mxComplexUint16 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4589 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4590 return ptr->set_complex_uint16s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4591 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4592
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4593 int mxSetComplexUint32s (mxArray *ptr, mxComplexUint32 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4594 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4595 return ptr->set_complex_uint32s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4596 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4597
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4598 int mxSetComplexUint64s (mxArray *ptr, mxComplexUint64 *data)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4599 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4600 return ptr->set_complex_uint64s (maybe_unmark (data));
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4601 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4602 #endif
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4603
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4604 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4605 mxSetPi (mxArray *ptr, double *pi)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4606 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4607 ptr->set_imag_data (maybe_unmark (pi));
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4608 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4609
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4610 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4611 mxSetImagData (mxArray *ptr, void *pi)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4612 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4613 ptr->set_imag_data (maybe_unmark (pi));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4614 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4615
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4616 // Classes.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4617 mxClassID
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4618 mxGetClassID (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4619 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4620 return ptr->get_class_id ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4621 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4622
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4623 const char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4624 mxGetClassName (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4625 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4626 return ptr->get_class_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4627 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4628
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4629 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4630 mxSetClassName (mxArray *ptr, const char *name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4631 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4632 ptr->set_class_name (name);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4633 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4634
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4635 void
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4636 mxSetProperty (mxArray *ptr, mwIndex idx, const char *property_name,
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4637 const mxArray *property_value)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4638 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4639 ptr->set_property (idx, property_name, property_value);
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4640 }
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23891
diff changeset
4641
23891
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4642 mxArray *
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4643 mxGetProperty (const mxArray *ptr, mwIndex idx, const char *property_name)
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4644 {
23891
142a9c7e403a Avoid CamelCase in variables names in mxGetProperty cset (bd9e719f04cc).
Rik <rik@octave.org>
parents: 23884
diff changeset
4645 return ptr->get_property (idx, property_name);
23884
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4646 }
bd9e719f04cc new mxGetProperty function for MEX API
Piotr Held <pjheld@gmail.com>
parents: 23795
diff changeset
4647
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4648 // Cell support.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4649 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4650 mxGetCell (const mxArray *ptr, mwIndex idx)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4651 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4652 return ptr->get_cell (idx);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4653 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4654
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4655 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4656 mxSetCell (mxArray *ptr, mwIndex idx, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4657 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4658 ptr->set_cell (idx, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4659 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4660
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4661 // Sparse support.
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4662 mwIndex *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4663 mxGetIr (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4664 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4665 return ptr->get_ir ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4666 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4667
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4668 mwIndex *
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4669 mxGetJc (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4670 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4671 return ptr->get_jc ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4672 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4673
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4674 mwSize
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4675 mxGetNzmax (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4676 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4677 return ptr->get_nzmax ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4678 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4679
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4680 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4681 mxSetIr (mxArray *ptr, mwIndex *ir)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4682 {
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
4683 ptr->set_ir (static_cast<mwIndex *> (maybe_unmark (ir)));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4684 }
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 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4687 mxSetJc (mxArray *ptr, mwIndex *jc)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4688 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
4689 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
4690 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4691
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4692 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4693 mxSetNzmax (mxArray *ptr, mwSize nzmax)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4694 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4695 ptr->set_nzmax (nzmax);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4696 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4697
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4698 // Structure support.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4699 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4700 mxAddField (mxArray *ptr, const char *key)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4701 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4702 return ptr->add_field (key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4703 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4704
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4705 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4706 mxRemoveField (mxArray *ptr, int key_num)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4707 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4708 ptr->remove_field (key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4709 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4710
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4711 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4712 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
4713 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4714 int key_num = mxGetFieldNumber (ptr, key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4715 return mxGetFieldByNumber (ptr, index, key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4716 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4717
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4718 mxArray *
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4719 mxGetFieldByNumber (const mxArray *ptr, mwIndex index, int key_num)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4720 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4721 return ptr->get_field_by_number (index, key_num);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4722 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4723
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4724 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4725 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
4726 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4727 int key_num = mxGetFieldNumber (ptr, key);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4728 mxSetFieldByNumber (ptr, index, key_num, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4729 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4730
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4731 void
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4732 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
4733 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4734 ptr->set_field_by_number (index, key_num, val);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4735 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4736
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4737 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4738 mxGetNumberOfFields (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4739 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4740 return ptr->get_number_of_fields ();
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4741 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4742
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4743 const char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4744 mxGetFieldNameByNumber (const mxArray *ptr, int key_num)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4745 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4746 return ptr->get_field_name_by_number (key_num);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4747 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4748
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4749 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4750 mxGetFieldNumber (const mxArray *ptr, const char *key)
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 return ptr->get_field_number (key);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4753 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4754
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4755 int
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4756 mxGetString (const mxArray *ptr, char *buf, mwSize buflen)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4757 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4758 return ptr->get_string (buf, buflen);
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 char *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4762 mxArrayToString (const mxArray *ptr)
5864
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 return ptr->array_to_string ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4765 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
4766
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4767 mwIndex
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6601
diff changeset
4768 mxCalcSingleSubscript (const mxArray *ptr, mwSize nsubs, mwIndex *subs)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4769 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4770 return ptr->calc_single_subscript (nsubs, subs);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4771 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4772
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
4773 std::size_t
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4774 mxGetElementSize (const mxArray *ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4775 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4776 return ptr->get_element_size ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4777 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4778
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4779 // ------------------------------------------------------------------
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4780
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4781 typedef void (*cmex_fptr) (int nlhs, mxArray **plhs, int nrhs, mxArray **prhs);
23498
647705ffb110 use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
4782 typedef F77_RET_T (*fmex_fptr) (F77_INT& nlhs, mxArray **plhs,
647705ffb110 use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
4783 F77_INT& nrhs, mxArray **prhs);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4784
30919
4ed7dfe28584 move eval of anon fcn handles and built-in and mex functions to pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 30793
diff changeset
4785 OCTAVE_NAMESPACE_BEGIN
4ed7dfe28584 move eval of anon fcn handles and built-in and mex functions to pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 30793
diff changeset
4786
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4787 octave_value_list
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4788 call_mex (octave_mex_function& mex_fcn, const octave_value_list& args,
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4789 int nargout_arg)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4790 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4791 octave_quit ();
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4792
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4793 // 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
4794 // still want to be able to return an ans.
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4795
8806
c7864bb74914 avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
4796 volatile int nargout = nargout_arg;
c7864bb74914 avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
4797
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4798 int nargin = args.length ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4799 OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4800 for (int i = 0; i < nargin; i++)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
4801 argin[i] = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4802
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
4803 int nout = (nargout == 0 ? 1 : nargout);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4804 OCTAVE_LOCAL_BUFFER (mxArray *, argout, nout);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4805 for (int i = 0; i < nout; i++)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
4806 argout[i] = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4807
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4808 // Save old mex pointer.
28823
26cfccfee9a0 Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents: 28370
diff changeset
4809 octave::unwind_protect_var<mex *> restore_var (mex_context);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
4810
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4811 mex context (mex_fcn);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4812
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4813 for (int i = 0; i < nargin; i++)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4814 argin[i] = context.make_value (args(i));
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4815
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4816 mex_context = &context;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4817
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4818 void *mex_fcn_ptr = mex_fcn.mex_fcn_ptr ();
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4819
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4820 if (mex_fcn.is_fmex ())
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4821 {
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4822 fmex_fptr fcn = reinterpret_cast<fmex_fptr> (mex_fcn_ptr);
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4823
23498
647705ffb110 use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
4824 F77_INT tmp_nargout = nargout;
647705ffb110 use F77_INT type for integer args to Fortran MEX functions
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
4825 F77_INT tmp_nargin = nargin;
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4826
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4827 fcn (tmp_nargout, argout, tmp_nargin, argin);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4828 }
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4829 else
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4830 {
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23498
diff changeset
4831 cmex_fptr fcn = reinterpret_cast<cmex_fptr> (mex_fcn_ptr);
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4832
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4833 fcn (nargout, argout, nargin, argin);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4834 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4835
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4836 // Convert returned array entries back into octave values.
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4837
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4838 octave_value_list retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4839
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4840 if (nargout == 0 && argout[0])
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4841 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4842 // We have something for ans.
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4843 nargout = 1;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4844 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4845
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4846 retval.resize (nargout);
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4847
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4848 // If using std::pmr::memory_resource object to manage memory, pass
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4849 // default allocator here because we are done with these mxArray
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4850 // values and want Octave to delete them.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4851
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4852 for (int i = 0; i < nargout; i++)
25451
f84755f24ccd allow NULL mxArray* to be returned as undefined from fcn calls (bug #54096)
John W. Eaton <jwe@octave.org>
parents: 25450
diff changeset
4853 retval(i) = mxArray::as_octave_value (argout[i], false);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
4854
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4855 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4856 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4857
30919
4ed7dfe28584 move eval of anon fcn handles and built-in and mex functions to pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 30793
diff changeset
4858 OCTAVE_NAMESPACE_END
4ed7dfe28584 move eval of anon fcn handles and built-in and mex functions to pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 30793
diff changeset
4859
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4860 // C interface to mex functions:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4861
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4862 const char *
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4863 mexFunctionName (void)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
4864 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4865 return mex_context ? mex_context->function_name () : "unknown";
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4866 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4867
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4868 static inline octave_value_list
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4869 mx_to_ov_args (int nargin, mxArray *argin[])
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4870 {
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4871 // Use a separate function for this job so that the
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4872 // current_mx_memory_resource will be restored immediately after the
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4873 // octave_value objects borrow the mxArray data. We could also use a
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4874 // dummy scope in mexCallMATLAB, but this function seems less likely
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4875 // to be accidentally deleted.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4876
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4877 octave_value_list args (nargin);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4878
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4879 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4880
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4881 // Use allocator that doesn't free memory because Octave may mutate
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4882 // the value (single element mxArray -> scalar octave_value object,
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4883 // for example) and we need these objects to continue to exist after
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4884 // mexCallMATLAB returns.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4885
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4886 octave::unwind_protect_var<std::pmr::memory_resource *>
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4887 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4888
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4889 #endif
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4890
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4891 for (int i = 0; i < nargin; i++)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4892 args(i) = mxArray::as_octave_value (argin[i]);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4893
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4894 return args;
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4895 }
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4896
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4897 int
15354
93dff6435fe1 tag calls to mxArray::malloc, mxArray::calloc, and mxArray::strsave with class name
John W. Eaton <jwe@octave.org>
parents: 15353
diff changeset
4898 mexCallMATLAB (int nargout, mxArray *argout[], int nargin,
15373
b5d0a47c171c * mex.cc (mexCallMATLAB): Remove stray const added in 93dff6435fe1 (bug #37342).
John W. Eaton <jwe@octave.org>
parents: 15354
diff changeset
4899 mxArray *argin[], const char *fname)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4900 {
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
4901 octave_value_list args = mx_to_ov_args (nargin, argin);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4902
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
4903 octave::interpreter& interp = octave::__get_interpreter__ ();
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4904
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4905 bool execution_error = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4906
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4907 octave_value_list retval;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4908
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4909 try
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4910 {
29172
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4911 octave::tree_evaluator& tw = interp.get_evaluator ();
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4912
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4913 octave::unwind_action act
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4914 ([&tw] (const std::list<octave::octave_lvalue> *lvl)
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4915 {
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4916 tw.set_lvalue_list (lvl);
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4917 }, tw.lvalue_list ());
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4918
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4919 tw.set_lvalue_list (nullptr);
32fdcf67a683 don't propagate prevailing isargout info through mexCallMATLAB (bug #59597)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
4920
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23052
diff changeset
4921 retval = octave::feval (fname, args, nargout);
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4922 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
4923 catch (const octave::execution_exception&)
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4924 {
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4925 if (mex_context->trap_feval_error)
22450
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4926 {
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4927 // FIXME: is there a way to indicate what error occurred?
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4928 // 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
4929 // save the exception info for lasterror?
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
4930
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
4931 interp.recover_from_exception ();
22450
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4932
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4933 execution_error = true;
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4934 }
20771
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4935 else
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4936 {
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4937 args.resize (0);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4938 retval.resize (0);
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4939
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4940 throw;
ed708a7ce0a2 simplify memory management for mex files (bug #46559)
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
4941 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4942 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4943
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4944 int num_to_copy = retval.length ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4945
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4946 if (nargout < retval.length ())
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4947 num_to_copy = nargout;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4948
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4949 for (int i = 0; i < num_to_copy; i++)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4950 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4951 // FIXME: it would be nice to avoid copying the value here,
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4952 // 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
4953 // 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
4954 // is allocated by malloc().
22450
2fb86778f78d Return correct status from mexCallMATLAB when mexSetTrapFlag is 1 (bug #48949).
Rik <rik@octave.org>
parents: 22449
diff changeset
4955 argout[i] = mex_context->make_value (retval(i));
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4956 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4957
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4958 while (num_to_copy < nargout)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23703
diff changeset
4959 argout[num_to_copy++] = nullptr;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4960
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
4961 return execution_error ? 1 : 0;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4962 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4963
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4964 mxArray *
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4965 mexCallMATLABWithTrap (int nargout, mxArray *argout[], int nargin,
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4966 mxArray *argin[], const char *fname)
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4967 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4968 mxArray *mx = nullptr;
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4969
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
4970 int old_flag = (mex_context ? mex_context->trap_feval_error : 0);
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4971 mexSetTrapFlag (1);
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4972 if (mexCallMATLAB (nargout, argout, nargin, argin, fname))
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4973 {
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4974 const char *field_names[] = {"identifier", "message", "case", "stack"};
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
4975 mx = mxCreateStructMatrix (1, 1, 4, field_names);
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4976 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX"));
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4977 std::string msg = "mexCallMATLABWithTrap: function call <"
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4978 + std::string (fname) + "> failed";
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4979 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ()));
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4980 mxSetFieldByNumber (mx, 0, 2, mxCreateCellMatrix (0, 0));
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
4981 mxSetFieldByNumber (mx, 0, 3, mxCreateStructMatrix (0, 1, 0, nullptr));
22451
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4982 }
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4983 mexSetTrapFlag (old_flag);
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4984
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4985 return mx;
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4986 }
ad5439817753 Add mexCallMATLABWithTrap to MEX API (bug #48949).
Rik <rik@octave.org>
parents: 22450
diff changeset
4987
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4988 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4989 mexSetTrapFlag (int flag)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4990 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4991 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4992 mex_context->trap_feval_error = flag;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4993 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4994
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4995 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4996 mexEvalString (const char *s)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4997 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4998 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
4999
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5000 octave::interpreter& interp = octave::__get_interpreter__ ();
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
5001
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5002 int parse_status;
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5003 bool execution_error = false;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5004
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5005 octave_value_list ret;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5006
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5007 try
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5008 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 25922
diff changeset
5009 ret = interp.eval_string (std::string (s), false, parse_status, 0);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5010 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
5011 catch (const octave::execution_exception&)
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5012 {
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
5013 interp.recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
5014
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5015 execution_error = true;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5016 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5017
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5018 if (parse_status || execution_error)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20527
diff changeset
5019 retval = 1;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5020
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5021 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5022 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5023
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5024 mxArray *
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5025 mexEvalStringWithTrap (const char *s)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5026 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
5027 mxArray *mx = nullptr;
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5028
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5029 octave::interpreter& interp = octave::__get_interpreter__ ();
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
5030
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5031 int parse_status;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5032 bool execution_error = false;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5033
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5034 octave_value_list ret;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5035
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5036 try
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5037 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 25922
diff changeset
5038 ret = interp.eval_string (std::string (s), false, parse_status, 0);
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5039 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5040 catch (const octave::execution_exception&)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5041 {
27474
3fec8e9fa2aa make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
5042 interp.recover_from_exception ();
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5043
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5044 execution_error = true;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5045 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5046
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5047 if (parse_status || execution_error)
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5048 {
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5049 const char *field_names[] = {"identifier", "message", "case", "stack"};
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5050 mx = mxCreateStructMatrix (1, 1, 4, field_names);
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5051 mxSetFieldByNumber (mx, 0, 0, mxCreateString ("Octave:MEX"));
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5052 std::string msg = "mexEvalStringWithTrap: eval of <"
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5053 + std::string (s) + "> failed";
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5054 mxSetFieldByNumber (mx, 0, 1, mxCreateString (msg.c_str ()));
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5055 mxSetFieldByNumber (mx, 0, 2, mxCreateCellMatrix (0, 0));
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
5056 mxSetFieldByNumber (mx, 0, 3, mxCreateStructMatrix (0, 1, 0, nullptr));
22454
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5057 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5058
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5059 return mx;
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5060 }
8445f67a8123 Add function mexEvalStringWithTrap to MEX API.
Rik <rik@octave.org>
parents: 22452
diff changeset
5061
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5062 void
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5063 mexErrMsgTxt (const char *s)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5064 {
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
5065 std::size_t len;
25751
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5066
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5067 if (s && (len = strlen (s)) > 0)
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5068 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5069 if (s[len - 1] == '\n')
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5070 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5071 std::string s_tmp (s, len - 1);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5072 error ("%s: %s\n", mexFunctionName (), s_tmp.c_str ());
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5073 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5074 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5075 error ("%s: %s", mexFunctionName (), s);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5076 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5077 else
16851
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5078 {
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5079 // For compatibility with Matlab, print an empty message.
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5080 // Octave's error routine requires a non-null input so use a SPACE.
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5081 error (" ");
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5082 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5083 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5084
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5085 void
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
5086 mexErrMsgIdAndTxt (const char *id, const char *fmt, ...)
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5087 {
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5088 if (fmt && strlen (fmt) > 0)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5089 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5090 const char *fname = mexFunctionName ();
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
5091 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5092 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5093 sprintf (tmpfmt, "%s: %s", fname, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5094 va_list args;
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5095 va_start (args, fmt);
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
5096 verror_with_id (id, tmpfmt, args);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5097 va_end (args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5098 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5099 else
16851
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5100 {
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5101 // For compatibility with Matlab, print an empty message.
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5102 // Octave's error routine requires a non-null input so use a SPACE.
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5103 error (" ");
209f0db3c32b mexErrMsgTxt should abort when called with an empty string (bug #39343).
Rik <rik@octave.org>
parents: 16708
diff changeset
5104 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5105 }
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5106
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5107 void
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5108 mexWarnMsgTxt (const char *s)
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5109 {
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
5110 std::size_t len;
25751
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5111
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5112 if (s && (len = strlen (s)) > 0)
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5113 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5114 if (s[len - 1] == '\n')
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5115 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5116 std::string s_tmp (s, len - 1);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5117 warning ("%s\n", s_tmp.c_str ());
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5118 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5119 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5120 warning ("%s", s);
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5121 }
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5122 else
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5123 {
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5124 // For compatibility with Matlab, print an empty message.
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5125 // Octave's warning routine requires a non-null input so use a SPACE.
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5126 warning (" ");
4bd60c9c6169 Suppress backtrace when MexErrMsgTxt message ends with newline (bug #54454).
Rik <rik@octave.org>
parents: 25688
diff changeset
5127 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5128 }
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5129
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5130 void
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
5131 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...)
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5132 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5133 // FIXME: is this right? What does Matlab do if fmt is NULL or
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5134 // an empty string?
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5135
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5136 if (fmt && strlen (fmt) > 0)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5137 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5138 const char *fname = mexFunctionName ();
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
5139 std::size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5140 OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5141 sprintf (tmpfmt, "%s: %s", fname, fmt);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5142 va_list args;
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5143 va_start (args, fmt);
30212
c27b9ba4c9bd * mex.cc: Don't use m_ prefix for function arguments and local variables.
John W. Eaton <jwe@octave.org>
parents: 30129
diff changeset
5144 vwarning_with_id (id, tmpfmt, args);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5145 va_end (args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6332
diff changeset
5146 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5147 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5148
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
5149 int
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5150 mexPrintf (const char *fmt, ...)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5151 {
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
5152 int retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5153 va_list args;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5154 va_start (args, fmt);
25646
4d565baa475e move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25452
diff changeset
5155 retval = octave::vformat (octave_stdout, fmt, args);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5156 va_end (args);
10127
f21fdff5c906 Change signature of mexPrintf.
David Grundberg <davidg@cs.umu.se>
parents: 10126
diff changeset
5157 return retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5158 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5159
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5160 mxArray *
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5161 mexGetVariable (const char *space, const char *name)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5162 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
5163 mxArray *retval = nullptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5164
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
5165 octave_value val;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5166
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5167 octave::interpreter& interp = octave::__get_interpreter__ ();
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
5168
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5169 if (! strcmp (space, "global"))
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
5170 val = interp.global_varval (name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5171 else
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
5172 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5173 // FIXME: should this be in variables.cc?
9144
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
5174
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
5175 octave::unwind_protect frame;
9144
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
5176
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5177 bool caller = ! strcmp (space, "caller");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5178 bool base = ! strcmp (space, "base");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5179
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5180 if (caller || base)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5181 {
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5182 // MEX files don't create a separate frame in the call stack,
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5183 // so we are already in the "caller" frame.
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5184
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5185 if (base)
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5186 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5187 octave::tree_evaluator& tw = interp.get_evaluator ();
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5188
29253
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
5189 frame.add (&octave::tree_evaluator::restore_frame, &tw,
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
5190 tw.current_call_stack_frame_number ());
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5191
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5192 tw.goto_base_frame ();
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5193 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5194
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
5195 val = interp.varval (name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5196 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
5197 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5198 mexErrMsgTxt ("mexGetVariable: symbol table does not exist");
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7577
diff changeset
5199 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
5200
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
5201 if (val.is_defined ())
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5202 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
5203 retval = mex_context->make_value (val);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
5204
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
5205 retval->set_name (name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5206 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5207
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5208 return retval;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5209 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5210
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5211 const mxArray *
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5212 mexGetVariablePtr (const char *space, const char *name)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5213 {
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5214 return mexGetVariable (space, name);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5215 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5216
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5217 int
15353
5f3a69a309a7 fix decl of mexPutVariable
John W. Eaton <jwe@octave.org>
parents: 15351
diff changeset
5218 mexPutVariable (const char *space, const char *name, const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5219 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5220 if (! ptr)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5221 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5222
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5223 if (! name)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5224 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5225
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5226 if (name[0] == '\0')
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5227 name = ptr->get_name ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5228
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5229 if (! name || name[0] == '\0')
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5230 return 1;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5231
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5232 octave::interpreter& interp = octave::__get_interpreter__ ();
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
5233
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5234 if (! strcmp (space, "global"))
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5235 {
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5236 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5237
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5238 // Use allocator that doesn't free memory because Octave may mutate
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5239 // the value (single element mxArray -> scalar octave_value object,
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5240 // for example) and we need these objects to continue to exist after
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5241 // mexCallMATLAB returns.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5242
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5243 octave::unwind_protect_var<std::pmr::memory_resource *>
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5244 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5245 #endif
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5246
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5247 interp.global_assign (name, mxArray::as_octave_value (ptr));
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5248 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5249 else
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5250 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5251 // FIXME: should this be in variables.cc?
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7179
diff changeset
5252
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
5253 octave::unwind_protect frame;
9144
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
5254
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5255 bool caller = ! strcmp (space, "caller");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5256 bool base = ! strcmp (space, "base");
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5257
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
5258 if (caller || base)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5259 {
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5260 // MEX files don't create a separate frame in the call stack,
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5261 // so we are already in the "caller" frame.
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5262
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5263 if (base)
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5264 {
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5265 octave::tree_evaluator& tw = interp.get_evaluator ();
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5266
29253
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
5267 frame.add (&octave::tree_evaluator::restore_frame, &tw,
28913793f678 prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents: 29173
diff changeset
5268 tw.current_call_stack_frame_number ());
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5269
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27083
diff changeset
5270 tw.goto_base_frame ();
16708
08f0f274de36 use correct "caller" workspace for mexputvariable and mexgetvariable
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
5271 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5272
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5273 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5274
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5275 // Use allocator that doesn't free memory because Octave may
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5276 // mutate the value (single element mxArray -> scalar
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5277 // octave_value object, for example) and we need these objects
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5278 // to continue to exist after mexCallMATLAB returns.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5279
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5280 octave::unwind_protect_var<std::pmr::memory_resource *>
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5281 upv (current_mx_memory_resource,
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5282 &the_mx_preserving_memory_resource);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5283 #endif
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5284
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26438
diff changeset
5285 interp.assign (name, mxArray::as_octave_value (ptr));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5286 }
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5287 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5288 mexErrMsgTxt ("mexPutVariable: symbol table does not exist");
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5289 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5290
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5291 return 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5292 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5293
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5294 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5295 mexMakeArrayPersistent (mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5296 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
5297 maybe_unmark_array (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5298 }
5879
4f1112bfafce [project @ 2006-07-05 23:50:44 by jwe]
jwe
parents: 5864
diff changeset
5299
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5300 void
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5301 mexMakeMemoryPersistent (void *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5302 {
7172
e9a590a137d8 [project @ 2007-11-14 16:17:10 by jwe]
jwe
parents: 7016
diff changeset
5303 maybe_unmark (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5304 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5305
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5306 int
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
5307 mexAtExit (void (*f) (void))
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5308 {
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
5309 if (mex_context)
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
5310 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5311 octave_mex_function& curr_mex_fcn = mex_context->current_mex_function ();
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5312
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5313 curr_mex_fcn.atexit (f);
6068
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
5314 }
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 6065
diff changeset
5315
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5316 return 0;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5317 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5318
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5319 const mxArray *
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5320 mexGet_interleaved (double handle, const char *property)
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5321 {
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5322 mxArray *m = nullptr;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5323
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5324 octave_value ret
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5325 = octave::get_property_from_handle (handle, property, "mexGet");
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5326
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5327 if (ret.is_defined ())
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5328 m = ret.as_mxArray (true);
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5329
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5330 return m;
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5331 }
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5332
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5333 const mxArray *
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
5334 mexGet (double handle, const char *property)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5335 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
5336 mxArray *m = nullptr;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
5337
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5338 octave_value ret
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5339 = octave::get_property_from_handle (handle, property, "mexGet");
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
5340
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
5341 if (ret.is_defined ())
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
5342 m = ret.as_mxArray (false);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
5343
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
5344 return m;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5345 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5346
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5347 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5348 mexIsGlobal (const mxArray *ptr)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5349 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5350 return mxIsFromGlobalWS (ptr);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5351 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5352
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5353 int
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5354 mexIsLocked (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5355 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5356 int retval = 0;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5357
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5358 if (mex_context)
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5359 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5360 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5361
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5362 octave::interpreter& interp = octave::__get_interpreter__ ();
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
5363
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
5364 retval = interp.mislocked (fname);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5365 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5366
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5367 return retval;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5368 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5369
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30349
diff changeset
5370 std::map<std::string, int> mex_lock_count;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5371
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5372 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5373 mexLock (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5374 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5375 if (mex_context)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5376 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5377 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5378
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5379 if (mex_lock_count.find (fname) == mex_lock_count.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5380 mex_lock_count[fname] = 1;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5381 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5382 mex_lock_count[fname]++;
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5383
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5384 octave::interpreter& interp = octave::__get_interpreter__ ();
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
5385
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
5386 interp.mlock ();
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5387 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5388 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5389
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5390 int
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
5391 mexSet (double handle, const char *property, mxArray *val)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5392 {
30770
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5393 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5394
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5395 // Use allocator that doesn't free memory because Octave may mutate
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5396 // the value (single element mxArray -> scalar octave_value object,
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5397 // for example) and we need these objects to continue to exist after
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5398 // mexCallMATLAB returns.
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5399
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5400 octave::unwind_protect_var<std::pmr::memory_resource *>
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5401 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource);
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5402
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5403 #endif
2aff9dda08f1 avoid early data free in mxArray -> octave_value data transfer (bug #61813)
John W. Eaton <jwe@octave.org>
parents: 30769
diff changeset
5404
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5405 bool ret = octave::set_property_in_handle (handle, property,
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5406 mxArray::as_octave_value (val),
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29870
diff changeset
5407 "mexSet");
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6493
diff changeset
5408 return (ret ? 0 : 1);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5409 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5410
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5411 void
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5412 mexUnlock (void)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5413 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5414 if (mex_context)
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5415 {
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5416 const char *fname = mexFunctionName ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5879
diff changeset
5417
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
5418 auto p = mex_lock_count.find (fname);
5905
e5c0831a48bd [project @ 2006-07-26 19:27:48 by jwe]
jwe
parents: 5903
diff changeset
5419
6062
a813714cb04b [project @ 2006-10-18 23:30:22 by jwe]
jwe
parents: 6018
diff changeset
5420 if (p != mex_lock_count.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5421 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5422 int count = --mex_lock_count[fname];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5423
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5424 if (count == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5425 {
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30919
diff changeset
5426 octave::interpreter& interp = octave::__get_interpreter__ ();
23703
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
5427
6eb5f6199a5a move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
5428 interp.munlock (fname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5429
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5430 mex_lock_count.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5431 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10225
diff changeset
5432 }
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5433 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
5434 }