Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BridgeJS: Swift closure support#463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
krodak wants to merge1 commit intoswiftwasm:main
base:main
Choose a base branch
Loading
fromPassiveLogic:feat/closure-support
Open
Show file tree
Hide file tree
Changes fromall 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 deletionsPlugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift
View file
Open in desktop

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletionsPlugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp