Skip to content

Commit e9c9166

Browse files
committed
refactor: Better code files organization
1 parent a31790a commit e9c9166

28 files changed

+1184
-953
lines changed

.vscode/settings.json

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
},
55
"typescript.tsdk": "node_modules\\typescript\\lib",
66
"debug.terminal.clearBeforeReusing": true,
7+
"vsicons.associations.files": [
8+
{
9+
"icon": "rollup",
10+
"extensions": [],
11+
"filenamesGlob": [
12+
"rollup.demos",
13+
],
14+
"extensionsGlob": [ "js" ],
15+
"filename": true,
16+
"format": "svg",
17+
},
18+
],
719
"cSpell.words": [
820
"dllname",
921
"Koffi",

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
],
4747
"scripts": {
4848
"build": "tsc",
49-
"build:demos": "rollup -c",
50-
"clean": "rimraf .tsbuildinfo dist"
49+
"build:demos": "rimraf demos && rollup -c rollup.demos.js",
50+
"clean": "rimraf .tsbuildinfo dist demos",
51+
"test": "echo No test yet",
52+
"prepublishOnly": "npm run clean && npm run build"
5153
},
5254
"dependencies": {
5355
"koffi": "^2.9.0"
File renamed without changes.

source/win32/kernel32.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from './kernel32/_alib.js'
2-
export * from './kernel32/_consts.js'
3-
export * from './kernel32/_functions.js'
1+
export { kernel32 } from './kernel32/_lib.js'
42
export * from './kernel32/module.js'
3+
export * from './kernel32/error.js'

source/win32/kernel32/_consts.ts

-1
This file was deleted.

source/win32/kernel32/_functions.ts

-20
This file was deleted.
File renamed without changes.

source/win32/kernel32/error.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { koffi } from '../../private.js'
2+
import { kernel32 } from './_lib.js'
3+
import { cDWORD } from '../../ctypes.js'
4+
5+
// #region Types
6+
// #endregion
7+
8+
// #region Functions
9+
10+
/**
11+
* Retrieves the calling thread's last-error code value.
12+
*
13+
* https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
14+
*/
15+
export const GetLastError: koffi.KoffiFunc<() => number> = kernel32.lib.func('GetLastError', cDWORD, [])
16+
17+
// #endregion
18+
19+
// #region Constants
20+
// #endregion

source/win32/kernel32/module.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
import { koffi } from '../../private.js'
2-
import { cHINSTANCE, type HINSTANCE } from '../../ctypes.js'
2+
import { kernel32 } from './_lib.js'
3+
import { cHINSTANCE, cLPCWSTR, type HINSTANCE } from '../../ctypes.js'
4+
5+
// #region Types
36

47
export const cHMODULE = koffi.alias('HMODULE', cHINSTANCE)
58
export type HMODULE = HINSTANCE
9+
10+
// #endregion
11+
12+
// #region Functions
13+
14+
/**
15+
* Retrieves a module handle for the specified module.
16+
*
17+
* https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlew
18+
*/
19+
export const GetModuleHandleW: koffi.KoffiFunc<(
20+
lpModuleName: string | null
21+
) => HMODULE> = kernel32.lib.func('GetModuleHandleW', cHMODULE, [ cLPCWSTR ])
22+
23+
// #endregion
24+
25+
// #region Constants
26+
// #endregion

source/win32/user32.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
export * from './user32/_alib.js'
2-
export * from './user32/_consts.js'
3-
export * from './user32/_functions.js'
1+
export { user32 } from './user32/_lib.js'
42
export * from './user32/point.js'
53
export * from './user32/rect.js'
64
export * from './user32/size.js'
7-
export * from './user32/minmaxinfo.js'
5+
export * from './user32/class.js'
86
export * from './user32/icon.js'
97
export * from './user32/cursor.js'
8+
export * from './user32/image.js'
109
export * from './user32/brush.js'
1110
export * from './user32/menu.js'
1211
export * from './user32/window.js'
13-
export * from './user32/msg.js'
12+
// export * from './user32/dialog.js'
13+
export * from './user32/message.js'
14+
export * from './user32/messagebox.js'
15+
export * from './user32/misc.js'

0 commit comments

Comments
 (0)