Mercurial > octave
annotate libinterp/corefcn/load-path.h @ 23418:0412433f016f
rename load_path::loader to load_path::package_info
* load-path.h, load-path.cc (load_path::package_info): Rename from
load_path::loader. Change all uses.
(load_path::get_package): Rename from load_path::get_loader.
Change all uses.
(load_path::package_info::m_package_name): Rename from
load_path::package_info::prefix. Change all uses.
(load_path::top_level_package): Rename from load_path::default_loader.
Change all uses.
(load_path::package_map): Rename from load_path::loader_map.
Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Apr 2017 00:16:08 -0400 |
parents | 092078913d54 |
children | d24d01273bd0 |
rev | line source |
---|---|
5832 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2006-2017 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
5832 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
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:
22407
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
11 (at your option) any later version. |
5832 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
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:
22407
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 GNU General Public License for more details. |
5832 | 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/>. | |
5832 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20770
diff
changeset
|
24 #if ! defined (octave_load_path_h) |
5832 | 25 #define octave_load_path_h 1 |
26 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
28 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
29 #include <iosfwd> |
5832 | 30 #include <list> |
31 #include <map> | |
22375
179d088a6375
Do the #include where they are needed.
Carnë Draug <carandraug@octave.org>
parents:
22323
diff
changeset
|
32 #include <set> |
5832 | 33 #include <string> |
34 | |
5835 | 35 #include "pathsearch.h" |
5832 | 36 #include "str-vec.h" |
37 | |
38 class | |
6241 | 39 OCTINTERP_API |
5832 | 40 load_path |
41 { | |
42 protected: | |
43 | |
9010
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8950
diff
changeset
|
44 load_path (void) |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
45 : package_map (), top_level_package (), dir_info_list (), init_dirs () { } |
5832 | 46 |
47 public: | |
48 | |
7336 | 49 typedef void (*hook_fcn_ptr) (const std::string& dir); |
5832 | 50 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
51 ~load_path (void) = default; |
5832 | 52 |
6365 | 53 static void initialize (bool set_initial_path = false) |
5832 | 54 { |
55 if (instance_ok ()) | |
6365 | 56 instance->do_initialize (set_initial_path); |
5832 | 57 } |
58 | |
59 static void clear (void) | |
60 { | |
61 if (instance_ok ()) | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
62 instance->do_clear (); |
5832 | 63 } |
64 | |
5867 | 65 static void set (const std::string& p, bool warn = false) |
5832 | 66 { |
67 if (instance_ok ()) | |
5867 | 68 instance->do_set (p, warn); |
5832 | 69 } |
70 | |
5867 | 71 static void append (const std::string& dir, bool warn = false) |
5832 | 72 { |
73 if (instance_ok ()) | |
5867 | 74 instance->do_append (dir, warn); |
5832 | 75 } |
76 | |
5867 | 77 static void prepend (const std::string& dir, bool warn = false) |
5832 | 78 { |
79 if (instance_ok ()) | |
5867 | 80 instance->do_prepend (dir, warn); |
5832 | 81 } |
82 | |
83 static bool remove (const std::string& dir) | |
84 { | |
85 return instance_ok () ? instance->do_remove (dir) : false; | |
86 } | |
87 | |
88 static void update (void) | |
89 { | |
90 if (instance_ok ()) | |
91 instance->do_update (); | |
92 } | |
93 | |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
94 static bool contains_canonical (const std::string& dir_name) |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
95 { |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
96 return instance_ok () ? instance->do_contains_canonical (dir_name) : false; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
97 } |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
98 |
7336 | 99 static std::string find_method (const std::string& class_name, |
10313 | 100 const std::string& meth, |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
101 std::string& dir_name, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
102 const std::string& pack_name = "") |
7336 | 103 { |
104 return instance_ok () | |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
105 ? instance->get_package (pack_name).find_method (class_name, meth, |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
106 dir_name) |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
107 : ""; |
7336 | 108 } |
109 | |
110 static std::string find_method (const std::string& class_name, | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
111 const std::string& meth, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
112 const std::string& pack_name = "") |
7336 | 113 { |
114 std::string dir_name; | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
115 return find_method (class_name, meth, dir_name, pack_name); |
7336 | 116 } |
117 | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
118 static std::list<std::string> methods (const std::string& class_name, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
119 const std::string& pack_name = "") |
7336 | 120 { |
121 return instance_ok () | |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
122 ? instance->get_package (pack_name).methods (class_name) |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
123 : std::list<std::string> (); |
7336 | 124 } |
125 | |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
126 static std::list<std::string> overloads (const std::string& meth) |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
127 { |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
128 return instance_ok () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 ? instance->do_overloads (meth) : std::list<std::string> (); |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
130 } |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
131 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
132 static bool find_package (const std::string& package_name) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
133 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
134 return instance_ok () |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
135 ? instance->do_find_package (package_name) : false; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
136 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
137 |
16690
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
138 static std::list<std::string> |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
139 get_all_package_names (bool only_top_level = true) |
7336 | 140 { |
141 return instance_ok () | |
16690
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
142 ? instance->do_get_all_package_names (only_top_level) |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
143 : std::list<std::string> (); |
7336 | 144 } |
145 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
146 static std::string find_fcn (const std::string& fcn, std::string& dir_name, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
147 const std::string& pack_name = "") |
7336 | 148 { |
149 return instance_ok () | |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
150 ? instance->get_package (pack_name).find_fcn (fcn, dir_name) |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
151 : ""; |
7336 | 152 } |
153 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
154 static std::string find_fcn (const std::string& fcn, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
155 const std::string& pack_name = "") |
5832 | 156 { |
7336 | 157 std::string dir_name; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
158 return find_fcn (fcn, dir_name, pack_name); |
7336 | 159 } |
160 | |
161 static std::string find_private_fcn (const std::string& dir, | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
162 const std::string& fcn, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
163 const std::string& pack_name = "") |
7336 | 164 { |
5832 | 165 return instance_ok () |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
166 ? instance->get_package (pack_name).find_private_fcn (dir, fcn) |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
167 : ""; |
5832 | 168 } |
169 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
170 static std::string find_fcn_file (const std::string& fcn, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
171 const std::string& pack_name = "") |
5832 | 172 { |
7336 | 173 std::string dir_name; |
174 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
175 return instance_ok () |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
176 ? instance->get_package (pack_name).find_fcn (fcn, dir_name, M_FILE) |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
177 : ""; |
5832 | 178 } |
179 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
180 static std::string find_oct_file (const std::string& fcn, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
181 const std::string& pack_name = "") |
5832 | 182 { |
7336 | 183 std::string dir_name; |
184 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
185 return instance_ok () |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
186 ? instance->get_package (pack_name).find_fcn (fcn, dir_name, M_FILE) |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
187 : ""; |
5832 | 188 } |
189 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
190 static std::string find_mex_file (const std::string& fcn, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
191 const std::string& pack_name = "") |
5864 | 192 { |
7336 | 193 std::string dir_name; |
194 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
195 return instance_ok () |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
196 ? instance->get_package (pack_name).find_fcn (fcn, dir_name, M_FILE) |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
197 : ""; |
5864 | 198 } |
199 | |
5832 | 200 static std::string find_file (const std::string& file) |
201 { | |
202 return instance_ok () | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
203 ? instance->do_find_file (file) : ""; |
5832 | 204 } |
205 | |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
206 static std::string find_dir (const std::string& dir) |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
207 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
208 return instance_ok () |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
209 ? instance->do_find_dir (dir) : ""; |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
210 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
211 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
212 static string_vector find_matching_dirs (const std::string& dir) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
213 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
214 return instance_ok () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
215 ? instance->do_find_matching_dirs (dir) : string_vector (); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
216 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
217 |
5832 | 218 static std::string find_first_of (const string_vector& files) |
219 { | |
220 return instance_ok () ? | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
221 instance->do_find_first_of (files) : ""; |
5832 | 222 } |
223 | |
224 static string_vector find_all_first_of (const string_vector& files) | |
225 { | |
226 return instance_ok () ? | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
227 instance->do_find_all_first_of (files) : string_vector (); |
5832 | 228 } |
229 | |
230 static string_vector dirs (void) | |
231 { | |
232 return instance_ok () ? instance->do_dirs () : string_vector (); | |
233 } | |
234 | |
235 static std::list<std::string> dir_list (void) | |
236 { | |
237 return instance_ok () | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 ? instance->do_dir_list () : std::list<std::string> (); |
5832 | 239 } |
240 | |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
241 static string_vector files (const std::string& dir, bool omit_exts = false) |
5832 | 242 { |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
243 return instance_ok () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
244 ? instance->do_files (dir, omit_exts) : string_vector (); |
5832 | 245 } |
246 | |
247 static string_vector fcn_names (void) | |
248 { | |
249 return instance_ok () ? instance->do_fcn_names () : string_vector (); | |
250 } | |
251 | |
252 static std::string path (void) | |
253 { | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
254 return instance_ok () ? instance->do_path () : ""; |
5832 | 255 } |
256 | |
257 static void display (std::ostream& os) | |
258 { | |
259 if (instance_ok ()) | |
260 instance->do_display (os); | |
261 } | |
262 | |
21417
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
263 static hook_fcn_ptr get_add_hook (void) { return add_hook; } |
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
264 static hook_fcn_ptr get_remove_hook (void) { return remove_hook; } |
5832 | 265 |
21417
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
266 static void set_add_hook (hook_fcn_ptr f) { add_hook = f; } |
7336 | 267 static void set_remove_hook (hook_fcn_ptr f) { remove_hook = f; } |
5832 | 268 |
21417
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
269 static void execute_pkg_add (const std::string& dir); |
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
270 static void execute_pkg_del (const std::string& dir); |
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
271 |
5832 | 272 static void set_command_line_path (const std::string& p) |
273 { | |
5835 | 274 if (command_line_path.empty ()) |
275 command_line_path = p; | |
276 else | |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
277 command_line_path += octave::directory_path::path_sep_str () + p; |
5832 | 278 } |
279 | |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
280 static std::string get_command_line_path (void) |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
281 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
282 return instance_ok () ? instance->do_get_command_line_path () |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
283 : ""; |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
284 } |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
285 |
6626 | 286 static std::string system_path (void) |
287 { | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
288 return instance_ok () ? instance->do_system_path () : ""; |
6626 | 289 } |
290 | |
5832 | 291 private: |
292 | |
293 static const int M_FILE = 1; | |
294 static const int OCT_FILE = 2; | |
5864 | 295 static const int MEX_FILE = 4; |
5832 | 296 |
297 class dir_info | |
298 { | |
299 public: | |
300 | |
7336 | 301 // <FCN_NAME, TYPE> |
302 typedef std::map<std::string, int> fcn_file_map_type; | |
303 | |
304 typedef fcn_file_map_type::const_iterator const_fcn_file_map_iterator; | |
305 typedef fcn_file_map_type::iterator fcn_file_map_iterator; | |
306 | |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
307 struct class_info |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
308 { |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
309 class_info (void) : method_file_map (), private_file_map () { } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
310 |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
311 class_info (const class_info& ci) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
312 : method_file_map (ci.method_file_map), |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
313 private_file_map (ci.private_file_map) { } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
314 |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
315 class_info& operator = (const class_info& ci) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
316 { |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
317 if (this != &ci) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
318 { |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
319 method_file_map = ci.method_file_map; |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
320 private_file_map = ci.private_file_map; |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
321 } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
322 return *this; |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
323 } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
324 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
325 ~class_info (void) = default; |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
326 |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
327 fcn_file_map_type method_file_map; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
328 fcn_file_map_type private_file_map; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
329 }; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
330 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
331 // <CLASS_NAME, CLASS_INFO> |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
332 typedef std::map<std::string, class_info> method_file_map_type; |
7336 | 333 |
334 typedef method_file_map_type::const_iterator const_method_file_map_iterator; | |
335 typedef method_file_map_type::iterator method_file_map_iterator; | |
336 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
337 // <PACKAGE_NAME, DIR_INFO> |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
338 typedef std::map<std::string, dir_info> package_dir_map_type; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
339 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
340 typedef package_dir_map_type::const_iterator const_package_dir_map_iterator; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
341 typedef package_dir_map_type::iterator package_dir_map_iterator; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
342 |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
343 // This default constructor is only provided so we can create a |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
344 // std::map of dir_info objects. You should not use this |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
345 // constructor for any other purpose. |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
346 dir_info (void) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
347 : dir_name (), abs_dir_name (), is_relative (false), |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
348 dir_mtime (), dir_time_last_checked (), |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
349 all_files (), fcn_files (), private_file_map (), method_file_map (), |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
350 package_dir_map () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 { } |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
352 |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
353 dir_info (const std::string& d) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
354 : dir_name (d), abs_dir_name (), is_relative (false), |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
355 dir_mtime (), dir_time_last_checked (), |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
356 all_files (), fcn_files (), private_file_map (), method_file_map (), |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
357 package_dir_map () |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
358 { |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
359 initialize (); |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
360 } |
5832 | 361 |
362 dir_info (const dir_info& di) | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
363 : dir_name (di.dir_name), abs_dir_name (di.abs_dir_name), |
10313 | 364 is_relative (di.is_relative), |
365 dir_mtime (di.dir_mtime), | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
366 dir_time_last_checked (di.dir_time_last_checked), |
10313 | 367 all_files (di.all_files), fcn_files (di.fcn_files), |
368 private_file_map (di.private_file_map), | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
369 method_file_map (di.method_file_map), |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
370 package_dir_map (di.package_dir_map) { } |
5832 | 371 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
372 ~dir_info (void) = default; |
5832 | 373 |
374 dir_info& operator = (const dir_info& di) | |
375 { | |
376 if (&di != this) | |
10313 | 377 { |
378 dir_name = di.dir_name; | |
379 abs_dir_name = di.abs_dir_name; | |
380 is_relative = di.is_relative; | |
381 dir_mtime = di.dir_mtime; | |
382 dir_time_last_checked = di.dir_time_last_checked; | |
383 all_files = di.all_files; | |
384 fcn_files = di.fcn_files; | |
385 private_file_map = di.private_file_map; | |
386 method_file_map = di.method_file_map; | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
387 package_dir_map = di.package_dir_map; |
10313 | 388 } |
5832 | 389 |
390 return *this; | |
391 } | |
392 | |
393 void update (void); | |
394 | |
395 std::string dir_name; | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
396 std::string abs_dir_name; |
5832 | 397 bool is_relative; |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21417
diff
changeset
|
398 octave::sys::time dir_mtime; |
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21417
diff
changeset
|
399 octave::sys::time dir_time_last_checked; |
5832 | 400 string_vector all_files; |
401 string_vector fcn_files; | |
7336 | 402 fcn_file_map_type private_file_map; |
403 method_file_map_type method_file_map; | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
404 package_dir_map_type package_dir_map; |
5832 | 405 |
20052
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
406 bool is_package (const std::string& name) const; |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
407 |
5832 | 408 private: |
409 | |
410 void initialize (void); | |
411 | |
7336 | 412 void get_file_list (const std::string& d); |
413 | |
414 void get_private_file_map (const std::string& d); | |
5832 | 415 |
7336 | 416 void get_method_file_map (const std::string& d, |
10313 | 417 const std::string& class_name); |
7336 | 418 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
419 void get_package_dir (const std::string& d, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
420 const std::string& package_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
421 |
7336 | 422 friend fcn_file_map_type get_fcn_files (const std::string& d); |
5832 | 423 }; |
424 | |
425 class file_info | |
426 { | |
427 public: | |
428 | |
429 file_info (const std::string& d, int t) : dir_name (d), types (t) { } | |
430 | |
431 file_info (const file_info& fi) | |
432 : dir_name (fi.dir_name), types (fi.types) { } | |
433 | |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
434 ~file_info (void) = default; |
5832 | 435 |
436 file_info& operator = (const file_info& fi) | |
437 { | |
438 if (&fi != this) | |
10313 | 439 { |
440 dir_name = fi.dir_name; | |
441 types = fi.types; | |
442 } | |
5832 | 443 |
444 return *this; | |
445 } | |
446 | |
447 std::string dir_name; | |
448 int types; | |
449 }; | |
450 | |
451 // We maintain two ways of looking at the same information. | |
452 // | |
453 // First, a list of directories and the set of "public" files and | |
454 // private files (those found in the special "private" subdirectory) | |
455 // in each directory. | |
456 // | |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20052
diff
changeset
|
457 // Second, a map from filenames (the union of all "public" files for all |
7336 | 458 // directories, but without filename extensions) to a list of |
5832 | 459 // corresponding information (directory name and file types). This |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20052
diff
changeset
|
460 // way, we can quickly find shadowed filenames and look up all |
5832 | 461 // overloaded functions (in the "@" directories used to implement |
462 // classes). | |
463 | |
7336 | 464 typedef std::list<dir_info> dir_info_list_type; |
465 | |
466 typedef dir_info_list_type::const_iterator const_dir_info_list_iterator; | |
467 typedef dir_info_list_type::iterator dir_info_list_iterator; | |
468 | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
469 typedef std::map<std::string, dir_info> abs_dir_cache_type; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
470 |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
471 typedef abs_dir_cache_type::const_iterator const_abs_dir_cache_iterator; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
472 typedef abs_dir_cache_type::iterator abs_dir_cache_iterator; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
473 |
7336 | 474 typedef std::list<file_info> file_info_list_type; |
475 | |
476 typedef file_info_list_type::const_iterator const_file_info_list_iterator; | |
477 typedef file_info_list_type::iterator file_info_list_iterator; | |
478 | |
479 // <FCN_NAME, FILE_INFO_LIST> | |
480 typedef std::map<std::string, file_info_list_type> fcn_map_type; | |
481 | |
482 typedef fcn_map_type::const_iterator const_fcn_map_iterator; | |
483 typedef fcn_map_type::iterator fcn_map_iterator; | |
5832 | 484 |
7336 | 485 // <DIR_NAME, <FCN_NAME, TYPE>> |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
486 typedef std::map<std::string, dir_info::fcn_file_map_type> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
487 private_fcn_map_type; |
7336 | 488 |
489 typedef private_fcn_map_type::const_iterator const_private_fcn_map_iterator; | |
490 typedef private_fcn_map_type::iterator private_fcn_map_iterator; | |
491 | |
492 // <CLASS_NAME, <FCN_NAME, FILE_INFO_LIST>> | |
493 typedef std::map<std::string, fcn_map_type> method_map_type; | |
494 | |
495 typedef method_map_type::const_iterator const_method_map_iterator; | |
496 typedef method_map_type::iterator method_map_iterator; | |
10907
6105ed2db9d7
load_path::dir_info::initialize: clear method_file_map before updating file list
John W. Eaton <jwe@octave.org>
parents:
10521
diff
changeset
|
497 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
498 class package_info |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
499 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
500 public: |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
501 package_info (const std::string& package_name = "") |
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
502 : m_package_name (package_name), dir_list (), fcn_map (), private_fcn_map (), |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
503 method_map () { } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
504 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
505 package_info (const package_info& l) |
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
506 : m_package_name (l.m_package_name), dir_list (l.dir_list), |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
507 private_fcn_map (l.private_fcn_map), method_map (l.method_map) { } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
508 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
509 ~package_info (void) = default; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
510 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
511 package_info& operator = (const package_info& l) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
512 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
513 if (&l != this) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
514 { |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
515 m_package_name = l.m_package_name; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
516 dir_list = l.dir_list; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
517 fcn_map = l.fcn_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
518 private_fcn_map = l.private_fcn_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
519 method_map = l.method_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
520 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
521 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
522 return *this; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
523 } |
7336 | 524 |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
525 void add (const dir_info& di, bool at_end, bool updating) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
526 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
527 if (at_end) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
528 dir_list.push_back (di.dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
529 else |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
530 dir_list.push_front (di.dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
531 |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
532 add_to_fcn_map (di, at_end, updating); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
533 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
534 add_to_private_fcn_map (di); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
535 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
536 add_to_method_map (di, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
537 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
538 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
539 void move (const dir_info& di, bool at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
540 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
541 void remove (const dir_info& di); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
542 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
543 void clear (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
544 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
545 dir_list.clear (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
546 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
547 fcn_map.clear (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
548 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
549 private_fcn_map.clear (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
550 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
551 method_map.clear (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
552 } |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
553 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
554 void display (std::ostream& out) const; |
7336 | 555 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
556 std::string find_fcn (const std::string& fcn, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
557 std::string& dir_name, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
558 int type = M_FILE | OCT_FILE | MEX_FILE) const; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
559 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
560 std::string find_private_fcn (const std::string& dir, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
561 const std::string& fcn, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
562 int type = M_FILE | OCT_FILE | MEX_FILE) const; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
563 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
564 std::string find_method (const std::string& class_name, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
565 const std::string& meth, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
566 std::string& dir_name, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
567 int type = M_FILE | OCT_FILE | MEX_FILE) const; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
568 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
569 std::list<std::string> methods (const std::string& class_name) const; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
570 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
571 void overloads (const std::string& meth, std::list<std::string>& l) const; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
572 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
573 string_vector fcn_names (void) const; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
574 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
575 private: |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
576 void add_to_fcn_map (const dir_info& di, bool at_end, bool updating); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
577 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
578 void add_to_private_fcn_map (const dir_info& di); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
579 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
580 void add_to_method_map (const dir_info& di, bool at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
581 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
582 void move_fcn_map (const std::string& dir, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
583 const string_vector& fcn_files, bool at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
584 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
585 void move_method_map (const std::string& dir, bool at_end); |
7336 | 586 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
587 void remove_fcn_map (const std::string& dir, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
588 const string_vector& fcn_files); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
589 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
590 void remove_private_fcn_map (const std::string& dir); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
591 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
592 void remove_method_map (const std::string& dir); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
593 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
594 private: |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
595 |
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
596 std::string m_package_name; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
597 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
598 std::list<std::string> dir_list; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
599 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
600 fcn_map_type fcn_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
601 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
602 private_fcn_map_type private_fcn_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
603 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
604 method_map_type method_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
605 }; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
606 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
607 // <PACKAGE_NAME, LOADER> |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
608 typedef std::map<std::string, package_info> package_map_type; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
609 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
610 typedef package_map_type::const_iterator const_package_map_iterator; |
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
611 typedef package_map_type::iterator package_map_iterator; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
612 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
613 mutable package_map_type package_map; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
614 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
615 mutable package_info top_level_package; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
616 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
617 mutable dir_info_list_type dir_info_list; |
5832 | 618 |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
619 mutable std::set<std::string> init_dirs; |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
620 |
5832 | 621 static load_path *instance; |
622 | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
623 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:
11586
diff
changeset
|
624 |
7336 | 625 static hook_fcn_ptr add_hook; |
5832 | 626 |
7336 | 627 static hook_fcn_ptr remove_hook; |
5832 | 628 |
629 static std::string command_line_path; | |
630 | |
6626 | 631 static std::string sys_path; |
632 | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
633 static abs_dir_cache_type abs_dir_cache; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
634 |
5832 | 635 static bool instance_ok (void); |
636 | |
637 const_dir_info_list_iterator find_dir_info (const std::string& dir) const; | |
638 dir_info_list_iterator find_dir_info (const std::string& dir); | |
639 | |
640 bool contains (const std::string& dir) const; | |
641 | |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
642 bool do_contains_canonical (const std::string& dir) const; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
643 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
644 void do_move (dir_info_list_iterator i, bool at_end); |
7336 | 645 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
646 void move (const dir_info& di, bool at_end, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
647 const std::string& pname = ""); |
7336 | 648 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
649 void remove (const dir_info& di, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
650 const std::string& pname = ""); |
5832 | 651 |
6365 | 652 void do_initialize (bool set_initial_path); |
5832 | 653 |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
654 void do_clear (void); |
5832 | 655 |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
656 void do_set (const std::string& p, bool warn, bool is_init = false); |
5867 | 657 |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
658 void do_append (const std::string& dir, bool warn); |
5832 | 659 |
5867 | 660 void do_prepend (const std::string& dir, bool warn); |
5832 | 661 |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
662 void do_add (const std::string& dir, bool at_end, bool warn); |
5832 | 663 |
664 bool do_remove (const std::string& dir); | |
665 | |
666 void do_update (void) const; | |
667 | |
7336 | 668 static bool |
669 check_file_type (std::string& fname, int type, int possible_types, | |
10313 | 670 const std::string& fcn, const char *who); |
7336 | 671 |
20052
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
672 bool is_package (const std::string& name) const; |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
673 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
674 package_info& get_package (const std::string& name) const |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
675 { |
20052
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
676 if (! name.empty () && is_package (name)) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
677 { |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
678 package_map_iterator pi = package_map.find (name); |
5832 | 679 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
680 if (pi == package_map.end ()) |
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
681 pi = package_map.insert (package_map.end (), |
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
682 package_map_type::value_type (name, package_info (name))); |
7336 | 683 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
684 return pi->second; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
685 } |
7336 | 686 |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
687 return top_level_package; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
688 } |
7336 | 689 |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
690 std::list<std::string> do_overloads (const std::string& meth) const; |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
691 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
692 bool do_find_package (const std::string& package_name) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
693 { |
23418
0412433f016f
rename load_path::loader to load_path::package_info
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
694 return (package_map.find (package_name) != package_map.end ()); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
695 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
696 |
16690
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
697 std::list<std::string> do_get_all_package_names (bool only_top_level) const; |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
698 |
5832 | 699 std::string do_find_file (const std::string& file) const; |
700 | |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
701 std::string do_find_dir (const std::string& dir) const; |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
702 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
703 string_vector do_find_matching_dirs (const std::string& dir) const; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
704 |
5832 | 705 std::string do_find_first_of (const string_vector& files) const; |
706 | |
707 string_vector do_find_all_first_of (const string_vector& files) const; | |
708 | |
709 string_vector do_dirs (void) const; | |
710 | |
711 std::list<std::string> do_dir_list (void) const; | |
712 | |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
713 string_vector do_files (const std::string& dir, bool omit_exts) const; |
5832 | 714 |
715 string_vector do_fcn_names (void) const; | |
716 | |
717 std::string do_path (void) const; | |
718 | |
7336 | 719 friend void print_types (std::ostream& os, int types); |
720 | |
721 friend string_vector get_file_list (const dir_info::fcn_file_map_type& lst); | |
722 | |
723 friend void | |
724 print_fcn_list (std::ostream& os, const dir_info::fcn_file_map_type& lst); | |
725 | |
5832 | 726 void do_display (std::ostream& os) const; |
727 | |
6629 | 728 std::string do_system_path (void) const { return sys_path; } |
6626 | 729 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
730 std::string do_get_command_line_path (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
731 { return command_line_path; } |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
732 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16547
diff
changeset
|
733 void add (const dir_info& di, bool at_end, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
734 const std::string& pname = "", |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
735 bool updating = false) const; |
7336 | 736 |
737 friend dir_info::fcn_file_map_type get_fcn_files (const std::string& d); | |
5832 | 738 }; |
739 | |
740 extern std::string | |
741 genpath (const std::string& dir, const string_vector& skip = "private"); | |
742 | |
743 #endif |