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
4 changes: 1 addition & 3 deletions Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,6 @@ public struct BridgeJSLink {
}
}
return type.tsType
case .swiftStruct(let name):
return name.components(separatedBy: ".").last ?? name
case .nullable(let wrapped, let kind):
let base = resolveTypeScriptType(wrapped, exportedSkeletons: exportedSkeletons)
return "\(base) | \(kind.absenceLiteral)"
Expand Down Expand Up @@ -3612,7 +3610,7 @@ extension BridgeType {
case .associatedValueEnum(let name):
return "\(name)Tag"
case .swiftStruct(let name):
return "\(name)Tag"
return name.components(separatedBy: ".").last ?? name
case .namespaceEnum(let name):
return name
case .swiftProtocol(let name):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ import JavaScriptKit
}
}

@JS public struct Animal {
public let type: String

@JS public init(type: String) {
self.type = type
}
}

@JS class TestProcessor {
@JS init(transform: @escaping (String) -> String) {}
}

@JS func roundtripAnimal(_ animalClosure: (Animal) -> Animal) -> (Animal) -> Animal
@JS func roundtripOptionalAnimal(_ animalClosure: (Animal?) -> Animal?) -> (Animal?) -> Animal?

@JS func roundtripString(_ stringClosure: (String) -> String) -> (String) -> String
@JS func roundtripInt(_ intClosure: (Int) -> Int) -> (Int) -> Int
@JS func roundtripBool(_ boolClosure: (Bool) -> Bool) -> (Bool) -> Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,152 @@
],
"exposeToGlobal" : false,
"functions" : [
{
"abiName" : "bjs_roundtripAnimal",
"effects" : {
"isAsync" : false,
"isStatic" : false,
"isThrows" : false
},
"name" : "roundtripAnimal",
"parameters" : [
{
"label" : "_",
"name" : "animalClosure",
"type" : {
"closure" : {
"_0" : {
"isAsync" : false,
"isThrows" : false,
"mangleName" : "10TestModule6AnimalV_6AnimalV",
"moduleName" : "TestModule",
"parameters" : [
{
"swiftStruct" : {
"_0" : "Animal"
}
}
],
"returnType" : {
"swiftStruct" : {
"_0" : "Animal"
}
},
"sendingParameters" : false
},
"useJSTypedClosure" : false
}
}
}
],
"returnType" : {
"closure" : {
"_0" : {
"isAsync" : false,
"isThrows" : false,
"mangleName" : "10TestModule6AnimalV_6AnimalV",
"moduleName" : "TestModule",
"parameters" : [
{
"swiftStruct" : {
"_0" : "Animal"
}
}
],
"returnType" : {
"swiftStruct" : {
"_0" : "Animal"
}
},
"sendingParameters" : false
},
"useJSTypedClosure" : false
}
}
},
{
"abiName" : "bjs_roundtripOptionalAnimal",
"effects" : {
"isAsync" : false,
"isStatic" : false,
"isThrows" : false
},
"name" : "roundtripOptionalAnimal",
"parameters" : [
{
"label" : "_",
"name" : "animalClosure",
"type" : {
"closure" : {
"_0" : {
"isAsync" : false,
"isThrows" : false,
"mangleName" : "10TestModuleSq6AnimalV_Sq6AnimalV",
"moduleName" : "TestModule",
"parameters" : [
{
"nullable" : {
"_0" : {
"swiftStruct" : {
"_0" : "Animal"
}
},
"_1" : "null"
}
}
],
"returnType" : {
"nullable" : {
"_0" : {
"swiftStruct" : {
"_0" : "Animal"
}
},
"_1" : "null"
}
},
"sendingParameters" : false
},
"useJSTypedClosure" : false
}
}
}
],
"returnType" : {
"closure" : {
"_0" : {
"isAsync" : false,
"isThrows" : false,
"mangleName" : "10TestModuleSq6AnimalV_Sq6AnimalV",
"moduleName" : "TestModule",
"parameters" : [
{
"nullable" : {
"_0" : {
"swiftStruct" : {
"_0" : "Animal"
}
},
"_1" : "null"
}
}
],
"returnType" : {
"nullable" : {
"_0" : {
"swiftStruct" : {
"_0" : "Animal"
}
},
"_1" : "null"
}
},
"sendingParameters" : false
},
"useJSTypedClosure" : false
}
}
},
{
"abiName" : "bjs_roundtripString",
"effects" : {
Expand Down Expand Up @@ -1872,7 +2018,45 @@

],
"structs" : [
{
"constructor" : {
"abiName" : "bjs_Animal_init",
"effects" : {
"isAsync" : false,
"isStatic" : false,
"isThrows" : false
},
"parameters" : [
{
"label" : "type",
"name" : "type",
"type" : {
"string" : {

}
}
}
]
},
"explicitAccessControl" : "public",
"methods" : [

],
"name" : "Animal",
"properties" : [
{
"isReadonly" : true,
"isStatic" : false,
"name" : "type",
"type" : {
"string" : {

}
}
}
],
"swiftCallName" : "Animal"
}
]
},
"moduleName" : "TestModule",
Expand Down
Loading
Loading