3329
|
1 /* |
|
2 |
8920
|
3 Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2007, 2008 |
7017
|
4 John W. Eaton |
3329
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
3329
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
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 |
|
20 <http://www.gnu.org/licenses/>. |
3329
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include "oct-shlib.h" |
|
29 |
|
30 #include <defaults.h> |
|
31 #include "dynamic-ld.h" |
|
32 #include "error.h" |
|
33 #include "oct-obj.h" |
|
34 #include "ov-dld-fcn.h" |
|
35 #include "ov.h" |
|
36 |
|
37 DEFINE_OCTAVE_ALLOCATOR (octave_dld_function); |
|
38 |
|
39 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_dld_function, |
4612
|
40 "dynamically-linked function", |
3329
|
41 "dynamically-linked function"); |
|
42 |
|
43 |
|
44 octave_dld_function::octave_dld_function |
|
45 (octave_builtin::fcn ff, const octave_shlib& shl, |
3523
|
46 const std::string& nm, const std::string& ds) |
3329
|
47 : octave_builtin (ff, nm, ds), sh_lib (shl) |
|
48 { |
|
49 mark_fcn_file_up_to_date (time_parsed ()); |
|
50 |
3523
|
51 std::string file_name = fcn_file_name (); |
3329
|
52 |
|
53 system_fcn_file |
|
54 = (! file_name.empty () |
5397
|
55 && Voct_file_dir == file_name.substr (0, Voct_file_dir.length ())); |
3329
|
56 } |
|
57 |
|
58 octave_dld_function::~octave_dld_function (void) |
|
59 { |
7872
|
60 octave_dynamic_loader::remove_oct (my_name, sh_lib); |
3329
|
61 } |
|
62 |
3536
|
63 std::string |
3329
|
64 octave_dld_function::fcn_file_name (void) const |
|
65 { |
|
66 return sh_lib.file_name (); |
|
67 } |
|
68 |
|
69 octave_time |
|
70 octave_dld_function::time_parsed (void) const |
|
71 { |
|
72 return sh_lib.time_loaded (); |
|
73 } |
|
74 |
7349
|
75 // Note: this wrapper around the octave_dld_function constructor is |
|
76 // necessary to work around a MSVC limitation handling in |
|
77 // virtual destructors that prevents unloading a dynamic module |
|
78 // before *all* objects (of class using a virtual dtor) have |
|
79 // been fully deleted; indeed, MSVC attaches auto-generated code |
|
80 // (scalar deleting destructor) to objects created in a dynamic |
|
81 // module, and this code will be executed in the dynamic module |
|
82 // context at object deletion; unloading the dynamic module |
|
83 // before objects have been deleted will make the "delete" code |
|
84 // of objects to point to an invalid code segment. |
|
85 |
|
86 octave_dld_function* |
|
87 octave_dld_function::create (octave_builtin::fcn ff, const octave_shlib& shl, |
|
88 const std::string& nm, const std::string& ds) |
|
89 { |
|
90 return new octave_dld_function (ff, shl, nm, ds); |
|
91 } |
|
92 |
3329
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; End: *** |
|
97 */ |