Skip to content

Commit

Permalink
Perhaps this should be split into multiple PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Jan 9, 2024
1 parent a7bf09a commit fc2955e
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 204 deletions.
86 changes: 86 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# C++ files
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWrappedFunctionNames: true
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
6 changes: 3 additions & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
'src/NetworkListener.cpp',
'src/nuclear/src/extension/network/NUClearNetwork.cpp',
'src/nuclear/src/util/platform.cpp',
'src/nuclear/src/util/serialise/xxhash.c',
'src/nuclear/src/util/network/get_interfaces.cpp'
'src/nuclear/src/util/network/get_interfaces.cpp',
'src/nuclear/src/util/network/resolve.cpp',
'src/nuclear/src/util/serialise/xxhash.cpp'
],
'cflags': [],
'include_dirs': [
'<!@(node -p "require(\'node-addon-api\').include")',
"<!@(node -p \"require('napi-thread-safe-callback').include\")",
'src/nuclear/src/include'
],
"defines": [
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class NUClearNet extends EventEmitter {
}
});

// Bind our callback functions
this._net.on('packet', this._onPacket.bind(this));
this._net.on('join', this._onJoin.bind(this));
this._net.on('leave', this._onLeave.bind(this));
this._net.on('wait', this._onWait.bind(this));
// Pass our javascript callbacks to the C++ side
this._net.onPacket(this._onPacket.bind(this));
this._net.onJoin(this._onJoin.bind(this));
this._net.onLeave(this._onLeave.bind(this));
this._net.onWait(this._onWait.bind(this));
}

_onPacket(name, address, port, reliable, hash, payload) {
Expand Down
90 changes: 62 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
},
"dependencies": {
"bindings": "^1.5.0",
"napi-thread-safe-callback": "0.0.6",
"node-addon-api": "^4.2.0"
"node-addon-api": "^7.0.0"
}
}
Loading

0 comments on commit fc2955e

Please sign in to comment.