summaryrefslogtreecommitdiff
path: root/cpp/src/slice2php/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2php/Main.cpp')
-rw-r--r--cpp/src/slice2php/Main.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 73822f05f9d..205aec133b3 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);
+ CodeVisitor(IceUtilInternal::Output&, bool, int);
virtual void visitClassDecl(const ClassDeclPtr&);
virtual bool visitClassDefStart(const ClassDefPtr&);
@@ -141,8 +141,10 @@ private:
//
// CodeVisitor implementation.
//
-CodeVisitor::CodeVisitor(Output& out, bool ns) :
- _out(out), _ns(ns)
+CodeVisitor::CodeVisitor(Output& out, bool ns, int warningLevel) :
+ ParserVisitor(warningLevel),
+ _out(out),
+ _ns(ns)
{
}
@@ -961,8 +963,13 @@ CodeVisitor::visitDictionary(const DictionaryPtr& p)
case Slice::Builtin::KindFloat:
case Slice::Builtin::KindDouble:
- emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP");
+ {
+ if(warningLevel() > 0)
+ {
+ emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP");
+ }
break;
+ }
case Slice::Builtin::KindObject:
case Slice::Builtin::KindObjectProxy:
@@ -973,7 +980,10 @@ CodeVisitor::visitDictionary(const DictionaryPtr& p)
}
else if(!EnumPtr::dynamicCast(keyType))
{
- emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP");
+ if(warningLevel() > 0)
+ {
+ emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP");
+ }
}
string type = getTypeVar(p);
@@ -1463,7 +1473,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)
+generate(const UnitPtr& un, bool all, bool checksum, bool ns, const vector<string>& includePaths, Output& out, int warningLevel)
{
if(!all)
{
@@ -1494,7 +1504,7 @@ generate(const UnitPtr& un, bool all, bool checksum, bool ns, const vector<strin
}
}
- CodeVisitor codeVisitor(out, ns);
+ CodeVisitor codeVisitor(out, ns, warningLevel);
un->visit(&codeVisitor, false);
if(checksum)
@@ -1610,6 +1620,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"
;
}
@@ -1634,6 +1645,7 @@ 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();
@@ -1705,6 +1717,8 @@ 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;
@@ -1856,7 +1870,7 @@ compile(const vector<string>& argv)
//
// Generate the PHP mapping.
//
- generate(u, all, checksum, ns, includePaths, out);
+ generate(u, all, checksum, ns, includePaths, out, warningLevel);
out << "?>\n";
out.close();