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
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 //
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
31 #include <string>
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
32
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
33 #include "oct-shlib.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
34
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
35 #include "ov-fcn.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
36 #include "ov-builtin.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
37 #include "ov-typeinfo.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
38
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
39 class octave_value;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
40 class octave_value_list;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
47 // Dynamically-linked functions.
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
48
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
49 class
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
50 octave_mex_function : public octave_function
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
51 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
52 public:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
70 ~octave_mex_function (void);
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
80
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
81 std::string fcn_file_name (void) const;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
88
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
89 bool is_builtin_function (void) const { return false; }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
90
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
91 bool is_mex_function (void) const { return true; }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 5864
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
112 private:
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
113
23499
7d89f815d78e modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents: 23446
diff changeset
114 void *m_mex_fcn_ptr;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
c9f0839c583f [project @ 2006-10-20 16:54:30 by jwe]
jwe
parents: 5864
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
119
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
120 // The time the file was last checked to see if it needs to be
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
128 // True if this function came from a file that is considered to be a
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
129 // system function. This affects whether we check the time stamp
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
132
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
133 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
134 };
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
135
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
136 #endif