Fundamental types
struct api | c type |
---|---|
bool | bool |
char | signed char |
uchar | unsigned char |
short | short |
ushort | unsigned short |
int | int |
uint | unsigned int |
long | long |
ulong | unsigned long |
longlong | long long |
ulonglong | unsigned long long |
float | float |
double | double |
ssize_t | ssize_t |
size_t | size_t |
int8_t | int8_t |
uint8_t | uint8_t |
int16_t | int16_t |
uint16_t | uint16_t |
int32_t | int32_t |
uint32_t | uint32_t |
int64_t | int64_t |
uint64_t | uint64_t |
struct | struct |
union | union |
Inheritance diagram
built-in methods
-
get $buffer ()
Return a node buffer
-
get $arrayBuffer ()
Return an ArrayBuffer
-
get $address ()
Return real address of current object
-
get $value ()
Get value
-
set $value (value)
Set value
Static methods
-
get byteSize ()
Similar with sizeof()
-
times (length)
Return an instance of BaseArrayType
Example
int
const struct = const a = a$value = 100 console // <Buffer 64 00 00 00>console // 100
array
const struct = const arr = new structint for let i = 0; i < arrlength; i++ arri$value = i + 1 console // <Buffer 01 00 00 00 02 00 00 00 03 00 00 00>console // 2
union
const struct = union static { return 'x' structchar 'y' structint } const a = a$value = 'x': 266 console // <Buffer 0a 00 00 00>console // 10console // 10 a$value = 'y': 267 console // <Buffer 0b 01 00 00>console // 11console // 267
struct
const struct = struct static { return 'x' structint 'y' structint } const point = x: 1 y: 10 pointy$value = 2 console // <Buffer 01 00 00 00 02 00 00 00>
complex struct
const struct = struct static { return 'x' structint 'y' structint } struct static { return 'a' structchar 's' Point 'b' structchar } const s = sa$value = 1ssx$value = 2ssy$value = 3sb0$value = 4sb1$value = 5sb2$value = 6 console // <Buffer 01 00 00 00 02 00 00 00 03 00 00 00 04 05 06 00>