Skip to content

Commit 624e961

Browse files
triasbratasentialx
authored andcommitted
fix compile in 32bit (#14)
1 parent fa95b5e commit 624e961

File tree

9 files changed

+112
-22
lines changed

9 files changed

+112
-22
lines changed

.clang-format

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
AccessModifierOffset: 0
2+
AlignEscapedNewlinesLeft: true
3+
AlignTrailingComments: false
4+
AllowAllParametersOfDeclarationOnNextLine: false
5+
AllowShortFunctionsOnASingleLine: false
6+
AllowShortIfStatementsOnASingleLine: true
7+
AllowShortLoopsOnASingleLine: false
8+
AlwaysBreakBeforeMultilineStrings: false
9+
AlwaysBreakTemplateDeclarations: false
10+
BinPackParameters: false
11+
BreakBeforeBinaryOperators: false
12+
BreakBeforeBraces: Attach
13+
BreakBeforeTernaryOperators: false
14+
BreakConstructorInitializersBeforeComma: false
15+
ColumnLimit: 100
16+
CommentPragmas: ''
17+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
18+
ConstructorInitializerIndentWidth: 0
19+
ContinuationIndentWidth: 0
20+
Cpp11BracedListStyle: false
21+
DerivePointerBinding: false
22+
IndentCaseLabels: false
23+
IndentFunctionDeclarationAfterType: false
24+
IndentWidth: 4
25+
Language: Cpp
26+
MaxEmptyLinesToKeep: 2
27+
NamespaceIndentation: None
28+
ObjCSpaceAfterProperty: true
29+
ObjCSpaceBeforeProtocolList: true
30+
PenaltyBreakBeforeFirstCallParameter: 100
31+
PenaltyBreakComment: 100
32+
PenaltyBreakFirstLessLess: 0
33+
PenaltyBreakString: 100
34+
PenaltyExcessCharacter: 1
35+
PenaltyReturnTypeOnItsOwnLine: 20
36+
PointerBindsToType: true
37+
SpaceBeforeAssignmentOperators: true
38+
SpaceBeforeParens: Always
39+
SpaceInEmptyParentheses: false
40+
SpacesBeforeTrailingComments: 1
41+
SpacesInAngles: false
42+
SpacesInCStyleCastParentheses: false
43+
SpacesInContainerLiterals: false
44+
SpacesInParentheses: false
45+
Standard: Cpp11
46+
TabWidth: 4
47+
UseTab: Never

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "lldb",
9+
"request": "launch",
10+
"name": "Debug",
11+
"program": "C://nodejs/node.exe",
12+
"preLaunchTask": "npm: prepublishOnly-dev",
13+
"args": ".//example.js",
14+
"env": {
15+
"NODE_ENV": "dev"
16+
},
17+
"cwd": "${workspaceFolder}"
18+
}
19+
]
20+
}

.vscode/tasks.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "build",
9+
"problemMatcher": []
10+
},
11+
{
12+
"type": "npm",
13+
"script": "rebuild",
14+
"problemMatcher": []
15+
},
16+
{
17+
"type": "npm",
18+
"script": "prepublishOnly",
19+
"problemMatcher": [],
20+
"group": {
21+
"kind": "build",
22+
"isDefault": true
23+
},
24+
},
25+
]
26+
}

example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { windowManager } = require("./dist/index");
33
console.time("getActiveWindow");
44
const window = windowManager.getActiveWindow();
55
console.timeEnd("getActiveWindow");
6-
6+
console.log(windowManager.getWindows());
77
console.time("getTitle");
88
console.log(window.getTitle());
99
console.timeEnd("getTitle");

lib/windows.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,15 @@ Napi::Array getWindows(const Napi::CallbackInfo &info) {
8484
_windows.clear();
8585
EnumWindows(&EnumWindowsProc, NULL);
8686

87-
auto arr = Napi::Array::New(env, _windows.size());
88-
89-
for (int i = 0; i < _windows.size(); i++) {
90-
auto obj{Napi::Object::New(env)};
91-
92-
obj.Set("id", _windows[i].id);
93-
obj.Set("processId", _windows[i].process.pid);
94-
obj.Set("path", _windows[i].process.path);
95-
96-
arr[i] = obj;
87+
auto arr = Napi::Array::New (env);
88+
auto i = 0;
89+
for (auto _win : _windows) {
90+
if (_win.process.path.empty ()) continue;
91+
auto obj{ Napi::Object::New (env) };
92+
obj.Set("id", _win.id);
93+
obj.Set("processId", _win.process.pid);
94+
obj.Set("path", _win.process.path);
95+
arr.Set(i++, obj);
9796
}
9897

9998
return arr;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"watch": "tsc --watch",
1010
"install": "npm run rebuild",
1111
"rebuild": "node-gyp rebuild",
12-
"prepublishOnly": "npm run build && npm run rebuild"
12+
"prepublishOnly": "npm run build && npm run rebuild",
13+
"prepublishOnly-dev": "npm run build && npm run rebuild -- --debug"
1314
},
1415
"repository": {
1516
"type": "git",
@@ -36,10 +37,5 @@
3637
"dependencies": {
3738
"node-addon-api": "1.6.3",
3839
"node-gyp": "5.0.0"
39-
},
40-
"files": [
41-
"dist/",
42-
"binding.gyp",
43-
"lib/"
44-
]
45-
}
40+
}
41+
}

src/classes/window.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { windowManager } from "..";
44
let addon: any;
55

66
if (platform() === "win32" || platform() === "darwin") {
7-
addon = require("../../build/Release/addon.node");
7+
let path_addon: string = (process.env.NODE_ENV != "dev") ? "Release" : "Debug";
8+
addon = require(`../../build/${path_addon}/addon.node`);
89
}
910

1011
interface Rectangle {

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { platform, release } from "os";
55
let addon: any;
66

77
if (platform() === "win32" || platform() === "darwin") {
8-
addon = require("../build/Release/addon.node");
8+
let path_addon: string = (process.env.NODE_ENV != "dev") ? "Release" : "Debug";
9+
addon = require(`../build/${path_addon}/addon.node`);
910
}
1011

1112
let interval: any = null;

0 commit comments

Comments
 (0)