From 543110511035d79381f51bd8ce8b6ba75de4a5aa Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 14 Jun 2024 02:57:36 -0700 Subject: [PATCH 1/5] build: fix clangd IDE intelligence --- .clangd | 2 ++ package.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 00000000..0aab8235 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + CompilationDatabase: build/Debug diff --git a/package.json b/package.json index b0b3e68f..32db528a 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,8 @@ "build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser", "deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"", "prebuild": "run-s build.js && node ./script/prebuild.js", - "build.native": "node-gyp configure --release && node-gyp build --release", - "build.native.debug": "cross-env CMAKE_BUILD_TYPE=Debug node-gyp configure --debug && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug", + "build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release", + "build.native.debug": "node-gyp configure --debug && node-gyp configure --debug -- -f compile_commands_json && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug", "build": "run-s build.js build.native", "build.debug": "run-s build.js build.native.debug", "test": "run-s build && mocha --exit", From d2d7dc4801b7ccdf524f3f9f84ea7e3828e4b22c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 14 Jun 2024 02:57:47 -0700 Subject: [PATCH 2/5] build: run the libzmq builds in parallel --- script/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/build.ts b/script/build.ts index fe93c10b..b342e18c 100644 --- a/script/build.ts +++ b/script/build.ts @@ -82,7 +82,7 @@ function main() { console.log(cmake_configure) exec(cmake_configure, execOptions) - const cmake_build = `cmake --build ./build --config ${CMAKE_BUILD_TYPE} --target install` + const cmake_build = `cmake --build ./build --config ${CMAKE_BUILD_TYPE} --target install --parallel` console.log(cmake_build) exec(cmake_build, execOptions) From 26bea83b3cf2b9fe211c162bced9d8bfe7af1224 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 14 Jun 2024 02:58:22 -0700 Subject: [PATCH 3/5] build: fix the build warnings due to NAPI_VERSION --- src/prefix.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/prefix.h b/src/prefix.h index edd26dc1..ae9c4b6f 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -2,8 +2,6 @@ #pragma once #include -#include -#define NAPI_BUILD_VERSION NAPI_VERSION #include #if ZMQ_VERSION < ZMQ_MAKE_VERSION(4, 1, 0) From 4369f64058836a8662dd1c9d812e249df91924ce Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 14 Jun 2024 03:10:02 -0700 Subject: [PATCH 4/5] build: install weak-napi only for the tests --- package.json | 9 +++--- pnpm-lock.yaml | 43 ------------------------ test/package.json | 6 ++++ test/pnpm-lock.yaml | 79 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 48 deletions(-) create mode 100644 test/package.json create mode 100644 test/pnpm-lock.yaml diff --git a/package.json b/package.json index 32db528a..5a8f6363 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@types/node": "^18.19.34", "@types/semver": "^7.5.8", "@types/shelljs": "^0.8.15", - "@types/weak-napi": "^2.0.3", "@types/which": "^2.0.2", "benchmark": "^2.1.4", "chai": "^4.4.1", @@ -54,7 +53,6 @@ "ts-node": "~10.9.2", "typedoc": "^0.25.13", "typescript": "~4.9.5", - "weak-napi": "^2.0.2", "which": "^3.0.1" }, "pnpm": { @@ -95,9 +93,10 @@ "build.native.debug": "node-gyp configure --debug && node-gyp configure --debug -- -f compile_commands_json && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug", "build": "run-s build.js build.native", "build.debug": "run-s build.js build.native.debug", - "test": "run-s build && mocha --exit", - "test.skip_gc_tests": "run-s build.debug && cross-env SKIP_GC_TESTS=true mocha --exit", - "test.electron.main": "run-s build && electron-mocha", + "test.deps": "cd test && pnpm install && cd ..", + "test": "run-s test.deps build && mocha --exit", + "test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit", + "test.electron.main": "run-s test.deps build && electron-mocha", "format": "prettier --write .", "test.electron.renderer": "run-s build && electron-mocha --renderer", "lint.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4a1b04d8..590fd51d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -115,9 +115,6 @@ importers: typescript: specifier: ~4.9.5 version: 4.9.5 - weak-napi: - specifier: ^2.0.2 - version: 2.0.2 which: specifier: ^3.0.1 version: 3.0.1 @@ -1741,12 +1738,6 @@ packages: resolution: {integrity: sha512-g0QYk1dZBxGwk+Ngc+ltRH2IBp2f7zBkBMBJZCDerh6EhlhSR6+9irMCuT/09zD6qkarHUSn529sK/yL4S27mg==} engines: {node: '>= 0.4'} - get-symbol-from-current-process-h@1.0.2: - resolution: {integrity: sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==} - - get-uv-event-loop-napi-h@1.0.6: - resolution: {integrity: sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==} - gh-pages@4.0.0: resolution: {integrity: sha512-p8S0T3aGJc68MtwOcZusul5qPSNZCalap3NWbhRUZYu1YOdp+EjZ+4kPmRM8h3NNRdqw00yuevRjlkuSzCn7iQ==} engines: {node: '>=10'} @@ -2525,17 +2516,10 @@ packages: node-addon-api@1.7.2: resolution: {integrity: sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==} - node-addon-api@3.2.1: - resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==} - node-addon-api@7.1.0: resolution: {integrity: sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==} engines: {node: ^16 || ^18 || >= 20} - node-gyp-build@4.5.0: - resolution: {integrity: sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==} - hasBin: true - node-gyp@10.0.1: resolution: {integrity: sha512-gg3/bHehQfZivQVfqIyy8wTdSymF9yTyP4CJifK73imyNMU8AIGQE2pUa7dNWfmMeG9cDVF2eehiRMv0LC1iAg==} engines: {node: ^16.14.0 || >=18.0.0} @@ -3174,9 +3158,6 @@ packages: resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} engines: {node: '>= 0.4'} - setimmediate-napi@1.0.6: - resolution: {integrity: sha512-sdNXN15Av1jPXuSal4Mk4tEAKn0+8lfF9Z50/negaQMrAIO9c1qM0eiCh8fT6gctp0RiCObk+6/Xfn5RMGdZoA==} - shebang-command@1.2.0: resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} engines: {node: '>=0.10.0'} @@ -3659,9 +3640,6 @@ packages: vscode-uri@3.0.6: resolution: {integrity: sha512-fmL7V1eiDBFRRnu+gfRWTzyPpNIHJTc4mWnFkwBUmO9U3KPgJAmTx7oxi2bl/Rh6HLdU7+4C9wlj0k2E4AdKFQ==} - weak-napi@2.0.2: - resolution: {integrity: sha512-LcOSVFrghtVXf4QH+DLIy8iPiCktV7lVbqRDYP+bDPpLzC41RCHQPMyQOnPpWO41Ie4CmnDxS+mbL72r5xFMMQ==} - which-boxed-primitive@1.0.2: resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} @@ -5887,12 +5865,6 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.2.4 - get-symbol-from-current-process-h@1.0.2: {} - - get-uv-event-loop-napi-h@1.0.6: - dependencies: - get-symbol-from-current-process-h: 1.0.2 - gh-pages@4.0.0: dependencies: async: 2.6.4 @@ -6738,12 +6710,8 @@ snapshots: node-addon-api@1.7.2: {} - node-addon-api@3.2.1: {} - node-addon-api@7.1.0: {} - node-gyp-build@4.5.0: {} - node-gyp@10.0.1: dependencies: env-paths: 2.2.1 @@ -7419,11 +7387,6 @@ snapshots: functions-have-names: 1.2.3 has-property-descriptors: 1.0.2 - setimmediate-napi@1.0.6: - dependencies: - get-symbol-from-current-process-h: 1.0.2 - get-uv-event-loop-napi-h: 1.0.6 - shebang-command@1.2.0: dependencies: shebang-regex: 1.0.0 @@ -7967,12 +7930,6 @@ snapshots: vscode-uri@3.0.6: {} - weak-napi@2.0.2: - dependencies: - node-addon-api: 3.2.1 - node-gyp-build: 4.5.0 - setimmediate-napi: 1.0.6 - which-boxed-primitive@1.0.2: dependencies: is-bigint: 1.0.4 diff --git a/test/package.json b/test/package.json new file mode 100644 index 00000000..dd32cba0 --- /dev/null +++ b/test/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "@types/weak-napi": "^2.0.3", + "weak-napi": "^2.0.2" + } +} diff --git a/test/pnpm-lock.yaml b/test/pnpm-lock.yaml new file mode 100644 index 00000000..cb54e0d3 --- /dev/null +++ b/test/pnpm-lock.yaml @@ -0,0 +1,79 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@types/weak-napi': + specifier: ^2.0.3 + version: 2.0.3 + weak-napi: + specifier: ^2.0.2 + version: 2.0.2 + +packages: + + '@types/node@20.14.2': + resolution: {integrity: sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==} + + '@types/weak-napi@2.0.3': + resolution: {integrity: sha512-hNh8wxRTaQC8gLT6BKkG5Kokwp4hEyWw4RshGTLwa1K4S1o6kX7G0bJ85kKr+2fK3fuF8HZuz1+Dy8YtICZDqg==} + + get-symbol-from-current-process-h@1.0.2: + resolution: {integrity: sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==} + + get-uv-event-loop-napi-h@1.0.6: + resolution: {integrity: sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==} + + node-addon-api@3.2.1: + resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==} + + node-gyp-build@4.8.1: + resolution: {integrity: sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==} + hasBin: true + + setimmediate-napi@1.0.6: + resolution: {integrity: sha512-sdNXN15Av1jPXuSal4Mk4tEAKn0+8lfF9Z50/negaQMrAIO9c1qM0eiCh8fT6gctp0RiCObk+6/Xfn5RMGdZoA==} + + undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + + weak-napi@2.0.2: + resolution: {integrity: sha512-LcOSVFrghtVXf4QH+DLIy8iPiCktV7lVbqRDYP+bDPpLzC41RCHQPMyQOnPpWO41Ie4CmnDxS+mbL72r5xFMMQ==} + +snapshots: + + '@types/node@20.14.2': + dependencies: + undici-types: 5.26.5 + + '@types/weak-napi@2.0.3': + dependencies: + '@types/node': 20.14.2 + + get-symbol-from-current-process-h@1.0.2: {} + + get-uv-event-loop-napi-h@1.0.6: + dependencies: + get-symbol-from-current-process-h: 1.0.2 + + node-addon-api@3.2.1: {} + + node-gyp-build@4.8.1: {} + + setimmediate-napi@1.0.6: + dependencies: + get-symbol-from-current-process-h: 1.0.2 + get-uv-event-loop-napi-h: 1.0.6 + + undici-types@5.26.5: {} + + weak-napi@2.0.2: + dependencies: + node-addon-api: 3.2.1 + node-gyp-build: 4.8.1 + setimmediate-napi: 1.0.6 From 7c747636eb4e1e678d279d7143064ee392dc8e61 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 14 Jun 2024 03:40:53 -0700 Subject: [PATCH 5/5] fix: clean-up the includes in C++ files --- .clang-format | 18 ++++++++++++++++-- .eslintrc | 4 +++- .prettierignore | 1 + src/closable.h | 9 +++++++++ src/context.cc | 10 ++++++---- src/context.h | 4 +++- src/incoming_msg.cc | 4 +++- src/incoming_msg.h | 4 +++- src/inline.h | 7 +++++++ src/module.cc | 15 +++++++++------ src/module.h | 15 ++++----------- src/observer.cc | 13 ++++++------- src/observer.h | 8 +++++--- src/outgoing_msg.cc | 4 ++-- src/outgoing_msg.h | 4 +++- src/proxy.cc | 8 ++++---- src/proxy.h | 5 ++++- src/socket.cc | 21 +++++++++++---------- src/socket.h | 10 +++++----- src/util/arguments.h | 4 +++- src/util/async_scope.h | 2 ++ src/util/electron_helper.h | 1 + src/util/error.h | 5 +++++ src/util/object.h | 2 ++ src/util/reaper.h | 1 + src/util/to_string.h | 2 ++ src/util/trash.h | 6 +++--- src/util/uvhandle.h | 3 ++- src/util/uvloop.h | 5 +++++ src/{prefix.h => zmq_inc.h} | 22 ++-------------------- test/.eslintrc | 3 ++- test/package.json | 8 ++++---- 32 files changed, 138 insertions(+), 90 deletions(-) create mode 100644 src/closable.h create mode 100644 src/inline.h rename src/{prefix.h => zmq_inc.h} (60%) diff --git a/.clang-format b/.clang-format index 7faa88f4..4ca9e18b 100644 --- a/.clang-format +++ b/.clang-format @@ -56,7 +56,7 @@ SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 -SpacesInAngles: false +SpacesInAngles: "Never" SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false @@ -64,5 +64,19 @@ SpacesInSquareBrackets: false Standard: Auto TabWidth: 4 UseTab: Never ---- +IncludeBlocks: Regroup +IncludeCategories: + # # Specific external headers in <> to put first + - Regex: "<(catch2|gtest).*>" + Priority: 1 + # External headers in <> with extension or / + - Regex: '<[-\w\/-_]+[\.\/][-\w\/-_]+>' + Priority: 2 + # Standard headers in <> + - Regex: '<[-\w\/-_]+>' + Priority: 3 + # Local headers in "" + - Regex: '"[-\w\/-_]*"' + Priority: 4 +SortUsingDeclarations: true diff --git a/.eslintrc b/.eslintrc index 0e34faea..ff805017 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,8 @@ "v5-compat.d.ts", "draft.d.ts", "script/*.js", - "script/*.d.ts" + "script/*.d.ts", + "docs/", + "docs-raw/" ] } diff --git a/.prettierignore b/.prettierignore index 210ad4e4..d1955fc5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,4 @@ /prebuilds /node_modules pnpm-lock.yaml +/build diff --git a/src/closable.h b/src/closable.h new file mode 100644 index 00000000..891ebf7f --- /dev/null +++ b/src/closable.h @@ -0,0 +1,9 @@ +#pragma once + +/* A thing that can be closed. Simple interface to allow us to correctly clean + up ZMQ resources at agent exit. */ +namespace zmq { +struct Closable { + virtual void Close() = 0; +}; +} diff --git a/src/context.cc b/src/context.cc index 9712efb9..e61db5ee 100644 --- a/src/context.cc +++ b/src/context.cc @@ -1,9 +1,11 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ -#include "context.h" -#include "module.h" -#include "socket.h" +#include "./context.h" -#include "util/uvwork.h" +#include "./module.h" +#include "./socket.h" +#include "util/arguments.h" +#include "util/error.h" +#include "util/object.h" namespace zmq { Context::Context(const Napi::CallbackInfo& info) diff --git a/src/context.h b/src/context.h index 9da578d4..3a5913b1 100644 --- a/src/context.h +++ b/src/context.h @@ -1,7 +1,9 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" +#include + +#include "closable.h" namespace zmq { class Module; diff --git a/src/incoming_msg.cc b/src/incoming_msg.cc index 6974c8bf..282bf28f 100644 --- a/src/incoming_msg.cc +++ b/src/incoming_msg.cc @@ -1,5 +1,7 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ -#include "incoming_msg.h" +#include "./incoming_msg.h" + +#include #include "util/electron_helper.h" #include "util/error.h" diff --git a/src/incoming_msg.h b/src/incoming_msg.h index 368de329..5febfbc4 100644 --- a/src/incoming_msg.h +++ b/src/incoming_msg.h @@ -1,7 +1,9 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" +#include + +#include "./zmq_inc.h" namespace zmq { class IncomingMsg { diff --git a/src/inline.h b/src/inline.h new file mode 100644 index 00000000..bb8a7b0d --- /dev/null +++ b/src/inline.h @@ -0,0 +1,7 @@ +#pragma once + +#ifdef _MSC_VER +#define force_inline inline __forceinline +#else +#define force_inline inline __attribute__((always_inline)) +#endif diff --git a/src/module.cc b/src/module.cc index 551f1d38..3743502d 100644 --- a/src/module.cc +++ b/src/module.cc @@ -1,10 +1,13 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ -#include "module.h" -#include "context.h" -#include "observer.h" -#include "outgoing_msg.h" -#include "proxy.h" -#include "socket.h" +#include "./module.h" + +#include "./context.h" +#include "./observer.h" +#include "./outgoing_msg.h" +#include "./proxy.h" +#include "./socket.h" +#include "util/error.h" +#include "util/to_string.h" namespace zmq { static inline Napi::String Version(const Napi::Env& env) { diff --git a/src/module.h b/src/module.h index fb6451ee..7028070e 100644 --- a/src/module.h +++ b/src/module.h @@ -1,21 +1,14 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" - -#include "outgoing_msg.h" +#include +#include -#include "util/arguments.h" -#include "util/error.h" -#include "util/object.h" +#include "./closable.h" +#include "./outgoing_msg.h" #include "util/reaper.h" -#include "util/to_string.h" #include "util/trash.h" -#include -#include -#include - namespace zmq { class Context; class Socket; diff --git a/src/observer.cc b/src/observer.cc index b8652340..d470f960 100644 --- a/src/observer.cc +++ b/src/observer.cc @@ -1,15 +1,14 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ -#include "observer.h" -#include "context.h" -#include "module.h" -#include "socket.h" +#include "./observer.h" -#include "incoming_msg.h" +#include "./context.h" +#include "./module.h" +#include "./socket.h" +#include "util/arguments.h" #include "util/async_scope.h" +#include "util/error.h" #include "util/take.h" -#include - namespace zmq { static inline constexpr const char* EventName(uint32_t val) { switch (val) { diff --git a/src/observer.h b/src/observer.h index c4b8bc6a..1b34dedb 100644 --- a/src/observer.h +++ b/src/observer.h @@ -1,12 +1,14 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" - -#include "poller.h" +#include #include +#include "./closable.h" +#include "./inline.h" +#include "./poller.h" + namespace zmq { class Module; diff --git a/src/outgoing_msg.cc b/src/outgoing_msg.cc index 2cafab30..269e850e 100644 --- a/src/outgoing_msg.cc +++ b/src/outgoing_msg.cc @@ -1,7 +1,7 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ -#include "outgoing_msg.h" -#include "module.h" +#include "./outgoing_msg.h" +#include "./module.h" #include "util/error.h" namespace zmq { diff --git a/src/outgoing_msg.h b/src/outgoing_msg.h index a13eb138..6ec12609 100644 --- a/src/outgoing_msg.h +++ b/src/outgoing_msg.h @@ -1,10 +1,12 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" +#include #include +#include "./zmq_inc.h" + namespace zmq { class Module; diff --git a/src/proxy.cc b/src/proxy.cc index 86c2d598..2b4b21bf 100644 --- a/src/proxy.cc +++ b/src/proxy.cc @@ -1,9 +1,9 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ -#include "proxy.h" -#include "context.h" -#include "module.h" -#include "socket.h" +#include "./proxy.h" +#include "./context.h" +#include "./module.h" +#include "./socket.h" #include "util/arguments.h" #include "util/async_scope.h" #include "util/error.h" diff --git a/src/proxy.h b/src/proxy.h index c8d56c3c..7527ba79 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -1,7 +1,10 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" +#include + +#include "./zmq_inc.h" +#include "closable.h" #ifdef ZMQ_HAS_STEERABLE_PROXY diff --git a/src/socket.cc b/src/socket.cc index b024176a..9f1dbc7c 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -1,24 +1,25 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #define NOMINMAX // prevent minwindef.h from defining max macro in the debug build -#include "socket.h" -#include "context.h" -#include "incoming_msg.h" -#include "module.h" -#include "observer.h" +#include "./socket.h" + +#include +#include +#include + +#include "./context.h" +#include "./incoming_msg.h" +#include "./module.h" +#include "./observer.h" #include "util/arguments.h" #include "util/async_scope.h" #include "util/error.h" +#include "util/object.h" #include "util/take.h" #include "util/uvdelayed.h" -#include "util/uvloop.h" #include "util/uvwork.h" -#include -#include -#include - namespace zmq { /* The maximum number of sync I/O operations that are allowed before the I/O methods will force the returned promise to be resolved in the next tick. */ diff --git a/src/socket.h b/src/socket.h index 28e00644..d639ecb3 100644 --- a/src/socket.h +++ b/src/socket.h @@ -1,13 +1,13 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "prefix.h" - -#include "outgoing_msg.h" -#include "poller.h" - #include +#include "./closable.h" +#include "./inline.h" +#include "./outgoing_msg.h" +#include "./poller.h" + namespace zmq { class Module; diff --git a/src/util/arguments.h b/src/util/arguments.h index bd32ac27..60845feb 100644 --- a/src/util/arguments.h +++ b/src/util/arguments.h @@ -1,10 +1,12 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "to_string.h" +#include #include +#include "to_string.h" + namespace zmq { namespace Arg { typedef bool (Napi::Value::*ValueMethod)() const; diff --git a/src/util/async_scope.h b/src/util/async_scope.h index 8b1479c7..16b31795 100644 --- a/src/util/async_scope.h +++ b/src/util/async_scope.h @@ -1,6 +1,8 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once +#include + namespace zmq { class AsyncScope { Napi::HandleScope handle_scope; diff --git a/src/util/electron_helper.h b/src/util/electron_helper.h index 1beb6ae6..769efe22 100644 --- a/src/util/electron_helper.h +++ b/src/util/electron_helper.h @@ -1,6 +1,7 @@ #pragma once #include + #include namespace zmq { diff --git a/src/util/error.h b/src/util/error.h index a92ae4e0..1526aad3 100644 --- a/src/util/error.h +++ b/src/util/error.h @@ -2,6 +2,11 @@ #pragma once #include +#include + +#include + +#include "../zmq_inc.h" namespace zmq { static inline constexpr const char* ErrnoMessage(int32_t errorno); diff --git a/src/util/object.h b/src/util/object.h index 5b367389..111c3104 100644 --- a/src/util/object.h +++ b/src/util/object.h @@ -1,6 +1,8 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once +#include + namespace zmq { /* Seals an object to prevent setting incorrect options. */ static inline void Seal(Napi::Object object) { diff --git a/src/util/reaper.h b/src/util/reaper.h index 24a6685f..5b028ea9 100644 --- a/src/util/reaper.h +++ b/src/util/reaper.h @@ -1,6 +1,7 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once +#include #include #include #include diff --git a/src/util/to_string.h b/src/util/to_string.h index 9f3c6647..8724eedc 100644 --- a/src/util/to_string.h +++ b/src/util/to_string.h @@ -1,6 +1,8 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once +#include + namespace zmq { /* Provide an alternative, simplified std::to_string implementation for integers to work around https://bugs.alpinelinux.org/issues/8626. */ diff --git a/src/util/trash.h b/src/util/trash.h index effa4a75..76299325 100644 --- a/src/util/trash.h +++ b/src/util/trash.h @@ -1,13 +1,13 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include "uvhandle.h" -#include "uvloop.h" - #include #include #include +#include "./uvhandle.h" +#include "./uvloop.h" + namespace zmq { /* Container for unused references to outgoing messages. Once an item is added to the trash it will be cleared on the main thread once UV decides diff --git a/src/util/uvhandle.h b/src/util/uvhandle.h index 3b8b9638..87411813 100644 --- a/src/util/uvhandle.h +++ b/src/util/uvhandle.h @@ -1,9 +1,10 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include #include +#include + namespace zmq { template struct UvDeleter { diff --git a/src/util/uvloop.h b/src/util/uvloop.h index 10e2caaa..cf743d14 100644 --- a/src/util/uvloop.h +++ b/src/util/uvloop.h @@ -1,6 +1,11 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once +#include +#include + +#include + namespace zmq { inline uv_loop_t* UvLoop(const Napi::Env& env) { uv_loop_t* loop = nullptr; diff --git a/src/prefix.h b/src/zmq_inc.h similarity index 60% rename from src/prefix.h rename to src/zmq_inc.h index ae9c4b6f..259d3d6b 100644 --- a/src/prefix.h +++ b/src/zmq_inc.h @@ -1,20 +1,10 @@ /* Copyright (c) 2017-2019 Rolf Timmermans */ #pragma once -#include +#include // IWYU pragma: export -#include #if ZMQ_VERSION < ZMQ_MAKE_VERSION(4, 1, 0) -#include -#endif - -#include -#include - -#ifdef _MSC_VER -#define force_inline inline __forceinline -#else -#define force_inline inline __attribute__((always_inline)) +#include // IWYU pragma: export #endif #ifdef _MSC_VER @@ -39,11 +29,3 @@ #define ZMQ_HAS_POLLABLE_THREAD_SAFE 1 #endif #endif - -/* A thing that can be closed. Simple interface to allow us to correctly clean - up ZMQ resources at agent exit. */ -namespace zmq { -struct Closable { - virtual void Close() = 0; -}; -} diff --git a/test/.eslintrc b/test/.eslintrc index a07352ad..a1f8dc0f 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -11,6 +11,7 @@ "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/explicit-function-return-type": "off", "no-await-in-loop": "off", - "require-await": "off" + "require-await": "off", + "import/no-extraneous-dependencies": "off" } } diff --git a/test/package.json b/test/package.json index dd32cba0..701c7a33 100644 --- a/test/package.json +++ b/test/package.json @@ -1,6 +1,6 @@ { - "devDependencies": { - "@types/weak-napi": "^2.0.3", - "weak-napi": "^2.0.2" - } + "devDependencies": { + "@types/weak-napi": "^2.0.3", + "weak-napi": "^2.0.2" + } }