diff options
author | Jose <jose@zeroc.com> | 2019-07-09 17:13:39 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-07-09 17:13:39 +0200 |
commit | f0352140506800ed3a53a7fa7caca63f251bb1a4 (patch) | |
tree | 355dc0f3bb7ea8534e087474a35371140b3d0b18 /cpp/src | |
parent | IceSSL fixes for RHEL8 (diff) | |
download | ice-f0352140506800ed3a53a7fa7caca63f251bb1a4.tar.bz2 ice-f0352140506800ed3a53a7fa7caca63f251bb1a4.tar.xz ice-f0352140506800ed3a53a7fa7caca63f251bb1a4.zip |
Remove forward declarations limitation - Close #97
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 112 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.h | 1 | ||||
-rw-r--r-- | cpp/src/Slice/RubyUtil.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 20 | ||||
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 5 | ||||
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2js/JsUtil.cpp | 24 |
9 files changed, 40 insertions, 135 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 8a729092a71..a38c8c4bbf9 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -752,13 +752,13 @@ Slice::typeToString(const TypePtr& type, const string& scope, const StringList& // Non local classes without operations map to the base // proxy class shared_ptr<Ice::ObjectPrx> // - if(def && !def->isInterface() && def->allOperations().empty()) + if(!def || def->isAbstract()) { - return getUnqualified(cpp11BuiltinTable[Builtin::KindObjectProxy], scope); + return "::std::shared_ptr<" + getUnqualified(fixKwd(proxy->_class()->scoped() + "Prx"), scope) + ">"; } else { - return "::std::shared_ptr<" + getUnqualified(fixKwd(proxy->_class()->scoped() + "Prx"), scope) + ">"; + return getUnqualified(cpp11BuiltinTable[Builtin::KindObjectProxy], scope); } } else diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 327e4b92a5d..78dd64f2080 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -3764,8 +3764,7 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, if(proxy) { ClassDefPtr def = proxy->_class()->definition(); - assert(def); - if(def->isAbstract()) + if(!def || def->isAbstract()) { return getUnqualified(proxy->_class(), package, "", "Prx"); } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index e49c20f1c50..bd9d210bb47 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -6835,11 +6835,6 @@ Slice::Unit::parse(const string& filename, FILE* file, bool debug) popContainer(); assert(_definitionContextStack.size() == 1); popDefinitionContext(); - - if(!checkUndefinedTypes()) - { - status = EXIT_FAILURE; - } } Slice::unit = 0; @@ -6938,113 +6933,6 @@ Slice::Unit::eraseWhiteSpace(string& s) } } -bool -Slice::Unit::checkUndefinedTypes() -{ - class Visitor : public ParserVisitor - { - public: - - Visitor(int& errors) : - _errors(errors), - _local(false) - { - } - - virtual bool visitClassDefStart(const ClassDefPtr& p) - { - _local = p->isLocal(); - return true; - } - - virtual bool visitExceptionStart(const ExceptionPtr& p) - { - _local = p->isLocal(); - return true; - } - - virtual bool visitStructStart(const StructPtr& p) - { - _local = p->isLocal(); - return true; - } - - virtual void visitOperation(const OperationPtr& p) - { - if(p->returnType()) - { - checkUndefined(p->returnType(), "return type", p->file(), p->line()); - } - ParamDeclList params = p->parameters(); - for(ParamDeclList::const_iterator q = params.begin(); q != params.end(); ++q) - { - checkUndefined((*q)->type(), "parameter " + (*q)->name(), (*q)->file(), (*q)->line()); - } - } - - virtual void visitParamDecl(const ParamDeclPtr& p) - { - checkUndefined(p->type(), "parameter " + p->name(), p->file(), p->line()); - } - - virtual void visitDataMember(const DataMemberPtr& p) - { - checkUndefined(p->type(), "member " + p->name(), p->file(), p->line()); - } - - virtual void visitSequence(const SequencePtr& p) - { - _local = p->isLocal(); - checkUndefined(p->type(), "element type", p->file(), p->line()); - } - - virtual void visitDictionary(const DictionaryPtr& p) - { - _local = p->isLocal(); - checkUndefined(p->keyType(), "key type", p->file(), p->line()); - checkUndefined(p->valueType(), "value type", p->file(), p->line()); - } - - private: - - void checkUndefined(const TypePtr& type, const string& desc, const string& file, const string& line) - { - // - // See ICE-6867. Any use of a proxy requires the full type definition, as does any - // use of a class in a non-local context. - // - ProxyPtr p = ProxyPtr::dynamicCast(type); - if(p) - { - const ClassDeclPtr cl = p->_class(); - if(!cl->definition()) - { - ostringstream ostr; - ostr << desc << " uses a proxy for undefined type `" << cl->scoped() << "'"; - emitError(file, line, ostr.str()); - _errors++; - } - } - - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if(cl && !cl->definition() && !_local) - { - ostringstream ostr; - ostr << desc << " refers to undefined type `" << cl->scoped() << "'"; - emitError(file, line, ostr.str()); - _errors++; - } - } - - int& _errors; - bool _local; - }; - - Visitor v(_errors); - visit(&v, true); - return _errors == 0; -} - // ---------------------------------------------------------------------- // CICompare // ---------------------------------------------------------------------- diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index 77bbce0c6e1..793416cb44c 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -1118,7 +1118,6 @@ private: Unit(bool, bool, bool, bool, const StringList&); static void eraseWhiteSpace(::std::string&); - bool checkUndefinedTypes(); bool _ignRedefs; bool _all; diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp index eea8791ec4c..af1f273ac6d 100644 --- a/cpp/src/Slice/RubyUtil.cpp +++ b/cpp/src/Slice/RubyUtil.cpp @@ -1224,7 +1224,7 @@ Slice::Ruby::CodeVisitor::writeType(const TypePtr& p) if(prx) { ClassDefPtr def = prx->_class()->definition(); - if(def->isInterface() || def->allOperations().size() > 0) + if(!def || def->isAbstract()) { _out << getAbsolute(prx->_class(), IdentToUpper, "T_") << "Prx"; } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 50459105167..2f0d27832eb 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -978,6 +978,7 @@ Slice::Gen::generate(const UnitPtr& p) { string md = *q++; static const string includePrefix = "cpp:include:"; + static const string sourceIncludePrefix = "cpp:source-include:"; if(md.find(includePrefix) == 0) { if(md.size() > includePrefix.size()) @@ -992,6 +993,20 @@ Slice::Gen::generate(const UnitPtr& p) globalMetaData.remove(md); } } + else if(md.find(sourceIncludePrefix) == 0) + { + if(md.size() > sourceIncludePrefix.size()) + { + C << nl << "#include <" << md.substr(sourceIncludePrefix.size()) << ">"; + } + else + { + ostringstream ostr; + ostr << "ignoring invalid global metadata `" << md << "'"; + dc->warning(InvalidMetaData, file, -1, ostr.str()); + globalMetaData.remove(md); + } + } } dc->setMetaData(globalMetaData); } @@ -5371,6 +5386,7 @@ Slice::Gen::MetaDataVisitor::visitUnitStart(const UnitPtr& p) if(s.find(prefix) == 0) { static const string cppIncludePrefix = "cpp:include:"; + static const string cppSourceIncludePrefix = "cpp:source-include"; static const string cppHeaderExtPrefix = "cpp:header-ext:"; static const string cppSourceExtPrefix = "cpp:source-ext:"; static const string cppDllExportPrefix = "cpp:dll-export:"; @@ -5380,6 +5396,10 @@ Slice::Gen::MetaDataVisitor::visitUnitStart(const UnitPtr& p) { continue; } + else if(s.find(cppSourceIncludePrefix) == 0 && s.size() > cppSourceIncludePrefix.size()) + { + continue; + } else if(s.find(cppHeaderExtPrefix) == 0 && s.size() > cppHeaderExtPrefix.size()) { headerExtension++; diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index de027895412..36db22c4350 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -1,4 +1,3 @@ - // // Copyright (c) ZeroC, Inc. All rights reserved. // @@ -458,7 +457,7 @@ Slice::CsGenerator::typeToString(const TypePtr& type, const string& package, boo if(proxy) { ClassDefPtr def = proxy->_class()->definition(); - if(def->isInterface() || def->allOperations().size() > 0) + if(!def || def->isAbstract()) { return getUnqualified(proxy->_class(), package, "", "Prx"); } @@ -794,7 +793,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, if(prx) { ClassDefPtr def = prx->_class()->definition(); - if(def->isInterface() || def->allOperations().size() > 0) + if(!def || def->isAbstract()) { string typeS = typeToString(type, package); if(marshal) diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 1a6c60177b1..f59050a784e 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -2180,7 +2180,7 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type) if(proxy) { ClassDefPtr def = proxy->_class()->definition(); - if(def->isInterface() || def->allOperations().size() > 0) + if(!def || def->isAbstract()) { return "\"" + fixId(proxy->_class()->scoped() + "Prx") + "\""; } diff --git a/cpp/src/slice2js/JsUtil.cpp b/cpp/src/slice2js/JsUtil.cpp index 07c2f9b5325..2229d81f6a9 100644 --- a/cpp/src/slice2js/JsUtil.cpp +++ b/cpp/src/slice2js/JsUtil.cpp @@ -500,17 +500,7 @@ Slice::JsGenerator::typeToString(const TypePtr& type, { ostringstream os; ClassDefPtr def = proxy->_class()->definition(); - if(!def->isInterface() && def->allOperations().empty()) - { - if(getModuleMetadata(toplevel) != "ice") - { - os << "iceNS0."; - } - os << getUnqualified(typeScriptBuiltinTable[Builtin::KindObjectProxy], - toplevel->scope(), - getModuleMetadata(toplevel)); - } - else + if(!def || def->isAbstract()) { string prefix; if(typescript) @@ -528,6 +518,16 @@ Slice::JsGenerator::typeToString(const TypePtr& type, os << fixId(proxy->_class()->scoped() + "Prx"); } } + else + { + if(getModuleMetadata(toplevel) != "ice") + { + os << "iceNS0."; + } + os << getUnqualified(typeScriptBuiltinTable[Builtin::KindObjectProxy], + toplevel->scope(), + getModuleMetadata(toplevel)); + } return os.str(); } @@ -983,7 +983,7 @@ Slice::JsGenerator::getHelper(const TypePtr& type) if(prx) { ClassDefPtr def = prx->_class()->definition(); - if(def->isInterface() || def->allOperations().size() > 0) + if(!def || def->isAbstract()) { return typeToString(type); } |