annotate liboctave/util/oct-shlib.h @ 23446:cd4e1ee28716

maint: Use convention 'void * fcn ()' for functions which return pointers. * make_int.cc, dialog.h, file-editor-interface.h, file-editor-tab.h, file-editor.h, octave-txt-lexer.h, main-window.h, octave-dock-widget.h, parser.h, webinfo.h, resource-manager.h, thread-manager.h, c-file-ptr-stream.h, call-stack.h, comment-list.h, ft-text-renderer.h, gl-render.cc, input.h, mex.cc, mexproto.h, mxarray.in.h, oct-fstrm.h, oct-iostrm.h, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-link.h, sighandlers.cc, symtab.h, sysdep.h, utils.h, audiodevinfo.cc, ov-base-diag.h, ov-base-int.h, ov-base-scalar.h, ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h, ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h, ov-classdef.h, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h, ov-fcn-handle.h, ov-fcn-inline.h, ov-fcn.h, ov-float.h, ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.h, ov-mex-fcn.h, ov-oncleanup.h, ov-perm.h, ov-range.h, ov-re-diag.h, ov-re-mat.h, ov-re-sparse.h, ov-scalar.h, ov-str-mat.h, ov-struct.h, ov-usr-fcn.h, ov.h, octave.h, bp-table.h, jit-ir.h, jit-typeinfo.h, jit-util.h, lex.h, parse.h, pt-arg-list.h, pt-array-list.h, pt-assign.h, pt-binop.h, pt-cell.h, pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.h, pt-except.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h, pt-jit.h, pt-jump.h, pt-loop.h, pt-mat.h, pt-misc.h, pt-select.h, pt-stmt.h, pt-unop.h, token.h, Array.cc, Array.h, DiagArray2.h, Sparse.h, dim-vector.h, idx-vector.h, sparse-chol.cc, cmd-edit.cc, cmd-edit.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc, lo-utils.h, oct-inttypes.h, oct-locbuf.h, oct-refcount.h, oct-rl-edit.h, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h, str-vec.h, canonicalize-file-name-wrapper.h, dirent-wrappers.h, getopt-wrapper.h, glob-wrappers.h, localcharset-wrapper.h, set-program-name-wrapper.h, signal-wrappers.h, strdup-wrapper.h, tmpfile-wrapper.h, unistd-wrappers.h, display-available.h: Use convention 'void * fcn ()' for functions which return pointers.
author Rik <rik@octave.org>
date Thu, 27 Apr 2017 09:48:57 -0700
parents 092078913d54
children b075b1629c26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
1 /*
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1999-2017 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
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
5
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
7
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
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
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
11 (at your option) any later version.
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
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
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
17
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6323
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6323
diff changeset
20 <http://www.gnu.org/licenses/>.
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
21
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
22 */
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
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
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
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
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
29 #include <string>
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
30 #include <map>
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
31
4848
8122518935e4 [project @ 2004-04-06 15:15:44 by jwe]
jwe
parents: 4055
diff changeset
32 #include "oct-time.h"
12125
a21a3875ca83 implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents: 11586
diff changeset
33 #include "oct-refcount.h"
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
34
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
35 namespace octave
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
36 {
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
37 class
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
38 OCTAVE_API
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
39 dynamic_library
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
40 {
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
41 public: // FIXME: make this class private?
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
42
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
43 typedef std::string (*name_mangler) (const std::string&);
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
44 typedef void (*close_hook) (const std::string&);
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
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)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
51 : count (1), file (), tm_loaded (time_t ()), fcn_names () { }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
52
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
53 protected:
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
54
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
55 dynlib_rep (const std::string& f);
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
56
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
57 public:
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
58
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
59 virtual ~dynlib_rep (void)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
60 {
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
61 instances.erase (file);
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
62 }
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
63
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
64 virtual bool is_open (void) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
65 { return false; }
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
66
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
67 virtual void * search (const std::string&, name_mangler = 0)
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
68 { return 0; }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
69
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
70 bool is_out_of_date (void) const;
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 // 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
73 static dynlib_rep * new_instance (const std::string& f);
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
74
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
75 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
76
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
77 octave::sys::time time_loaded (void) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
78 { return tm_loaded; }
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
79
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
80 std::string file_name (void) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
81 { return file; }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
82
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
83 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
84
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
85 void add_fcn_name (const std::string&);
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
86
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
87 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
88
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
89 void do_close_hook (close_hook cl_hook);
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
90
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
91 public:
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
92
23012
27e4ec3b0b49 move octave_refcount inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
93 octave::refcount<int> count;
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 protected:
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
96
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
97 void fake_reload (void);
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
98
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
99 std::string file;
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
100 octave::sys::time tm_loaded;
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
101
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
102 // Set of hooked function names.
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
103 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
104 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
105
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
106 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
107
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
108 static std::map<std::string, dynlib_rep *> instances;
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
109 };
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
110
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
111 private:
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
112
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
113 static dynlib_rep nil_rep;
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
114
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
115 public:
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
116
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
117 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
118
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
119 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
120 : 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
121
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
122 ~dynamic_library (void)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
123 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
124 if (--rep->count == 0)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
125 delete rep;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
126 }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
127
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
128 dynamic_library (const dynamic_library& sl)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
129 : rep (sl.rep)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
130 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
131 rep->count++;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
132 }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
133
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
134 dynamic_library& operator = (const dynamic_library& sl)
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 if (rep != sl.rep)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
137 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
138 if (--rep->count == 0)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
139 delete rep;
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
140
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
141 rep = sl.rep;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
142 rep->count++;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
143 }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
144
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
145 return *this;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
146 }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
147
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
148 bool operator == (const dynamic_library& sl) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
149 { return (rep == sl.rep); }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
150
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
151 operator bool () const { return rep->is_open (); }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
152
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
153 void open (const std::string& f)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
154 { *this = dynamic_library (f); }
7749
14e05160b99f reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
155
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
156 void close (close_hook cl_hook = 0)
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 if (cl_hook)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
159 rep->do_close_hook (cl_hook);
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
160
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
161 *this = dynamic_library ();
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
162 }
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
163
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
164 void * search (const std::string& nm, name_mangler mangler = 0) const
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
165 {
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
166 void *f = rep->search (nm, mangler);
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
167 if (f)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
168 rep->add_fcn_name (nm);
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
169
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
170 return f;
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
171 }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
172
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
173 void add (const std::string& name)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
174 { rep->add_fcn_name (name); }
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
175
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
176 bool remove (const std::string& name)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
177 { return rep->remove_fcn_name (name); }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
178
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
179 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
180 { return rep->num_fcn_names (); }
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
181
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
182 bool is_out_of_date (void) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
183 { return rep->is_out_of_date (); }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
184
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
185 std::string file_name (void) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
186 { return rep->file_name (); }
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
187
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
188 octave::sys::time time_loaded (void) const
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
189 { return rep->time_loaded (); }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
190
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
191 private:
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
192
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
193 dynlib_rep *rep;
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
194 };
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
195 }
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
196
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
197 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
198
21752
949cb46e6bdb use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents: 21750
diff changeset
199 OCTAVE_DEPRECATED ("use 'octave::dynamic_library' instead")
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
200 typedef octave::dynamic_library octave_shlib;
3326
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
201
c19f4b9484af [project @ 1999-10-29 21:52:12 by jwe]
jwe
parents:
diff changeset
202 #endif
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
203
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
204 #endif