File tree Expand file tree Collapse file tree 10 files changed +37
-26
lines changed Expand file tree Collapse file tree 10 files changed +37
-26
lines changed Original file line number Diff line number Diff line change 22#include < nlohmann/json.hpp>
33
44#include " nix/cmd/command.hh"
5+ #include " nix/cmd/legacy.hh"
56#include " nix/cmd/markdown.hh"
67#include " nix/store/store-open.hh"
78#include " nix/store/local-fs-store.hh"
1415
1516namespace nix {
1617
18+ RegisterCommand::Commands & RegisterCommand::commands ()
19+ {
20+ static RegisterCommand::Commands commands;
21+ return commands;
22+ }
23+
24+ RegisterLegacyCommand::Commands & RegisterLegacyCommand::commands ()
25+ {
26+ static RegisterLegacyCommand::Commands commands;
27+ return commands;
28+ }
29+
1730nix::Commands RegisterCommand::getCommandsFor (const std::vector<std::string> & prefix)
1831{
1932 nix::Commands res;
Original file line number Diff line number Diff line change @@ -286,11 +286,7 @@ struct RegisterCommand
286286{
287287 typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
288288
289- static Commands & commands ()
290- {
291- static Commands commands;
292- return commands;
293- }
289+ static Commands & commands ();
294290
295291 RegisterCommand (std::vector<std::string> && name, std::function<ref<Command>()> command)
296292 {
Original file line number Diff line number Diff line change @@ -13,11 +13,7 @@ struct RegisterLegacyCommand
1313{
1414 typedef std::map<std::string, MainFunction> Commands;
1515
16- static Commands & commands ()
17- {
18- static Commands commands;
19- return commands;
20- }
16+ static Commands & commands ();
2117
2218 RegisterLegacyCommand (const std::string & name, MainFunction fun)
2319 {
Original file line number Diff line number Diff line change @@ -12,11 +12,7 @@ struct RegisterPrimOp
1212{
1313 typedef std::vector<PrimOp> PrimOps;
1414
15- static PrimOps & primOps ()
16- {
17- static PrimOps primOps;
18- return primOps;
19- }
15+ static PrimOps & primOps ();
2016
2117 /* *
2218 * You can register a constant by passing an arity of 0. fun
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ struct PrintOptions
110110 * `PrintOptions` for unknown and therefore potentially large values in error messages,
111111 * to avoid printing "too much" output.
112112 */
113- static PrintOptions errorPrintOptions = PrintOptions{
113+ static constexpr PrintOptions errorPrintOptions = PrintOptions{
114114 .ansiColors = true ,
115115 .maxDepth = 10 ,
116116 .maxAttrs = 10 ,
Original file line number Diff line number Diff line change 4040
4141namespace nix {
4242
43+ RegisterPrimOp::PrimOps & RegisterPrimOp::primOps ()
44+ {
45+ static RegisterPrimOp::PrimOps primOps;
46+ return primOps;
47+ }
48+
4349/* ************************************************************
4450 * Miscellaneous
4551 *************************************************************/
Original file line number Diff line number Diff line change 1010
1111namespace nix {
1212
13+ RegisterBuiltinBuilder::BuiltinBuilders & RegisterBuiltinBuilder::builtinBuilders ()
14+ {
15+ static RegisterBuiltinBuilder::BuiltinBuilders builders;
16+ return builders;
17+ }
18+
1319namespace {
1420
1521struct State
Original file line number Diff line number Diff line change @@ -33,11 +33,7 @@ struct RegisterBuiltinBuilder
3333{
3434 typedef std::map<std::string, BuiltinBuilder> BuiltinBuilders;
3535
36- static BuiltinBuilders & builtinBuilders ()
37- {
38- static BuiltinBuilders builders;
39- return builders;
40- }
36+ static BuiltinBuilders & builtinBuilders ();
4137
4238 RegisterBuiltinBuilder (const std::string & name, BuiltinBuilder && fun)
4339 {
Original file line number Diff line number Diff line change 44
55namespace nix {
66
7+ GlobalConfig::ConfigRegistrations & GlobalConfig::configRegistrations ()
8+ {
9+ static GlobalConfig::ConfigRegistrations configRegistrations;
10+ return configRegistrations;
11+ }
12+
713bool GlobalConfig::set (const std::string & name, const std::string & value)
814{
915 for (auto & config : configRegistrations ())
Original file line number Diff line number Diff line change @@ -9,11 +9,7 @@ struct GlobalConfig : public AbstractConfig
99{
1010 typedef std::vector<Config *> ConfigRegistrations;
1111
12- static ConfigRegistrations & configRegistrations ()
13- {
14- static ConfigRegistrations configRegistrations;
15- return configRegistrations;
16- }
12+ static ConfigRegistrations & configRegistrations ();
1713
1814 bool set (const std::string & name, const std::string & value) override ;
1915
You can’t perform that action at this time.
0 commit comments