import { IKoffiCType } from 'koffi'; /** * A nominal type is a type that is defined by its name, rather than its structure. This allows us to take * multiple C types that would otherwise map to the same TypeScript (JavaScript) type and treat them as * distinct types. * * For example, `int`, `unsigned int`, `long`, etc. are all distinct types with their own meaning and own * features in C, however in TypeScript they all map to `number`. By using nominal types, we can make * TypeScript display an error when you try to use an `Int` type in a function that expects an * `UnsignedInt` type for example. * * Note that there is no runtime safety to this! This is purely a compile-time check to help you catch errors * early. For example, if a C function expects an `unsigned int` and you pass in a positive `int` ignoring * the TypeScript error, it will work fine at runtime. If you however try to pass a negative `int`, you will * get a runtime error. * * **You have been warned!** * * @template T The underlying TypeScript type. * @template U The name of the nominal type. * * @example * * type Int = Nominal; * type UnsignedInt = Nominal; * * function add(a: Int, b: Int): Int { * return a + b; * } * * const one: Int = 123; * const two: Int = 456; * const three: UnsignedInt = 789; * * add(one, two); // OK * add(one, three); // Error */ export type Nominal = T & { [Symbol.species]?: U; __jsType?: T; }; export type JsType> = NonNullable; export type CType> = NonNullable; export type Win32Type | null> = IKoffiCType & { __jsType?: JsType>; [Symbol.species]?: CType>; }; export declare const AU3_INTDEFAULT = -2147483647; export declare const SW_SHOWNORMAL = 1; export declare const BOOL: Win32Type; export declare const BYTE: Win32Type; export declare const CHAR: Win32Type; export declare const DWORD: Win32Type; export declare const INT: Win32Type; export declare const UINT: Win32Type; export declare const UINT_PTR: Win32Type; export declare const WCHAR: Win32Type; export declare const LONG: Win32Type; export declare const LONG_PTR: Win32Type; export declare const VOID: Win32Type; export declare const WORD: Win32Type; export declare const PVOID: Win32Type; export declare const LPARAM: Win32Type; export declare const LRESULT: Win32Type; export declare const WPARAM: Win32Type; export declare const LPCSTR: Win32Type; export declare const LPWSTR: Win32Type; export declare const LPCWSTR: Win32Type; export declare const LPVOID: Win32Type; export declare const HANDLE: Win32Type; export declare const HBITMAP: Win32Type; export declare const HDC: Win32Type; export declare const HINSTANCE: Win32Type; export declare const HMENU: Win32Type; export declare const HWND: Win32Type; export type Bool = Nominal; export type Byte = Nominal; export type Char = Nominal; export type DoubleWord = Nominal; export type Int = Nominal; export type UnsignedInt = Nominal; export type UnsignedIntPointer = Nominal; export type WideChar = Nominal; export type Long = Nominal; export type LongPointer = Nominal; export type Void = Nominal; export type Word = Nominal; export type PointerToVoid = Nominal; export type LongParam = Nominal; export type LongResult = Nominal; export type WordParam = Nominal; export type LongPointerToConstantString = Nominal; export type LongPointerToWideString = Nominal; export type LongPointerToConstantWideString = Nominal; export type LongPointerToVoid = Nominal; export type Handle = Nominal; export type BitmapHandle = Nominal, 'HBITMAP'>; export type DeviceContextHandle = Nominal, 'HDC'>; export type InstanceHandle = Nominal, 'HINSTANCE'>; export type MenuHandle = Nominal, 'HMENU'>; export type WindowHandle = Nominal, 'HWND'>;