Open svaarala opened 9 years ago
A non-breaking change would be to add separate calls to get string/buffer data, with the calls accepting both plain and boxed strings/buffers, e.g.:
char *buf;
duk_size_t sz;
buf = (char *) duk_get_buffer_data(ctx, idx_mybuf, &sz);
The obvious question then is whether to deprecate duk_get_buffer()
etc in Duktape 2.x.
Related issue: #190.
A solution for Duktape 1.4.0 would also be nice, but not mandatory.
Currently e.g.
duk_get_string()
andduk_get_buffer()
only operate on plain string/buffer values. If they're used with a String or Duktape.Buffer object they'll return NULL and zero length.It might be more useful if the calls accepted String and Duktape.Buffer objects like plain values.
With Node.js Buffer and TypedArray bindings, they should similarly return pointers and lengths for Node.js Buffer, ArrayBuffer, and TypedArray/DataView values. Same boxed/unboxed issue also affects Number and Boolean types (e.g.
duk_get_number()
andduk_get_boolean()
).