summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2019-03-09 21:13:01 +0100
committerJose <jose@zeroc.com>2019-03-09 21:13:01 +0100
commit32047cdd87984b54e1ac80b161e288f32f93d51a (patch)
treeb6089bbd57e900188e069330187e67da7face46a /cpp/src
parentValue marshalling fixes (diff)
downloadice-32047cdd87984b54e1ac80b161e288f32f93d51a.tar.bz2
ice-32047cdd87984b54e1ac80b161e288f32f93d51a.tar.xz
ice-32047cdd87984b54e1ac80b161e288f32f93d51a.zip
Swift class resolver updates
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2swift/Gen.cpp32
-rw-r--r--cpp/src/slice2swift/SwiftUtil.cpp8
-rw-r--r--cpp/src/slice2swift/SwiftUtil.h1
3 files changed, 37 insertions, 4 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index d3d05567e8e..11dfe2da2ba 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -841,6 +841,38 @@ Gen::ValueVisitor::visitClassDefStart(const ClassDefPtr& p)
base = bases.front();
}
+ //
+ // For each Value class we generate a extension in ClassResolver
+ //
+ ostringstream factory;
+ StringList parts = splitScopedName(p->scoped());
+ for(StringList::const_iterator it = parts.begin(); it != parts.end();)
+ {
+ factory << (*it);
+ if(++it != parts.end())
+ {
+ factory << "_";
+ }
+ }
+
+ 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 << sb;
+ out << nl << "return " << name << "_TypeResolver()";
+ out << eb;
+ out << eb;
+
out << sp;
out << nl << "public class " << name << ": ";
if(base)
diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp
index 1fe9ccf7fe0..5c3bcac9013 100644
--- a/cpp/src/slice2swift/SwiftUtil.cpp
+++ b/cpp/src/slice2swift/SwiftUtil.cpp
@@ -62,11 +62,13 @@ replace(string s, string patt, string val)
return r;
}
+}
+
//
// Split a scoped name into its components and return the components as a list of (unscoped) identifiers.
//
-static StringList
-splitScopedName(const string& scoped)
+StringList
+Slice::splitScopedName(const string& scoped)
{
assert(scoped[0] == ':');
StringList ids;
@@ -97,8 +99,6 @@ splitScopedName(const string& scoped)
return ids;
}
-}
-
//
// Check the given identifier against Swift's list of reserved words. If it matches
// a reserved word, then an escaped version is returned with a leading underscore.
diff --git a/cpp/src/slice2swift/SwiftUtil.h b/cpp/src/slice2swift/SwiftUtil.h
index 3a8f952675e..9adb06df0b2 100644
--- a/cpp/src/slice2swift/SwiftUtil.h
+++ b/cpp/src/slice2swift/SwiftUtil.h
@@ -26,6 +26,7 @@ ModulePtr getTopLevelModule(const ContainedPtr&);
ModulePtr getTopLevelModule(const TypePtr&);
std::string fixIdent(const std::string&);
+StringList splitScopedName(const std::string&);
class SwiftGenerator : private IceUtil::noncopyable
{