Skip to content

Commit 3375964

Browse files
committed
Code refactoring
1 parent 31dd24a commit 3375964

File tree

9 files changed

+292
-126
lines changed

9 files changed

+292
-126
lines changed

gm_dotnet_native/.clang-format

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
2+
---
3+
Language: Cpp
4+
AccessModifierOffset: -4
5+
AlignAfterOpenBracket: Align
6+
#AlignConsecutiveAssignments: AcrossComments
7+
#AlignConsecutiveDeclarations: AcrossComments
8+
AlignEscapedNewlines: Left
9+
AlignOperands: true
10+
AlignTrailingComments: false
11+
AllowAllArgumentsOnNextLine: false
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: false
14+
AllowShortBlocksOnASingleLine: false
15+
AllowShortCaseLabelsOnASingleLine: false
16+
AllowShortFunctionsOnASingleLine: None
17+
AllowShortIfStatementsOnASingleLine: false
18+
AllowShortLambdasOnASingleLine: false
19+
AllowShortLoopsOnASingleLine: false
20+
AlwaysBreakAfterReturnType: None
21+
AlwaysBreakBeforeMultilineStrings: false
22+
AlwaysBreakTemplateDeclarations: Yes
23+
BinPackArguments: false
24+
BinPackParameters: false
25+
BraceWrapping:
26+
AfterCaseLabel: true
27+
AfterClass: true
28+
AfterControlStatement: Always
29+
AfterEnum: true
30+
AfterFunction: true
31+
AfterNamespace: true
32+
AfterObjCDeclaration: true
33+
AfterStruct: true
34+
AfterUnion: true
35+
AfterExternBlock: true
36+
BeforeCatch: true
37+
BeforeElse: true
38+
#BeforeLambdaBody: false
39+
BeforeWhile: false
40+
IndentBraces: false
41+
SplitEmptyFunction: true
42+
SplitEmptyRecord: true
43+
SplitEmptyNamespace: true
44+
BreakBeforeBinaryOperators: All
45+
BreakBeforeBraces: Custom
46+
BreakBeforeConceptDeclarations: true
47+
BreakBeforeTernaryOperators: true
48+
BreakConstructorInitializers: BeforeComma
49+
BreakInheritanceList: BeforeComma
50+
BreakStringLiterals: true
51+
ColumnLimit: 140
52+
CommentPragmas: '^ IWYU pragma:|^!|^:'
53+
CompactNamespaces: false
54+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
55+
ConstructorInitializerIndentWidth: 4
56+
ContinuationIndentWidth: 4
57+
Cpp11BracedListStyle: true
58+
DeriveLineEnding: false
59+
DerivePointerAlignment: false
60+
DisableFormat: false
61+
EmptyLineBeforeAccessModifier: LogicalBlock
62+
ExperimentalAutoDetectBinPacking: false
63+
FixNamespaceComments: true
64+
ForEachMacros:
65+
- forever # avoids { wrapped to next line
66+
- foreach
67+
- Q_FOREACH
68+
- BOOST_FOREACH
69+
IncludeBlocks: Preserve
70+
IncludeCategories:
71+
# C stdlib
72+
- Regex: '^<c[[:alnum:]]+>$'
73+
Priority: 1
74+
# C++ stdlib
75+
- Regex: '^<(algorithm|any|array|bit|bitset|deque|exception|execution|filesystem|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iostream|istream|iterator|limits|list|locale|map|memory_resource|memory|mutex|new|numeric|optional|ostream|queue|random|ranges|ratio|regex|scoped_allocator|set|shared_mutex|span|sstream|stack|stdexcept|streambuf|string_view|string|strstream|syncstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|variant|vector)>$'
76+
Priority: 2
77+
# C++ stdlib (experimental)
78+
- Regex: '^<experimental/[[:alnum:]]+>$'
79+
Priority: 3
80+
# Windows.h
81+
- Regex: '^<[Ww]indows.h>$'
82+
Priority: 8
83+
# Global
84+
- Regex: '^<.+>$'
85+
Priority: 9
86+
# Local (private)
87+
- Regex: '^"private/.+"$'
88+
Priority: 10
89+
# Local
90+
- Regex: '^".+"$'
91+
Priority: 11
92+
IncludeIsMainRegex: '(Test)?$'
93+
#IndentAccessModifiers: false
94+
IndentCaseBlocks: false
95+
IndentCaseLabels: true
96+
IndentGotoLabels: false
97+
IndentPPDirectives: None
98+
IndentRequires: true
99+
IndentWidth: 4
100+
IndentWrappedFunctionNames: false
101+
InsertTrailingCommas: Wrapped
102+
JavaScriptQuotes: Leave
103+
JavaScriptWrapImports: true
104+
KeepEmptyLinesAtTheStartOfBlocks: false
105+
MacroBlockBegin: ""
106+
MacroBlockEnd: ""
107+
MaxEmptyLinesToKeep: 1
108+
NamespaceIndentation: None
109+
ObjCBlockIndentWidth: 4
110+
ObjCSpaceAfterProperty: false
111+
ObjCSpaceBeforeProtocolList: true
112+
PenaltyBreakAssignment: 150
113+
PenaltyBreakBeforeFirstCallParameter: 300
114+
PenaltyBreakComment: 500
115+
PenaltyBreakFirstLessLess: 400
116+
PenaltyBreakString: 600
117+
PenaltyExcessCharacter: 50
118+
PenaltyReturnTypeOnItsOwnLine: 300
119+
PointerAlignment: Left
120+
ReflowComments: false
121+
SortIncludes: true #CaseSensitive
122+
SortUsingDeclarations: true
123+
SpaceAfterCStyleCast: false
124+
SpaceAfterLogicalNot: false
125+
SpaceAfterTemplateKeyword: false
126+
SpaceAroundPointerQualifiers: Before
127+
SpaceBeforeAssignmentOperators: true
128+
SpaceBeforeCaseColon: false
129+
SpaceBeforeCpp11BracedList: false
130+
SpaceBeforeCtorInitializerColon: false
131+
SpaceBeforeInheritanceColon: false
132+
SpaceBeforeParens: Never
133+
SpaceBeforeRangeBasedForLoopColon: false
134+
SpaceBeforeSquareBrackets: false
135+
SpaceInEmptyBlock: false
136+
SpaceInEmptyParentheses: false
137+
SpacesBeforeTrailingComments: 1
138+
SpacesInAngles: false
139+
SpacesInCStyleCastParentheses: false
140+
SpacesInConditionalStatement: false
141+
SpacesInContainerLiterals: false
142+
SpacesInCStyleCastParentheses: false
143+
SpacesInParentheses: false
144+
SpacesInSquareBrackets: false
145+
Standard: Latest
146+
StatementAttributeLikeMacros: [emit]
147+
StatementMacros: [Q_UNUSED]
148+
TabWidth: 4
149+
UseTab: Never

