Skip to content

Commit eedf683

Browse files
committed
fixes
1 parent 9c687a2 commit eedf683

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/source/SwiftGenerator.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
101101
}
102102
})
103103
writeSwiftPrivateFile(ident, origin, List[String]("DjinniSupport", spec.swiftModule), w => {
104-
w.wl(s"typealias ${marshal.typename(ident, e)}Marshaller = DjinniSupport.EnumMarshaller<${marshal.typename(ident, e)}>")
104+
w.wl(s"public typealias ${marshal.typename(ident, e)}Marshaller = DjinniSupport.EnumMarshaller<${marshal.typename(ident, e)}>")
105105
})
106106
}
107107

@@ -206,9 +206,9 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
206206
}
207207
})
208208
writeSwiftPrivateFile(ident, origin, refs.privateImports, w => {
209-
w.w(s"enum ${marshal.typename(ident, r)}Marshaller: DjinniSupport.Marshaller").braced {
210-
w.wl(s"typealias SwiftType = ${marshal.fqTypename(ident, r)}")
211-
w.w("static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType").braced {
209+
w.w(s"public enum ${marshal.typename(ident, r)}Marshaller: DjinniSupport.Marshaller").braced {
210+
w.wl(s"public typealias SwiftType = ${marshal.fqTypename(ident, r)}")
211+
w.w("public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType").braced {
212212
w.wl("return withUnsafePointer(to: c) { p in").nested {
213213
for ((f, i) <- r.fields.view.zipWithIndex) {
214214
val swiftExp = s"djinni.swift.getMember(p, $i)"
@@ -219,7 +219,7 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
219219
}
220220
w.wl("}")
221221
}
222-
w.w("static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue").braced {
222+
w.w("public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue").braced {
223223
if (r.fields.nonEmpty) {
224224
w.wl("var ret = djinni.swift.makeCompositeValue()")
225225
for (f <- r.fields) {
@@ -267,12 +267,12 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
267267
if (m.params.nonEmpty) { w.w("_ ") }
268268
w.w(m.params.map(p => s"${idSwift.local(p.ident)}: ${marshal.fqParamType(p.ty)}").mkString(", "))
269269
w.w(s") throws -> ${marshal.fqReturnType(m.ret)}").braced {
270-
w.wl("var params = djinni.swift.ParameterList()")
271-
w.wl("params.addValue(inst)")
270+
w.wl("var _params = djinni.swift.ParameterList()")
271+
w.wl("_params.addValue(inst)")
272272
for (p <- m.params) {
273-
w.wl(s"params.addValue(${marshal.toCpp(p.ty, idSwift.local(p.ident))})")
273+
w.wl(s"_params.addValue(${marshal.toCpp(p.ty, idSwift.local(p.ident))})")
274274
}
275-
w.wl(s"var ret = ${spec.swiftxxNamespace}.${marshal.typename(ident, i)}_${idSwift.method(m.ident)}(&params)")
275+
w.wl(s"var ret = ${spec.swiftxxNamespace}.${marshal.typename(ident, i)}_${idSwift.method(m.ident)}(&_params)")
276276
w.wl("try handleCppErrors(&ret)")
277277
if (!m.ret.isEmpty) {
278278
w.wl(s"return ${marshal.fromCpp(m.ret.get, "ret")}")
@@ -310,13 +310,13 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
310310
w.wl
311311
}
312312
// Define the marshaller
313-
w.w(s"enum ${marshal.typename(ident, i)}Marshaller: DjinniSupport.Marshaller").braced {
314-
w.wl(s"typealias SwiftType = ${marshal.fqTypename(ident, i)}")
315-
w.w("static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType").braced {
313+
w.w(s"public enum ${marshal.typename(ident, i)}Marshaller: DjinniSupport.Marshaller").braced {
314+
w.wl(s"public typealias SwiftType = ${marshal.fqTypename(ident, i)}")
315+
w.w("public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType").braced {
316316
val newProxyBlock = if (i.ext.cpp) {s"{ ${marshal.typename(ident, i)}CppProxy(c) as SwiftType }"} else {"{ fatalError(\"n/a\") }"}
317317
w.wl(s"return cppInterfaceToSwift(c, ${newProxyBlock})")
318318
}
319-
w.w("static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue").braced {
319+
w.w("public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue").braced {
320320
val newProxyBlock = if (i.ext.swift) {s"{ ${spec.swiftxxNamespace}.$swiftProxyClassName.make(ctxPtr(s, ${swiftProxyVtbl}), dispatcherProtocalCall)}"} else {"{ fatalError(\"n/a\") }"}
321321
w.wl(s"return swiftInterfaceToCpp(s, ${newProxyBlock})")
322322
}
@@ -330,11 +330,11 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
330330
if (m.params.nonEmpty) { w.w("_ ") }
331331
w.w(m.params.map(p => s"${idSwift.local(p.ident)}: ${marshal.fqParamType(p.ty)}").mkString(", "))
332332
w.w(s") throws -> ${marshal.fqReturnType(m.ret)}").braced {
333-
w.wl("var params = djinni.swift.ParameterList()")
333+
w.wl("var _params = djinni.swift.ParameterList()")
334334
for (p <- m.params) {
335-
w.wl(s"params.addValue(${marshal.toCpp(p.ty, idSwift.local(p.ident))})")
335+
w.wl(s"_params.addValue(${marshal.toCpp(p.ty, idSwift.local(p.ident))})")
336336
}
337-
w.wl(s"var ret = ${spec.swiftxxNamespace}.${marshal.typename(ident, i)}_${idSwift.method(m.ident)}(&params)")
337+
w.wl(s"var ret = ${spec.swiftxxNamespace}.${marshal.typename(ident, i)}_${idSwift.method(m.ident)}(&_params)")
338338
w.wl("try handleCppErrors(&ret)")
339339
if (!m.ret.isEmpty) {
340340
w.wl(s"return ${marshal.fromCpp(m.ret.get, "ret")}")

src/source/SwiftMarshal.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) {
5959
case MOptional => throw new AssertionError("nested optional?")
6060
case m => s"Optional<${f(arg)}>"
6161
}
62-
case e: MExtern => e.swift.typename + (if (e.swift.generic) args(tm) else "")
62+
case e: MExtern => e.swift.module + "." + e.swift.typename + (if (e.swift.generic) args(tm) else "")
6363
case p: MProtobuf => p.body.swift match {
6464
case Some(o) => o.prefix + p.name
6565
case None => p.name
@@ -102,7 +102,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) {
102102
private def helperClass(tm: MExpr): String = helperName(tm) + helperTemplates(tm)
103103
def helperName(tm: MExpr): String = tm.base match {
104104
case d: MDef => helperClass(d.name)
105-
case e: MExtern => e.swift.translator
105+
case e: MExtern => e.swift.translatorModule + "." + e.swift.translator
106106
case o => o match {
107107
case p: MPrimitive => p.idlName match {
108108
case "i8" => "I8Marshaller"

src/source/YamlGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class YamlGenerator(spec: Spec) extends Generator(spec) {
130130
)
131131

132132
private def typeDef(td: TypeDecl) = {
133-
def ext(e: Ext): String = (if(e.cpp) " +c" else "") + (if(e.objc) " +o" else "") + (if(e.java) " +j" else "") + (if(e.js) " +w" else "")
133+
def ext(e: Ext): String = (if(e.cpp) " +c" else "") + (if(e.objc) " +o" else "") + (if(e.java) " +j" else "") + (if(e.js) " +w" else "") + (if(e.swift) " +sw" else "")
134134
def deriving(r: Record) = {
135135
if(r.derivingTypes.isEmpty) {
136136
""

0 commit comments

Comments
 (0)