The type to point to
A pointer type with create(), fromBuffer(), etc.
const IntPtr = POINTER(c_int32);
const buf = Buffer.alloc(4);
buf.writeInt32LE(42, 0);
const p = IntPtr.fromBuffer(buf);
console.log(p.contents.value); // 42
console.log(p[0]); // 42
// Structure fields don't accept POINTER() types directly — use c_void_p,
// then wrap with POINTER().fromAddress() for typed indexed access:
class Column extends Structure {
static _fields_ = [["pValues", c_void_p], ["count", c_uint32]];
}
const pValues = POINTER(ValueStruct).fromAddress(col.pValues);
for (let i = 0; i < col.count; i++) {
console.log(pValues[i].field); // struct view at offset i
}
Lazy base type, for self-referential structs: POINTER(() => Node).
Create a pointer type for a given base type.
Python equivalent:
ctypes.POINTER