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
6 changes: 3 additions & 3 deletions Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public struct BridgeJSLink {
printer.write("bjs[\"swift_js_struct_lift_\(structDef.name)\"] = function() {")
printer.indent {
printer.write(
"const value = \(JSGlueVariableScope.reservedStructHelpers).\(structDef.name).lift(\(JSGlueVariableScope.reservedTmpRetStrings), \(JSGlueVariableScope.reservedTmpRetInts), \(JSGlueVariableScope.reservedTmpRetF32s), \(JSGlueVariableScope.reservedTmpRetF64s), \(JSGlueVariableScope.reservedTmpRetPointers));"
"const value = \(JSGlueVariableScope.reservedStructHelpers).\(structDef.name).lift();"
)
printer.write("return \(JSGlueVariableScope.reservedSwift).memory.retain(value);")
}
Expand Down Expand Up @@ -1162,7 +1162,7 @@ public struct BridgeJSLink {
for skeleton in skeletons.compactMap(\.exported) {
for enumDef in skeleton.enums where enumDef.enumType == .associatedValue {
printer.write(
"const \(enumDef.name)Helpers = __bjs_create\(enumDef.valuesName)Helpers()(\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTmpParamPointers), \(JSGlueVariableScope.reservedTmpRetPointers), \(JSGlueVariableScope.reservedTextEncoder), \(JSGlueVariableScope.reservedSwift), \(JSGlueVariableScope.reservedStructHelpers), \(JSGlueVariableScope.reservedEnumHelpers));"
"const \(enumDef.name)Helpers = __bjs_create\(enumDef.valuesName)Helpers()();"
)
printer.write("\(JSGlueVariableScope.reservedEnumHelpers).\(enumDef.name) = \(enumDef.name)Helpers;")
printer.nextLine()
Expand All @@ -1178,7 +1178,7 @@ public struct BridgeJSLink {
for skeleton in skeletons.compactMap(\.exported) {
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), \(JSGlueVariableScope.reservedEnumHelpers));"
"const \(structDef.name)Helpers = __bjs_create\(structDef.name)Helpers()();"
)
printer.write(
"\(JSGlueVariableScope.reservedStructHelpers).\(structDef.name) = \(structDef.name)Helpers;"
Expand Down
4 changes: 2 additions & 2 deletions Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ struct IntrinsicJSFragment: Sendable {
printer.write("const __bjs_create\(enumName)Helpers = () => {")
printer.indent()
printer.write(
"return (\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTmpParamPointers), \(JSGlueVariableScope.reservedTmpRetPointers), textEncoder, \(JSGlueVariableScope.reservedSwift), \(JSGlueVariableScope.reservedStructHelpers), \(JSGlueVariableScope.reservedEnumHelpers)) => ({"
"return () => ({"
)
printer.indent()

Expand Down Expand Up @@ -3109,7 +3109,7 @@ struct IntrinsicJSFragment: Sendable {
printer.write("const __bjs_create\(structName)Helpers = () => {")
printer.indent()
printer.write(
"return (\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTmpParamPointers), \(JSGlueVariableScope.reservedTmpRetPointers), textEncoder, \(JSGlueVariableScope.reservedSwift), \(JSGlueVariableScope.reservedEnumHelpers)) => ({"
"return () => ({"
)
printer.indent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function createInstantiator(options, swift) {
let _exports = null;
let bjs = null;
const __bjs_createPointHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers) => ({
return () => ({
lower: (value) => {
tmpParamF64s.push(value.x);
tmpParamF64s.push(value.y);
Expand Down Expand Up @@ -147,7 +147,7 @@ export async function createInstantiator(options, swift) {
return 0;
}
bjs["swift_js_struct_lift_Point"] = function() {
const value = structHelpers.Point.lift(tmpRetStrings, tmpRetInts, tmpRetF32s, tmpRetF64s, tmpRetPointers);
const value = structHelpers.Point.lift();
return swift.memory.retain(value);
}
bjs["swift_js_return_optional_bool"] = function(isSome, value) {
Expand Down Expand Up @@ -389,7 +389,7 @@ export async function createInstantiator(options, swift) {
}

}
const PointHelpers = __bjs_createPointHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers);
const PointHelpers = __bjs_createPointHelpers()();
structHelpers.Point = PointHelpers;

const exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function createInstantiator(options, swift) {
let _exports = null;
let bjs = null;
const __bjs_createConfigHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers) => ({
return () => ({
lower: (value) => {
const bytes = textEncoder.encode(value.name);
const id = swift.memory.retain(bytes);
Expand All @@ -63,7 +63,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createMathOperationsHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers) => ({
return () => ({
lower: (value) => {
tmpParamF64s.push(value.baseValue);
return { cleanup: undefined };
Expand Down Expand Up @@ -172,7 +172,7 @@ export async function createInstantiator(options, swift) {
return 0;
}
bjs["swift_js_struct_lift_Config"] = function() {
const value = structHelpers.Config.lift(tmpRetStrings, tmpRetInts, tmpRetF32s, tmpRetF64s, tmpRetPointers);
const value = structHelpers.Config.lift();
return swift.memory.retain(value);
}
bjs["swift_js_struct_lower_MathOperations"] = function(objectId) {
Expand All @@ -183,7 +183,7 @@ export async function createInstantiator(options, swift) {
return 0;
}
bjs["swift_js_struct_lift_MathOperations"] = function() {
const value = structHelpers.MathOperations.lift(tmpRetStrings, tmpRetInts, tmpRetF32s, tmpRetF64s, tmpRetPointers);
const value = structHelpers.MathOperations.lift();
return swift.memory.retain(value);
}
bjs["swift_js_return_optional_bool"] = function(isSome, value) {
Expand Down Expand Up @@ -431,10 +431,10 @@ export async function createInstantiator(options, swift) {
}
}
}
const ConfigHelpers = __bjs_createConfigHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers);
const ConfigHelpers = __bjs_createConfigHelpers()();
structHelpers.Config = ConfigHelpers;

const MathOperationsHelpers = __bjs_createMathOperationsHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers);
const MathOperationsHelpers = __bjs_createMathOperationsHelpers()();
structHelpers.MathOperations = MathOperationsHelpers;

const exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function createInstantiator(options, swift) {
let _exports = null;
let bjs = null;
const __bjs_createPointHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers) => ({
return () => ({
lower: (value) => {
tmpParamF64s.push(value.x);
tmpParamF64s.push(value.y);
Expand All @@ -130,7 +130,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createAPIResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -201,7 +201,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createComplexResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -321,7 +321,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -385,7 +385,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createNetworkingResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -431,7 +431,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createAPIOptionalResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -560,7 +560,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createTypedPayloadResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -635,7 +635,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createAllTypesResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -722,7 +722,7 @@ export async function createInstantiator(options, swift) {
});
};
const __bjs_createOptionalAllTypesResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -965,7 +965,7 @@ export async function createInstantiator(options, swift) {
return 0;
}
bjs["swift_js_struct_lift_Point"] = function() {
const value = structHelpers.Point.lift(tmpRetStrings, tmpRetInts, tmpRetF32s, tmpRetF64s, tmpRetPointers);
const value = structHelpers.Point.lift();
return swift.memory.retain(value);
}
bjs["swift_js_return_optional_bool"] = function(isSome, value) {
Expand Down Expand Up @@ -1103,31 +1103,31 @@ export async function createInstantiator(options, swift) {
}

}
const PointHelpers = __bjs_createPointHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers);
const PointHelpers = __bjs_createPointHelpers()();
structHelpers.Point = PointHelpers;

const APIResultHelpers = __bjs_createAPIResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const APIResultHelpers = __bjs_createAPIResultValuesHelpers()();
enumHelpers.APIResult = APIResultHelpers;

const ComplexResultHelpers = __bjs_createComplexResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const ComplexResultHelpers = __bjs_createComplexResultValuesHelpers()();
enumHelpers.ComplexResult = ComplexResultHelpers;

const ResultHelpers = __bjs_createResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const ResultHelpers = __bjs_createResultValuesHelpers()();
enumHelpers.Result = ResultHelpers;

const NetworkingResultHelpers = __bjs_createNetworkingResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const NetworkingResultHelpers = __bjs_createNetworkingResultValuesHelpers()();
enumHelpers.NetworkingResult = NetworkingResultHelpers;

const APIOptionalResultHelpers = __bjs_createAPIOptionalResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const APIOptionalResultHelpers = __bjs_createAPIOptionalResultValuesHelpers()();
enumHelpers.APIOptionalResult = APIOptionalResultHelpers;

const TypedPayloadResultHelpers = __bjs_createTypedPayloadResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const TypedPayloadResultHelpers = __bjs_createTypedPayloadResultValuesHelpers()();
enumHelpers.TypedPayloadResult = TypedPayloadResultHelpers;

const AllTypesResultHelpers = __bjs_createAllTypesResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const AllTypesResultHelpers = __bjs_createAllTypesResultValuesHelpers()();
enumHelpers.AllTypesResult = AllTypesResultHelpers;

const OptionalAllTypesResultHelpers = __bjs_createOptionalAllTypesResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const OptionalAllTypesResultHelpers = __bjs_createOptionalAllTypesResultValuesHelpers()();
enumHelpers.OptionalAllTypesResult = OptionalAllTypesResultHelpers;

const exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function createInstantiator(options, swift) {
let _exports = null;
let bjs = null;
const __bjs_createFooContainerHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers) => ({
return () => ({
lower: (value) => {
let id;
if (value.foo != null) {
Expand Down Expand Up @@ -184,7 +184,7 @@ export async function createInstantiator(options, swift) {
return 0;
}
bjs["swift_js_struct_lift_FooContainer"] = function() {
const value = structHelpers.FooContainer.lift(tmpRetStrings, tmpRetInts, tmpRetF32s, tmpRetF64s, tmpRetPointers);
const value = structHelpers.FooContainer.lift();
return swift.memory.retain(value);
}
bjs["swift_js_return_optional_bool"] = function(isSome, value) {
Expand Down Expand Up @@ -298,7 +298,7 @@ export async function createInstantiator(options, swift) {
/** @param {WebAssembly.Instance} instance */
createExports: (instance) => {
const js = swift.memory.heap;
const FooContainerHelpers = __bjs_createFooContainerHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, enumHelpers);
const FooContainerHelpers = __bjs_createFooContainerHelpers()();
structHelpers.FooContainer = FooContainerHelpers;

const exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function createInstantiator(options, swift) {
let _exports = null;
let bjs = null;
const __bjs_createResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -723,7 +723,7 @@ export async function createInstantiator(options, swift) {
for (const cleanup of arrayCleanups) { cleanup(); }
}
}
const ResultHelpers = __bjs_createResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const ResultHelpers = __bjs_createResultValuesHelpers()();
enumHelpers.Result = ResultHelpers;

const exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function createInstantiator(options, swift) {
let _exports = null;
let bjs = null;
const __bjs_createAPIResultValuesHelpers = () => {
return (tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers) => ({
return () => ({
lower: (value) => {
const enumTag = value.tag;
switch (enumTag) {
Expand Down Expand Up @@ -312,7 +312,7 @@ export async function createInstantiator(options, swift) {
return ret;
}
}
const APIResultHelpers = __bjs_createAPIResultValuesHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, tmpParamPointers, tmpRetPointers, textEncoder, swift, structHelpers, enumHelpers);
const APIResultHelpers = __bjs_createAPIResultValuesHelpers()();
enumHelpers.APIResult = APIResultHelpers;

if (typeof globalThis.Utils === 'undefined') {
Expand Down
Loading