annotate src/dynamic-ld.h @ 13983:7dd7cccf0757

clean up memory allocated for singletons before exit * singleton-cleanup.h, singleton-cleanup.cc: New files. * liboctave/Makefile.am (INCS, LIBOCTAVE_CXX_SOURCES): Add them to the lists. * toplev.cc (clean_up_and_exit): Call singleton_cleanup_list::cleanup. * debug.h, debug.cc (bp_table::instance_ok): Move definition to debug.cc. * coment-list.h (octave_comment_buffer::~octave_comment_buffer): Define destructor for class. * ov-typeinfo.h (octave_value_typeinfo::~octave_value_typeinfo): Likewise. * cmd-edit.h (command_editor::cleanup_instance): New function. * cmd-hist.h (command_history::cleanup_instance): New function. * file-ops.h (file_ops::cleanup_instance): New function. * mach-info.h (oct_mach_info::cleanup_instance): New function. * oct-env.h (octave_env::cleanup_instance): New function. * oct-fftw.h (octave_fftw_planner::cleanup_instance): New function. * oct-rand.h (octave_rand::cleanup_instance): New function. * oct-spparms.h (octave_sparse_params::cleanup_instance): New function. * pathsearch.h (static_members::cleanup_instance): New function. * comment-list.h (octave_comment_buffer::cleanup_instance): New function. * debug.h (bp_table::cleanup_instance): New function. * display.h (display_info::cleanup_instance): New function. * dynamic-ld.cc (octave_shlib_list::cleanup_instance, octave_mex_file_list::cleanup_instance): New functions. * dynamic-ld.h (octave_dynamic_loader::cleanup_instance): New function. * load-path.h (load_path::cleanup_instance): New function. * oct-stream.h (octave_stream_list::cleanup_instance): New function. * ov-typeinfo.h (octave_value_typeinfo::cleanup_instance): New function. * pager.h, pager.cc (octave_pager_stream::instance_ok, octave_pager_stream::cleanup_instance): New functions. (octave_diary_stream::instance_ok, octave_diary_stream::cleanup_instance): New functions. * sighandlers.h (octave_child_list::cleanup_instance): New function. * toplev.h (octave_call_stack * pager.cc (octave_pager_stream::stream, octave_diary_stream::stream): Use instance_ok to create instance. * toplev.h (octave_call_stack::cleanup_instance): New function. * cmd-edit.cc (command_editor::instance_ok): Register cleanup function. * cmd-hist.cc (command_history::instance_ok): Likewise. * file-ops.cc (file_ops::instance_ok): Likewise. * mach-info.cc (oct_mach_info::instance_ok): Likewise. * oct-env.cc (octave_env::instance_ok): Likewise. * oct-fftw.cc (octave_fftw_planner::instance_ok): Likewise. * oct-rand.cc (octave_rand::instance_ok): Likewise. * oct-spparms.cc (octave_sparse_params::instance_ok): Likewise. * pathsearch.cc (dir_path::static_members::instance_ok): Likewise. * comment-list.cc (comment_list::instance_ok): Likewise. * debug.cc (bp_table::instance_ok): Likewise. * display.cc (display_info::instance_ok): Likewise. * dynamic-ld.cc (octave_shlib_list::instance_ok, octave_mex_file_list::instance_ok, octave_dynamic_loader): Likewise. * load-path.cc (load_path::instance_ok): Likewise. * oct-stream.cc (octave_stream_list::instance_ok): Likewise. * ov-typeinfo.cc (octave_value_typeinfo::instance_ok): Likewise. * sighandlers.cc (octave_child_list::instance_ok): Likewise. * symtab.h, symtab.cc (symbol_table::scope_id::create_instance): New function. * symtab.h (symbol_table::scope_id::instance_ok): Call create_instance. * toplev.h, toplev.cc (octave_call_stack::create_instance): New function. * toplev.cc (octave_call_stack::instance_ok): Call create_instance. * pager.h, pager.cc (octave_pager_stream::set_diary_skip, octave_pager_stream::flush_current_contents_to_diary): Now static. octave_pager_stream::do_set_diary_skip, octave_pager_stream::do_flush_current_contents_to_diary): New functions. (octave_pager_stream::stream): Return std::ostream&, not octave_pager_stream&. If instance creation fails, return std::cout. (octave_diary_stream::stream): Return std::ostream&, not octave_diary_stream&. If instance creation fails, return std::cout. (octave_pager_stream::do_reset, octave_diary_stream::do_reset): Use instance_ok to create instance.
author John W. Eaton <jwe@octave.org>
date Sat, 03 Dec 2011 04:34:17 -0500
parents fd0a3ac60b0e
children 72c96de7a403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
3 Copyright (C) 1993-2011 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6323
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6323
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 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
18 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
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
383
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 240
diff changeset
23 #if !defined (octave_dynamic_ld_h)
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 240
diff changeset
24 #define octave_dynamic_ld_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
2862
95e85daad148 [project @ 1997-04-15 22:00:57 by jwe]
jwe
parents: 2847
diff changeset
26 #include <string>
95e85daad148 [project @ 1997-04-15 22:00:57 by jwe]
jwe
parents: 2847
diff changeset
27
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2970
diff changeset
28 #include "oct-shlib.h"
2894
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
29
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
30 class octave_function;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
31
2894
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
32 class
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
33 octave_dynamic_loader
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
34 {
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
35 protected:
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
36
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
37 octave_dynamic_loader (void) { }
2894
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
38
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
39 public:
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
40
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
41 virtual ~octave_dynamic_loader (void) { }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
42
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
43 static octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
44 load_oct (const std::string& fcn_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
45 const std::string& file_name = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
46 bool relative = false);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5307
diff changeset
47
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
48 static octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
49 load_mex (const std::string& fcn_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
50 const std::string& file_name = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
51 bool relative = false);
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2970
diff changeset
52
7872
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
53 static bool remove_oct (const std::string& fcn_name, octave_shlib& shl);
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
54
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
55 static bool remove_mex (const std::string& fcn_name, octave_shlib& shl);
2894
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
56
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
57 private:
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
58
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
59 // No copying!
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
60
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
61 octave_dynamic_loader (const octave_dynamic_loader&);
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
62
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
63 octave_dynamic_loader& operator = (const octave_dynamic_loader&);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
64
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
65 static octave_dynamic_loader *instance;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
66
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
67 static void cleanup_instance (void) { delete instance; instance = 0; }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
68
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
69 static bool instance_ok (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
70
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
71 octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
72 do_load_oct (const std::string& fcn_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
73 const std::string& file_name = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
74 bool relative = false);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5307
diff changeset
75
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
76 octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
77 do_load_mex (const std::string& fcn_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
78 const std::string& file_name = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
79 bool relative = false);
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2970
diff changeset
80
7872
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
81 bool do_remove_oct (const std::string& fcn_name, octave_shlib& shl);
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
82
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
83 bool do_remove_mex (const std::string& fcn_name, octave_shlib& shl);
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2970
diff changeset
84
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2970
diff changeset
85 static bool doing_load;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
86
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
87 protected:
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2894
diff changeset
88
7996
6a7db240b3a3 configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents: 7872
diff changeset
89 static std::string name_mangler (const std::string& name);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
90
7996
6a7db240b3a3 configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents: 7872
diff changeset
91 static std::string name_uscore_mangler (const std::string& name);
7872
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
92
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
93 static std::string mex_mangler (const std::string& name);
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
94
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
95 static std::string mex_uscore_mangler (const std::string& name);
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
96
1b63f8da772d fix unloading of mex files
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
97 static std::string mex_f77_mangler (const std::string& name);
2894
f1c5f8151397 [project @ 1997-04-28 05:39:26 by jwe]
jwe
parents: 2893
diff changeset
98 };
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
99
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
100 #endif