Skip to content
Merged
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: 2 additions & 2 deletions Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,15 @@ public class ExportSwift {
func callName(for property: ExportedProperty) -> String {
switch self {
case .enumStatic(let enumDef):
return property.callName(prefix: enumDef.swiftCallName)
return "\(enumDef.swiftCallName).\(property.name)"
case .classStatic(let klass):
// property.callName() would use staticContext (the ABI name) as prefix;
// use swiftCallName directly so the emitted expression is valid Swift.
return "\(klass.swiftCallName).\(property.name)"
case .classInstance:
return property.callName()
case .structStatic(let structDef):
return property.callName(prefix: structDef.swiftCallName)
return "\(structDef.swiftCallName).\(property.name)"
}
}
}
Expand Down
565 changes: 303 additions & 262 deletions Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@JS class Account {
@JS enum Role: String {
case admin
case guest
}

@JS struct Credentials {
var token: String

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

@JS static var maxLength: Int { 64 }

@JS static func empty() -> Credentials {
Credentials(token: "")
}
}

@JS var name: String

@JS var role: Role { .admin }

@JS static var defaultRole: Role { .guest }

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

@JS func describe() -> String {
name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@JS struct Shape {
@JS enum Kind: String {
case circle
case square
}

var label: String

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

@JS struct Widget {
@JS enum Variant: String {
case button
case slider
}

@JS struct Layout {
@JS enum Alignment: String {
case leading
case trailing
}

var padding: Int
}

@JS struct Bounds {
var width: Int
var height: Int

@JS init(width: Int, height: Int) {
self.width = width
self.height = height
}

@JS static var dimensions: Int {
2
}

@JS static func zero() -> Bounds {
Bounds(width: 0, height: 0)
}
}

var name: String

@JS init(name: String) {
self.name = name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
{
"exported" : {
"aliases" : [

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

}
}
}
]
},
"methods" : [
{
"abiName" : "bjs_Account_describe",
"effects" : {
"isAsync" : false,
"isStatic" : false,
"isThrows" : false
},
"name" : "describe",
"parameters" : [

],
"returnType" : {
"string" : {

}
}
}
],
"name" : "Account",
"properties" : [
{
"isReadonly" : false,
"isStatic" : false,
"name" : "name",
"type" : {
"string" : {

}
}
},
{
"isReadonly" : true,
"isStatic" : false,
"name" : "role",
"type" : {
"rawValueEnum" : {
"_0" : "Account.Role",
"_1" : "String"
}
}
},
{
"isReadonly" : true,
"isStatic" : true,
"name" : "defaultRole",
"staticContext" : {
"className" : {
"_0" : "Account"
}
},
"type" : {
"rawValueEnum" : {
"_0" : "Account.Role",
"_1" : "String"
}
}
}
],
"swiftCallName" : "Account"
}
],
"enums" : [
{
"cases" : [
{
"associatedValues" : [

],
"name" : "admin"
},
{
"associatedValues" : [

],
"name" : "guest"
}
],
"emitStyle" : "const",
"name" : "Role",
"namespace" : [
"Account"
],
"rawType" : "String",
"staticMethods" : [

],
"staticProperties" : [

],
"swiftCallName" : "Account.Role",
"tsFullPath" : "Account.Role"
}
],
"exposeToGlobal" : false,
"functions" : [

],
"protocols" : [

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

}
}
}
]
},
"methods" : [
{
"abiName" : "bjs_Account_Credentials_static_empty",
"effects" : {
"isAsync" : false,
"isStatic" : true,
"isThrows" : false
},
"name" : "empty",
"parameters" : [

],
"returnType" : {
"swiftStruct" : {
"_0" : "Account.Credentials"
}
},
"staticContext" : {
"structName" : {
"_0" : "Account_Credentials"
}
}
}
],
"name" : "Credentials",
"namespace" : [
"Account"
],
"properties" : [
{
"isReadonly" : true,
"isStatic" : false,
"name" : "token",
"namespace" : [
"Account"
],
"type" : {
"string" : {

}
}
},
{
"isReadonly" : true,
"isStatic" : true,
"name" : "maxLength",
"staticContext" : {
"structName" : {
"_0" : "Account_Credentials"
}
},
"type" : {
"integer" : {
"_0" : {
"isSigned" : true,
"width" : "word"
}
}
}
}
],
"swiftCallName" : "Account.Credentials"
}
]
},
"moduleName" : "TestModule",
"usedExternalModules" : [

]
}
Loading
Loading