gm_dotnet_native/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ set(NET_CORE_VERSION "1.0.0" CACHE STRING "Version of bundled .NET Core Runtime"
2121

2222
#Project name
2323
project(gm_dotnet_native)
24-
add_library(gm_dotnet_native SHARED src/gm_dotnet.cpp dotnethelper-src/cleanup_function_type.h)
24+
add_library(gm_dotnet_native SHARED src/gm_dotnet.cpp dotnethelper-src/cleanup_function_type.h utils/get_exe_path.cpp)
2525
add_library(dotnethelper SHARED dotnethelper-src/dotnethelper.cpp dotnethelper-src/cleanup_function_type.h
26-
dotnethelper-src/LuaAPIExposure.h dotnethelper-src/LuaAPIExposure.cpp)
26+
dotnethelper-src/LuaAPIExposure.h dotnethelper-src/LuaAPIExposure.cpp utils/get_exe_path.cpp)
2727
#Set up external include libraries
28-
include_directories ("${EXTERNAL_INCLUDES_PATH}")
28+
include_directories ("${EXTERNAL_INCLUDES_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}")
2929
add_subdirectory ("${EXTERNAL_INCLUDES_PATH}/dynalo")
3030
target_link_libraries(gm_dotnet_native PUBLIC dynalo)
3131
target_link_libraries(dotnethelper PUBLIC dynalo)

gm_dotnet_native/dotnethelper-src/LuaAPIExposure.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//
22
// Created by Gleb Krasilich on 06.10.2019.
33
//
4+
#pragma once
45

5-
#ifndef GM_DOTNET_NATIVE_LUAAPIEXPOSURE_H
6-
#define GM_DOTNET_NATIVE_LUAAPIEXPOSURE_H
76
#include <GarrysMod/Lua/Interface.h>
87
#include <GarrysMod/Lua/LuaBase.h>
98

@@ -333,5 +332,3 @@ double export_check_number(GarrysMod::Lua::ILuaBase * lua, int iStackPos);
333332
/// \param lua ILuaBase pointer
334333
/// \param val function to push on stack
335334
void export_push_c_function_safe(GarrysMod::Lua::ILuaBase * lua, GarrysMod::Lua::CFunc safe_wrapper, GarrysMod::Lua::CFunc val);
336-
337-
#endif //GM_DOTNET_NATIVE_LUAAPIEXPOSURE_H
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
//
22
// Created by glebc on 11.10.2020.
33
//
4+
#pragma once
45

5-
#ifndef GM_DOTNET_NATIVE_CLEANUP_FUNCTION_TYPE_H
6-
#define GM_DOTNET_NATIVE_CLEANUP_FUNCTION_TYPE_H
76
#include <GarrysMod/Lua/LuaBase.h>
87

98
typedef void(*cleanup_function_fn)(GarrysMod::Lua::ILuaBase* lua);
10-
11-
#endif //GM_DOTNET_NATIVE_CLEANUP_FUNCTION_TYPE_H

0 commit comments

Comments
 (0)