Mercurial > hg > octave-lyh
annotate src/interp-core/mxarray.in.h @ 15096:909a2797935b
maint: Move interp source code without DEFUNs to interp-core/ dir.
* src/Makefile.am, interpfcn/module.mk, operators/module.mk,
parse-tree/module.mk: Update build system by moving source lists and rules
to the correct directory.
* Cell.cc, Cell.h, c-file-ptr-stream.cc, c-file-ptr-stream.h, comment-list.cc,
comment-list.h, cutils.c, cutils.h, defun-dld.h, defun-int.h, display.cc,
display.h, dynamic-ld.cc, dynamic-ld.h, gl-render.cc, gl-render.h,
gl2ps-renderer.cc, gl2ps-renderer.h, gl2ps.c, gl2ps.h, gripes.cc, gripes.h,
jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h,
ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h, ls-mat-ascii.cc,
ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.cc, ls-mat5.h, ls-oct-binary.cc,
ls-oct-binary.h, ls-utils.cc, ls-utils.h, matherr.c, mex.cc, mex.h, mexproto.h,
module.mk, mxarray.in.h, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc,
oct-fstrm.h, oct-hdf5.h, oct-iostrm.cc, oct-iostrm.h, oct-lvalue.cc,
oct-lvalue.h, oct-map.cc, oct-map.h, oct-obj.cc, oct-obj.h, oct-prcstrm.cc,
oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc,
oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct.h, procstream.cc,
procstream.h, pt-jit.cc, pt-jit.h, siglist.c, siglist.h, sparse-xdiv.cc,
sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, txt-eng-ft.cc, txt-eng-ft.h,
txt-eng.h, unwind-prot.cc, unwind-prot.h, xdiv.cc, xdiv.h, xgl2ps.c, xnorm.cc,
xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h: Move from src/ dir to
src/interp-core dir.
* ops.h: Move to operators/ directory.
* octave.gperf, token.cc, token.h: Move to parse-tree directory.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 03 Aug 2012 13:18:21 -0700 |
parents | src/mxarray.in.h@8a62283e3783 |
children | 8523df595d42 |
rev | line source |
---|---|
15089
8a62283e3783
maint: Add DO NOT EDIT messages to src/*.in.h for propagation to generated .h files.
Rik <rik@octave.org>
parents:
14547
diff
changeset
|
1 // DO NOT EDIT! Generated automatically from mxarray.in.h by configure |
6686 | 2 /* |
3 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4 Copyright (C) 2001-2012 Paul Kienzle |
6686 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
6686 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
6686 | 21 |
22 */ | |
23 | |
24 /* | |
25 | |
26 Part of this code was originally distributed as part of Octave Forge under | |
27 the following terms: | |
28 | |
29 Author: Paul Kienzle | |
30 I grant this code to the public domain. | |
31 2001-03-22 | |
32 | |
33 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
34 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
35 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
36 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
37 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
38 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
39 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
40 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
41 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
42 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
43 SUCH DAMAGE. | |
44 | |
45 */ | |
46 | |
47 #if ! defined (MXARRAY_H) | |
48 #define MXARRAY_H | |
49 | |
50 typedef enum | |
51 { | |
52 mxREAL = 0, | |
53 mxCOMPLEX = 1 | |
54 } | |
55 mxComplexity; | |
56 | |
57 typedef enum | |
58 { | |
59 mxUNKNOWN_CLASS = 0, | |
60 mxCELL_CLASS, | |
61 mxSTRUCT_CLASS, | |
62 mxLOGICAL_CLASS, | |
63 mxCHAR_CLASS, | |
64 mxUNUSED_CLASS, | |
65 mxDOUBLE_CLASS, | |
66 mxSINGLE_CLASS, | |
67 mxINT8_CLASS, | |
68 mxUINT8_CLASS, | |
69 mxINT16_CLASS, | |
70 mxUINT16_CLASS, | |
71 mxINT32_CLASS, | |
72 mxUINT32_CLASS, | |
73 mxINT64_CLASS, | |
74 mxUINT64_CLASS, | |
7056 | 75 mxFUNCTION_CLASS |
6686 | 76 } |
77 mxClassID; | |
78 | |
7574
9669b69e34ef
define mxLogical as unsigned char instead of int
John W. Eaton <jwe@octave.org>
parents:
7417
diff
changeset
|
79 typedef unsigned char mxLogical; |
6686 | 80 |
81 /* typedef Uint16 mxChar; */ | |
82 typedef char mxChar; | |
83 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
84 /* |
6686 | 85 * FIXME? Mathworks says these should be size_t on 64-bit system and when |
86 * mex is used with the -largearraydims flag, but why do that? Its better | |
87 * to conform to the same indexing as the rest of Octave | |
88 */ | |
9906 | 89 typedef %OCTAVE_IDX_TYPE% mwSize; |
90 typedef %OCTAVE_IDX_TYPE% mwIndex; | |
6686 | 91 |
92 #if ! defined (MXARRAY_TYPEDEFS_ONLY) | |
93 | |
7417 | 94 #include <cstring> |
95 | |
6686 | 96 class octave_value; |
97 | |
98 #define DO_MUTABLE_METHOD(RET_T, METHOD_CALL) \ | |
99 RET_T retval = rep->METHOD_CALL; \ | |
100 \ | |
101 if (rep->mutation_needed ()) \ | |
102 { \ | |
103 maybe_mutate (); \ | |
104 retval = rep->METHOD_CALL; \ | |
105 } \ | |
106 \ | |
107 return retval | |
108 | |
109 #define DO_VOID_MUTABLE_METHOD(METHOD_CALL) \ | |
110 rep->METHOD_CALL; \ | |
111 \ | |
112 if (rep->mutation_needed ()) \ | |
113 { \ | |
114 maybe_mutate (); \ | |
115 rep->METHOD_CALL; \ | |
116 } | |
117 | |
118 // This just provides a way to avoid infinite recursion when building | |
119 // mxArray objects. | |
120 | |
121 struct | |
122 xmxArray | |
123 { | |
124 xmxArray (void) { } | |
125 }; | |
126 | |
127 // The main interface class. The representation can be based on an | |
128 // octave_value object or a separate object that tries to reproduce | |
129 // the semantics of mxArray objects in Matlab more directly. | |
130 | |
131 class mxArray | |
132 { | |
133 public: | |
134 | |
135 mxArray (const octave_value& ov); | |
136 | |
137 mxArray (mxClassID id, mwSize ndims, const mwSize *dims, | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
138 mxComplexity flag = mxREAL); |
6686 | 139 |
140 mxArray (mxClassID id, const dim_vector& dv, mxComplexity flag = mxREAL); | |
141 | |
142 mxArray (mxClassID id, mwSize m, mwSize n, mxComplexity flag = mxREAL); | |
143 | |
144 mxArray (mxClassID id, double val); | |
145 | |
146 mxArray (mxClassID id, mxLogical val); | |
147 | |
148 mxArray (const char *str); | |
149 | |
6806 | 150 mxArray (mwSize m, const char **str); |
6686 | 151 |
6806 | 152 mxArray (mxClassID id, mwSize m, mwSize n, mwSize nzmax, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
153 mxComplexity flag = mxREAL); |
6686 | 154 |
155 mxArray (mwSize ndims, const mwSize *dims, int num_keys, const char **keys); | |
156 | |
157 mxArray (const dim_vector& dv, int num_keys, const char **keys); | |
158 | |
159 mxArray (mwSize m, mwSize n, int num_keys, const char **keys); | |
160 | |
161 mxArray (mwSize ndims, const mwSize *dims); | |
162 | |
163 mxArray (const dim_vector& dv); | |
164 | |
165 mxArray (mwSize m, mwSize n); | |
166 | |
11277
7d5351fc575a
mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents:
11100
diff
changeset
|
167 virtual mxArray *dup (void) const |
6686 | 168 { |
11277
7d5351fc575a
mex.cc: convert mxArray_octave_value to matlab style representation when duplicating
John W. Eaton <jwe@octave.org>
parents:
11100
diff
changeset
|
169 mxArray *new_rep = rep->dup (); |
6686 | 170 |
171 return new mxArray (new_rep, name); | |
172 } | |
173 | |
174 virtual ~mxArray (void); | |
175 | |
176 virtual bool is_octave_value (void) const { return rep->is_octave_value (); } | |
177 | |
178 virtual int is_cell (void) const { return rep->is_cell (); } | |
179 | |
180 virtual int is_char (void) const { return rep->is_char (); } | |
181 | |
182 virtual int is_class (const char *name_arg) const { return rep->is_class (name_arg); } | |
183 | |
184 virtual int is_complex (void) const { return rep->is_complex (); } | |
185 | |
186 virtual int is_double (void) const { return rep->is_double (); } | |
187 | |
11100
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
188 virtual int is_function_handle (void) const { return rep->is_function_handle (); } |
cdf940db26a0
provide mxIsFunctionHandle MEX interface function
John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
189 |
6686 | 190 virtual int is_int16 (void) const { return rep->is_int16 (); } |
191 | |
192 virtual int is_int32 (void) const { return rep->is_int32 (); } | |
193 | |
194 virtual int is_int64 (void) const { return rep->is_int64 (); } | |
195 | |
196 virtual int is_int8 (void) const { return rep->is_int8 (); } | |
197 | |
198 virtual int is_logical (void) const { return rep->is_logical (); } | |
199 | |
200 virtual int is_numeric (void) const { return rep->is_numeric (); } | |
201 | |
202 virtual int is_single (void) const { return rep->is_single (); } | |
203 | |
204 virtual int is_sparse (void) const { return rep->is_sparse (); } | |
205 | |
206 virtual int is_struct (void) const { return rep->is_struct (); } | |
207 | |
208 virtual int is_uint16 (void) const { return rep->is_uint16 (); } | |
209 | |
210 virtual int is_uint32 (void) const { return rep->is_uint32 (); } | |
211 | |
212 virtual int is_uint64 (void) const { return rep->is_uint64 (); } | |
213 | |
214 virtual int is_uint8 (void) const { return rep->is_uint8 (); } | |
215 | |
216 virtual int is_logical_scalar (void) const { return rep->is_logical_scalar (); } | |
217 | |
218 virtual int is_logical_scalar_true (void) const { return rep->is_logical_scalar_true (); } | |
219 | |
220 virtual mwSize get_m (void) const { return rep->get_m (); } | |
221 | |
222 virtual mwSize get_n (void) const { return rep->get_n (); } | |
223 | |
224 virtual mwSize *get_dimensions (void) const { return rep->get_dimensions (); } | |
225 | |
226 virtual mwSize get_number_of_dimensions (void) const { return rep->get_number_of_dimensions (); } | |
227 | |
228 virtual void set_m (mwSize m) { DO_VOID_MUTABLE_METHOD (set_m (m)); } | |
229 | |
230 virtual void set_n (mwSize n) { DO_VOID_MUTABLE_METHOD (set_n (n)); } | |
231 | |
232 virtual void set_dimensions (mwSize *dims_arg, mwSize ndims_arg) { DO_VOID_MUTABLE_METHOD (set_dimensions (dims_arg, ndims_arg)); } | |
233 | |
234 virtual mwSize get_number_of_elements (void) const { return rep->get_number_of_elements (); } | |
235 | |
236 virtual int is_empty (void) const { return get_number_of_elements () == 0; } | |
237 | |
238 const char *get_name (void) const { return name; } | |
239 | |
240 void set_name (const char *name_arg); | |
241 | |
242 virtual mxClassID get_class_id (void) const { return rep->get_class_id (); } | |
243 | |
244 virtual const char *get_class_name (void) const { return rep->get_class_name (); } | |
245 | |
246 virtual void set_class_name (const char *name_arg) { DO_VOID_MUTABLE_METHOD (set_class_name (name_arg)); } | |
247 | |
248 virtual mxArray *get_cell (mwIndex idx) const { DO_MUTABLE_METHOD (mxArray *, get_cell (idx)); } | |
249 | |
250 virtual void set_cell (mwIndex idx, mxArray *val) { DO_VOID_MUTABLE_METHOD (set_cell (idx, val)); } | |
251 | |
252 virtual double get_scalar (void) const { return rep->get_scalar (); } | |
253 | |
254 virtual void *get_data (void) const { DO_MUTABLE_METHOD (void *, get_data ()); } | |
255 | |
256 virtual void *get_imag_data (void) const { DO_MUTABLE_METHOD (void *, get_imag_data ()); } | |
257 | |
258 virtual void set_data (void *pr) { DO_VOID_MUTABLE_METHOD (set_data (pr)); } | |
259 | |
260 virtual void set_imag_data (void *pi) { DO_VOID_MUTABLE_METHOD (set_imag_data (pi)); } | |
261 | |
262 virtual mwIndex *get_ir (void) const { DO_MUTABLE_METHOD (mwIndex *, get_ir ()); } | |
263 | |
264 virtual mwIndex *get_jc (void) const { DO_MUTABLE_METHOD (mwIndex *, get_jc ()); } | |
265 | |
266 virtual mwSize get_nzmax (void) const { return rep->get_nzmax (); } | |
267 | |
268 virtual void set_ir (mwIndex *ir) { DO_VOID_MUTABLE_METHOD (set_ir (ir)); } | |
269 | |
270 virtual void set_jc (mwIndex *jc) { DO_VOID_MUTABLE_METHOD (set_jc (jc)); } | |
271 | |
272 virtual void set_nzmax (mwSize nzmax) { DO_VOID_MUTABLE_METHOD (set_nzmax (nzmax)); } | |
273 | |
274 virtual int add_field (const char *key) { DO_MUTABLE_METHOD (int, add_field (key)); } | |
275 | |
276 virtual void remove_field (int key_num) { DO_VOID_MUTABLE_METHOD (remove_field (key_num)); } | |
277 | |
278 virtual mxArray *get_field_by_number (mwIndex index, int key_num) const { DO_MUTABLE_METHOD (mxArray *, get_field_by_number (index, key_num)); } | |
279 | |
280 virtual void set_field_by_number (mwIndex index, int key_num, mxArray *val) { DO_VOID_MUTABLE_METHOD (set_field_by_number (index, key_num, val)); } | |
281 | |
282 virtual int get_number_of_fields (void) const { return rep->get_number_of_fields (); } | |
283 | |
284 virtual const char *get_field_name_by_number (int key_num) const { DO_MUTABLE_METHOD (const char*, get_field_name_by_number (key_num)); } | |
285 | |
286 virtual int get_field_number (const char *key) const { DO_MUTABLE_METHOD (int, get_field_number (key)); } | |
287 | |
6806 | 288 virtual int get_string (char *buf, mwSize buflen) const { return rep->get_string (buf, buflen); } |
6686 | 289 |
290 virtual char *array_to_string (void) const { return rep->array_to_string (); } | |
291 | |
292 virtual mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const { return rep->calc_single_subscript (nsubs, subs); } | |
293 | |
294 virtual size_t get_element_size (void) const { return rep->get_element_size (); } | |
295 | |
296 virtual bool mutation_needed (void) const { return rep->mutation_needed (); } | |
297 | |
298 virtual mxArray *mutate (void) const { return rep->mutate (); } | |
299 | |
300 static void *malloc (size_t n); | |
301 | |
302 static void *calloc (size_t n, size_t t); | |
303 | |
304 static char *strsave (const char *str) | |
305 { | |
306 char *retval = 0; | |
307 | |
308 if (str) | |
309 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
310 mwSize sz = sizeof (mxChar) * (strlen (str) + 1); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
311 retval = static_cast<char *> (mxArray::malloc (sz)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
312 strcpy (retval, str); |
6686 | 313 } |
314 | |
315 return retval; | |
316 } | |
317 | |
318 static octave_value as_octave_value (mxArray *ptr); | |
319 | |
320 protected: | |
321 | |
322 virtual octave_value as_octave_value (void) const; | |
323 | |
324 mxArray (const xmxArray&) : rep (0), name (0) { } | |
325 | |
326 private: | |
327 | |
328 mutable mxArray *rep; | |
329 | |
330 char *name; | |
331 | |
332 mxArray (mxArray *r, const char *n) | |
333 : rep (r), name (strsave (n)) { } | |
334 | |
335 void maybe_mutate (void) const; | |
336 | |
337 // No copying! | |
338 | |
339 mxArray (const mxArray&); | |
340 | |
341 mxArray& operator = (const mxArray&); | |
342 }; | |
343 | |
344 #undef DO_MUTABLE_METHOD | |
345 #undef DO_VOID_MUTABLE_METHOD | |
346 | |
347 #endif | |
348 #endif |