Mercurial > octave
annotate libinterp/octave-value/ov-mex-fcn.h @ 28125:0a88a4743096
tag mex function as supporting interleaved complex (or not)
* dynamic-ld.cc (dynamic_loader::try_load_mex): New function.
(dynamic_loader::load_mex): Call it. Check mex file for
__mx_has_interleaved_complex__ symbol and pass flag to
octave_mex_function constructor.
* ov-mex-fcn.cc (octave_mex_function::m_interleaved): New data member.
(octave_mex_function::octave_mex_function):
New arg, interleaved.
(octave_mex_function::use_interleaved_complex): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 18 Feb 2020 12:50:18 -0500 |
parents | bd51beb6205e |
children | b743a63e2dab |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1996-2020 The Octave Project Developers |
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 //////////////////////////////////////////////////////////////////////// |
5864 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 #if ! defined (octave_ov_mex_fcn_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
27 #define octave_ov_mex_fcn_h 1 |
5864 | 28 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
30 |
5864 | 31 #include <string> |
32 | |
33 #include "oct-shlib.h" | |
34 | |
35 #include "ov-fcn.h" | |
36 #include "ov-builtin.h" | |
37 #include "ov-typeinfo.h" | |
38 | |
39 class octave_value; | |
40 class octave_value_list; | |
41 | |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23520
diff
changeset
|
42 namespace octave |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23520
diff
changeset
|
43 { |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23520
diff
changeset
|
44 class tree_evaluator; |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23520
diff
changeset
|
45 } |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23520
diff
changeset
|
46 |
5864 | 47 // Dynamically-linked functions. |
48 | |
49 class | |
50 octave_mex_function : public octave_function | |
51 { | |
52 public: | |
53 | |
12123
9ea6f69259d7
more constructor initialization fixes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11523
diff
changeset
|
54 octave_mex_function (void) |
28125
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
55 : m_mex_fcn_ptr (nullptr), m_exit_fcn_ptr (nullptr), m_sh_lib (), |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
56 m_time_checked (), m_interleaved (false), m_is_fmex (false), |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
57 m_is_system_fcn_file (false) |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
58 { } |
5864 | 59 |
28125
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
60 octave_mex_function (void *fptr, bool interleaved, bool fmex, |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
61 const octave::dynamic_library& shl, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
62 const std::string& nm = ""); |
5864 | 63 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
64 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
65 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
66 octave_mex_function (const octave_mex_function& fn) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
67 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
68 octave_mex_function& operator = (const octave_mex_function& fn) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
69 |
5864 | 70 ~octave_mex_function (void); |
71 | |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
72 octave_function * function_value (bool = false) { return this; } |
5864 | 73 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
74 const octave_function * function_value (bool = false) const { return this; } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
75 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
76 void mark_fcn_file_up_to_date (const octave::sys::time& t) |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
77 { |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
78 m_time_checked = t; |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
79 } |
5864 | 80 |
81 std::string fcn_file_name (void) const; | |
82 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
83 octave::sys::time time_parsed (void) const; |
5864 | 84 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
85 octave::sys::time time_checked (void) const { return m_time_checked; } |
5864 | 86 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
87 bool is_system_fcn_file (void) const { return m_is_system_fcn_file; } |
5864 | 88 |
89 bool is_builtin_function (void) const { return false; } | |
90 | |
91 bool is_mex_function (void) const { return true; } | |
92 | |
28125
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
93 bool use_interleaved_complex (void) const { return m_interleaved; } |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
94 |
26917
9dd1d8973877
avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
95 // We don't need to override both forms of the call method. The using |
9dd1d8973877
avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
96 // declaration will avoid warnings about partially-overloaded virtual |
9dd1d8973877
avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
97 // functions. |
9dd1d8973877
avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
98 using octave_function::call; |
9dd1d8973877
avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
99 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
100 octave_value_list |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
101 call (octave::tree_evaluator& tw, int nargout = 0, |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
102 const octave_value_list& args = octave_value_list ()); |
5864 | 103 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
104 void atexit (void (*fcn) (void)) { m_exit_fcn_ptr = fcn; } |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
105 |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
106 octave::dynamic_library get_shlib (void) const { return m_sh_lib; } |
6068 | 107 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
108 void *mex_fcn_ptr (void) const { return m_mex_fcn_ptr; } |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
109 |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
110 bool is_fmex (void) const { return m_is_fmex; } |
9960
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
111 |
5864 | 112 private: |
113 | |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
114 void *m_mex_fcn_ptr; |
5864 | 115 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
116 void (*m_exit_fcn_ptr) (void); |
6068 | 117 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
118 octave::dynamic_library m_sh_lib; |
5864 | 119 |
120 // The time the file was last checked to see if it needs to be | |
121 // parsed again. | |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
122 mutable octave::sys::time m_time_checked; |
5864 | 123 |
28125
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
124 bool m_interleaved; |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
125 |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
126 bool m_is_fmex; |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
127 |
5864 | 128 // True if this function came from a file that is considered to be a |
129 // system function. This affects whether we check the time stamp | |
130 // on the file to see if it has changed. | |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
131 bool m_is_system_fcn_file; |
5864 | 132 |
133 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
134 }; | |
135 | |
136 #endif |