Mercurial > octave
annotate libinterp/octave-value/ov-mex-fcn.cc @ 32060:1203a2d81a42
Add BIST tests for Matlab compatibility for functions which accept negative dimensions.
* data.cc (Fones, Finf, Feps, Feye): Add BIST test for negative dimensions.
* rand.cc (Frand): Add BIST test for negative dimensions.
* ov-cell.cc (Fcell): Add BIST test for negative dimensions.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 26 Apr 2023 16:26:32 -0700 |
parents | 21f9b34eb893 |
children | 2e484f9f1f18 |
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 // |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31607
diff
changeset
|
3 // Copyright (C) 1996-2023 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 //////////////////////////////////////////////////////////////////////// |
5864 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
5864 | 28 #endif |
29 | |
29639
161daebce243
Mark compiled system functions correctly if OCTAVE_HOME is non-canonical (bug #60554).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
30 #include "file-ops.h" |
5864 | 31 #include "oct-shlib.h" |
32 | |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
33 #include "defaults.h" |
5864 | 34 #include "dynamic-ld.h" |
35 #include "error.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
36 #include "errwarn.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
37 #include "interpreter-private.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
38 #include "interpreter.h" |
5864 | 39 #include "ov-mex-fcn.h" |
40 #include "ov.h" | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
41 #include "ovl.h" |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
42 #include "profiler.h" |
5864 | 43 #include "unwind-prot.h" |
44 | |
45 | |
46 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
|
47 "mex function", "mex function"); |
5864 | 48 |
49 octave_mex_function::octave_mex_function | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
50 (void *fptr, bool interleaved, bool fmex, const octave::dynamic_library& shl, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
51 const std::string& nm) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23753
diff
changeset
|
52 : octave_function (nm), m_mex_fcn_ptr (fptr), m_exit_fcn_ptr (nullptr), |
28125
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
53 m_sh_lib (shl), m_interleaved (interleaved), m_is_fmex (fmex), |
0a88a4743096
tag mex function as supporting interleaved complex (or not)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
54 m_is_system_fcn_file (false) |
5864 | 55 { |
56 mark_fcn_file_up_to_date (time_parsed ()); | |
57 | |
58 std::string file_name = fcn_file_name (); | |
59 | |
29643
874430de1cc7
Fix error if test suite is run before Octave is installed (bug #60554).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29639
diff
changeset
|
60 static const std::string canonical_oct_file_dir |
874430de1cc7
Fix error if test suite is run before Octave is installed (bug #60554).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29639
diff
changeset
|
61 = octave::sys::canonicalize_file_name (octave::config::oct_file_dir ()); |
29639
161daebce243
Mark compiled system functions correctly if OCTAVE_HOME is non-canonical (bug #60554).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
62 static const std::string oct_file_dir |
29643
874430de1cc7
Fix error if test suite is run before Octave is installed (bug #60554).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29639
diff
changeset
|
63 = canonical_oct_file_dir.empty () ? octave::config::oct_file_dir () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
64 : canonical_oct_file_dir; |
29643
874430de1cc7
Fix error if test suite is run before Octave is installed (bug #60554).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29639
diff
changeset
|
65 |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
66 m_is_system_fcn_file |
5864 | 67 = (! file_name.empty () |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23627
diff
changeset
|
68 && oct_file_dir == file_name.substr (0, oct_file_dir.length ())); |
5864 | 69 } |
70 | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
71 octave_mex_function::~octave_mex_function () |
5864 | 72 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
73 if (m_exit_fcn_ptr) |
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
74 (*m_exit_fcn_ptr) (); |
6068 | 75 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30919
diff
changeset
|
76 octave::dynamic_loader& dyn_loader = octave::__get_dynamic_loader__ (); |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
77 |
30034
0edbd0efb69d
maint: use "m_" prefix for member variables in octave_function class.
Rik <rik@octave.org>
parents:
29644
diff
changeset
|
78 dyn_loader.remove_mex (m_name, m_sh_lib); |
5864 | 79 } |
80 | |
81 std::string | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
82 octave_mex_function::fcn_file_name () const |
5864 | 83 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
84 return m_sh_lib.file_name (); |
5864 | 85 } |
86 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 octave::sys::time |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
88 octave_mex_function::time_parsed () const |
5864 | 89 { |
23499
7d89f815d78e
modernize octave_mex_function
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
90 return m_sh_lib.time_loaded (); |
5864 | 91 } |
92 | |
93 octave_value_list | |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
94 octave_mex_function::execute (octave::tree_evaluator& tw, int nargout, |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
95 const octave_value_list& args) |
5864 | 96 { |
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:
30564
diff
changeset
|
97 return tw.execute_mex_function (*this, nargout, args); |
5864 | 98 } |