about summary refs log tree commit diff stats
path: root/src/bindings
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-21 20:22:21 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-21 20:22:21 +0200
commit69870f3b974e65d61b564b396e01d21cc023e6e9 (patch)
treef773f5446a2232739c4818080e467851deabb4f8 /src/bindings
parentf77db0bdefd43ec03d7d26ec7a5d793bece25030 (diff)
downloadchawan-69870f3b974e65d61b564b396e01d21cc023e6e9.tar.gz
javascript: add TextEncoder, TextDecoder
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/quickjs.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bindings/quickjs.nim b/src/bindings/quickjs.nim
index 17bac15a..a401bf1b 100644
--- a/src/bindings/quickjs.nim
+++ b/src/bindings/quickjs.nim
@@ -87,6 +87,8 @@ type
     opaque: pointer): JSModuleDef {.cdecl.}
   JSJobFunc* = proc (ctx: JSContext, argc: cint, argv: ptr JSValue): JSValue {.cdecl.}
   JSGCObjectHeader* {.importc, header: qjsheader.} = object
+  JSFreeArrayBufferDataFunc* = proc (rt: JSRuntime,
+    opaque, p: pointer) {.cdecl.}
 
   JSPropertyDescriptor* {.importc, header: qjsheader.} = object
     flags*: cint
@@ -342,10 +344,19 @@ proc JS_SetOpaque*(obj: JSValue, opaque: pointer)
 proc JS_GetOpaque*(obj: JSValue, class_id: JSClassID): pointer
 proc JS_GetOpaque2*(ctx: JSContext, obj: JSValue, class_id: JSClassID): pointer
 proc JS_GetClassID*(obj: JSValue): JSClassID
+
 proc JS_ParseJSON*(ctx: JSContext, buf: cstring, buf_len: csize_t, filename: cstring): JSValue
 proc JS_ParseJSON2*(ctx: JSContext, buf: cstring, buf_len: csize_t,
   filename: cstring, flags: cint): JSValue
 
+proc JS_NewArrayBuffer*(ctx: JSContext, buf: ptr UncheckedArray[uint8],
+  len: csize_t, free_func: JSFreeArrayBufferDataFunc, opaque: pointer,
+  is_shared: JS_BOOL): JSValue
+proc JS_GetArrayBuffer*(ctx: JSContext, psize: ptr csize_t, obj: JSValue): ptr uint8
+proc JS_GetUint8Array*(ctx: JSContext, psize: ptr csize_t, obj: JSValue): ptr uint8
+proc JS_GetTypedArrayBuffer*(ctx: JSContext, obj: JSValue, pbyte_offset,
+  pbyte_length, pbytes_per_element: ptr csize_t): JSValue
+
 proc JS_NewClassID*(pclass_id: ptr JSClassID): JSClassID
 proc JS_NewClass*(rt: JSRuntime, class_id: JSClassID, class_def: ptr JSClassDef): cint
 proc JS_IsRegisteredClass*(rt: JSRuntime, class_id: JSClassID): cint