Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
364 changes: 329 additions & 35 deletions Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ extension BridgeType {
case .string: return .string
case .jsObject: return .jsObject
case .void: return .void
case .closure:
throw BridgeJSCoreError("Closure types are not yet supported in TypeScript imports")
case .swiftHeapObject(let className):
switch context {
case .importTS:
Expand All @@ -442,7 +444,7 @@ extension BridgeType {
Swift classes can only be used in @JS protocols where Swift owns the instance.
"""
)
case .protocolExport:
case .exportSwift:
return LoweringParameterInfo(loweredParameters: [("pointer", .pointer)])
}
case .swiftProtocol:
Expand All @@ -451,22 +453,22 @@ extension BridgeType {
switch context {
case .importTS:
throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
return LoweringParameterInfo(loweredParameters: [("value", .i32)])
}
case .rawValueEnum(_, let rawType):
switch context {
case .importTS:
throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
// For protocol export we return .i32 for String raw value type instead of nil
return LoweringParameterInfo(loweredParameters: [("value", rawType.wasmCoreType ?? .i32)])
}
case .associatedValueEnum:
switch context {
case .importTS:
throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
return LoweringParameterInfo(loweredParameters: [("caseId", .i32)])
}
case .namespaceEnum:
Expand All @@ -475,7 +477,7 @@ extension BridgeType {
switch context {
case .importTS:
throw BridgeJSCoreError("Optional types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
let wrappedInfo = try wrappedType.loweringParameterInfo(context: context)
var params = [("isSome", WasmCoreType.i32)]
params.append(contentsOf: wrappedInfo.loweredParameters)
Expand Down Expand Up @@ -507,6 +509,8 @@ extension BridgeType {
case .string: return .string
case .jsObject: return .jsObject
case .void: return .void
case .closure:
throw BridgeJSCoreError("Closure types are not yet supported in TypeScript imports")
case .swiftHeapObject(let className):
switch context {
case .importTS:
Expand All @@ -516,7 +520,7 @@ extension BridgeType {
JavaScript cannot create Swift heap objects.
"""
)
case .protocolExport:
case .exportSwift:
return LiftingReturnInfo(valueToLift: .pointer)
}
case .swiftProtocol:
Expand All @@ -525,22 +529,22 @@ extension BridgeType {
switch context {
case .importTS:
throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
return LiftingReturnInfo(valueToLift: .i32)
}
case .rawValueEnum(_, let rawType):
switch context {
case .importTS:
throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
// For protocol export we return .i32 for String raw value type instead of nil
return LiftingReturnInfo(valueToLift: rawType.wasmCoreType ?? .i32)
}
case .associatedValueEnum:
switch context {
case .importTS:
throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
return LiftingReturnInfo(valueToLift: .i32)
}
case .namespaceEnum:
Expand All @@ -549,7 +553,7 @@ extension BridgeType {
switch context {
case .importTS:
throw BridgeJSCoreError("Optional types are not yet supported in TypeScript imports")
case .protocolExport:
case .exportSwift:
let wrappedInfo = try wrappedType.liftingReturnInfo(context: context)
return LiftingReturnInfo(valueToLift: wrappedInfo.valueToLift)
}
Expand Down
Loading
Loading