GNU Octave  4.4.1
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-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "oct-shlib.h"
28 
29 #include "defaults.h"
30 #include "dynamic-ld.h"
31 #include "error.h"
32 #include "interpreter-private.h"
33 #include "ovl.h"
34 #include "ov-dld-fcn.h"
35 #include "ov.h"
36 
37 
39  "dynamically-linked function",
40  "dynamically-linked function");
41 
44  const std::string& nm, const std::string& ds)
45  : octave_builtin (ff, nm, ds), sh_lib (shl)
46 {
47  mark_fcn_file_up_to_date (time_parsed ());
48 
49  std::string file_name = fcn_file_name ();
50 
52 
53  system_fcn_file
54  = (! file_name.empty ()
55  && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
56 }
57 
60  const std::string& nm, const std::string& ds)
61  : octave_builtin (mm, nm, ds), sh_lib (shl)
62 {
63  mark_fcn_file_up_to_date (time_parsed ());
64 
65  std::string file_name = fcn_file_name ();
66 
68 
69  system_fcn_file
70  = (! file_name.empty ()
71  && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
72 }
73 
75 {
76  octave::dynamic_loader& dyn_loader
77  = octave::__get_dynamic_loader__ ("~octave_dld_function");
78 
79  dyn_loader.remove_oct (my_name, sh_lib);
80 }
81 
84 {
85  return sh_lib.file_name ();
86 }
87 
90 {
91  return sh_lib.time_loaded ();
92 }
93 
94 // Note: this wrapper around the octave_dld_function constructor is
95 // necessary to work around a MSVC limitation handling in
96 // virtual destructors that prevents unloading a dynamic module
97 // before *all* objects (of class using a virtual dtor) have
98 // been fully deleted; indeed, MSVC attaches auto-generated code
99 // (scalar deleting destructor) to objects created in a dynamic
100 // module, and this code will be executed in the dynamic module
101 // context at object deletion; unloading the dynamic module
102 // before objects have been deleted will make the "delete" code
103 // of objects to point to an invalid code segment.
104 
107  const octave::dynamic_library& shl,
108  const std::string& nm, const std::string& ds)
109 {
110  return new octave_dld_function (ff, shl, nm, ds);
111 }
112 
115  const octave::dynamic_library& shl,
116  const std::string& nm, const std::string& ds)
117 {
118  return new octave_dld_function (mm, shl, nm, ds);
119 }
std::string file_name(void) const
Definition: oct-shlib.h:193
std::string my_name
Definition: ov-fcn.h:233
octave_value_list(* fcn)(const octave_value_list &, int)
Definition: ov-builtin.h:60
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:180
bool remove_oct(const std::string &fcn_name, dynamic_library &shl)
Definition: dynamic-ld.cc:260
sys::time time_loaded(void) const
Definition: oct-shlib.h:196
~octave_dld_function(void)
Definition: ov-dld-fcn.cc:74
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:975
std::string fcn_file_name(void) const
Definition: ov-dld-fcn.cc:83
octave_dld_function(void)
Definition: ov-dld-fcn.h:47
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition: ov-builtin.h:57
dynamic_loader & __get_dynamic_loader__(const std::string &who)
std::string oct_file_dir(void)
Definition: defaults.cc:289
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:106
octave::sys::time time_parsed(void) const
Definition: ov-dld-fcn.cc:89
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
octave::dynamic_library sh_lib
Definition: ov-dld-fcn.h:98