Surfing on wave.. WASM

Sebastiaan Koppe mail at skoppe.eu
Tue May 28 14:30:00 UTC 2019


On Tuesday, 28 May 2019 at 13:22:57 UTC, Adam D. Ruppe wrote:
> On Tuesday, 28 May 2019 at 11:19:47 UTC, Sebastiaan Koppe wrote:
>> I also have bindings to many web apis. All generated from 
>> WebIDL files.
>
> Indeed, and then, as I understand it, you generate javascript 
> for the extern(C) things actually referenced after the linker 
> does its thing, with one extern(C) function corresponding to 
> one Javascript method, right?

Yep. There is a bindgen utility that generates only the js glue 
code you need.

Last time I looked Go takes a similar approach to yours, i.e. 
dynamically resolving calls based on strings. It does result in 
less js glue code, at the cost of having to decode strings. Both 
approaches are valid, but I wanted to focus on calling js 
function with little overhead.

> I see int handles into a node array, just like I was thinking...
> but do you have a solution to memory management?

I tried doing Unique+move, but failed with optional and sumtypes 
(don't like @disable this(this))

So it will probably be refcounts (but on the D side).

> What I wanna do here is see if I can manage storing things 
> fairly effectively with a minimal amount of code. I think a 
> refcounting scheme, similar to how objective-c does it for the 
> native handles would work and is reasonably easy to use.

Nice. Good to see more people working on this.

btw. for the strings you can have a look at 
https://github.com/skoppe/spasm/blob/master/examples/fetch/spasm/modules/spasm.js#L42


More information about the Digitalmars-d mailing list