-
Notifications
You must be signed in to change notification settings - Fork 892
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
Update JS_NewTypedArray()
to C level API
#294
base: master
Are you sure you want to change the base?
Conversation
179a58a
to
29e1525
Compare
29e1525
to
9c2a19e
Compare
For strings we have an api that copies data and one that doesn't. Should we have the same here? /cc @chqrlie |
What string APIs are you referring to? Regarding typed arrays, the APIs should either create a view on an existing What are the needs for integrating QuickJS into larger applications ? |
Sorry I think I was thing about arraybuffer. In txiki.js I have both use cases, but the one I use the most is the one that doesn't copy. This is what I use for sockets, stdio and so on. |
My own use case is replacing the implementation of this function: https://github.com/holepunchto/libqjs/blob/eff318a3c97839b55880bc52cc92ee6528005811/src/qjs.c#L2846-L2891. The function behaves the same as the various typed array constructors in that it takes an arraybuffer, an offset, and a length and constructs a view over that. |
@kasperisager in your case, you want to bypass the overhead of What is 2 separate APIs seem to be advisable. |
This is the little wrapper I use: https://github.com/saghul/txiki.js/blob/4896636f13dd298468c9f6b3d46cbc0dcbab12b3/src/utils.c#L262 since When reading data from a socket with libuv I allocate some memory and then that memory becomes the uint8array. |
@chqrlie The |
OK node has the enum, not v8... We should definitely renumber our own enum to make it compatible. |
Yep, for V8 we have to fetch the corresponding constructor function, it doesn't have a type enum: https://github.com/holepunchto/libjs/blob/41ba260766291ca2477a1473c652d5a5494e3f7d/src/js.cc#L3974-L4001 |
I agree, that is why the initial API was argc, argv.
How What about: I am not sure about what is the best arrayBuffer type. |
Zero-copy version sounds good too. |
No description provided.