diff options
author | Jose <jose@zeroc.com> | 2019-03-27 11:24:14 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-03-27 11:24:14 +0100 |
commit | 3a05df792b57c0c267c9ed3a4ea8abf2edadad52 (patch) | |
tree | 67af5c066017fa3b940962b625ce5751645655bc /cpp/src/slice2swift/Gen.cpp | |
parent | Dictionary unmarshal improvements (diff) | |
download | ice-3a05df792b57c0c267c9ed3a4ea8abf2edadad52.tar.bz2 ice-3a05df792b57c0c267c9ed3a4ea8abf2edadad52.tar.xz ice-3a05df792b57c0c267c9ed3a4ea8abf2edadad52.zip |
Compact id fixes
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r-- | cpp/src/slice2swift/Gen.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index 301d709364f..8da841c0e75 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -321,7 +321,7 @@ Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) out << sp; out << nl << "public extension Ice.ClassResolver"; out << sb; - out << nl << "@objc public static func " << factory.str() << "() -> Ice.UserExceptionTypeResolver"; + out << nl << "@objc static func " << factory.str() << "() -> Ice.UserExceptionTypeResolver"; out << sb; out << nl << "return " << name << "_TypeResolver()"; out << eb; @@ -965,8 +965,33 @@ Gen::ValueVisitor::visitClassDefStart(const ClassDefPtr& p) base = bases.front(); } + out << sp; + out << nl << "public class " << name << "_TypeResolver: Ice.ValueTypeResolver"; + out << sb; + out << nl << "public override func type() -> Ice.Value.Type"; + out << sb; + out << nl << "return " << name << ".self"; + out << eb; + out << eb; + + if(p->compactId() >= 0) + { + // + // For each Value class using a compact id we generate an extension + // method in TypeIdResolver. + // + out << sp; + out << nl << "public extension Ice.TypeIdResolver"; + out << sb; + out << nl << "@objc static func TypeId_" << p->compactId() << "() -> String"; + out << sb; + out << nl << "return \"" << p->scoped() << "\""; + out << eb; + out << eb; + } + // - // For each Value class we generate a extension in ClassResolver + // For each Value class we generate an extension method in ClassResolver // ostringstream factory; StringList parts = splitScopedName(p->scoped()); @@ -980,18 +1005,9 @@ Gen::ValueVisitor::visitClassDefStart(const ClassDefPtr& p) } out << sp; - out << nl << "public class " << name << "_TypeResolver: Ice.ValueTypeResolver"; - out << sb; - out << nl << "public override func type() -> Ice.Value.Type"; - out << sb; - out << nl << "return " << name << ".self"; - out << eb; - out << eb; - - out << sp; out << nl << "public extension Ice.ClassResolver"; out << sb; - out << nl << "@objc public static func " << factory.str() << "() -> Ice.ValueTypeResolver"; + out << nl << "@objc static func " << factory.str() << "() -> Ice.ValueTypeResolver"; out << sb; out << nl << "return " << name << "_TypeResolver()"; out << eb; @@ -1035,7 +1051,6 @@ Gen::ValueVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp; out << nl; - out << nl; if(base) { out << "override "; |