GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-mex-fcn.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "file-ops.h"
31 #include "oct-shlib.h"
32 
33 #include "defaults.h"
34 #include "dynamic-ld.h"
35 #include "error.h"
36 #include "errwarn.h"
37 #include "interpreter-private.h"
38 #include "interpreter.h"
39 #include "ov-mex-fcn.h"
40 #include "ov.h"
41 #include "ovl.h"
42 #include "profiler.h"
43 #include "unwind-prot.h"
44 
45 
47  "mex function", "mex function");
48 
50 (void *fptr, bool interleaved, bool fmex, const octave::dynamic_library& shl,
51  const std::string& nm)
52  : octave_function (nm), m_mex_fcn_ptr (fptr), m_exit_fcn_ptr (nullptr),
53  m_sh_lib (shl), m_interleaved (interleaved), m_is_fmex (fmex),
54  m_is_system_fcn_file (false)
55 {
57 
58  std::string file_name = fcn_file_name ();
59 
60  static const std::string canonical_oct_file_dir
62  static const std::string oct_file_dir
63  = canonical_oct_file_dir.empty () ? octave::config::oct_file_dir ()
64  : canonical_oct_file_dir;
65 
67  = (! file_name.empty ()
68  && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
69 }
70 
72 {
73  if (m_exit_fcn_ptr)
74  (*m_exit_fcn_ptr) ();
75 
76  octave::dynamic_loader& dyn_loader = octave::__get_dynamic_loader__ ();
77 
78  dyn_loader.remove_mex (m_name, m_sh_lib);
79 }
80 
81 std::string
83 {
84  return m_sh_lib.file_name ();
85 }
86 
87 octave::sys::time
89 {
90  return m_sh_lib.time_loaded ();
91 }
92 
94 octave_mex_function::execute (octave::tree_evaluator& tw, int nargout,
95  const octave_value_list& args)
96 {
97  return tw.execute_mex_function (*this, nargout, args);
98 }
std::string m_name
Definition: ov-fcn.h:267
void(* m_exit_fcn_ptr)(void)
Definition: ov-mex-fcn.h:112
octave_value_list execute(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
Definition: ov-mex-fcn.cc:94
void mark_fcn_file_up_to_date(const octave::sys::time &t)
Definition: ov-mex-fcn.h:77
~octave_mex_function(void)
Definition: ov-mex-fcn.cc:71
octave::sys::time time_parsed(void) const
Definition: ov-mex-fcn.cc:88
octave::dynamic_library m_sh_lib
Definition: ov-mex-fcn.h:114
std::string fcn_file_name(void) const
Definition: ov-mex-fcn.cc:82
octave_mex_function(void)
Definition: ov-mex-fcn.h:55
std::string oct_file_dir(void)
Definition: defaults.cc:283
std::string canonicalize_file_name(const std::string &name)
Definition: file-ops.cc:744
dynamic_loader & __get_dynamic_loader__(void)
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
Definition: lo-specfun.cc:1102
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:229