node-ctypes - v2.10.0
    Preparing search index...

    Function POINTER

    • Create a pointer type for a given base type.

      Python equivalent: ctypes.POINTER

      Type Parameters

      Parameters

      • baseType: T

        The type to point to

      Returns PointerTypeDef<T>

      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).

      Type Parameters

      Parameters

      • baseType: () => T

      Returns PointerTypeDef<T>