diff options
author | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-08-02 19:12:47 +0000 |
---|---|---|
committer | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-08-02 19:12:47 +0000 |
commit | 97daf39bc6c9d136615da301e13a198018c886a9 (patch) | |
tree | 7de0bc2c6999dfaa2d9d496f22778eb6221e5d4d | |
parent | fae05d7fa20c44b2a19e548c1a38aa77dead394a (diff) | |
download | ATCD-97daf39bc6c9d136615da301e13a198018c886a9.tar.gz |
ChangeLogTag: Wed Aug 2 18:52:14 UTC 2006 Boris Kolpackov <boris@kolpackov.net>
-rw-r--r-- | CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp | 39 | ||||
-rw-r--r-- | CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp | 111 | ||||
-rw-r--r-- | CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp | 5 | ||||
-rw-r--r-- | CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp | 391 | ||||
-rw-r--r-- | CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp | 131 | ||||
-rw-r--r-- | CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp | 4 | ||||
-rw-r--r-- | CIAO/CIDLC/DescriptorGenerator.cpp | 4 | ||||
-rw-r--r-- | CIAO/CIDLC/DescriptorGenerator.hpp | 2 | ||||
-rw-r--r-- | CIAO/CIDLC/ExecImplGenerator.cpp | 15 | ||||
-rw-r--r-- | CIAO/CIDLC/ExecImplGenerator.hpp | 6 | ||||
-rw-r--r-- | CIAO/CIDLC/ExecutorMappingGenerator.cpp | 26 | ||||
-rw-r--r-- | CIAO/CIDLC/ExecutorMappingGenerator.hpp | 4 | ||||
-rw-r--r-- | CIAO/CIDLC/ServantGenerator.cpp | 22 | ||||
-rw-r--r-- | CIAO/CIDLC/ServantGenerator.hpp | 6 | ||||
-rw-r--r-- | CIAO/CIDLC/cidlc.cpp | 151 | ||||
-rw-r--r-- | CIAO/ChangeLog | 34 |
16 files changed, 366 insertions, 585 deletions
diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp index 69d5716eeb8..6c3d84b2481 100644 --- a/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp @@ -14,9 +14,9 @@ class CommandLine { public: - - CommandLine () throw () : separator (false) {} - + CommandLine () + { + } // Option constrain checking public: @@ -71,9 +71,9 @@ public: options.end (), OptionNamePredicat (name)); - if (i != options.end () && !(i->value_.empty ())) + if (i != options.end () && !(i->value ().empty ())) { - return i->value_; + return i->value (); } else { @@ -92,9 +92,9 @@ public: options.end (), OptionNamePredicat (name)); - if (i != options.end () && !(i->value_.empty ())) + if (i != options.end () && !(i->value ().empty ())) { - return i->value_; + return i->value (); } else { @@ -123,34 +123,31 @@ public: struct Option { - enum OptionType + Option (std::string const& name) + : name_ (name) { - EQUATIONAL, - COMPOSITE - }; + } - Option (OptionType type, - std::string const& name, - std::string const& value) throw () - : type_ (type), - name_ (name), + Option (std::string const& name, + std::string const& value) + : name_ (name), value_ (value) { } - std::string + std::string const& name () const { return name_; } - std::string + std::string const& value () const { return value_; } - OptionType type_; + private: std::string name_; std::string value_; }; @@ -210,7 +207,7 @@ public: bool operator ()(Option const& option) throw () { - return name_ == option.name_; + return name_ == option.name (); } private: @@ -220,8 +217,6 @@ public: std::string command; Options options; Arguments arguments; - - bool separator; }; #endif // COMMAND_LINE_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp index 1944d8b4f59..a7c6961cf1f 100644 --- a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp @@ -5,32 +5,65 @@ #ifndef COMMAND_LINE_DESCRIPTOR_H #define COMMAND_LINE_DESCRIPTOR_H -#include <string> +#include <map> +#include <list> #include <vector> +#include <string> #include <ostream> +#include <cassert> + -//@@ temporary. should probably be changed to CommandLine namespace CL { + struct OptionType + { + enum Value + { + flag, + value + }; + + OptionType (Value v) + : v_ (v) + { + } + + operator Value () const + { + return v_; + } + + private: + Value v_; + }; + + class OptionDescription { public: OptionDescription (std::string name, std::string description, - bool optional) - : optional_ (optional), - name_ (name), - value_synopsis_ (), - description_ (description) + OptionType type, + bool optional = true) + : optional_ (optional), + type_ (type), + name_ (name), + value_synopsis_ (), + description_ (description) { + // There should be value_synopsis for non-flag options. + // + assert (type == OptionType::flag); } OptionDescription (std::string name, std::string value_synopsis, std::string description, - bool optional) + OptionType type, + bool optional = true) : optional_ (optional), + type_ (type), name_ (name), value_synopsis_ (value_synopsis), description_ (description) @@ -44,6 +77,12 @@ namespace CL return optional_; } + OptionType + type () const + { + return type_; + } + std::string name () const { @@ -65,6 +104,7 @@ namespace CL private: bool optional_; + OptionType type_; std::string name_; std::string value_synopsis_; std::string description_; @@ -80,10 +120,23 @@ namespace CL } private: + Description (Description const&); + + Description& + operator= (Description const&); + + private: + // We are storing pointer to elements in this list in the map below. + // To prevent element moving we will use list instead of vector. + // typedef - std::vector<OptionDescription> + std::list<OptionDescription> OptionDescriptionList; + typedef + std::map<std::string, OptionDescription*> + OptionDescriptionMap; + public: std::string @@ -110,10 +163,24 @@ namespace CL return options_.end (); } + typedef + OptionDescriptionMap::const_iterator + OptionMapIterator; + + OptionDescription const* + find_option (std::string const& option) const + { + OptionDescriptionMap::const_iterator i ( + option_map_.find (option)); + + return i == option_map_.end () ? 0 : i->second; + } + void add_option (OptionDescription const& od) { options_.push_back (od); + option_map_[od.name ()] = &options_.back (); } private: @@ -145,9 +212,9 @@ namespace CL } private: - std::string command_; OptionDescriptionList options_; + OptionDescriptionMap option_map_; ArgumentDescriptionList arguments_; }; @@ -178,11 +245,13 @@ namespace CL for (; ob != oe; ob++) { - os << (ob->optional () ? "[--" : "--") - << ob->name () - << (ob->value_synopsis ().empty () ? "" : " ") - << ob->value_synopsis () - << (ob->optional () ? "]" : "") + bool flag (ob->type () == OptionType::flag); + bool optional (ob->optional ()); + std::string prefix (ob->name ().length () == 1 ? "-" : "--"); + + os << (optional ? "[" : "") << prefix << ob->name () + << (flag ? "" : " ") << ob->value_synopsis () + << (optional ? "]" : "") << endl; os << "\t\t" << ob->description () << endl << endl; @@ -234,13 +303,15 @@ namespace CL for (; ob != oe; ob++) { + bool flag (ob->type () == OptionType::flag); + bool optional (ob->optional ()); + std::string prefix (ob->name ().length () == 1 ? "-" : "--"); + os << "<dt>" << endl << "<code>" << endl - << (ob->optional () ? "[--" : "--") - << ob->name () - << (ob->value_synopsis ().empty () ? "" : " ") - << ob->value_synopsis () - << (ob->optional () ? "]" : "") << endl + << (optional ? "[" : "") << prefix << ob->name () + << (flag ? "" : " ") << ob->value_synopsis () + << (optional ? "]" : "") << endl << "</code>" << endl << "</dt>" << endl; diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp deleted file mode 100644 index fc700def53a..00000000000 --- a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// file : CCF/CodeGenerationKit/CommandLineGrammar.cpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#include "CCF/CodeGenerationKit/CommandLineGrammar.hpp" diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp deleted file mode 100644 index 6a8fdfcabc3..00000000000 --- a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp +++ /dev/null @@ -1,391 +0,0 @@ -// file : CCF/CodeGenerationKit/CommandLineGrammar.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef COMMAND_LINE_GRAMMAR_H -#define COMMAND_LINE_GRAMMAR_H - -#include <vector> -#include <string> - -#include <boost/spirit.hpp> - -#include "CCF/CodeGenerationKit/CommandLine.hpp" - - -using namespace std; -using namespace boost::spirit; - -template <typename S> -struct string_directive : public unary<S, parser<string_directive<S> > > -{ - typedef - string_directive - self_t; - - string_directive (S const& a) - : unary<S, parser<string_directive<S> > > (a) - { - } - - template <typename ScannerT> - typename parser_result<self_t, ScannerT>::type - parse(ScannerT const& scan) const - { - typedef - typename ScannerT::iterator_t - Iterator; - - typedef - typename ScannerT::value_t - Value; - - typedef - typename Value::const_iterator - ValueIterator; - - Iterator save = scan.first; - - if (!scan.at_end()) - { - // Now go one level deeper - - Value const& v = *scan; - - ValueIterator first = v.begin (); - ValueIterator last = v.end (); - - scanner<ValueIterator, scanner_policies <> > sl_scan(first, last); - - match<nil_t> hit = this->subject ().parse(sl_scan); - - if (static_cast<std::size_t> (hit.length()) == v.length ()) - { - ++scan; - - return scan.create_match(1, nil_t(), save, scan.first); - } - else - { - return scan.no_match(); - } - } - else - { - return scan.no_match(); - } - } -}; - - -template <typename S> -string_directive<S> -string_d (parser<S> const& a) -{ - return string_directive<S>(a.derived()); -} - - -struct CLineGrammar : public grammar<CLineGrammar> -{ - CommandLine& cl_; - - CLineGrammar (CommandLine& cl) throw () : cl_(cl) {} - - - template <typename IteratorT, typename CodeT> - struct SemanticAction - { - SemanticAction (CommandLine& cl) : cl_ (cl), code_ () {} - - void operator()(IteratorT first, IteratorT last) const - { - string str (first, last); - code_.execute (cl_, str); - } - - private: - CommandLine& cl_; - CodeT code_; - }; - - - struct SetCommandName - { - void execute (CommandLine& cl, string const& s) const throw () - { - cl.command = s; - } - }; - - - template <typename IteratorT> - struct SetOptionName - { - SetOptionName (CommandLine& cl, - CommandLine::Option::OptionType type) - : cl_ (cl), type_ (type) - { - } - - void operator()(IteratorT first, IteratorT last) const - { - string s (first, last); - cl_.options.push_back (CommandLine::Option(type_, s, "")); - } - - private: - CommandLine& cl_; - CommandLine::Option::OptionType type_; - }; - - - struct SetOptionValue - { - void execute (CommandLine& cl, string const& s) const throw () - { - CommandLine::Options::reverse_iterator r = cl.options.rbegin (); - - if (r != cl.options.rend () && r->value_ == "") - { - r->value_ = s; - } - else - { - //@@ - //throw - } - } - }; - - struct SetArgument - { - void execute (CommandLine& cl, string const& s) const throw () - { - cl.arguments.push_back (s); - } - }; - - struct SetSeparator - { - void execute (CommandLine& cl, string const&) const throw () - { - cl.separator = true; - } - }; - - - template <typename ScannerT> - struct definition - { - typedef - typename ScannerT::value_t::const_iterator - SLIterator; - - typedef - scanner<SLIterator, scanner_policies <> > - SLScanner; - - typedef - rule<ScannerT> - Rule; - - typedef - rule<SLScanner> - SLRule; - - - Rule r_argument; - Rule r_arg_list; - - Rule argument; - Rule arg_list; - - SLRule option_prefix; - SLRule e_name; // equational name, i.e. can meet '=' - SLRule c_name; // composite name, i.e. failes if meets '=' - SLRule e_value; // equational value, i.e. can contain leading '-' - SLRule c_value; // composite value, i.e. cannot contain leading '-' - - Rule composite; - Rule equational; - - Rule option_list; - Rule option; - - SLRule command_name; - - Rule command_line; - - // Semantic actions - - typedef - SemanticAction<SLIterator, SetCommandName> - CommandNameHandler; - - typedef - SetOptionName<SLIterator> - OptionNameHandler; - - typedef - SemanticAction<SLIterator, SetOptionValue> - OptionValueHandler; - - typedef - SemanticAction<SLIterator, SetArgument> - ArgumentHandler; - - typedef - SemanticAction<SLIterator, SetSeparator> - SeperatorHandler; - - /* - - <epigraph> - - As many people naively believe command line is - not a space separated array of words. - - -- unknown author. - </epigraph> - - - - NOTE: - - (1) This grammar is space-sensitive. - - (2) Anychar is assumend not to clash with <argv-delim>. Instead - <argv-delim> is assumed to be a next-dimension entitiy. - - - <command-line> ::= <command-name> - [ - [ <argv-delim> <option-list>] - [ - <option-prefix> [<argv-delim> <arg-list>] | - <argv-delim> <r-arg-list> - ] - ] - - <command-name> ::= anychar+ - - <option-list> ::= <option> { <argv-delim> <option> }* - <option> ::= <composite> | <equational> - <composite> ::= <option-prefix> <name> [ <argv-delim><c-value> ] - <equational> ::= <option-prefix> <name> '=' <e-value> - <option-prefix> ::= '-' [ '-' ] - <name> ::= {anychar - '='}+ - <c-value> ::= anychar+ - {<option-prefix> anychar*} - <e-valie> ::= anychar+ - - <arg-list> ::= <argument> { <arg-delim> <argument> }* - <r-arg-list> ::= <r-argument> { <arg-delim> <argument> }* - - <argument> ::= anychar+ - <r-argument> ::= anychar+ - {<option-prefix> anychar*} - - - */ - - - definition(CLineGrammar const& self) - { - command_line = - - string_d (command_name) >> - !option_list >> - !( - ( - string_d - ( - option_prefix[ SeperatorHandler (self.cl_) ] - ) >> !arg_list - ) | r_arg_list - ); - - // command name - - command_name = (+anychar_p)[CommandNameHandler (self.cl_)]; - - // options - - option_list = *(option); - - option = composite | equational; - - composite = - - string_d - ( - option_prefix >> c_name - - ) >> !string_d (c_value); - - equational = string_d (option_prefix >> e_name >> '=' >> e_value); - - option_prefix = lexeme_d[ch_p('-') >> !ch_p('-')]; - - e_name = - - lexeme_d - [ - ( - +( - anychar_p - ('=' | space_p) - ) - - )[ OptionNameHandler (self.cl_, CommandLine::Option::EQUATIONAL) ] - ]; - - c_name = - - lexeme_d - [ - ( - +(anychar_p - space_p) - - - ( - *(anychar_p - '=') >> '=' >> *anychar_p - ) - - )[ OptionNameHandler (self.cl_, CommandLine::Option::COMPOSITE) ] - ]; - - e_value = (+anychar_p)[ OptionValueHandler (self.cl_) ]; - - - c_value = - ( - +anychar_p - ( option_prefix >> *anychar_p ) - - )[ OptionValueHandler (self.cl_) ]; - - - - // arguments - - arg_list = *(argument); - r_arg_list = !(r_argument >> *argument); - - argument = string_d ((+anychar_p)[ ArgumentHandler (self.cl_) ]); - - r_argument = string_d - ( - ( - +anychar_p - (option_prefix >> *anychar_p) - - )[ ArgumentHandler (self.cl_) ] - ); - - } - - rule<ScannerT> const& start() const - { - return command_line; - } - }; -}; - - -#endif // COMMAND_LINE_GRAMMAR_H diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp index 49e241fc475..5f7d1d603bd 100644 --- a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp @@ -3,57 +3,118 @@ // cvs-id : $Id$ #include "CCF/CodeGenerationKit/CommandLineParser.hpp" -#include "CCF/CodeGenerationKit/CommandLineGrammar.hpp" -#include <vector> #include <string> #include <iostream> using std::cerr; using std::endl; -bool parse (int argc, char* argv[], CommandLine& cl) throw () +bool +parse (int argc, char* argv[], CL::Description const& cld, CommandLine& cl) { - typedef - std::vector<std::string> - Argv; + cl.command = argv[0]; - Argv v; + bool seen_double_dash (false); - for (int i = 0; i < argc; i++) + for (int i (1); i < argc; ++i) { - v.push_back (argv[i]); - } - - Argv::iterator first = v.begin (); - Argv::iterator last = v.end (); - - scanner<Argv::iterator, scanner_policies <> > scan(first, last); - - CLineGrammar g (cl); + std::string arg (argv[i]); - match<nil_t> hit = g.parse(scan); - - bool result = static_cast<std::size_t>(hit.length()) == v.size (); - - // some semantic analisys - if (!cl.separator) - { - CommandLine::Options::reverse_iterator r = cl.options.rbegin (); - - if (r != cl.options.rend () && - r->value_ != "" && - r->type_ == CommandLine::Option::COMPOSITE) + if (seen_double_dash) { + cl.arguments.push_back (arg); + continue; + } - cerr << "command line: assuming <" << r->value_ - << "> to be a value of option <" << r->name_ - << "> and not the first argument" << endl; + if (arg == "--") + { + seen_double_dash = true; + continue; + } - cerr << "command line: write ... --" << r->name_ << " -- " - << r->value_ << " ... to indicate otherwise" << endl; + if (arg.length () > 0 && arg[0] == '-') + { + if (arg.length () > 1 && arg[1] == '-') + { + // Double-dash (long) option. + // + + std::string op (arg, 2); + + if (CL::OptionDescription const* d = cld.find_option (op)) + { + if (d->type () == CL::OptionType::value) + { + if (++i >= argc) + { + cerr << argv[0] << ": argument expected for option '--" + << op << "'" << endl; + return false; + } + + // cerr << "--" << op << ": " << argv[i] << endl; + + cl.options.push_back (CommandLine::Option (op, argv[i])); + } + else + cl.options.push_back (CommandLine::Option (op)); + + continue; + } + } + else + { + // Single-dash (short) option. We support two formats: '-D foo' and + // -Dfoo. + // + std::string op (arg, 1, 1); + + if (CL::OptionDescription const* d = cld.find_option (op)) + { + if (d->type () == CL::OptionType::value) + { + std::string value; + + if (arg.length () > 2) + { + value.assign (arg, 2, arg.size () - 2); + } + else + { + if (++i >= argc) + { + cerr << argv[0] << ": argument expected for option '-" + << op << "'" << endl; + return false; + } + + value = argv[i]; + } + + // cerr << "-" << op << ": " << value << endl; + + cl.options.push_back (CommandLine::Option (op, value)); + } + else + { + if (arg.length () > 2) + { + cerr << argv[0] << ": argument not expected for option '-" + << op << "' in '" << arg << "'" << endl; + return false; + } + + cl.options.push_back (CommandLine::Option (op)); + } + + continue; + } + } } + + cl.arguments.push_back (arg); } - return result; + return true; } diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp index f985b448ae3..2e85dc7e266 100644 --- a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp @@ -6,7 +6,9 @@ #define COMMAND_LINE_PARSER_H #include "CCF/CodeGenerationKit/CommandLine.hpp" +#include "CCF/CodeGenerationKit/CommandLineDescriptor.hpp" -bool parse (int argc, char* argv[], CommandLine& cl) throw (); +bool +parse (int argc, char* argv[], CL::Description const&, CommandLine&); #endif // COMMAND_LINE_PARSER_H diff --git a/CIAO/CIDLC/DescriptorGenerator.cpp b/CIAO/CIDLC/DescriptorGenerator.cpp index f7b5912f3fa..456f0fe4b12 100644 --- a/CIAO/CIDLC/DescriptorGenerator.cpp +++ b/CIAO/CIDLC/DescriptorGenerator.cpp @@ -526,14 +526,14 @@ DescriptorGenerator::options (CL::Description& d) "suffix", "Use provided suffix instead of default \'.ccd\' " "when constructing name of descriptor file.", - true)); + CL::OptionType::value)); d.add_option (CL::OptionDescription ( "desc-file-regex", "regex", "Use provided regular expression when constructing " "name of descriptor file.", - true)); + CL::OptionType::value)); } void diff --git a/CIAO/CIDLC/DescriptorGenerator.hpp b/CIAO/CIDLC/DescriptorGenerator.hpp index 75a2392331a..e481c38e7d9 100644 --- a/CIAO/CIDLC/DescriptorGenerator.hpp +++ b/CIAO/CIDLC/DescriptorGenerator.hpp @@ -13,7 +13,7 @@ class DescriptorGenerator { public: - void + static void options (CL::Description& d); void diff --git a/CIAO/CIDLC/ExecImplGenerator.cpp b/CIAO/CIDLC/ExecImplGenerator.cpp index a1b9fc992e7..18edb06796a 100644 --- a/CIAO/CIDLC/ExecImplGenerator.cpp +++ b/CIAO/CIDLC/ExecImplGenerator.cpp @@ -43,39 +43,42 @@ void ExecImplGenerator::options (CL::Description& d) "suffix", "Use provided suffix instead of default \'_exec.h\' " "when constructing name of executor implementation file.", - true)); + CL::OptionType::value)); d.add_option (CL::OptionDescription ( "exec-hdr-file-regex", "regex", "Use provided regular expression when constructing " "name of executor implementation file.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "exec-src-file-suffix", "suffix", "Use provided suffix instead of default \'_exec.cpp\' " "when constructing name of executor implementation file.", - true)); + CL::OptionType::value)); d.add_option (CL::OptionDescription ( "exec-src-file-regex", "regex", "Use provided regular expression when constructing " "name of executor implementation file.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "exec-export-macro", "macro", "Replace default executor DLL export macro " "with provided macro.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "exec-export-include", "file", "Replace default executor export include file " "with provided file.", - true)); + CL::OptionType::value)); } diff --git a/CIAO/CIDLC/ExecImplGenerator.hpp b/CIAO/CIDLC/ExecImplGenerator.hpp index 17a366172a2..51536b3aaa3 100644 --- a/CIAO/CIDLC/ExecImplGenerator.hpp +++ b/CIAO/CIDLC/ExecImplGenerator.hpp @@ -14,11 +14,11 @@ class ExecImplGenerator { public: - ExecImplGenerator (CommandLine const& cl); - - void + static void options (CL::Description& d); + ExecImplGenerator (CommandLine const& cl); + void generate (CCF::CIDL::SemanticGraph::TranslationUnit&, fs::path const& file); diff --git a/CIAO/CIDLC/ExecutorMappingGenerator.cpp b/CIAO/CIDLC/ExecutorMappingGenerator.cpp index 0c3658fb8f4..c30f11ce59f 100644 --- a/CIAO/CIDLC/ExecutorMappingGenerator.cpp +++ b/CIAO/CIDLC/ExecutorMappingGenerator.cpp @@ -1672,27 +1672,27 @@ void ExecutorMappingGenerator:: options (CL::Description& d) { d.add_option (CL::OptionDescription ( + "lem-force-all", + "Force generation of local executor mapping for all IDL " + "types including those not used (directly or inderectly) " + "by compositions. This option is useful for generating a " + "common portion of local executor mapping used by more " + "than one component or composition.", + CL::OptionType::flag)); + + d.add_option (CL::OptionDescription ( "lem-file-suffix", "suffix", "Use provided suffix instead of default \'E\' " "when constructing name of local executor mapping file.", - true)); + CL::OptionType::value)); d.add_option (CL::OptionDescription ( "lem-file-regex", "regex", "Use provided regular expression when constructing " "name of local executor mapping file.", - true)); - - d.add_option (CL::OptionDescription ( - "lem-force-all", - "Force generation of local executor mapping for all IDL " - "types including those not used (directly or inderectly) " - "by compositions. This option is useful for generating a " - "common portion of local executor mapping used by more " - "than one component or composition.", - true)); + CL::OptionType::value)); } @@ -1929,7 +1929,7 @@ generate (CommandLine const& cl, { os << "#include \"ciao/CCM_Container.idl\"" << endl; - + if (cl.get_value ("lem-force-all", false) && !file_name.empty ()) { os << "#include \"" << file_name << '\"' << endl; @@ -1970,7 +1970,7 @@ generate (CommandLine const& cl, Traversal::BracketIncludes bracket_includes; IncludesEmitter includes_emitter (ctx, os); - + principal_region.edge_traverser (includes_emitter); principal_region.edge_traverser (quote_includes); principal_region.edge_traverser (bracket_includes); diff --git a/CIAO/CIDLC/ExecutorMappingGenerator.hpp b/CIAO/CIDLC/ExecutorMappingGenerator.hpp index 048fd798434..b67892c0658 100644 --- a/CIAO/CIDLC/ExecutorMappingGenerator.hpp +++ b/CIAO/CIDLC/ExecutorMappingGenerator.hpp @@ -17,9 +17,7 @@ class ExecutorMappingGenerator { public: - - //@@ should be static? - void + static void options (CL::Description& d); //@@ maybe I should introduce constant and non-constant diff --git a/CIAO/CIDLC/ServantGenerator.cpp b/CIAO/CIDLC/ServantGenerator.cpp index 1f85a107600..b2f40f18d91 100644 --- a/CIAO/CIDLC/ServantGenerator.cpp +++ b/CIAO/CIDLC/ServantGenerator.cpp @@ -43,50 +43,54 @@ void ServantGenerator::options (CL::Description& d) "suffix", "Use provided suffix instead of default \'_svnt.h\' " "when constructing name of servant file.", - true)); + CL::OptionType::value)); d.add_option (CL::OptionDescription ( "svnt-hdr-file-regex", "regex", "Use provided regular expression when constructing " "name of servant file.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "svnt-src-file-suffix", "suffix", "Use provided suffix instead of default \'_svnt.cpp\' " "when constructing name of servant file.", - true)); + CL::OptionType::value)); d.add_option (CL::OptionDescription ( "svnt-src-file-regex", "regex", "Use provided regular expression when constructing " "name of servant file.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "svnt-export-macro", "macro", "Replace default servant DLL export macro " "with provided ,acro.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "svnt-export-include", "file", "Replace default servant export include file " "with provided file.", - true)); + CL::OptionType::value)); + d.add_option (CL::OptionDescription ( "suppress-register-factory", - "", "Suppress generation of code to register eventtype " "factories for event sinks.", - true)); + CL::OptionType::flag)); + d.add_option (CL::OptionDescription ( "custom-container", "type", "Generate code for custom container of the provided type.", - true)); + CL::OptionType::value)); } diff --git a/CIAO/CIDLC/ServantGenerator.hpp b/CIAO/CIDLC/ServantGenerator.hpp index 643d588ef39..ae6a4a90477 100644 --- a/CIAO/CIDLC/ServantGenerator.hpp +++ b/CIAO/CIDLC/ServantGenerator.hpp @@ -17,11 +17,11 @@ class ServantGenerator { public: - ServantGenerator (CommandLine const& cl); - - void + static void options (CL::Description& d); + ServantGenerator (CommandLine const& cl); + void generate (CCF::CIDL::SemanticGraph::TranslationUnit&, fs::path const& file); diff --git a/CIAO/CIDLC/cidlc.cpp b/CIAO/CIDLC/cidlc.cpp index 1afeb08b859..acf5909230d 100644 --- a/CIAO/CIDLC/cidlc.cpp +++ b/CIAO/CIDLC/cidlc.cpp @@ -82,75 +82,91 @@ main (int argc, char* argv[]) { try { - // Parsing command line options and arguments + // Parsing command line options and arguments. // - // - CommandLine cl; - - if (!parse (argc, argv, cl)) - { - cerr << "command line syntax error" << endl; - cerr << "try " << argv[0] << " --help for usage information" << endl; - return -1; - } - if (cl.get_value ("version", false)) - { - cerr << "CIAO CIDL Compiler " << CIAO_VERSION - << " (built on " << __DATE__ << " at " << __TIME__ << ")" << endl; - return 0; - } + CL::Description cld (argv[0]); + cld.add_option (CL::OptionDescription ( + "version", + "Display version information and exit.", + CL::OptionType::flag)); - ExecutorMappingGenerator lem_gen; - ServantGenerator svnt_gen (cl); - ExecImplGenerator impl_gen (cl); - RepositoryIdGenerator repid_gen; - DescriptorGenerator desc_gen; - SizeTypeCalculator sizetype_calc; + cld.add_option (CL::OptionDescription ( + "help", + "Display usage information and exit.", + CL::OptionType::flag)); - if (cl.get_value ("help", false) || cl.get_value ("help-html", false)) - { - CL::Description d (argv[0]); + cld.add_option (CL::OptionDescription ( + "help-html", + "Dump usage information in html format and exit.", + CL::OptionType::flag)); + + cld.add_option (CL::OptionDescription ( + "I", + "dir", + "Add the directory dir to the list of directories to " + "be searched for header files.", + CL::OptionType::value)); + + cld.add_option (CL::OptionDescription ( + "D", + "name[=definition]", + "Predefine name as a macro with the value definition " + "if present, 1 otherwise.", + CL::OptionType::value)); + + cld.add_option (CL::OptionDescription ( + "gen-exec-impl", + "Generate the executor implementation classes.", + CL::OptionType::flag)); - lem_gen.options (d); - svnt_gen.options (d); - desc_gen.options (d); - impl_gen.options (d); + ExecutorMappingGenerator::options (cld); + ServantGenerator::options (cld); + DescriptorGenerator::options (cld); + ExecImplGenerator::options (cld); - d.add_option (CL::OptionDescription ( + cld.add_option (CL::OptionDescription ( "trace-semantic-actions", "Turn on semantic actions tracing facility.", - true)); + CL::OptionType::flag)); - d.add_option (CL::OptionDescription ( + cld.add_option (CL::OptionDescription ( "preprocess-only", "Run preprocessor only and output result to stdout.", - true)); + CL::OptionType::flag)); - d.add_option (CL::OptionDescription ( - "gen-exec-impl", - "Generate the executor implementation classes.", - true)); + cld.add_argument ("cidl file"); - d.add_option (CL::OptionDescription ( - "help", - "Display usage information and exit.", - true)); - d.add_option (CL::OptionDescription ( - "help-html", - "Dump usage information in html format and exit.", - true)); + CommandLine cl; - d.add_argument ("cidl file"); + if (!parse (argc, argv, cld, cl)) + { + cerr << "try " << argv[0] << " --help for usage information" << endl; + return -1; + } - if (cl.get_value ("help-html", false)) CL::print_html (cerr, d); - else CL::print_text (cerr, d); + if (cl.get_value ("version", false)) + { + cerr << "CIAO CIDL Compiler " << CIAO_VERSION + << " (built on " << __DATE__ << " at " << __TIME__ << ")" << endl; + return 0; + } + if (cl.get_value ("help", false)) + { + CL::print_text (cerr, cld); return 0; } + if (cl.get_value ("help-html", false)) + { + CL::print_html (cerr, cld); + return 0; + } + + fs::ifstream ifs; ifs.exceptions (std::ios_base::badbit | std::ios_base::failbit); @@ -209,12 +225,6 @@ main (int argc, char* argv[]) else symbols.insert (def); } - else if (i->name ()[0] == 'D') - { - std::string opt (i->name ()); - std::string def (opt.begin () + 1, opt.end ()); - symbols.insert (def); - } } CPP::Preprocessor pp (isa, symbols); @@ -278,23 +288,18 @@ main (int argc, char* argv[]) if (i->name () == "I") { path = i->value (); - } - else if (i->name ()[0] == 'I') - { - std::string opt (i->name ()); - path = std::string (opt.begin () + 1, opt.end ()); - } - - try - { - include_paths.push_back (fs::path (path, fs::native)); - } - catch (fs::filesystem_error const&) - { - cerr << "error: invalid filesystem path '" << path << "' " - << "provided with the -I option" << endl; - return 1; + try + { + include_paths.push_back (fs::path (path, fs::native)); + } + catch (fs::filesystem_error const&) + { + cerr << "error: invalid filesystem path '" << path << "' " + << "provided with the -I option" << endl; + + return 1; + } } } @@ -324,33 +329,39 @@ main (int argc, char* argv[]) // Generate executor mapping. { + ExecutorMappingGenerator lem_gen; lem_gen.generate (cl, tu, file_path); } // Calculate the size type of everything in the AST. // This must be executed before the servant code generator. { + SizeTypeCalculator sizetype_calc; sizetype_calc.calculate (tu); } // Compute repository IDs in a separate pass. { + RepositoryIdGenerator repid_gen; if (!repid_gen.generate (tu)) return 1; } // Generate servant code. { + ServantGenerator svnt_gen (cl); svnt_gen.generate (tu, file_path); } // Generate executor implementation code. if (cl.get_value ("gen-exec-impl", false)) { + ExecImplGenerator impl_gen (cl); impl_gen.generate (tu, file_path); } // Generate descriptor code. { + DescriptorGenerator desc_gen; desc_gen.generate (cl, tu); } diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 8f04323ed25..102f7f0667b 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,9 +1,41 @@ +Wed Aug 2 18:52:14 UTC 2006 Boris Kolpackov <boris@kolpackov.net> + + * CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp: + + Added option types: flag or value. + + * CCF/CCF/CodeGenerationKit/CommandLineParser.cpp: + * CCF/CCF/CodeGenerationKit/CommandLineParser.hpp: + * CCF/CCF/CodeGenerationKit/CommandLine.hpp: + + Reimplemented to use hand-coded parser instead of Spirit. The + new implementation takes into account the option types. + + * CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp: + * CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp: + + Removed. + + * CIDLC/cidlc.cpp: + * CIDLC/ServantGenerator.hpp: + * CIDLC/ServantGenerator.cpp: + * CIDLC/DescriptorGenerator.hpp: + * CIDLC/DescriptorGenerator.cpp: + * CIDLC/ExecutorMappingGenerator.hpp: + * CIDLC/ExecutorMappingGenerator.cpp: + * CIDLC/ExecImplGenerator.cpp: + * CIDLC/ExecImplGenerator.hpp: + + Updated with the option types. This fixes bugzilla bug #2426. + + Fri Jul 28 17:53:57 UTC 2006 Boris Kolpackov <boris@kolpackov.net> * CCF/CCF/IDL2/SemanticGraph/Translation.cpp: Reimplemented a chunk of code that resulted in what appears to - be invalid code generation by the Intel C++ compiler. + be invalid code generation by the Intel C++ compiler. This + fixes bugzilla bug #2387. Thu Jul 27 18:08:47 UTC 2006 William R. Otte <wotte@dre.vanderbilt.edu> |