GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
ov-dld-fcn.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 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 "interpreter-private.h"
37#include "ovl.h"
38#include "ov-dld-fcn.h"
39#include "ov.h"
40
41
43 "dynamically-linked function",
44 "dynamically-linked function");
45
47(octave_builtin::fcn ff, const octave::dynamic_library& shl,
48 const std::string& nm, const std::string& ds)
49 : octave_builtin (ff, nm, ds), m_sh_lib (shl)
50{
52
53 std::string file_name = fcn_file_name ();
54
55 static const std::string canonical_oct_file_dir
56 = octave::sys::canonicalize_file_name (octave::config::oct_file_dir ());
57 static const std::string oct_file_dir
58 = canonical_oct_file_dir.empty () ? octave::config::oct_file_dir ()
59 : canonical_oct_file_dir;
60
61 m_system_fcn_file
62 = (! file_name.empty ()
63 && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
64}
65
67(octave_builtin::meth mm, const octave::dynamic_library& shl,
68 const std::string& nm, const std::string& ds)
69 : octave_builtin (mm, nm, ds), m_sh_lib (shl)
70{
72
73 std::string file_name = fcn_file_name ();
74
75 static const std::string canonical_oct_file_dir
76 = octave::sys::canonicalize_file_name (octave::config::oct_file_dir ());
77 static const std::string oct_file_dir
78 = canonical_oct_file_dir.empty () ? octave::config::oct_file_dir ()
79 : canonical_oct_file_dir;
80
81 m_system_fcn_file
82 = (! file_name.empty ()
83 && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
84}
85
87{
88 octave::dynamic_loader& dyn_loader = octave::__get_dynamic_loader__ ();
89
90 dyn_loader.remove_oct (m_name, m_sh_lib);
91}
92
93std::string
95{
96 return m_sh_lib.file_name ();
97}
98
99octave::sys::time
101{
102 return m_sh_lib.time_loaded ();
103}
104
105// Note: this wrapper around the octave_dld_function constructor is
106// necessary to work around a MSVC limitation handling in
107// virtual destructors that prevents unloading a dynamic module
108// before *all* objects (of class using a virtual dtor) have
109// been fully deleted; indeed, MSVC attaches auto-generated code
110// (scalar deleting destructor) to objects created in a dynamic
111// module, and this code will be executed in the dynamic module
112// context at object deletion; unloading the dynamic module
113// before objects have been deleted will make the "delete" code
114// of objects to point to an invalid code segment.
115
118 const octave::dynamic_library& shl,
119 const std::string& nm, const std::string& ds)
120{
121 return new octave_dld_function (ff, shl, nm, ds);
122}
123
126 const octave::dynamic_library& shl,
127 const std::string& nm, const std::string& ds)
128{
129 return new octave_dld_function (mm, shl, nm, ds);
130}
octave_value_list(* fcn)(const octave_value_list &, int)
Definition ov-builtin.h:61
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition ov-builtin.h:58
void mark_fcn_file_up_to_date(const octave::sys::time &t)
Definition ov-dld-fcn.h:66
std::string fcn_file_name() const
Definition ov-dld-fcn.cc:94
static octave_dld_function * create(octave_builtin::fcn ff, const octave::dynamic_library &shl, const std::string &nm="", const std::string &ds="")
octave::sys::time time_parsed() const
std::string m_name
Definition ov-fcn.h:267
std::string oct_file_dir()
Definition defaults.cc:309
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition ov-base.h:246