diff options
author | 2022-09-08 23:29:00 -0700 | |
---|---|---|
committer | 2022-09-08 23:29:30 -0700 | |
commit | 206820d27a952e2a7c84da9177ca36d825ee7987 (patch) | |
tree | 9cc9c6e82820e358fa2cd4172d2998509baf37b2 /src/bun.js/bindings/headers.zig | |
parent | 8d8b72cf3f7119f0bc018513d89eca5f8ec44ab3 (diff) | |
download | bun-206820d27a952e2a7c84da9177ca36d825ee7987.tar.gz bun-206820d27a952e2a7c84da9177ca36d825ee7987.tar.zst bun-206820d27a952e2a7c84da9177ca36d825ee7987.zip |
[bun:ffi] Implement `read.{u8,i8,i16,i32,u16,u32,ptr,intptr}`
`read` in `bun:ffi` lets you read data from a pointer without creating a new DataView/ArrayBufferView
```
import {read} from 'bun:ffi';
expect(read.i8(ptr_, i)).toBe(view.getInt8(i, true));
expect(read.i16(ptr_, i)).toBe(view.getInt16(i, true));
expect(read.i32(ptr_, i)).toBe(view.getInt32(i, true));
expect(read.u8(ptr_, i)).toBe(view.getUint8(i, true));
expect(read.u16(ptr_, i)).toBe(view.getUint16(i, true));
expect(read.u32(ptr_, i)).toBe(view.getUint32(i, true));
}
```
Diffstat (limited to 'src/bun.js/bindings/headers.zig')
-rw-r--r-- | src/bun.js/bindings/headers.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index 7aedef63f..4c2172404 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -411,6 +411,14 @@ pub extern fn WTF__StringView__is8Bit(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__isEmpty(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__length(arg0: [*c]const WTF__StringView) usize; pub extern fn FFI__ptr__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__u8__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__u16__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__u32__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__ptr__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__i8__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__i16__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__i32__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__intptr__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; pub extern fn Zig__GlobalObject__create(arg0: [*c]JSClassRef, arg1: i32, arg2: ?*anyopaque) ?*JSC__JSGlobalObject; pub extern fn Zig__GlobalObject__getModuleRegistryMap(arg0: ?*JSC__JSGlobalObject) ?*anyopaque; pub extern fn Zig__GlobalObject__resetModuleRegistryMap(arg0: ?*JSC__JSGlobalObject, arg1: ?*anyopaque) bool; |