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

Appearance settings
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
1 change: 1 addition & 0 deletions 1 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
echo "SWIFT_SDK_ID=${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" >> $GITHUB_ENV
echo "SWIFT_BIN_PATH=$(dirname $(which swiftc))" >> $GITHUB_ENV
- run: make bootstrap
- run: npm run test:runtime
- run: make unittest
# Skip unit tests with uwasi because its proc_exit throws
# unhandled promise rejection.
Expand Down
7 changes: 4 additions & 3 deletions 7 Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public struct BridgeJSLink {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down Expand Up @@ -428,7 +429,7 @@ public struct BridgeJSLink {
"\(JSGlueVariableScope.reservedSwift).\(JSGlueVariableScope.reservedMemory).release(sourceId);"
)
printer.write(
"const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, bytesPtr);"
"const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, bytesPtr >>> 0);"
)
printer.write("bytes.set(source);")
}
Expand All @@ -443,7 +444,7 @@ public struct BridgeJSLink {
printer.write("bjs[\"swift_js_init_memory_with_result\"] = function(ptr, len) {")
printer.indent {
printer.write(
"const target = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, ptr, len);"
"const target = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, ptr >>> 0, len >>> 0);"
)
printer.write("target.set(\(JSGlueVariableScope.reservedStorageToReturnBytes));")
printer.write("\(JSGlueVariableScope.reservedStorageToReturnBytes) = undefined;")
Expand Down Expand Up @@ -789,7 +790,7 @@ public struct BridgeJSLink {
helperPrinter.write("if (state.unregistered) {")
helperPrinter.indent {
helperPrinter.write(
"const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, state.file);"
"const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, state.file >>> 0);"
)
helperPrinter.write("let length = 0;")
helperPrinter.write("while (bytes[length] !== 0) { length += 1; }")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down Expand Up @@ -390,6 +390,7 @@ export async function createInstantiator(options, swift) {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function createInstantiator(options, swift) {
const state = { pointer, file, line, unregistered: false };
const real = (...args) => {
if (state.unregistered) {
const bytes = new Uint8Array(memory.buffer, state.file);
const bytes = new Uint8Array(memory.buffer, state.file >>> 0);
let length = 0;
while (bytes[length] !== 0) { length += 1; }
const fileID = decodeString(state.file, length);
Expand Down Expand Up @@ -160,14 +160,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function createInstantiator(options, swift) {
const state = { pointer, file, line, unregistered: false };
const real = (...args) => {
if (state.unregistered) {
const bytes = new Uint8Array(memory.buffer, state.file);
const bytes = new Uint8Array(memory.buffer, state.file >>> 0);
let length = 0;
while (bytes[length] !== 0) { length += 1; }
const fileID = decodeString(state.file, length);
Expand Down Expand Up @@ -159,14 +159,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down Expand Up @@ -301,6 +301,7 @@ export async function createInstantiator(options, swift) {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down Expand Up @@ -310,6 +310,7 @@ export async function createInstantiator(options, swift) {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,14 +788,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down Expand Up @@ -987,6 +987,7 @@ export async function createInstantiator(options, swift) {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down Expand Up @@ -293,6 +293,7 @@ export async function createInstantiator(options, swift) {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) {
bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
swift.memory.release(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0);
bytes.set(source);
}
bjs["swift_js_make_js_string"] = function(ptr, len) {
return swift.memory.retain(decodeString(ptr, len));
}
bjs["swift_js_init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
Expand Down Expand Up @@ -274,6 +274,7 @@ export async function createInstantiator(options, swift) {
/// Represents a Swift heap object like a class instance or an actor instance.
class SwiftHeapObject {
static __wrap(pointer, deinit, prototype, identityCache) {
pointer = pointer >>> 0;
const makeFresh = (identityMap) => {
const obj = Object.create(prototype);
const state = { pointer, deinit, hasReleased: false, identityMap };
Expand Down
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.