romgrk / node-gtk

GTK+ bindings for NodeJS (via GObject introspection)
MIT License
494 stars 41 forks source link

(better) support for typed arrays #287

Open mildsunrise opened 3 years ago

mildsunrise commented 3 years ago

See the commit messages for full change list, but basically

We still need a memcpy, but transferring large data buffers should be much faster now.

mildsunrise commented 3 years ago

the last commit also allows accessing array fields on structs

romgrk commented 3 years ago

Yes, I've read the thing quickly but I have a work thing to finish by tomorrow, will be more available to review the PRs after that.

Two comments meanwhile:

mildsunrise commented 3 years ago

wait, the struct setters work with arrays? I thought they weren't primitives and you could only get the array, not set it

edit: according to the code, plain C arrays (the only kind of arrays where length makes sense) can't be set via a struct setter since it would require memory management. so we're fine. in the future we could maybe omit memcpy entirely and this would let users modify the array elements through the typed array

mildsunrise commented 3 years ago

Yes, I've read the thing quickly but I have a work thing to finish by tomorrow, will be more available to review the PRs after that.

oh don't worry, the comment was just to keep track of the things in the PR. these PRs can perfectly wait :)

I'll fix the typo and the other two things you mentioned (test case and ERROR) when I find some time

mildsunrise commented 3 years ago

in the meanwhile I've done some improvements to the GArray -> V8 conversion, and also implemented conversion from GByteArray GValues <-> V8

I don't think there's an easy way to implement conversions for arbitrary GArrays for now, because we don't have info about the element GType