diff options
author | Jose <jose@zeroc.com> | 2017-02-01 23:16:30 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-02-01 23:16:30 +0100 |
commit | ca131951f8d81ea3da13277172a24234b5c848ea (patch) | |
tree | 28b8d9ad6a09f550ef43f3b24df8048da8e70d7d /cpp/src/slice2js | |
parent | Added entries for support of try-with-resources/with statement in Java/Python (diff) | |
download | ice-ca131951f8d81ea3da13277172a24234b5c848ea.tar.bz2 ice-ca131951f8d81ea3da13277172a24234b5c848ea.tar.xz ice-ca131951f8d81ea3da13277172a24234b5c848ea.zip |
Add --no-warn option to Slice compilers
Diffstat (limited to 'cpp/src/slice2js')
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 32 | ||||
-rw-r--r-- | cpp/src/slice2js/Gen.h | 15 | ||||
-rw-r--r-- | cpp/src/slice2js/Main.cpp | 8 |
3 files changed, 33 insertions, 22 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 29c1c9f47dc..74297f80738 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -89,7 +89,7 @@ getDeprecateReason(const ContainedPtr& p1, const ContainedPtr& p2, const string& } -Slice::JsVisitor::JsVisitor(Output& out) : _out(out) +Slice::JsVisitor::JsVisitor(Output& out, int warningLevel) : ParserVisitor(warningLevel), _out(out) { } @@ -329,9 +329,10 @@ Slice::JsVisitor::writeDocComment(const ContainedPtr& p, const string& deprecate _out << nl << " **/"; } -Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir) : +Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir, int warningLevel) : _includePaths(includePaths), - _useStdout(false) + _useStdout(false), + _warningLevel(warningLevel) { _fileBase = base; string::size_type pos = base.find_last_of("/\\"); @@ -361,10 +362,12 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st printGeneratedHeader(_out, _fileBase + ".ice"); } -Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir, ostream& out) : +Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir, ostream& out, + int warningLevel) : _out(out), _includePaths(includePaths), - _useStdout(true) + _useStdout(true), + _warningLevel(warningLevel) { _fileBase = base; string::size_type pos = base.find_last_of("/\\"); @@ -415,17 +418,17 @@ Slice::Gen::generate(const UnitPtr& p) _out.restoreIndent(); } } - RequireVisitor requireVisitor(_out, _includePaths, icejs, es6module); + RequireVisitor requireVisitor(_out, _includePaths, icejs, es6module, _warningLevel); p->visit(&requireVisitor, false); vector<string> seenModules = requireVisitor.writeRequires(p); - TypesVisitor typesVisitor(_out, seenModules, icejs); + TypesVisitor typesVisitor(_out, seenModules, icejs, _warningLevel); p->visit(&typesVisitor, false); // // Export the top-level modules. // - ExportVisitor exportVisitor(_out, icejs, es6module); + ExportVisitor exportVisitor(_out, icejs, es6module, _warningLevel); p->visit(&exportVisitor, false); if(!es6module) @@ -478,8 +481,8 @@ Slice::Gen::printHeader() } Slice::Gen::RequireVisitor::RequireVisitor(IceUtilInternal::Output& out, vector<string> includePaths, - bool icejs, bool es6modules) : - JsVisitor(out), + bool icejs, bool es6modules, int warningLevel) : + JsVisitor(out, warningLevel), _icejs(icejs), _es6modules(es6modules), _seenClass(false), @@ -840,8 +843,9 @@ Slice::Gen::RequireVisitor::writeRequires(const UnitPtr& p) return seenModules; } -Slice::Gen::TypesVisitor::TypesVisitor(IceUtilInternal::Output& out, vector<string> seenModules, bool icejs) : - JsVisitor(out), +Slice::Gen::TypesVisitor::TypesVisitor(IceUtilInternal::Output& out, vector<string> seenModules, bool icejs, + int warningLevel) : + JsVisitor(out, warningLevel), _seenModules(seenModules), _icejs(icejs) { @@ -1845,8 +1849,8 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type) return "???"; } -Slice::Gen::ExportVisitor::ExportVisitor(IceUtilInternal::Output& out, bool icejs, bool es6modules) : - JsVisitor(out), +Slice::Gen::ExportVisitor::ExportVisitor(IceUtilInternal::Output& out, bool icejs, bool es6modules, int warningLevel) : + JsVisitor(out, warningLevel), _icejs(icejs), _es6modules(es6modules) { diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h index 8196ba1b48b..dc3b65f18ba 100644 --- a/cpp/src/slice2js/Gen.h +++ b/cpp/src/slice2js/Gen.h @@ -19,7 +19,7 @@ class JsVisitor : public JsGenerator, public ParserVisitor { public: - JsVisitor(::IceUtilInternal::Output&); + JsVisitor(::IceUtilInternal::Output&, int); virtual ~JsVisitor(); protected: @@ -44,12 +44,14 @@ public: Gen(const std::string&, const std::vector<std::string>&, - const std::string&); + const std::string&, + int); Gen(const std::string&, const std::vector<std::string>&, const std::string&, - std::ostream&); + std::ostream&, + int); ~Gen(); @@ -64,6 +66,7 @@ private: std::vector<std::string> _includePaths; std::string _fileBase; bool _useStdout; + int _warningLevel; void printHeader(); @@ -71,7 +74,7 @@ private: { public: - RequireVisitor(::IceUtilInternal::Output&, std::vector<std::string>, bool, bool); + RequireVisitor(::IceUtilInternal::Output&, std::vector<std::string>, bool, bool, int); virtual bool visitClassDefStart(const ClassDefPtr&); virtual bool visitStructStart(const StructPtr&); @@ -103,7 +106,7 @@ private: { public: - TypesVisitor(::IceUtilInternal::Output&, std::vector< std::string>, bool); + TypesVisitor(::IceUtilInternal::Output&, std::vector< std::string>, bool, int); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); @@ -127,7 +130,7 @@ private: { public: - ExportVisitor(::IceUtilInternal::Output&, bool, bool); + ExportVisitor(::IceUtilInternal::Output&, bool, bool, int); virtual bool visitModuleStart(const ModulePtr&); private: diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp index a73738fcee9..03f17331e59 100644 --- a/cpp/src/slice2js/Main.cpp +++ b/cpp/src/slice2js/Main.cpp @@ -80,6 +80,7 @@ usage(const string& n) " deprecated: use instead [[\"ice-prefix\"]] metadata.\n" "--underscore Allow underscores in Slice identifiers\n" " deprecated: use instead [[\"underscore\"]] metadata.\n" + "--no-warn Disable all warnings.\n" ; } @@ -103,6 +104,7 @@ compile(const vector<string>& argv) opts.addOpt("d", "debug"); opts.addOpt("", "ice"); opts.addOpt("", "underscore"); + opts.addOpt("", "no-warn"); bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); @@ -172,6 +174,8 @@ compile(const vector<string>& argv) bool underscore = opts.isSet("underscore"); + int warningLevel = opts.isSet("no-warn") ? 0 : 1; + if(args.empty()) { consoleErr << argv[0] << ": error: no input file" << endl; @@ -335,12 +339,12 @@ compile(const vector<string>& argv) { if(useStdout) { - Gen gen(icecpp->getBaseName(), includePaths, output, cout); + Gen gen(icecpp->getBaseName(), includePaths, output, cout, warningLevel); gen.generate(p); } else { - Gen gen(icecpp->getBaseName(), includePaths, output); + Gen gen(icecpp->getBaseName(), includePaths, output, warningLevel); gen.generate(p); } } |