Mercurial > octave
annotate libinterp/corefcn/defaults.h @ 25460:627d6bde9b8d
solve installation info initialization problem differently
Back out changesets 893344cee100 and 69fc8935020b.
* defaults.h, defaults.cc: Instead of storing installation info like
include_dir, data_dir, info_dir, etc., in file-scope static variables
or a class object owned by the interpreter, store the initialized
values as constants inside the functions that return them. This way
they are initialized on demand and we don't have to worry about
initialization order of static data. It's OK for these to be static
because even though they may require some computation to intialize
(looking at environment variables or substituting the value of
OCTAVE_HOME), they are constants for any given installation of
Octave and will be the same for any instantiation of the interpreter.
Only include defaults.h in files that actually need it.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 12 Jun 2018 13:03:04 -0400 |
parents | 893344cee100 |
children | 00f796120a6d |
rev | line source |
---|---|
12 | 1 /* |
2 | |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24899
diff
changeset
|
3 Copyright (C) 1993-2018 John W. Eaton |
12 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23721
diff
changeset
|
7 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
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23721
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
12 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 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
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
12 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23721
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
12 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_defaults_h) |
423 | 24 #define octave_defaults_h 1 |
12 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
27 |
2204 | 28 #include <string> |
29 | |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
30 #include "pathsearch.h" |
3174 | 31 |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
32 namespace octave |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
33 { |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
34 namespace config |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
35 { |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
36 extern OCTINTERP_API std::string |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
37 prepend_octave_home (const std::string& s); |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
38 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
39 extern OCTINTERP_API std::string |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
40 prepend_octave_exec_home (const std::string& s); |
25440
893344cee100
rename defaults source files to installation-data
John W. Eaton <jwe@octave.org>
parents:
25439
diff
changeset
|
41 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
42 // These could be defined as pure constants, but we'll use |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
43 // functions to be consistent with the values that require |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
44 // initialization. |
23713
4feef926733a
rename files missed in previous commit
John W. Eaton <jwe@octave.org>
parents:
23712
diff
changeset
|
45 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
46 extern OCTINTERP_API std::string canonical_host_type (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
47 extern OCTINTERP_API std::string release (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
48 extern OCTINTERP_API std::string default_pager (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
49 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
50 // These require initialization, so can't be defined as pure |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
51 // constants. We use functions to access these values so that |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
52 // they can't be modified by users. |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
53 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
54 extern OCTINTERP_API std::string octave_home (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
55 extern OCTINTERP_API std::string octave_exec_home (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
56 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
57 extern OCTINTERP_API std::string bin_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
58 extern OCTINTERP_API std::string data_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
59 extern OCTINTERP_API std::string dataroot_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
60 extern OCTINTERP_API std::string include_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
61 extern OCTINTERP_API std::string lib_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
62 extern OCTINTERP_API std::string libexec_dir (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
63 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
64 extern OCTINTERP_API std::string local_ver_arch_lib_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
65 extern OCTINTERP_API std::string local_api_arch_lib_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
66 extern OCTINTERP_API std::string local_arch_lib_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
67 extern OCTINTERP_API std::string arch_lib_dir (void); |
23713
4feef926733a
rename files missed in previous commit
John W. Eaton <jwe@octave.org>
parents:
23712
diff
changeset
|
68 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
69 extern OCTINTERP_API std::string local_ver_oct_file_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
70 extern OCTINTERP_API std::string local_api_oct_file_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
71 extern OCTINTERP_API std::string local_oct_file_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
72 extern OCTINTERP_API std::string oct_file_dir (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
73 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
74 extern OCTINTERP_API std::string local_ver_fcn_file_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
75 extern OCTINTERP_API std::string local_api_fcn_file_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
76 extern OCTINTERP_API std::string local_fcn_file_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
77 extern OCTINTERP_API std::string fcn_file_dir (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
78 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
79 extern OCTINTERP_API std::string oct_data_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
80 extern OCTINTERP_API std::string oct_doc_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
81 extern OCTINTERP_API std::string oct_etc_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
82 extern OCTINTERP_API std::string oct_fonts_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
83 extern OCTINTERP_API std::string oct_include_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
84 extern OCTINTERP_API std::string oct_lib_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
85 extern OCTINTERP_API std::string oct_locale_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
86 extern OCTINTERP_API std::string oct_tests_dir (void); |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
87 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
88 extern OCTINTERP_API std::string info_dir (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
89 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
90 extern OCTINTERP_API std::string man_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
91 extern OCTINTERP_API std::string man1_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
92 extern OCTINTERP_API std::string man1_ext (void); |
5814 | 93 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
94 extern OCTINTERP_API std::string image_dir (void); |
25439
69fc8935020b
move some static configuration variables inside a class
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
95 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
96 extern OCTINTERP_API std::string local_startupfile_dir (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
97 extern OCTINTERP_API std::string startupfile_dir (void); |
5814 | 98 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
99 extern OCTINTERP_API std::string local_site_defaults_file (void); |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
100 extern OCTINTERP_API std::string site_defaults_file (void); |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
101 } |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23713
diff
changeset
|
102 } |
15157
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15100
diff
changeset
|
103 |
12 | 104 #endif |