GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-dld-fcn.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 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 "oct-shlib.h"
31 
32 #include "defaults.h"
33 #include "dynamic-ld.h"
34 #include "error.h"
35 #include "interpreter-private.h"
36 #include "ovl.h"
37 #include "ov-dld-fcn.h"
38 #include "ov.h"
39 
40 
42  "dynamically-linked function",
43  "dynamically-linked function");
44 
47  const std::string& nm, const std::string& ds)
48  : octave_builtin (ff, nm, ds), sh_lib (shl)
49 {
51 
52  std::string file_name = fcn_file_name ();
53 
55 
57  = (! file_name.empty ()
58  && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
59 }
60 
63  const std::string& nm, const std::string& ds)
64  : octave_builtin (mm, nm, ds), sh_lib (shl)
65 {
67 
68  std::string file_name = fcn_file_name ();
69 
71 
73  = (! file_name.empty ()
74  && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
75 }
76 
78 {
79  octave::dynamic_loader& dyn_loader
80  = octave::__get_dynamic_loader__ ("~octave_dld_function");
81 
82  dyn_loader.remove_oct (my_name, sh_lib);
83 }
84 
85 std::string
87 {
88  return sh_lib.file_name ();
89 }
90 
93 {
94  return sh_lib.time_loaded ();
95 }
96 
97 // Note: this wrapper around the octave_dld_function constructor is
98 // necessary to work around a MSVC limitation handling in
99 // virtual destructors that prevents unloading a dynamic module
100 // before *all* objects (of class using a virtual dtor) have
101 // been fully deleted; indeed, MSVC attaches auto-generated code
102 // (scalar deleting destructor) to objects created in a dynamic
103 // module, and this code will be executed in the dynamic module
104 // context at object deletion; unloading the dynamic module
105 // before objects have been deleted will make the "delete" code
106 // of objects to point to an invalid code segment.
107 
110  const octave::dynamic_library& shl,
111  const std::string& nm, const std::string& ds)
112 {
113  return new octave_dld_function (ff, shl, nm, ds);
114 }
115 
118  const octave::dynamic_library& shl,
119  const std::string& nm, const std::string& ds)
120 {
121  return new octave_dld_function (mm, shl, nm, ds);
122 }
sys::time time_loaded(void) const
Definition: oct-shlib.h:200
std::string file_name(void) const
Definition: oct-shlib.h:197
bool remove_oct(const std::string &fcn_name, dynamic_library &shl)
Definition: dynamic-ld.cc:259
octave_value_list(* fcn)(const octave_value_list &, int)
Definition: ov-builtin.h:63
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition: ov-builtin.h:60
octave::sys::time time_parsed(void) const
Definition: ov-dld-fcn.cc:92
octave_dld_function(void)
Definition: ov-dld-fcn.h:50
octave::dynamic_library sh_lib
Definition: ov-dld-fcn.h:101
std::string fcn_file_name(void) const
Definition: ov-dld-fcn.cc:86
~octave_dld_function(void)
Definition: ov-dld-fcn.cc:77
void mark_fcn_file_up_to_date(const octave::sys::time &t)
Definition: ov-dld-fcn.h:72
static octave_dld_function * create(octave_builtin::fcn ff, const octave::dynamic_library &shl, const std::string &nm="", const std::string &ds="")
Definition: ov-dld-fcn.cc:109
std::string my_name
Definition: ov-fcn.h:276
std::string oct_file_dir(void)
Definition: defaults.cc:283
dynamic_loader & __get_dynamic_loader__(const std::string &who)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:180