Dynamic module ref

Index

Variables

Interfaces

Functions

Variables

NULL: Buffer

A Buffer that references the C NULL pointer.

NULL_POINTER: Buffer

A pointer-sized buffer pointing to NULL.

endianness: string

Represents the native endianness of the processor ("LE" or "BE").

types: { void: "ref".Type; int64: "ref".Type; ushort: "ref".Type; int: "ref".Type; uint64: "ref".Type; float: "ref".Type; uint: "ref".Type; long: "ref".Type; double: "ref".Type; int8: "ref".Type; ulong: "ref".Type; Object: "ref".Type; uint8: "ref".Type; longlong: "ref".Type; CString: "ref".Type; int16: "ref".Type; ulonglong: "ref".Type; bool: "ref".Type; uint16: "ref".Type; char: "ref".Type; byte: "ref".Type; int32: "ref".Type; uchar: "ref".Type; size_t: "ref".Type; uint32: "ref".Type; short: "ref".Type; }

Default types.

public types.CString: Type

public types.Object: Type

public types.bool: Type

public types.byte: Type

public types.char: Type

public types.double: Type

public types.float: Type

public types.int: Type

public types.int16: Type

public types.int32: Type

public types.int64: Type

public types.int8: Type

public types.long: Type

public types.longlong: Type

public types.short: Type

public types.size_t: Type

public types.uchar: Type

public types.uint: Type

public types.uint16: Type

public types.uint32: Type

public types.uint64: Type

public types.uint8: Type

public types.ulong: Type

public types.ulonglong: Type

public types.ushort: Type

public types.void: Type

Functions

_attach(buffer: Buffer, object: Object)

Attach object to buffer such. It prevents object from being garbage collected until buffer does.

Parameters

  • buffer: Buffer
  • object: Object

_reinterpret(buffer: Buffer, size: number, offset?: number): Buffer

Same as ref.reinterpret, except that this version does not attach buffer.

Parameters

  • buffer: Buffer
  • size: number
  • offset?: number optional

Returns

Buffer

_reinterpretUntilZeros(buffer: Buffer, size: number, offset?: number): Buffer

Same as ref.reinterpretUntilZeros, except that this version does not attach buffer.

Parameters

  • buffer: Buffer
  • size: number
  • offset?: number optional

Returns

Buffer

_writeObject(buffer: Buffer, offset: number, object: Object)

Same as ref.writeObject, except that this version does not attach object.

Parameters

  • buffer: Buffer
  • offset: number
  • object: Object

_writePointer(buffer: Buffer, offset: number, pointer: Buffer)

Same as ref.writePointer, except that this version does not attach pointer.

Parameters

address(buffer: Buffer): number

Get the memory address of buffer.

Parameters

Returns

number

alloc(type: Type, value?: any): Buffer

Allocate the memory with the given value written to it.

Parameters

  • type: Type
  • value?: any optional

Returns

Buffer

alloc(type: string, value?: any): Buffer

Allocate the memory with the given value written to it.

Parameters

  • type: string
  • value?: any optional

Returns

Buffer

allocCString(string: string, encoding?: string): Buffer

Allocate the memory with the given string written to it with the given encoding (defaults to utf8). The buffer is 1 byte longer than the string itself, and is NULL terminated.

Parameters

  • string: string
  • encoding?: string optional

Returns

Buffer

coerceType(type: Type): Type

Coerce a type.

Parameters

Returns

Type

coerceType(type: string): Type

Coerce a type. String are looked up from the ref.types object.

Parameters

  • type: string

Returns

Type

deref(buffer: Buffer): any

Get value after dereferencing buffer. That is, first it checks the indirection count of buffer's type, and if it's greater than 1 then it merely returns another Buffer, but with one level less indirection.

Parameters

Returns

any

derefType(type: Type): Type

Create clone of the type, with decremented indirection level by 1.

Parameters

Returns

Type

derefType(type: string): Type

Create clone of the type, with decremented indirection level by 1.

Parameters

  • type: string

Returns

Type

get(buffer: Buffer, offset?: number, type?: Type): any

Check the indirection level and return a dereferenced when necessary.

Parameters

  • buffer: Buffer
  • offset?: number optional
  • type?: Type optional

Returns

any

get(buffer: Buffer, offset?: number, type?: string): any

Check the indirection level and return a dereferenced when necessary.

Parameters

  • buffer: Buffer
  • offset?: number optional
  • type?: string optional

Returns

any

getType(buffer: Buffer): Type

Get type of the buffer. Create a default type when none exists.

Parameters

Returns

Type

isNull(buffer: Buffer): boolean

Check the NULL.

Parameters

Returns

