diff options
author | Bernard Normier <bernard@zeroc.com> | 2017-02-04 16:48:50 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2017-02-04 16:48:50 -0500 |
commit | abb5616afdbe48c59b0f09f4b11aaa6fc5bb13be (patch) | |
tree | 900cd08e75cd11aceee75c7ab93085cbea824e60 /cpp/src/slice2php | |
parent | Fixed (ICE-7556) - header-ext and makefile dependencies (diff) | |
download | ice-abb5616afdbe48c59b0f09f4b11aaa6fc5bb13be.tar.bz2 ice-abb5616afdbe48c59b0f09f4b11aaa6fc5bb13be.tar.xz ice-abb5616afdbe48c59b0f09f4b11aaa6fc5bb13be.zip |
Slice compilers now emit deprecated warning for classes with operations (ICE-7557)
Refactored suppress-warning implementation
Diffstat (limited to 'cpp/src/slice2php')
-rw-r--r-- | cpp/src/slice2php/Main.cpp | 155 |
1 files changed, 74 insertions, 81 deletions
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index aace7d638ec..b0167d6a150 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -160,8 +160,8 @@ CodeVisitor::visitClassDecl(const ClassDeclPtr& p) string type = getTypeVar(p); _out << sp << nl << "global " << type << ';'; - - bool isInterface = p->isInterface(); + + bool isInterface = p->isInterface(); if(!p->isLocal() && (isInterface || p->definition()->allOperations().size() > 0)) { _out << nl << "global " << type << "Prx;"; @@ -432,8 +432,8 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p) // const bool preserved = p->hasMetaData("preserve-slice") || p->inheritsMetaData("preserve-slice"); _out << sp << nl << type << " = IcePHP_defineClass('" << scoped << "', '" << escapeName(abs) << "', " - << p->compactId() << ", " << (preserved ? "true" : "false") << ", " - << (isInterface ? "true" : "false") << ", "; + << p->compactId() << ", " << (preserved ? "true" : "false") << ", " + << (isInterface ? "true" : "false") << ", "; if(!base || (isInterface && !p->isLocal())) { _out << "$Ice__t_Value"; @@ -578,7 +578,7 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p) if((*t)->optional()) { _out << ", " << (*t)->tag(); - } + } _out << ')'; ++count; } @@ -763,7 +763,7 @@ CodeVisitor::visitExceptionStart(const ExceptionPtr& p) } else { - _out << getTypeVar(base); + _out << getTypeVar(base); } _out << ", "; // @@ -946,48 +946,41 @@ 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"); + const UnitPtr unit = p->unit(); + const DefinitionContextPtr dc = unit->findDefinitionContext(p->file()); + assert(dc); if(b) { switch(b->kind()) { - case Slice::Builtin::KindBool: - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindString: - // - // These types are acceptable as dictionary keys. - // - break; + case Slice::Builtin::KindBool: + case Slice::Builtin::KindByte: + case Slice::Builtin::KindShort: + case Slice::Builtin::KindInt: + case Slice::Builtin::KindLong: + case Slice::Builtin::KindString: + // + // These types are acceptable as dictionary keys. + // + break; - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - { - if(emitWarnings) + case Slice::Builtin::KindFloat: + case Slice::Builtin::KindDouble: { - emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP"); + dc->warning(InvalidMetaData, p->file(), p->line(), "dictionary key type not supported in PHP"); + break; } - break; - } - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - case Slice::Builtin::KindValue: - assert(false); + case Slice::Builtin::KindObject: + case Slice::Builtin::KindObjectProxy: + case Slice::Builtin::KindLocalObject: + case Slice::Builtin::KindValue: + assert(false); } } else if(!EnumPtr::dynamicCast(keyType)) { - if(emitWarnings) - { - emitWarning(p->file(), p->line(), "dictionary key type not supported in PHP"); - } + dc->warning(InvalidMetaData, p->file(), p->line(), "dictionary key type not supported in PHP"); } string type = getTypeVar(p); @@ -1331,47 +1324,47 @@ CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePtr& va { switch(b->kind()) { - case Slice::Builtin::KindBool: - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - { - _out << value; - break; - } - case Slice::Builtin::KindLong: - { - IceUtil::Int64 l; - IceUtilInternal::stringToInt64(value, l); - // - // The platform's 'long' type may not be 64 bits, so we store 64-bit - // values as a string. - // - if(sizeof(IceUtil::Int64) > sizeof(long) && (l < LONG_MIN || l > LONG_MAX)) + case Slice::Builtin::KindBool: + case Slice::Builtin::KindByte: + case Slice::Builtin::KindShort: + case Slice::Builtin::KindInt: + case Slice::Builtin::KindFloat: + case Slice::Builtin::KindDouble: { - _out << "'" << value << "'"; + _out << value; + break; } - else + case Slice::Builtin::KindLong: { - _out << value; + IceUtil::Int64 l; + IceUtilInternal::stringToInt64(value, l); + // + // The platform's 'long' type may not be 64 bits, so we store 64-bit + // values as a string. + // + if(sizeof(IceUtil::Int64) > sizeof(long) && (l < LONG_MIN || l > LONG_MAX)) + { + _out << "'" << value << "'"; + } + else + { + _out << value; + } + break; } - break; - } - case Slice::Builtin::KindString: - { - // PHP 7.x also supports an EC6UCN-like notation, see: - // https://wiki.php.net/rfc/unicode_escape - // - _out << "\"" << toStringLiteral(value, "\f\n\r\t\v\x1b", "$", Octal, 0) << "\""; - break; - } - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - case Slice::Builtin::KindValue: - assert(false); + case Slice::Builtin::KindString: + { + // PHP 7.x also supports an EC6UCN-like notation, see: + // https://wiki.php.net/rfc/unicode_escape + // + _out << "\"" << toStringLiteral(value, "\f\n\r\t\v\x1b", "$", Octal, 0) << "\""; + break; + } + case Slice::Builtin::KindObject: + case Slice::Builtin::KindObjectProxy: + case Slice::Builtin::KindLocalObject: + case Slice::Builtin::KindValue: + assert(false); } } else if(en) @@ -1548,14 +1541,14 @@ static void printHeader(IceUtilInternal::Output& out) { static const char* header = -"// **********************************************************************\n" -"//\n" -"// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.\n" -"//\n" -"// This copy of Ice is licensed to you under the terms described in the\n" -"// ICE_LICENSE file included in this distribution.\n" -"//\n" -"// **********************************************************************\n" + "// **********************************************************************\n" + "//\n" + "// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.\n" + "//\n" + "// This copy of Ice is licensed to you under the terms described in the\n" + "// ICE_LICENSE file included in this distribution.\n" + "//\n" + "// **********************************************************************\n" ; out << header; |