Skip to content

Make SwiftRuntime.memory constant property #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2025
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
36 changes: 14 additions & 22 deletions Plugins/PackageToJS/Templates/runtime.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
type ref = number;
type pointer = number;

declare class Memory {
readonly rawMemory: WebAssembly.Memory;
private readonly heap;
constructor(exports: WebAssembly.Exports);
retain: (value: any) => number;
getObject: (ref: number) => any;
release: (ref: number) => void;
retainByRef: (ref: number) => number;
bytes: () => Uint8Array<ArrayBuffer>;
dataView: () => DataView<ArrayBuffer>;
writeBytes: (ptr: pointer, bytes: Uint8Array) => void;
readUint32: (ptr: pointer) => number;
readUint64: (ptr: pointer) => bigint;
readInt64: (ptr: pointer) => bigint;
readFloat64: (ptr: pointer) => number;
writeUint32: (ptr: pointer, value: number) => void;
writeUint64: (ptr: pointer, value: bigint) => void;
writeInt64: (ptr: pointer, value: bigint) => void;
writeFloat64: (ptr: pointer, value: number) => void;
declare class JSObjectSpace {
private _heapValueById;
private _heapEntryByValue;
private _heapNextKey;
constructor();
retain(value: any): number;
retainByRef(ref: ref): number;
release(ref: ref): void;
getObject(ref: ref): any;
}

/**
Expand Down Expand Up @@ -96,7 +86,7 @@ type SwiftRuntimeThreadChannel = {
};
declare class ITCInterface {
private memory;
constructor(memory: Memory);
constructor(memory: JSObjectSpace);
send(sendingObject: ref, transferringObjects: ref[], sendingContext: pointer): {
object: any;
sendingContext: pointer;
Expand Down Expand Up @@ -182,14 +172,17 @@ type SwiftRuntimeOptions = {
};
declare class SwiftRuntime {
private _instance;
private _memory;
private readonly memory;
private _closureDeallocator;
private options;
private version;
private textDecoder;
private textEncoder;
/** The thread ID of the current thread. */
private tid;
private getDataView;
private getUint8Array;
private wasmMemory;
UnsafeEventLoopYield: typeof UnsafeEventLoopYield;
constructor(options?: SwiftRuntimeOptions);
setInstance(instance: WebAssembly.Instance): void;
Expand All @@ -202,7 +195,6 @@ declare class SwiftRuntime {
startThread(tid: number, startArg: number): void;
private get instance();
private get exports();
private get memory();
private get closureDeallocator();
private callHostFunction;
/** @deprecated Use `wasmImports` instead */
Expand Down
Loading