Skip to content

Commit

Permalink
fix: clean-up the includes in C++ files
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 14, 2024
1 parent 4369f64 commit 7c74763
Show file tree
Hide file tree
Showing 32 changed files with 138 additions and 90 deletions.
18 changes: 16 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,27 @@ SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: "Never"
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
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
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"v5-compat.d.ts",
"draft.d.ts",
"script/*.js",
"script/*.d.ts"
"script/*.d.ts",
"docs/",
"docs-raw/"
]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/prebuilds
/node_modules
pnpm-lock.yaml
/build
9 changes: 9 additions & 0 deletions src/closable.h
Original file line number Diff line number Diff line change
@@ -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;
};
}
10 changes: 6 additions & 4 deletions src/context.cc
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/context.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include "closable.h"

namespace zmq {
class Module;
Expand Down
4 changes: 3 additions & 1 deletion src/incoming_msg.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "incoming_msg.h"
#include "./incoming_msg.h"

#include <cassert>

#include "util/electron_helper.h"
#include "util/error.h"
Expand Down
4 changes: 3 additions & 1 deletion src/incoming_msg.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include "./zmq_inc.h"

namespace zmq {
class IncomingMsg {
Expand Down
7 changes: 7 additions & 0 deletions src/inline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#ifdef _MSC_VER
#define force_inline inline __forceinline
#else
#define force_inline inline __attribute__((always_inline))
#endif
15 changes: 9 additions & 6 deletions src/module.cc
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
15 changes: 4 additions & 11 deletions src/module.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"

#include "outgoing_msg.h"
#include <cstdio>
#include <future>

#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 <chrono>
#include <cstdio>
#include <future>

namespace zmq {
class Context;
class Socket;
Expand Down
13 changes: 6 additions & 7 deletions src/observer.cc
Original file line number Diff line number Diff line change
@@ -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 <array>

namespace zmq {
static inline constexpr const char* EventName(uint32_t val) {
switch (val) {
Expand Down
8 changes: 5 additions & 3 deletions src/observer.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"

#include "poller.h"
#include <napi.h>

#include <optional>

#include "./closable.h"
#include "./inline.h"
#include "./poller.h"

namespace zmq {
class Module;

Expand Down
4 changes: 2 additions & 2 deletions src/outgoing_msg.cc
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/outgoing_msg.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include <forward_list>

#include "./zmq_inc.h"

namespace zmq {
class Module;

Expand Down
8 changes: 4 additions & 4 deletions src/proxy.cc
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 4 additions & 1 deletion src/proxy.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include "./zmq_inc.h"
#include "closable.h"

#ifdef ZMQ_HAS_STEERABLE_PROXY

Expand Down
21 changes: 11 additions & 10 deletions src/socket.cc
Original file line number Diff line number Diff line change
@@ -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 <cmath>
#include <limits>
#include <unordered_set>

#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 <cmath>
#include <limits>
#include <unordered_set>

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. */
Expand Down
10 changes: 5 additions & 5 deletions src/socket.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"

#include "outgoing_msg.h"
#include "poller.h"

#include <optional>

#include "./closable.h"
#include "./inline.h"
#include "./outgoing_msg.h"
#include "./poller.h"

namespace zmq {
class Module;

Expand Down
4 changes: 3 additions & 1 deletion src/util/arguments.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "to_string.h"
#include <napi.h>

#include <optional>

#include "to_string.h"

namespace zmq {
namespace Arg {
typedef bool (Napi::Value::*ValueMethod)() const;
Expand Down
2 changes: 2 additions & 0 deletions src/util/async_scope.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include <napi.h>

namespace zmq {
class AsyncScope {
Napi::HandleScope handle_scope;
Expand Down
1 change: 1 addition & 0 deletions src/util/electron_helper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <napi.h>

#include <string>

namespace zmq {
Expand Down
5 changes: 5 additions & 0 deletions src/util/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#pragma once

#include <errno.h>
#include <napi.h>

#include <string>

#include "../zmq_inc.h"

namespace zmq {
static inline constexpr const char* ErrnoMessage(int32_t errorno);
Expand Down
2 changes: 2 additions & 0 deletions src/util/object.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include <napi.h>

namespace zmq {
/* Seals an object to prevent setting incorrect options. */
static inline void Seal(Napi::Object object) {
Expand Down
1 change: 1 addition & 0 deletions src/util/reaper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include <cassert>
#include <mutex>
#include <set>
#include <vector>
Expand Down
2 changes: 2 additions & 0 deletions src/util/to_string.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include <string>

namespace zmq {
/* Provide an alternative, simplified std::to_string implementation for
integers to work around https://bugs.alpinelinux.org/issues/8626. */
Expand Down
6 changes: 3 additions & 3 deletions src/util/trash.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "uvhandle.h"
#include "uvloop.h"

#include <deque>
#include <memory>
#include <mutex>

#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
Expand Down
3 changes: 2 additions & 1 deletion src/util/uvhandle.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include <memory>
#include <uv.h>

#include <memory>

namespace zmq {
template <typename T>
struct UvDeleter {
Expand Down
Loading

0 comments on commit 7c74763

Please sign in to comment.