sysjs: Implement Object.copyBytes to copy over a slice to Js array type objects
It works with Uint8Array objects only but no type checking is done right now. Originally authored by iddev5 :) Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
28fb75c7eb
commit
3e69c54e79
2 changed files with 19 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ const js = struct {
|
|||
extern fn zigValueEqual(val: *const anyopaque, other: *const anyopaque) bool;
|
||||
extern fn zigValueInstanceOf(val: *const anyopaque, other: *const anyopaque) bool;
|
||||
extern fn zigDeleteIndex(id: u64, index: u32) void;
|
||||
extern fn zigCopyBytes(id: u64, bytes: [*]u8, expected_len: u32) void;
|
||||
extern fn zigFunctionCall(id: u64, name: [*]const u8, len: u32, args: ?*const anyopaque, args_len: u32, ret_ptr: *anyopaque) void;
|
||||
extern fn zigFunctionInvoke(id: u64, args: ?*const anyopaque, args_len: u32, ret_ptr: *anyopaque) void;
|
||||
extern fn zigGetParamCount(id: u64) u32;
|
||||
|
|
@ -140,6 +141,10 @@ pub const Object = struct {
|
|||
js.zigDeleteIndex(obj.ref, index);
|
||||
}
|
||||
|
||||
pub fn copyBytes(obj: *const Object, bytes: []u8) void {
|
||||
js.zigCopyBytes(obj.ref, bytes.ptr, bytes.len);
|
||||
}
|
||||
|
||||
pub fn call(obj: *const Object, fun: []const u8, args: []const Value) Value {
|
||||
var ret: Value = undefined;
|
||||
js.zigFunctionCall(obj.ref, fun.ptr, @intCast(u32, fun.len), args.ptr, @intCast(u32, args.len), &ret);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue