diff options
Diffstat (limited to 'cpp/src/slice2swift/SwiftUtil.cpp')
-rw-r--r-- | cpp/src/slice2swift/SwiftUtil.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp index 8ce47228c71..1fe9ccf7fe0 100644 --- a/cpp/src/slice2swift/SwiftUtil.cpp +++ b/cpp/src/slice2swift/SwiftUtil.cpp @@ -820,8 +820,11 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out, } else { + if(declareParam) + { + out << nl << "var " << param << ": " << typeStr; + } out << nl << "try " << stream << "read(" << unmarshalParam << ") { " << param << " = $0 }"; - } break; } @@ -837,6 +840,40 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out, } } + if(ClassDeclPtr::dynamicCast(type)) + { + if (marshal) + { + out << nl << stream << "write(" << marshalParam << ")"; + } + else + { + if(declareParam) + { + out << nl << "var " << param << ": " << typeStr; + } + out << nl << "try " << stream << "read"; + out << spar; + if(!unmarshalParam.empty()) + { + out << unmarshalParam; + } + const string swiftModule = getSwiftModule(getTopLevelModule(ContainedPtr::dynamicCast(type))); + const string className = getUnqualified(getAbsolute(type), swiftModule); + out << ("value: " + className + ".self"); + out << epar; + out << sb; + out << nl; + if(!declareParam) + { + out << "self."; + } + out << param << " = $0"; + out << eb; + } + return; + } + EnumPtr en = EnumPtr::dynamicCast(type); if(en) { |