node-ctypes - v2.17.1
    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
      class Column extends Structure {
      static _fields_ = [["pValues", POINTER(ValueStruct)], ["count", c_uint32]];
      }
      const pValues = col.pValues; // a POINTER(ValueStruct) over the field
      for (let i = 0; i < col.count; i++) {
      console.log(pValues[i].field); // struct view at offset i
      }
      // A c_void_p field holds an address: POINTER(ValueStruct).fromAddress(col.pRaw)
    • Lazy base type, for self-referential structs: POINTER(() => Node).

      Type Parameters

      Parameters

      • baseType: () => T

      Returns PointerTypeDef<T>

    • Python 3.14 incomplete pointer type POINTER('Name') (deprecated, as in CPython: a DeprecationWarning, code NODE_CTYPES_POINTER_STRING, is emitted once per process): the same type per name, usable as a field or parameter type and with from_buffer() / from_address(); creating an instance throws TypeError Cannot create instance: has no _type_ until set_type(T) completes it.

      Parameters

      • name: string

      Returns PointerTypeDef<any>

    • Python ctypes: POINTER(None) returns c_void_p.

      Parameters

      • baseType: null

      Returns SimpleCDataConstructor<"pointer">