GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-mex-fcn.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 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 (octave_ov_mex_fcn_h)
27 #define octave_ov_mex_fcn_h 1
28 
29 #include "octave-config.h"
30 
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 
43 
44 class tree_evaluator;
45 
46 OCTAVE_END_NAMESPACE(octave)
47 
48 // Dynamically-linked functions.
49 
50 class
52 {
53 public:
54 
56  : m_mex_fcn_ptr (nullptr), m_exit_fcn_ptr (nullptr), m_sh_lib (),
57  m_time_checked (), m_interleaved (false), m_is_fmex (false),
58  m_is_system_fcn_file (false)
59  { }
60 
61  octave_mex_function (void *fptr, bool interleaved, bool fmex,
62  const octave::dynamic_library& shl,
63  const std::string& nm = "");
64 
65  OCTAVE_DISABLE_COPY_MOVE (octave_mex_function)
66 
68 
69  octave_function * function_value (bool = false) { return this; }
70 
71  const octave_function * function_value (bool = false) const { return this; }
72 
73  void mark_fcn_file_up_to_date (const octave::sys::time& t)
74  {
75  m_time_checked = t;
76  }
77 
78  std::string fcn_file_name () const;
79 
80  octave::sys::time time_parsed () const;
81 
82  octave::sys::time time_checked () const { return m_time_checked; }
83 
84  bool is_system_fcn_file () const { return m_is_system_fcn_file; }
85 
86  bool is_builtin_function () const { return false; }
87 
88  bool is_mex_function () const { return true; }
89 
90  bool use_interleaved_complex () const { return m_interleaved; }
91 
93  execute (octave::tree_evaluator& tw, int nargout = 0,
94  const octave_value_list& args = octave_value_list ());
95 
96  void atexit (void (*fcn) ()) { m_exit_fcn_ptr = fcn; }
97 
98  octave::dynamic_library get_shlib () const { return m_sh_lib; }
99 
100  void * mex_fcn_ptr () const { return m_mex_fcn_ptr; }
101 
102  bool is_fmex () const { return m_is_fmex; }
103 
104 private:
105 
106  void *m_mex_fcn_ptr;
107 
108  void (*m_exit_fcn_ptr) ();
109 
110  octave::dynamic_library m_sh_lib;
111 
112  // The time the file was last checked to see if it needs to be
113  // parsed again.
114  octave::sys::time m_time_checked;
115 
116  bool m_interleaved;
117 
118  bool m_is_fmex;
119 
120  // True if this function came from a file that is considered to be a
121  // system function. This affects whether we check the time stamp
122  // on the file to see if it has changed.
123  bool m_is_system_fcn_file;
124 
126 };
127 
128 #endif
const octave_function * function_value(bool=false) const
Definition: ov-mex-fcn.h:71
void * mex_fcn_ptr() const
Definition: ov-mex-fcn.h:100
bool is_fmex() const
Definition: ov-mex-fcn.h:102
void mark_fcn_file_up_to_date(const octave::sys::time &t)
Definition: ov-mex-fcn.h:73
bool is_builtin_function() const
Definition: ov-mex-fcn.h:86
octave_function * function_value(bool=false)
Definition: ov-mex-fcn.h:69
bool is_system_fcn_file() const
Definition: ov-mex-fcn.h:84
octave::dynamic_library get_shlib() const
Definition: ov-mex-fcn.h:98
bool use_interleaved_complex() const
Definition: ov-mex-fcn.h:90
void atexit(void(*fcn)())
Definition: ov-mex-fcn.h:96
bool is_mex_function() const
Definition: ov-mex-fcn.h:88
octave::sys::time time_checked() const
Definition: ov-mex-fcn.h:82
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
Definition: lo-specfun.cc:1102
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:181