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
37 changes: 11 additions & 26 deletions Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,7 @@ struct BridgeJSLink {
}

private func generateVariableDeclarations() -> [String] {
let hasAssociatedValueEnums = exportedSkeletons.contains { skeleton in
skeleton.enums.contains { $0.enumType == .associatedValue }
}

var declarations = [
return [
"let \(JSGlueVariableScope.reservedInstance);",
"let \(JSGlueVariableScope.reservedMemory);",
"let \(JSGlueVariableScope.reservedSetException);",
Expand All @@ -237,25 +233,12 @@ struct BridgeJSLink {
"let \(JSGlueVariableScope.reservedTmpParamF64s) = [];",
"let \(JSGlueVariableScope.reservedTmpRetPointers) = [];",
"let \(JSGlueVariableScope.reservedTmpParamPointers) = [];",
"const \(JSGlueVariableScope.reservedEnumHelpers) = {};",
"const \(JSGlueVariableScope.reservedStructHelpers) = {};",
"",
"let _exports = null;",
"let bjs = null;",
]

let hasStructs = exportedSkeletons.contains { skeleton in
!skeleton.structs.isEmpty
}

if hasAssociatedValueEnums {
declarations.append("const enumHelpers = {};")
}

if hasStructs {
declarations.append("const structHelpers = {};")
}

declarations.append("")
declarations.append("let _exports = null;")
declarations.append("let bjs = null;")

return declarations
}

/// Checks if a skeleton contains any closure types
Expand Down Expand Up @@ -1046,7 +1029,7 @@ struct BridgeJSLink {
printer.write(
"const \(enumDef.name)Helpers = __bjs_create\(enumDef.valuesName)Helpers()(\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTextEncoder), \(JSGlueVariableScope.reservedSwift));"
)
printer.write("enumHelpers.\(enumDef.name) = \(enumDef.name)Helpers;")
printer.write("\(JSGlueVariableScope.reservedEnumHelpers).\(enumDef.name) = \(enumDef.name)Helpers;")
printer.nextLine()
}
}
Expand All @@ -1060,9 +1043,11 @@ struct BridgeJSLink {
for skeleton in exportedSkeletons {
for structDef in skeleton.structs {
printer.write(
"const \(structDef.name)Helpers = __bjs_create\(structDef.name)Helpers()(\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTmpParamPointers), \(JSGlueVariableScope.reservedTmpRetPointers), \(JSGlueVariableScope.reservedTextEncoder), \(JSGlueVariableScope.reservedSwift), enumHelpers);"
"const \(structDef.name)Helpers = __bjs_create\(structDef.name)Helpers()(\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTmpParamPointers), \(JSGlueVariableScope.reservedTmpRetPointers), \(JSGlueVariableScope.reservedTextEncoder), \(JSGlueVariableScope.reservedSwift), \(JSGlueVariableScope.reservedEnumHelpers));"
)
printer.write(
"\(JSGlueVariableScope.reservedStructHelpers).\(structDef.name) = \(structDef.name)Helpers;"
)
printer.write("structHelpers.\(structDef.name) = \(structDef.name)Helpers;")
printer.nextLine()
}
}
Expand Down
72 changes: 43 additions & 29 deletions Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ export async function createInstantiator(options, swift) {
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export async function createInstantiator(options, swift) {
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export async function createInstantiator(options, swift) {
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export async function createInstantiator(options, swift) {
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export async function createInstantiator(options, swift) {
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function createInstantiator(options, swift) {
let tmpParamF64s = [];
let tmpRetPointers = [];
let tmpParamPointers = [];
const enumHelpers = {};
const structHelpers = {};

let _exports = null;
let bjs = null;
Expand Down
Loading