Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
li-feng-sc committed Aug 29, 2024
1 parent 6e986dd commit 539df09
Show file tree
Hide file tree
Showing 81 changed files with 853 additions and 848 deletions.
8 changes: 4 additions & 4 deletions examples/generated-src/swift/ItemList+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import Foundation
import TextSort
import TextSortCxx

enum ItemListMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TextSort.ItemList
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ItemListMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TextSort.ItemList
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return withUnsafePointer(to: c) { p in
let items = ListMarshaller<StringMarshaller>.fromCpp(djinni.swift.getMember(p, 0))
return SwiftType(items: items)
}
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
var ret = djinni.swift.makeCompositeValue()
djinni.swift.addMember(&ret, ListMarshaller<StringMarshaller>.toCpp(s.items))
return ret
Expand Down
34 changes: 17 additions & 17 deletions examples/generated-src/swift/SortItems+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ import TextSortCxx
final class SortItemsCppProxy: DjinniSupport.CppProxy, TextSort.SortItems {
init(_ inst: djinni.swift.AnyValue) { super.init(inst:inst) }
func sort(_ order: TextSort.SortOrder, items: TextSort.ItemList) throws -> Void {
var params = djinni.swift.ParameterList()
params.addValue(inst)
params.addValue(SortOrderMarshaller.toCpp(order))
params.addValue(ItemListMarshaller.toCpp(items))
var ret = djinni_generated.SortItems_sort(&params)
var _params = djinni.swift.ParameterList()
_params.addValue(inst)
_params.addValue(SortOrderMarshaller.toCpp(order))
_params.addValue(ItemListMarshaller.toCpp(items))
var ret = djinni_generated.SortItems_sort(&_params)
try handleCppErrors(&ret)
}
}
enum SortItemsMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TextSort.SortItems
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum SortItemsMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TextSort.SortItems
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { SortItemsCppProxy(c) as SwiftType })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { fatalError("n/a") })
}
}
public class SortItems_statics {
static func createWithListener(_ listener: TextSort.TextboxListener) throws -> TextSort.SortItems {
var params = djinni.swift.ParameterList()
params.addValue(TextboxListenerMarshaller.toCpp(listener))
var ret = djinni_generated.SortItems_createWithListener(&params)
public static func createWithListener(_ listener: TextSort.TextboxListener) throws -> TextSort.SortItems {
var _params = djinni.swift.ParameterList()
_params.addValue(TextboxListenerMarshaller.toCpp(listener))
var ret = djinni_generated.SortItems_createWithListener(&_params)
try handleCppErrors(&ret)
return SortItemsMarshaller.fromCpp(ret)
}
static func runSort(_ items: TextSort.ItemList) throws -> TextSort.ItemList {
var params = djinni.swift.ParameterList()
params.addValue(ItemListMarshaller.toCpp(items))
var ret = djinni_generated.SortItems_runSort(&params)
public static func runSort(_ items: TextSort.ItemList) throws -> TextSort.ItemList {
var _params = djinni.swift.ParameterList()
_params.addValue(ItemListMarshaller.toCpp(items))
var ret = djinni_generated.SortItems_runSort(&_params)
try handleCppErrors(&ret)
return ItemListMarshaller.fromCpp(ret)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/generated-src/swift/SortOrder+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import DjinniSupport
import TextSort

typealias SortOrderMarshaller = DjinniSupport.EnumMarshaller<SortOrder>
public typealias SortOrderMarshaller = DjinniSupport.EnumMarshaller<SortOrder>
8 changes: 4 additions & 4 deletions examples/generated-src/swift/TextboxListener+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ let textboxListenerMethods: Vtbl<TextboxListener> = [
},
]

enum TextboxListenerMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TextSort.TextboxListener
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum TextboxListenerMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TextSort.TextboxListener
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { fatalError("n/a") })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { djinni_generated.TextboxListenerSwiftProxy.make(ctxPtr(s, textboxListenerMethods), dispatcherProtocalCall)})
}
}
4 changes: 2 additions & 2 deletions src/source/SwiftMarshal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) {
case MOptional => throw new AssertionError("nested optional?")
case m => s"Optional<${f(arg)}>"
}
case e: MExtern => e.swift.module + "." + e.swift.typename + (if (e.swift.generic) args(tm) else "")
case e: MExtern => Array(e.swift.module, e.swift.typename).filter(s => !s.isEmpty).mkString(".") + (if (e.swift.generic) args(tm) else "")
case p: MProtobuf => p.body.swift match {
case Some(o) => o.prefix + p.name
case None => p.name
Expand Down Expand Up @@ -102,7 +102,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) {
private def helperClass(tm: MExpr): String = helperName(tm) + helperTemplates(tm)
def helperName(tm: MExpr): String = tm.base match {
case d: MDef => helperClass(d.name)
case e: MExtern => e.swift.translator
case e: MExtern => Array(e.swift.translatorModule, e.swift.translator).filter(s => !s.isEmpty).mkString(".")
case o => o match {
case p: MPrimitive => p.idlName match {
case "i8" => "I8Marshaller"
Expand Down
2 changes: 1 addition & 1 deletion test-suite/djinni/vendor/third-party/date.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ts:
swift:
typename: 'Date'
translator: 'DateMarshaller'
module: 'DjinniSupport'
translatorModule: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Date'
header: '"djinni_support.hpp"'
7 changes: 7 additions & 0 deletions test-suite/djinni/vendor/third-party/duration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationMarshaller'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration'
header: '"Duration-swift.hpp"'
Expand Down Expand Up @@ -83,6 +84,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationH'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration_h'
header: '"Duration-swift.hpp"'
Expand Down Expand Up @@ -125,6 +127,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationMin'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration_min'
header: '"Duration-swift.hpp"'
Expand Down Expand Up @@ -167,6 +170,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationS'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration_s'
header: '"Duration-swift.hpp"'
Expand Down Expand Up @@ -209,6 +213,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationMs'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration_ms'
header: '"Duration-swift.hpp"'
Expand Down Expand Up @@ -251,6 +256,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationUs'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration_us'
header: '"Duration-swift.hpp"'
Expand Down Expand Up @@ -293,6 +299,7 @@ ts:
swift:
typename: 'Duration'
translator: 'DurationNs'
translator.module: 'TestSuite'
swiftxx:
translator: '::djinni::swift::Duration_ns'
header: '"Duration-swift.hpp"'
2 changes: 1 addition & 1 deletion test-suite/generated-src/swift/AccessFlags+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import DjinniSupport
import TestSuite

typealias AccessFlagsMarshaller = DjinniSupport.EnumMarshaller<AccessFlags>
public typealias AccessFlagsMarshaller = DjinniSupport.EnumMarshaller<AccessFlags>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Foundation
import TestSuite
import TestSuiteCxx

enum AssortedPrimitivesMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.AssortedPrimitives
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum AssortedPrimitivesMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.AssortedPrimitives
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return withUnsafePointer(to: c) { p in
let b = BoolMarshaller.fromCpp(djinni.swift.getMember(p, 0))
let eight = I8Marshaller.fromCpp(djinni.swift.getMember(p, 1))
Expand All @@ -28,7 +28,7 @@ enum AssortedPrimitivesMarshaller: DjinniSupport.Marshaller {
return SwiftType(b: b, eight: eight, sixteen: sixteen, thirtytwo: thirtytwo, sixtyfour: sixtyfour, fthirtytwo: fthirtytwo, fsixtyfour: fsixtyfour, oB: oB, oEight: oEight, oSixteen: oSixteen, oThirtytwo: oThirtytwo, oSixtyfour: oSixtyfour, oFthirtytwo: oFthirtytwo, oFsixtyfour: oFsixtyfour)
}
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
var ret = djinni.swift.makeCompositeValue()
djinni.swift.addMember(&ret, BoolMarshaller.toCpp(s.b))
djinni.swift.addMember(&ret, I8Marshaller.toCpp(s.eight))
Expand Down
12 changes: 6 additions & 6 deletions test-suite/generated-src/swift/AsyncInterface+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import TestSuiteCxx

let asyncInterfaceMethods: Vtbl<AsyncInterface> = [
{ inst, params, ret in
let _f = FutureMarshaller<I32Marshaller>.fromCpp(djinni.swift.getMember(params, 0))
djinni.swift.setReturnValue(ret, try FutureMarshaller<StringMarshaller>.toCpp(inst.futureRoundtrip(_f)))
let _f = DjinniSupport.FutureMarshaller<I32Marshaller>.fromCpp(djinni.swift.getMember(params, 0))
djinni.swift.setReturnValue(ret, try DjinniSupport.FutureMarshaller<StringMarshaller>.toCpp(inst.futureRoundtrip(_f)))
},
]

enum AsyncInterfaceMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.AsyncInterface
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum AsyncInterfaceMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.AsyncInterface
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { fatalError("n/a") })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { djinni_generated.AsyncInterfaceSwiftProxy.make(ctxPtr(s, asyncInterfaceMethods), dispatcherProtocalCall)})
}
}
2 changes: 1 addition & 1 deletion test-suite/generated-src/swift/AsyncInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import DjinniSupport
import Foundation

public protocol AsyncInterface: AnyObject {
func futureRoundtrip(_ f: DJFuture<Int32>) throws -> DJFuture<String>
func futureRoundtrip(_ f: DjinniSupport.DJFuture<Int32>) throws -> DjinniSupport.DJFuture<String>
}
8 changes: 4 additions & 4 deletions test-suite/generated-src/swift/ClientInterface+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ let clientInterfaceMethods: Vtbl<ClientInterface> = [
},
]

