Mercurial > octave-nkf
annotate libinterp/octave-value/ov-mex-fcn.cc @ 19632:76478d2da117
unconditionally disable the octave_allocator class
* configure.ac: Delete the --enable-octave-allocator option.
* oct-alloc.h: Delete octave_allocator class. Warn if file is
included. Unconditionally define macros to be empty.
* NEWS: Make note of these changes.
* oct-alloc.cc: Delete.
* liboctave/util/module.mk (UTIL_SRC): Remove it from the list.
* make_int.cc, Cell.h, oct-obj.cc, oct-obj.h, audiodevinfo.cc,
ov-base-int.h, ov-base-scalar.h, ov-bool-mat.cc, ov-bool-mat.h,
ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h,
ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.h,
ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc,
ov-complex.h, ov-cs-list.cc, ov-cs-list.h, ov-cx-diag.cc,
ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc,
ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc,
ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc,
ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc,
ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h,
ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc,
ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-java.cc,
ov-java.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-perm.cc, ov-perm.h,
ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc,
ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc,
ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h,
ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, ov.h, pt-const.cc, pt-const.h, idx-vector.cc,
idx-vector.h: Delete uses of oct-alloc.h and OCTAVE_ALLOCATOR macros.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 13:43:29 -0500 |
parents | 91cd85a75705 |
children | 4197fc428c7d |
rev | line source |
---|---|
5864 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
5864 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
5864 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
5864 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "oct-shlib.h" | |
28 | |
29 #include <defaults.h> | |
30 #include "dynamic-ld.h" | |
31 #include "error.h" | |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7872
diff
changeset
|
32 #include "gripes.h" |
5864 | 33 #include "oct-obj.h" |
34 #include "ov-mex-fcn.h" | |
35 #include "ov.h" | |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
36 #include "profiler.h" |
5864 | 37 #include "toplev.h" |
38 #include "unwind-prot.h" | |
39 | |
40 | |
41 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_mex_function, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
42 "mex function", "mex function"); |
5864 | 43 |
44 octave_mex_function::octave_mex_function | |
45 (void *fptr, bool fmex, const octave_shlib& shl, | |
46 const std::string& nm) | |
6068 | 47 : octave_function (nm), mex_fcn_ptr (fptr), exit_fcn_ptr (0), |
48 have_fmex (fmex), sh_lib (shl) | |
5864 | 49 { |
50 mark_fcn_file_up_to_date (time_parsed ()); | |
51 | |
52 std::string file_name = fcn_file_name (); | |
53 | |
54 system_fcn_file | |
55 = (! file_name.empty () | |
56 && Voct_file_dir == file_name.substr (0, Voct_file_dir.length ())); | |
57 } | |
58 | |
59 octave_mex_function::~octave_mex_function (void) | |
60 { | |
6068 | 61 if (exit_fcn_ptr) |
62 (*exit_fcn_ptr) (); | |
63 | |
7872 | 64 octave_dynamic_loader::remove_mex (my_name, sh_lib); |
5864 | 65 } |
66 | |
67 std::string | |
68 octave_mex_function::fcn_file_name (void) const | |
69 { | |
70 return sh_lib.file_name (); | |
71 } | |
72 | |
73 octave_time | |
74 octave_mex_function::time_parsed (void) const | |
75 { | |
76 return sh_lib.time_loaded (); | |
77 } | |
78 | |
79 octave_value_list | |
80 octave_mex_function::subsref (const std::string& type, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
81 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
82 int nargout) |
5864 | 83 { |
84 octave_value_list retval; | |
85 | |
86 switch (type[0]) | |
87 { | |
88 case '(': | |
89 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
90 int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; |
5864 | 91 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
92 retval = do_multi_index_op (tmp_nargout, idx.front ()); |
5864 | 93 } |
94 break; | |
95 | |
96 case '{': | |
97 case '.': | |
98 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
99 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
100 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
5864 | 101 } |
102 break; | |
103 | |
104 default: | |
105 panic_impossible (); | |
106 } | |
107 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
108 // FIXME: perhaps there should be an |
5864 | 109 // octave_value_list::next_subsref member function? See also |
110 // octave_user_function::subsref. | |
111 // | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 // FIXME: Note that if a function call returns multiple |
5864 | 113 // values, and there is further indexing to perform, then we are |
114 // ignoring all but the first value. Is this really what we want to | |
115 // do? If it is not, then what should happen for stat("file").size, | |
116 // for exmaple? | |
117 | |
118 if (idx.size () > 1) | |
119 retval = retval(0).next_subsref (nargout, type, idx); | |
120 | |
121 return retval; | |
122 } | |
123 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 // FIXME: shouldn't this declaration be a header file somewhere? |
5864 | 125 extern octave_value_list |
6068 | 126 call_mex (bool have_fmex, void *f, const octave_value_list& args, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
127 int nargout, octave_mex_function *curr_mex_fcn); |
5864 | 128 |
129 octave_value_list | |
130 octave_mex_function::do_multi_index_op (int nargout, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
131 const octave_value_list& args) |
5864 | 132 { |
133 octave_value_list retval; | |
134 | |
135 if (error_state) | |
136 return retval; | |
137 | |
138 if (args.has_magic_colon ()) | |
139 ::error ("invalid use of colon in function argument list"); | |
140 else | |
141 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
142 unwind_protect frame; |
5864 | 143 |
144 octave_call_stack::push (this); | |
145 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
146 frame.add_fcn (octave_call_stack::pop); |
5864 | 147 |
7487
1e01db14700b
catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
148 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
149 { |
19361
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17787
diff
changeset
|
150 BEGIN_PROFILER_BLOCK (octave_mex_function) |
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17787
diff
changeset
|
151 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
152 retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); |
19361
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17787
diff
changeset
|
153 |
12960
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
154 END_PROFILER_BLOCK |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
155 } |
7487
1e01db14700b
catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
156 catch (octave_execution_exception) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
157 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
158 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
159 } |
5864 | 160 } |
161 | |
162 return retval; | |
163 } |