Skip to content

Commit

Permalink
feat: remove types T.LPMSG, T.LPPOINT
Browse files Browse the repository at this point in the history
use S.LPMSG, S.LPPOINT instead

api:
- ClientToScreen()
- DispatchMessageW()
- GetMessageW()
- PeekMessageW()
  • Loading branch information
waitingsong committed Jun 30, 2024
1 parent a11f8b0 commit 1d7e972
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/win32-api/src/lib/user32/dict/CD.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class User32_C extends User32_B {
lpVoid: T.LPVOID,
) => T.LONG

ClientToScreen: (hWnd: T.HWND, lpPoint: T.LPPOINT) => T.BOOL
ClientToScreen: (hWnd: T.HWND, lpPoint: S.POINT_Type) => T.BOOL

/** https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-closewindow */
CloseWindow: (hWnd: T.HWND) => T.BOOL
Expand Down Expand Up @@ -47,7 +47,7 @@ export class User32_D extends User32_C {
DestroyWindow: (hWnd: T.HWND) => T.BOOL

/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessagew */
DispatchMessageW: (lpMsg: T.LPMSG) => T.LRESULT
DispatchMessageW: (lpMsg: S.MSG_Type) => T.LRESULT

}

Expand Down
3 changes: 2 additions & 1 deletion packages/win32-api/src/lib/user32/dict/G.def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class DefUser32_G extends DefUser32_F {
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getclasslongptrw */
static GetClassLongPtrW = [D.ULONG_PTR, [D.HWND, D.INT]]

static GetMessageW = [D.BOOL, [D.LPMSG, D.HWND, D.UINT, D.UINT]]
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessagew */
static GetMessageW = [D.BOOL, [`_Out_ ${S.LPMSG}`, D.HWND, D.UINT, D.UINT]]

static GetParent = [D.HWND, [D.HWND]]

Expand Down
7 changes: 4 additions & 3 deletions packages/win32-api/src/lib/user32/dict/G.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export class User32_G extends User32_F {

/**
* Copies the caret's position to the specified POINT structure.
* @link https://leran.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcaretpos
* @link https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcaretpos
*/
GetCaretPos: (lpPoint: T.LPPOINT) => T.BOOL
GetCaretPos: (lpPoint: S.POINT_Type) => T.BOOL

/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassinfoexw */
GetClassInfoExW: (hinst: T.HINSTANCE, lpszClass: T.LPCTSTR, LPWNDCLASSEX: S.WNDCLASSEXW_Type) => T.BOOL
Expand All @@ -39,7 +39,8 @@ export class User32_G extends User32_F {
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getclasslongptrw */
GetClassLongPtrW: (hWnd: T.HWND, nIndex: T.INT) => T.ULONG_PTR

GetMessageW: (lpMsg: T.LPMSG, HWND: T.HWND, wMsgFilterMin: T.UINT, wMsgFilterMax: T.UINT) => T.BOOL
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessagew */
GetMessageW: (lpMsg: S.MSG_Type, HWND: T.HWND, wMsgFilterMin: T.UINT, wMsgFilterMax: T.UINT) => T.BOOL

GetParent: (hWnd: T.HWND) => T.HWND

Expand Down
3 changes: 2 additions & 1 deletion packages/win32-api/src/lib/user32/dict/PR.def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { DefUser32_M } from './IM.def.js'

export class DefUser32_P extends DefUser32_M {

static PeekMessageW = [D.BOOL, [D.LPMSG, D.HWND, D.UINT, D.UINT, D.UINT]]
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-peekmessagew */
static PeekMessageW = [D.BOOL, [`_Out_ ${S.LPMSG}`, D.HWND, D.UINT, D.UINT, D.UINT]]

/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postmessagew */
static PostMessageW = [D.BOOL, [D.HWND, D.UINT, D.WPARAM, D.LPARAM]]
Expand Down
3 changes: 2 additions & 1 deletion packages/win32-api/src/lib/user32/dict/PR.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { User32_M } from './IM.types.js'

export class User32_P extends User32_M {

/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-peekmessagew */
PeekMessageW: (
lpMsg: T.LPMSG,
lpMsg: S.MSG_Type,
HWND: T.HWND,
wMsgFilterMin: T.UINT,
wMsgFilterMax: T.UINT,
Expand Down
3 changes: 1 addition & 2 deletions packages/win32-def/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export class DefWin32 extends Def_B implements T.LibDefBase {
}

export class Win32 implements T.LibDef2Type<typeof DefWin32> {
// test fake struct LPPOINT
ClientToScreen: (hWnd: T.HWND, lpPoint: T.LPPOINT) => T.BOOL
ClientToScreen: (hWnd: T.HWND, lpPoint: S.POINT_Type) => T.BOOL

EnumDisplayDevicesW: (
lpDevice: T.LPCWSTR | null,
Expand Down
1 change: 0 additions & 1 deletion packages/win32-def/src/lib/common.def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const LPDWORD: Def.uint16Ptr = Def.uint16Ptr
export const LPHANDLE: Def.int32Ptr | Def.int64Ptr = _WIN64 ? Def.int64Ptr : Def.int32Ptr
export const LPINT: Def.uint32Ptr | Def.uint64Ptr = ptr
export const LPLONG: Def.int32Ptr = Def.int32Ptr
export const LPMSG: Def.uint32Ptr | Def.uint64Ptr = ptr
export const LPSTR: Def.charPtr = Def.charPtr
export const LPWSTR: Def.uint16Ptr = Def.uint16Ptr
export const LPTSTR: Def.uint16Ptr = Def.uint16Ptr
Expand Down
2 changes: 0 additions & 2 deletions packages/win32-def/src/lib/common.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ export type LPDWORD = PUINT16 | string
export type LPHANDLE = _POINTER
export type LPINT = PINT
export type LPLONG = PINT32
export type LPMSG = _POINTER
export type LPPOINT = _POINTER
export type LPSTR = _POINTER | string
export type LPWSTR = PUINT16 | string
export type LPTSTR = _POINTER | string
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/def.class/api.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DefWin32Fake implements T.LibDefBase {

export class Win32 implements T.LibDef2Type<typeof DefWin32> {
// test fake struct LPPOINT
ClientToScreen: (hWnd: T.HWND, lpPoint: T.LPPOINT) => T.BOOL
ClientToScreen: (hWnd: T.HWND, lpPoint: S.POINT_Type) => T.BOOL

EnumDisplayDevicesW: (
lpDevice: T.LPCWSTR | null,
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/def.const/api.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Win32Fns {
) => T.BOOL

// test fake struct
ClientToScreen: (hWnd: T.HWND, lpPoint: T.LPPOINT) => T.BOOL
ClientToScreen: (hWnd: T.HWND, lpPoint: S.POINT_Type) => T.BOOL
}

// skip ClientToScreen
Expand Down

0 comments on commit 1d7e972

Please sign in to comment.