enum ClientInterfaceMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.ClientInterface
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ClientInterfaceMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.ClientInterface
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { fatalError("n/a") })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { djinni_generated.ClientInterfaceSwiftProxy.make(ctxPtr(s, clientInterfaceMethods), dispatcherProtocalCall)})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import Foundation
import TestSuite
import TestSuiteCxx

enum ClientReturnedRecordMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.ClientReturnedRecord
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ClientReturnedRecordMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.ClientReturnedRecord
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return withUnsafePointer(to: c) { p in
let recordId = I64Marshaller.fromCpp(djinni.swift.getMember(p, 0))
let content = StringMarshaller.fromCpp(djinni.swift.getMember(p, 1))
let misc = OptionalMarshaller<StringMarshaller>.fromCpp(djinni.swift.getMember(p, 2))
return SwiftType(recordId: recordId, content: content, misc: misc)
}
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
var ret = djinni.swift.makeCompositeValue()
djinni.swift.addMember(&ret, I64Marshaller.toCpp(s.recordId))
djinni.swift.addMember(&ret, StringMarshaller.toCpp(s.content))
Expand Down
2 changes: 1 addition & 1 deletion test-suite/generated-src/swift/Color+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import DjinniSupport
import TestSuite

typealias ColorMarshaller = DjinniSupport.EnumMarshaller<Color>
public typealias ColorMarshaller = DjinniSupport.EnumMarshaller<Color>
8 changes: 4 additions & 4 deletions test-suite/generated-src/swift/Conflict+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import TestSuiteCxx
final class ConflictCppProxy: DjinniSupport.CppProxy, TestSuite.Conflict {
init(_ inst: djinni.swift.AnyValue) { super.init(inst:inst) }
}
enum ConflictMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.Conflict
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ConflictMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.Conflict
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { ConflictCppProxy(c) as SwiftType })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { fatalError("n/a") })
}
}
22 changes: 11 additions & 11 deletions test-suite/generated-src/swift/ConflictUser+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import TestSuiteCxx
final class ConflictUserCppProxy: DjinniSupport.CppProxy, TestSuite.ConflictUser {
init(_ inst: djinni.swift.AnyValue) { super.init(inst:inst) }
func Conflict() throws -> TestSuite.Conflict {
var params = djinni.swift.ParameterList()
params.addValue(inst)
var ret = djinni_generated.ConflictUser_Conflict(&params)
var _params = djinni.swift.ParameterList()
_params.addValue(inst)
var ret = djinni_generated.ConflictUser_Conflict(&_params)
try handleCppErrors(&ret)
return ConflictMarshaller.fromCpp(ret)
}
func conflictArg(_ cs: Array<TestSuite.Conflict>) throws -> Bool {
var params = djinni.swift.ParameterList()
params.addValue(inst)
params.addValue(ListMarshaller<ConflictMarshaller>.toCpp(cs))
var ret = djinni_generated.ConflictUser_conflictArg(&params)
var _params = djinni.swift.ParameterList()
_params.addValue(inst)
_params.addValue(ListMarshaller<ConflictMarshaller>.toCpp(cs))
var ret = djinni_generated.ConflictUser_conflictArg(&_params)
try handleCppErrors(&ret)
return BoolMarshaller.fromCpp(ret)
}
}
enum ConflictUserMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.ConflictUser
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ConflictUserMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.ConflictUser
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { ConflictUserCppProxy(c) as SwiftType })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { fatalError("n/a") })
}
}
2 changes: 1 addition & 1 deletion test-suite/generated-src/swift/ConstantEnum+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import DjinniSupport
import TestSuite

