about summary refs log blame commit diff stats
path: root/src/js/jstypes.nim
blob: b8ef6c559da453db05bb1a3d4573f0beee6b53e2 (plain) (tree)































                                                                                
import bindings/quickjs

# This is the WebIDL dictionary type.
# We only use it for type inference in generics.
#TODO required members
type JSDict* = object of RootObj

# Containers compatible with the internal representation of strings in QuickJS.
# To convert these, a copy is still needed; however, they remove the UTF-8
# transcoding step.
type
  NarrowString* = distinct string
  WideString* = distinct seq[uint16]

# Various containers for array buffer types.
# Converting these only requires copying the metadata; buffers are never copied.
type
  JSArrayBuffer* = object
    p*: ptr UncheckedArray[uint8]
    len*: csize_t
    dealloc*: JSFreeArrayBufferDataFunc

  JSArrayBufferView* = object
    abuf*: JSArrayBuffer
    offset*: csize_t # offset into the buffer
    nmemb*: csize_t # number of members
    nsize*: csize_t # member size

  JSUint8Array* = object
    abuf*: JSArrayBuffer
    offset*: csize_t # offset into the buffer
    nmemb*: csize_t # number of members