diff options
author | Jose <jose@zeroc.com> | 2017-02-03 18:10:20 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-02-03 18:10:20 +0100 |
commit | 7274ebf13c7a1ff3b587598335201c3a4e848c90 (patch) | |
tree | ad673e775b6ab68d511bcc86cf420c519b65948d /cpp/src/slice2php | |
parent | Connection::close fixes for C#/Java/JS (diff) | |
download | ice-7274ebf13c7a1ff3b587598335201c3a4e848c90.tar.bz2 ice-7274ebf13c7a1ff3b587598335201c3a4e848c90.tar.xz ice-7274ebf13c7a1ff3b587598335201c3a4e848c90.zip |
Rework warning suppression to use global meta data
Diffstat (limited to 'cpp/src/slice2php')
-rw-r--r-- | cpp/src/slice2php/Main.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index 787e83ac1b8..aace7d638ec 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -63,7 +63,7 @@ class CodeVisitor : public ParserVisitor { public: - CodeVisitor(IceUtilInternal::Output&, bool, int); + CodeVisitor(IceUtilInternal::Output&, bool); virtual void visitClassDecl(const ClassDeclPtr&); virtual bool visitClassDefStart(const ClassDefPtr&); @@ -141,8 +141,7 @@ private: // // CodeVisitor implementation. // -CodeVisitor::CodeVisitor(Output& out, bool ns, int warningLevel) : - ParserVisitor(warningLevel), +CodeVisitor::CodeVisitor(Output& out, bool ns) : _out(out), _ns(ns) { @@ -946,6 +945,11 @@ CodeVisitor::visitDictionary(const DictionaryPtr& p) TypePtr keyType = p->keyType(); BuiltinPtr b = BuiltinPtr::dynamicCast(keyType); + + const UnitPtr unit = p->unit(); + const DefinitionContextPtr dc = unit->findDefinitionContext(p->file()); + assert(dc); + bool emitWarnings = !dc->suppressWarning("invalid-metadata"); if(b) { switch(b->kind()) @@ -964,7 +968,7 @@ CodeVisitor::visitDictionary(const DictionaryPtr& p) case Slice::Builtin::KindFloat: case Slice::Builtin::KindDouble: { - if(warningLevel() > 0) + if(emitWarnings) { emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP"); } @@ -980,7 +984,7 @@ CodeVisitor::visitDictionary(const DictionaryPtr& p) } else if(!EnumPtr::dynamicCast(keyType)) { - if(warningLevel() > 0) + if(emitWarnings) { emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP"); } @@ -1473,7 +1477,7 @@ CodeVisitor::collectExceptionMembers(const ExceptionPtr& p, MemberInfoList& allM } static void -generate(const UnitPtr& un, bool all, bool checksum, bool ns, const vector<string>& includePaths, Output& out, int warningLevel) +generate(const UnitPtr& un, bool all, bool checksum, bool ns, const vector<string>& includePaths, Output& out) { if(!all) { @@ -1504,12 +1508,12 @@ generate(const UnitPtr& un, bool all, bool checksum, bool ns, const vector<strin } } - CodeVisitor codeVisitor(out, ns, warningLevel); + CodeVisitor codeVisitor(out, ns); un->visit(&codeVisitor, false); if(checksum) { - ChecksumMap checksums = createChecksums(un, warningLevel); + ChecksumMap checksums = createChecksums(un); if(!checksums.empty()) { out << sp; @@ -1620,7 +1624,6 @@ 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" ; } @@ -1645,7 +1648,6 @@ compile(const vector<string>& argv) opts.addOpt("", "all"); opts.addOpt("", "checksum"); opts.addOpt("n", "no-namespace"); - opts.addOpt("", "no-warn"); bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); @@ -1717,8 +1719,6 @@ compile(const vector<string>& argv) bool ns = !opts.isSet("no-namespace"); - int warningLevel = opts.isSet("no-warn") ? 0 : 1; - if(args.empty()) { consoleErr << argv[0] << ": error: no input file" << endl; @@ -1870,7 +1870,7 @@ compile(const vector<string>& argv) // // Generate the PHP mapping. // - generate(u, all, checksum, ns, includePaths, out, warningLevel); + generate(u, all, checksum, ns, includePaths, out); out << "?>\n"; out.close(); |