typealias ConstantEnumMarshaller = DjinniSupport.EnumMarshaller<ConstantEnum>
public typealias ConstantEnumMarshaller = DjinniSupport.EnumMarshaller<ConstantEnum>
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import TestSuiteCxx
final class ConstantInterfaceWithEnumCppProxy: DjinniSupport.CppProxy, TestSuite.ConstantInterfaceWithEnum {
init(_ inst: djinni.swift.AnyValue) { super.init(inst:inst) }
}
enum ConstantInterfaceWithEnumMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.ConstantInterfaceWithEnum
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ConstantInterfaceWithEnumMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.ConstantInterfaceWithEnum
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return cppInterfaceToSwift(c, { ConstantInterfaceWithEnumCppProxy(c) as SwiftType })
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
return swiftInterfaceToCpp(s, { fatalError("n/a") })
}
}
8 changes: 4 additions & 4 deletions test-suite/generated-src/swift/ConstantRecord+Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import Foundation
import TestSuite
import TestSuiteCxx

enum ConstantRecordMarshaller: DjinniSupport.Marshaller {
typealias SwiftType = TestSuite.ConstantRecord
static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
public enum ConstantRecordMarshaller: DjinniSupport.Marshaller {
public typealias SwiftType = TestSuite.ConstantRecord
public static func fromCpp(_ c: djinni.swift.AnyValue) -> SwiftType {
return withUnsafePointer(to: c) { p in
let someInteger = I32Marshaller.fromCpp(djinni.swift.getMember(p, 0))
let someString = StringMarshaller.fromCpp(djinni.swift.getMember(p, 1))
return SwiftType(someInteger: someInteger, someString: someString)
}
}
static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
public static func toCpp(_ s: SwiftType) -> djinni.swift.AnyValue {
var ret = djinni.swift.makeCompositeValue()
djinni.swift.addMember(&ret, I32Marshaller.toCpp(s.someInteger))
djinni.swift.addMember(&ret, StringMarshaller.toCpp(s.someString))
Expand Down
Loading

0 comments on commit 539df09

Please sign in to comment.