rust-diplomat / diplomat

Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code
https://rust-diplomat.github.io/book/
Other
480 stars 45 forks source link

JS2 Backend: Lifetime Borrowing #525

Open ambiguousname opened 1 week ago

ambiguousname commented 1 week ago

For opaques: If we don't want to retain the selfEdge argument itself, we could this.#selfEdge.push(...selfEdge) (see example/ICU4XDataProvider for an example of this)

Need to do more testing for anything borrowed: slices, structs, opaques, etc.

sffc commented 1 week ago

Specific cases:

ambiguousname commented 1 day ago

Overly conservative edge setup.

For instance, Foo.bar should have this.#aEdge instead of this for aEdges.

ambiguousname commented 1 day ago

We could either immediately destroy anything, or register a garbage collection hook

ambiguousname commented 1 day ago

Set anything that we pass into WASM to something that wasm can't parse when it is destroyed.

ambiguousname commented 1 day ago

Possible values: Symbol() or bigints

ambiguousname commented 1 day ago

When returning a reference to an opaque, skip the step where you register the opaque with the FinalizationRegistry

Manishearth commented 1 day ago

(and make sure selfEdge is appropriately populated when a method does this)