Mercurial > octave
annotate liboctave/util/oct-shlib.h @ 26376:00f796120a6d stable
maint: Update copyright dates in all source files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Jan 2019 16:32:43 -0500 |
parents | 5960fd1b56f1 |
children | 3db033e86376 |
rev | line source |
---|---|
3326 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25147
diff
changeset
|
3 Copyright (C) 1999-2019 John W. Eaton |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
3326 | 5 |
6 This file is part of Octave. | |
7 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
11 (at your option) any later version. |
3326 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
16 GNU General Public License for more details. |
3326 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
3326 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20097
diff
changeset
|
24 #if ! defined (octave_oct_shlib_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
25 #define octave_oct_shlib_h 1 |
3326 | 26 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
28 |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
29 #include <list> |
3326 | 30 #include <string> |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
31 #include <map> |
3326 | 32 |
4848 | 33 #include "oct-time.h" |
12125
a21a3875ca83
implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents:
11586
diff
changeset
|
34 #include "oct-refcount.h" |
3326 | 35 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
36 namespace octave |
3326 | 37 { |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
38 class |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
39 OCTAVE_API |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
40 dynamic_library |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
41 { |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
42 public: // FIXME: make this class private? |
3326 | 43 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
44 typedef std::string (*name_mangler) (const std::string&); |
3326 | 45 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
46 class dynlib_rep |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
47 { |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
48 public: |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
49 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
50 dynlib_rep (void) |
24677
69b89e81d3d3
Fix unloading dynamic libraries (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24663
diff
changeset
|
51 : count (1), file (), tm_loaded (time_t ()), fcn_names (), |
69b89e81d3d3
Fix unloading dynamic libraries (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24663
diff
changeset
|
52 search_all_loaded (false) |
24663
ca416267c65f
oct-shlib: move common property to base class.
Markus Mützel <markus.muetzel@gmx.de>
parents:
24656
diff
changeset
|
53 { } |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
54 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
55 protected: |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
56 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
57 dynlib_rep (const std::string& f); |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
58 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
59 public: |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
60 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
61 virtual ~dynlib_rep (void) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
62 { |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
63 instances.erase (file); |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
64 } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
65 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
66 virtual bool is_open (void) const |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
67 { return false; } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
68 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
69 virtual void * search (const std::string&, name_mangler = nullptr) |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
70 { return nullptr; } |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
71 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
72 bool is_out_of_date (void) const; |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
73 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
74 // This method will be overridden conditionally. |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
75 static dynlib_rep * new_instance (const std::string& f); |
3326 | 76 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
77 static dynlib_rep * get_instance (const std::string& f, bool fake); |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
78 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
79 sys::time time_loaded (void) const |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
80 { return tm_loaded; } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
81 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
82 std::string file_name (void) const |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
83 { return file; } |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
84 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
85 size_t num_fcn_names (void) const { return fcn_names.size (); } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
86 |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
87 std::list<std::string> function_names (void) const; |
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
88 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
89 void add_fcn_name (const std::string&); |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
90 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
91 bool remove_fcn_name (const std::string&); |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
92 |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
93 void clear_fcn_names (void) { fcn_names.clear (); } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
94 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
95 public: |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
96 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
97 refcount<int> count; |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
98 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
99 protected: |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
100 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
101 void fake_reload (void); |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
102 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
103 std::string file; |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
104 sys::time tm_loaded; |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
105 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
106 // Set of hooked function names. |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
107 typedef std::map<std::string, size_t>::iterator fcn_names_iterator; |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
108 typedef std::map<std::string, size_t>::const_iterator fcn_names_const_iterator; |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
109 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
110 std::map<std::string, size_t> fcn_names; |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
111 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
112 static std::map<std::string, dynlib_rep *> instances; |
24677
69b89e81d3d3
Fix unloading dynamic libraries (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24663
diff
changeset
|
113 bool search_all_loaded; |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
114 }; |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
115 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
116 private: |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
117 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
118 static dynlib_rep nil_rep; |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
119 |
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
120 public: |
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
121 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
122 dynamic_library (void) : rep (&nil_rep) { rep->count++; } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
123 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
124 dynamic_library (const std::string& f, bool fake = true) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
125 : rep (dynlib_rep::get_instance (f, fake)) { } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
126 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
127 ~dynamic_library (void) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
128 { |
24677
69b89e81d3d3
Fix unloading dynamic libraries (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24663
diff
changeset
|
129 if (--rep->count == 0) |
24656
cd79f32fba85
Fix errors in changeset f0de21a6a426 (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24653
diff
changeset
|
130 delete rep; |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
131 } |
3326 | 132 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
133 dynamic_library (const dynamic_library& sl) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
134 : rep (sl.rep) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
135 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
136 rep->count++; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
137 } |
3326 | 138 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
139 dynamic_library& operator = (const dynamic_library& sl) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
140 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
141 if (rep != sl.rep) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
142 { |
24677
69b89e81d3d3
Fix unloading dynamic libraries (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24663
diff
changeset
|
143 if (--rep->count == 0) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
144 delete rep; |
3326 | 145 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
146 rep = sl.rep; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
147 rep->count++; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
148 } |
3326 | 149 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
150 return *this; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
151 } |
3326 | 152 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
153 bool operator == (const dynamic_library& sl) const |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
154 { return (rep == sl.rep); } |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
155 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
156 operator bool () const { return rep->is_open (); } |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
157 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
158 void open (const std::string& f) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
159 { *this = dynamic_library (f); } |
7749
14e05160b99f
reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
160 |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
161 std::list<std::string> close (void) |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
162 { |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
163 std::list<std::string> removed_fcns = rep->function_names (); |
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
164 |
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
165 rep->clear_fcn_names (); |
3326 | 166 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
167 *this = dynamic_library (); |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
168 |
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23446
diff
changeset
|
169 return removed_fcns; |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
170 } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
171 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
172 void * search (const std::string& nm, name_mangler mangler = nullptr) const |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
173 { |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
174 void *f = rep->search (nm, mangler); |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
175 if (f) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
176 rep->add_fcn_name (nm); |
3326 | 177 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
178 return f; |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
179 } |
3326 | 180 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
181 void add (const std::string& name) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
182 { rep->add_fcn_name (name); } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
183 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
184 bool remove (const std::string& name) |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
185 { return rep->remove_fcn_name (name); } |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
186 |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
187 size_t number_of_functions_loaded (void) const |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
188 { return rep->num_fcn_names (); } |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
189 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
190 bool is_out_of_date (void) const |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
191 { return rep->is_out_of_date (); } |
3326 | 192 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
193 std::string file_name (void) const |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
194 { return rep->file_name (); } |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
195 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
196 sys::time time_loaded (void) const |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
197 { return rep->time_loaded (); } |
3326 | 198 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
199 private: |
3326 | 200 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
201 dynlib_rep *rep; |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
202 }; |
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
203 } |
3326 | 204 |
205 #endif |