boolean

readCString(buffer: Buffer, offset?: number): string

Read C string until the first NULL.

Parameters

  • buffer: Buffer
  • offset?: number optional

Returns

string

readInt64BE(buffer: Buffer, offset?: number): any

Read a big-endian signed 64-bit int. If there is losing precision, then return a string, otherwise a number.

Parameters

  • buffer: Buffer
  • offset?: number optional

Returns

any

readInt64LE(buffer: Buffer, offset?: number): any

Read a little-endian signed 64-bit int. If there is losing precision, then return a string, otherwise a number.

Parameters

  • buffer: Buffer
  • offset?: number optional

Returns

any

readObject(buffer: Buffer, offset?: number): Object

Read a JS Object that has previously been written.

Parameters

  • buffer: Buffer
  • offset?: number optional

Returns

Object

readPointer(buffer: Buffer, offset?: number, length?: number): Buffer

Read data from the pointer.

Parameters

  • buffer: Buffer
  • offset?: number optional
  • length?: number optional

Returns

Buffer

readUInt64BE(buffer: Buffer, offset?: number): any

Read a big-endian unsigned 64-bit int. If there is losing precision, then return a string, otherwise a number.

Parameters

  • buffer: Buffer
  • offset?: number optional

Returns

any

readUInt64LE(buffer: Buffer, offset?: number): any

Read a little-endian unsigned 64-bit int. If there is losing precision, then return a string, otherwise a number.

Parameters

  • buffer: Buffer
  • offset?: number optional

Returns

any

ref(buffer: Buffer): Buffer

Create pointer to buffer.

Parameters

Returns

Buffer

refType(type: Type): Type

Create clone of the type, with incremented indirection level by 1.

Parameters

Returns

Type

refType(type: string): Type

Create clone of the type, with incremented indirection level by 1.

Parameters

  • type: string

Returns

Type

reinterpret(buffer: Buffer, size: number, offset?: number): Buffer

Create buffer with the specified size, with the same address as source. This function "attaches" source to the returned buffer to prevent it from being garbage collected.

Parameters

  • buffer: Buffer
  • size: number
  • offset?: number optional

Returns

Buffer

reinterpretUntilZeros(buffer: Buffer, size: number, offset?: number): Buffer

Scan past the boundary of the buffer's length until it finds size number of aligned NULL bytes.

Parameters

  • buffer: Buffer
  • size: number
  • offset?: number optional

Returns

Buffer

set(buffer: Buffer, offset: number, value: any, type?: Type)

Write pointer if the indirection is 1, otherwise write value.

Parameters

  • buffer: Buffer
  • offset: number
  • value: any
  • type?: Type optional

set(buffer: Buffer, offset: number, value: any, type?: string)

Write pointer if the indirection is 1, otherwise write value.

Parameters

  • buffer: Buffer
  • offset: number
  • value: any
  • type?: string optional

writeCString(buffer: Buffer, offset: number, string: string, encoding?: string)

Write the string as a NULL terminated. Default encoding is utf8.

Parameters

  • buffer: Buffer
  • offset: number
  • string: string
  • encoding?: string optional

writeInt64BE(buffer: Buffer, offset: number, input: number)

Write a big-endian signed 64-bit int.

Parameters

  • buffer: Buffer
  • offset: number
  • input: number

writeInt64BE(buffer: Buffer, offset: number, input: string)

Write a big-endian signed 64-bit int.

Parameters

  • buffer: Buffer
  • offset: number
  • input: string

writeInt64LE(buffer: Buffer, offset: number, input: number)

Write a little-endian signed 64-bit int.

Parameters

  • buffer: Buffer
  • offset: number
  • input: number

writeInt64LE(buffer: Buffer, offset: number, input: string)

Write a little-endian signed 64-bit int.

Parameters

  • buffer: Buffer
  • offset: number
  • input: string

writeObject(buffer: Buffer, offset: number, object: Object)

Write the JS Object. This function "attaches" object to buffer to prevent it from being garbage collected.

Parameters

  • buffer: Buffer
  • offset: number
  • object: Object

writePointer(buffer: Buffer, offset: number, pointer: Buffer)

Write the memory address of pointer to buffer at the specified offset. This function "attaches" object to buffer to prevent it from being garbage collected.

Parameters

writeUInt64BE(buffer: Buffer, offset: number, input: number)

Write a little-endian unsigned 64-bit int.

Parameters

  • buffer: Buffer
  • offset: number
  • input: number

writeUInt64BE(buffer: Buffer, offset: number, input: string)

Write a little-endian unsigned 64-bit int.

Parameters

  • buffer: Buffer
  • offset: number
  • input: string