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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
1 /*
5e41e06f6a78 [project @ 2006-05-26 21:41:32 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) 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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
5
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
7
5e41e06f6a78 [project @ 2006-05-26 21:41:32 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: 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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
17
5e41e06f6a78 [project @ 2006-05-26 21:41:32 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: 6630
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: 6630
diff changeset
20 <http://www.gnu.org/licenses/>.
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
21
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
22 */
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
25 #define octave_load_path_h 1
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
30 #include <list>
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
33 #include <string>
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
34
5835
07dd13bfc0ba [project @ 2006-05-31 18:21:49 by jwe]
jwe
parents: 5832
diff changeset
35 #include "pathsearch.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
36 #include "str-vec.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
37
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
38 class
6241
b84b59b614c5 [project @ 2007-01-11 07:35:52 by jwe]
jwe
parents: 5867
diff changeset
39 OCTINTERP_API
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
40 load_path
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
41 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
42 protected:
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
46
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
47 public:
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
48
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
49 typedef void (*hook_fcn_ptr) (const std::string& dir);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
52
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6241
diff changeset
53 static void initialize (bool set_initial_path = false)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
54 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
55 if (instance_ok ())
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6241
diff changeset
56 instance->do_initialize (set_initial_path);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
57 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
58
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
59 static void clear (void)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
60 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
63 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
64
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
65 static void set (const std::string& p, bool warn = false)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
66 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
67 if (instance_ok ())
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
68 instance->do_set (p, warn);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
69 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
70
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
71 static void append (const std::string& dir, bool warn = false)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
72 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
73 if (instance_ok ())
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
74 instance->do_append (dir, warn);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
75 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
76
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
77 static void prepend (const std::string& dir, bool warn = false)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
78 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
79 if (instance_ok ())
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
80 instance->do_prepend (dir, warn);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
81 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
82
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
83 static bool remove (const std::string& dir)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
84 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
85 return instance_ok () ? instance->do_remove (dir) : false;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
86 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
87
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
88 static void update (void)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
89 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
90 if (instance_ok ())
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
91 instance->do_update ();
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
92 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
99 static std::string find_method (const std::string& class_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
103 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
108 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
109
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
113 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
116 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
120 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
124 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
140 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
144 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
148 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
152 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
156 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
159 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
160
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
164 {
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
168 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
172 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
173 std::string dir_name;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
178 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
182 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
183 std::string dir_name;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
188 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5835
diff changeset
192 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
193 std::string dir_name;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5835
diff changeset
198 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5835
diff changeset
199
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
200 static std::string find_file (const std::string& file)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
201 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
204 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
218 static std::string find_first_of (const string_vector& files)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
219 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
222 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
223
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
224 static string_vector find_all_first_of (const string_vector& files)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
225 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
228 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
229
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
230 static string_vector dirs (void)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
231 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
232 return instance_ok () ? instance->do_dirs () : string_vector ();
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
233 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
234
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
235 static std::list<std::string> dir_list (void)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
236 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
239 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
245 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
246
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
247 static string_vector fcn_names (void)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
248 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
249 return instance_ok () ? instance->do_fcn_names () : string_vector ();
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
250 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
251
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
252 static std::string path (void)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
255 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
256
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
257 static void display (std::ostream& os)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
258 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
259 if (instance_ok ())
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
260 instance->do_display (os);
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
261 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
267 static void set_remove_hook (hook_fcn_ptr f) { remove_hook = f; }
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
272 static void set_command_line_path (const std::string& p)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
273 {
5835
07dd13bfc0ba [project @ 2006-05-31 18:21:49 by jwe]
jwe
parents: 5832
diff changeset
274 if (command_line_path.empty ())
07dd13bfc0ba [project @ 2006-05-31 18:21:49 by jwe]
jwe
parents: 5832
diff changeset
275 command_line_path = p;
07dd13bfc0ba [project @ 2006-05-31 18:21:49 by jwe]
jwe
parents: 5832
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
278 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
286 static std::string system_path (void)
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
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
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
289 }
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
290
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
291 private:
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
292
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
293 static const int M_FILE = 1;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
294 static const int OCT_FILE = 2;
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5835
diff changeset
295 static const int MEX_FILE = 4;
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
296
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
297 class dir_info
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
298 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
299 public:
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
300
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
301 // <FCN_NAME, TYPE>
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
302 typedef std::map<std::string, int> fcn_file_map_type;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
303
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
304 typedef fcn_file_map_type::const_iterator const_fcn_file_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
305 typedef fcn_file_map_type::iterator fcn_file_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
333
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
334 typedef method_file_map_type::const_iterator const_method_file_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
335 typedef method_file_map_type::iterator method_file_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
361
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
364 is_relative (di.is_relative),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
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
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
367 all_files (di.all_files), fcn_files (di.fcn_files),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
373
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
374 dir_info& operator = (const dir_info& di)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
375 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
376 if (&di != this)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
377 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
378 dir_name = di.dir_name;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
379 abs_dir_name = di.abs_dir_name;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
380 is_relative = di.is_relative;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
381 dir_mtime = di.dir_mtime;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
382 dir_time_last_checked = di.dir_time_last_checked;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
383 all_files = di.all_files;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
384 fcn_files = di.fcn_files;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
385 private_file_map = di.private_file_map;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
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
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
388 }
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
389
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
390 return *this;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
391 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
392
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
393 void update (void);
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
394
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
400 string_vector all_files;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
401 string_vector fcn_files;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
402 fcn_file_map_type private_file_map;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
408 private:
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
409
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
410 void initialize (void);
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
411
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
412 void get_file_list (const std::string& d);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
413
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
414 void get_private_file_map (const std::string& d);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
415
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
416 void get_method_file_map (const std::string& d,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
417 const std::string& class_name);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
422 friend fcn_file_map_type get_fcn_files (const std::string& d);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
423 };
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
424
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
425 class file_info
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
426 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
427 public:
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
428
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
429 file_info (const std::string& d, int t) : dir_name (d), types (t) { }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
430
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
431 file_info (const file_info& fi)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
432 : dir_name (fi.dir_name), types (fi.types) { }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
435
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
436 file_info& operator = (const file_info& fi)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
437 {
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
438 if (&fi != this)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
439 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
440 dir_name = fi.dir_name;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
441 types = fi.types;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
442 }
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
443
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
444 return *this;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
445 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
446
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
447 std::string dir_name;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
448 int types;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
449 };
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
450
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
451 // We maintain two ways of looking at the same information.
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
452 //
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
453 // First, a list of directories and the set of "public" files and
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
454 // private files (those found in the special "private" subdirectory)
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
455 // in each directory.
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
458 // directories, but without filename extensions) to a list of
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
461 // overloaded functions (in the "@" directories used to implement
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
462 // classes).
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
463
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
464 typedef std::list<dir_info> dir_info_list_type;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
465
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
466 typedef dir_info_list_type::const_iterator const_dir_info_list_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
467 typedef dir_info_list_type::iterator dir_info_list_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
474 typedef std::list<file_info> file_info_list_type;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
475
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
476 typedef file_info_list_type::const_iterator const_file_info_list_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
477 typedef file_info_list_type::iterator file_info_list_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
478
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
479 // <FCN_NAME, FILE_INFO_LIST>
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
480 typedef std::map<std::string, file_info_list_type> fcn_map_type;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
481
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
482 typedef fcn_map_type::const_iterator const_fcn_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
483 typedef fcn_map_type::iterator fcn_map_iterator;
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
484
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
488
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
489 typedef private_fcn_map_type::const_iterator const_private_fcn_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
490 typedef private_fcn_map_type::iterator private_fcn_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
491
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
492 // <CLASS_NAME, <FCN_NAME, FILE_INFO_LIST>>
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
493 typedef std::map<std::string, fcn_map_type> method_map_type;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
494
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
495 typedef method_map_type::const_iterator const_method_map_iterator;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
621 static load_path *instance;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
625 static hook_fcn_ptr add_hook;
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
626
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
627 static hook_fcn_ptr remove_hook;
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
628
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
629 static std::string command_line_path;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
630
6626
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
631 static std::string sys_path;
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
635 static bool instance_ok (void);
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
636
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
637 const_dir_info_list_iterator find_dir_info (const std::string& dir) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
638 dir_info_list_iterator find_dir_info (const std::string& dir);
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
639
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
640 bool contains (const std::string& dir) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
651
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6241
diff changeset
652 void do_initialize (bool set_initial_path);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
659
5867
b305874f50ef [project @ 2006-06-28 22:11:51 by jwe]
jwe
parents: 5864
diff changeset
660 void do_prepend (const std::string& dir, bool warn);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
663
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
664 bool do_remove (const std::string& dir);
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
665
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
666 void do_update (void) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
667
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
668 static bool
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
669 check_file_type (std::string& fname, int type, int possible_types,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
670 const std::string& fcn, const char *who);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
699 std::string do_find_file (const std::string& file) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
705 std::string do_find_first_of (const string_vector& files) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
706
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
707 string_vector do_find_all_first_of (const string_vector& files) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
708
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
709 string_vector do_dirs (void) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
710
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
711 std::list<std::string> do_dir_list (void) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
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
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
714
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
715 string_vector do_fcn_names (void) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
716
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
717 std::string do_path (void) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
718
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
719 friend void print_types (std::ostream& os, int types);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
720
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
721 friend string_vector get_file_list (const dir_info::fcn_file_map_type& lst);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
722
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
723 friend void
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
724 print_fcn_list (std::ostream& os, const dir_info::fcn_file_map_type& lst);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
725
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
726 void do_display (std::ostream& os) const;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
727
6629
7e2b5d0cf7ad [project @ 2007-05-16 15:18:18 by jwe]
jwe
parents: 6626
diff changeset
728 std::string do_system_path (void) const { return sys_path; }
6626
af16354ea09c [project @ 2007-05-16 14:58:26 by jwe]
jwe
parents: 6625
diff changeset
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
736
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
737 friend dir_info::fcn_file_map_type get_fcn_files (const std::string& d);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
738 };
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
739
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
740 extern std::string
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
741 genpath (const std::string& dir, const string_vector& skip = "private");
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
742
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
743 #endif