File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ void usage() {
1818 std::cerr << " \n " ;
1919 std::cerr << " options:\n " ;
2020 std::cerr << " -o <output_format> select output_format (default '" << DEFAULT_OUTPUT_FORMAT << " '); available options are:\n " ;
21- for (const auto & f : output_format::output_formats ) {
21+ for (const auto & f : output_format::all () ) {
2222 std::cerr << " " << f->name << std::endl;
2323 std::cerr << " " << f->get_description () << std::endl;
2424 }
@@ -79,11 +79,11 @@ int main(int argc, char *argv[]) {
7979 }
8080 std::shared_ptr<output_format> oformat;
8181 if (!res) {
82- const auto & e = std::find_if (output_format::output_formats .begin (), output_format::output_formats .end (),
82+ const auto & e = std::find_if (output_format::all () .begin (), output_format::all () .end (),
8383 [&](const std::shared_ptr<output_format> &f) {
8484 return f->name == format;
8585 });
86- if (e == output_format::output_formats .end ()) {
86+ if (e == output_format::all () .end ()) {
8787 std::cerr << " error: unknown output format '" << format << " '" << std::endl;
8888 res = 1 ;
8989 } else {
Original file line number Diff line number Diff line change @@ -77,13 +77,12 @@ struct compiled_source {
7777};
7878
7979struct output_format {
80- static std::vector<std::shared_ptr<output_format>> output_formats;
8180 static std::string default_name;
8281
8382 std::string name;
8483
8584 static void add (output_format *lang) {
86- output_formats .push_back (std::shared_ptr<output_format>(lang));
85+ all () .push_back (std::shared_ptr<output_format>(lang));
8786 }
8887
8988 virtual int output (std::string destination, std::vector<std::string> output_options,
@@ -93,6 +92,11 @@ struct output_format {
9392
9493 FILE *open_single_output (std::string destination);
9594 virtual ~output_format () = default ;
95+
96+ static std::vector<std::shared_ptr<output_format>>& all () {
97+ static std::vector<std::shared_ptr<output_format>> output_formats;
98+ return output_formats;
99+ }
96100protected:
97101 output_format (std::string name) : name(std::move(name)) {}
98102};
Original file line number Diff line number Diff line change 1515
1616using syntax_error = yy::parser::syntax_error;
1717
18- std::vector<std::shared_ptr<output_format>> output_format::output_formats;
1918std::string output_format::default_name = " c-sdk" ;
2019
2120pio_assembler::pio_assembler () {
@@ -324,7 +323,7 @@ std::vector<compiled_source::symbol> pio_assembler::public_symbols(program &prog
324323
325324int pio_assembler::write_output () {
326325 std::set<std::string> known_output_formats;
327- std::transform (output_format::output_formats .begin (), output_format::output_formats .end (),
326+ std::transform (output_format::all () .begin (), output_format::all () .end (),
328327 std::inserter (known_output_formats, known_output_formats.begin ()),
329328 [&](std::shared_ptr<output_format> &f) {
330329 return f->name ;
You can’t perform that action at this time.
0 commit comments