Skip to content

Commit e8fcb57

Browse files
committed
some formatting
1 parent a776b16 commit e8fcb57

File tree

11 files changed

+192
-147
lines changed

11 files changed

+192
-147
lines changed

.clang-format

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ IndentWidth: 4
33

44
AlignAfterOpenBracket: BlockIndent
55
AlignEscapedNewlines: Left
6+
AlignConsecutiveAssignments: false
67
AlignOperands: DontAlign
78
AlignTrailingComments: false
89

@@ -22,7 +23,7 @@ AlwaysBreakAfterReturnType: None
2223
AlwaysBreakBeforeMultilineStrings: true
2324
AlwaysBreakTemplateDeclarations: Yes
2425

25-
BinPackArguments: true
26+
BinPackArguments: false
2627
BinPackParameters: true
2728

2829
BraceWrapping:
@@ -49,15 +50,15 @@ BraceWrapping:
4950
BreakBeforeBinaryOperators: None
5051
BreakBeforeBraces: Custom
5152
BreakBeforeConceptDeclarations: true
52-
BreakBeforeTernaryOperators: true
53+
BreakBeforeTernaryOperators: false
5354
BreakConstructorInitializers: AfterColon
5455
BreakInheritanceList: AfterColon
5556
BreakStringLiterals: true
5657
ColumnLimit: 100
5758
CompactNamespaces: false
5859
ConstructorInitializerIndentWidth: 4
5960
ContinuationIndentWidth: 4
60-
Cpp11BracedListStyle: false
61+
Cpp11BracedListStyle: true
6162

6263
DeriveLineEnding: false
6364
UseCRLF: false
@@ -103,7 +104,7 @@ PenaltyBreakFirstLessLess: 120
103104
PenaltyBreakString: 1000
104105
PenaltyBreakOpenParenthesis: 0
105106
PenaltyBreakTemplateDeclaration: 10
106-
PenaltyExcessCharacter: 1000000
107+
PenaltyExcessCharacter: 10
107108
PenaltyReturnTypeOnItsOwnLine: 1000000
108109
PenaltyIndentedWhitespace: 0
109110

@@ -122,7 +123,7 @@ SpaceAfterTemplateKeyword: true
122123
SpaceAroundPointerQualifiers: Default
123124
SpaceBeforeAssignmentOperators: true
124125
SpaceBeforeCaseColon: false
125-
SpaceBeforeCpp11BracedList: true
126+
SpaceBeforeCpp11BracedList: false
126127
SpaceBeforeCtorInitializerColon: true
127128
SpaceBeforeInheritanceColon: true
128129
SpaceBeforeParens: ControlStatements

loader/include/Geode/DefaultInclude.hpp

+96-20
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,115 @@ namespace cocos2d::extension {}
7575
} \
7676
Class_(std::monostate, void*)
7777

78-
#define GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(Class_) \
79-
GEODE_MACOS(GEODE_FILL_CONSTRUCTOR(Class_, 0) {}) \
80-
GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0) {})
78+
#define GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(Class_) \
79+
GEODE_MACOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) \
80+
GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){})
8181

82-
#define GEODE_MONOSTATE_CONSTRUCTOR_COCOS(Class_, Base_) \
83-
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
84-
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {})
82+
#define GEODE_MONOSTATE_CONSTRUCTOR_COCOS(Class_, Base_) \
83+
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
84+
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){})
8585

86-
#define GEODE_MONOSTATE_CONSTRUCTOR_GD(Class_, Base_) \
87-
GEODE_WINDOWS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
88-
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
89-
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {})
86+
#define GEODE_MONOSTATE_CONSTRUCTOR_GD(Class_, Base_) \
87+
GEODE_WINDOWS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
88+
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
89+
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){})
9090

91-
#define GEODE_MONOSTATE_CONSTRUCTOR_CUTOFF(Class_, Base_) \
92-
GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_() {}) \
93-
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
94-
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {})
91+
#define GEODE_MONOSTATE_CONSTRUCTOR_CUTOFF(Class_, Base_) \
92+
GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_(){}) \
93+
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
94+
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){})
9595

9696
#define GEODE_NUMBER_OF_ARGS(...) \
9797
GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_(__VA_ARGS__, GEODE_NUMBER_SEQUENCE(), ))
9898
#define GEODE_NUMBER_OF_ARGS_(...) GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_N(__VA_ARGS__))
99-
#define GEODE_NUMBER_OF_ARGS_N( \
100-
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
101-
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, \
102-
_40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, \
103-
_59, _60, _61, _62, _63, N, ... \
104-
) \
99+
#define GEODE_NUMBER_OF_ARGS_N( \
100+
_1, \
101+
_2, \
102+
_3, \
103+
_4, \
104+
_5, \
105+
_6, \
106+
_7, \
107+
_8, \
108+
_9, \
109+
_10, \
110+
_11, \
111+
_12, \
112+
_13, \
113+
_14, \
114+
_15, \
115+
_16, \
116+
_17, \
117+
_18, \
118+
_19, \
119+
_20, \
120+
_21, \
121+
_22, \
122+
_23, \
123+
_24, \
124+
_25, \
125+
_26, \
126+
_27, \
127+
_28, \
128+
_29, \
129+
_30, \
130+
_31, \
131+
_32, \
132+
_33, \
133+
_34, \
134+
_35, \
135+
_36, \
136+
_37, \
137+
_38, \
138+
_39, \
139+
_40, \
140+
_41, \
141+
_42, \
142+
_43, \
143+
_44, \
144+
_45, \
145+
_46, \
146+
_47, \
147+
_48, \
148+
_49, \
149+
_50, \
150+
_51, \
151+
_52, \
152+
_53, \
153+
_54, \
154+
_55, \
155+
_56, \
156+
_57, \
157+
_58, \
158+
_59, \
159+
_60, \
160+
_61, \
161+
_62, \
162+
_63, \
163+
N, \
164+
... \
165+
) \
105166
N
106167
#define GEODE_NUMBER_SEQUENCE() \
107168
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \
108169
40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \
109170
18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
110171

172+
#define $execute \
173+
template <class> \
174+
void GEODE_CONCAT(geodeExecFunction, __LINE__)(); \
175+
namespace { \
176+
struct GEODE_CONCAT(ExecFuncUnique, __LINE__) {}; \
177+
} \
178+
static inline auto GEODE_CONCAT(Exec, __LINE__) = \
179+
(Loader::get()->scheduleOnModLoad( \
180+
nullptr, \
181+
&GEODE_CONCAT(geodeExecFunction, __LINE__) < GEODE_CONCAT(ExecFuncUnique, __LINE__) > \
182+
), \
183+
0); \
184+
template <class> \
185+
void GEODE_CONCAT(geodeExecFunction, __LINE__)()
186+
111187
// #define GEODE_NEST1(macro, begin) \
112188
// macro(GEODE_CONCAT(begin, 0)), \
113189
// macro(GEODE_CONCAT(begin, 1)), \

loader/include/Geode/modify/InternalMacros.hpp

-18
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,3 @@
5555
* Useful for callbacks
5656
*/
5757
#define $cls std::remove_pointer<decltype(this)>::type
58-
59-
#define GEODE_ONLY_FIELD(type, field_, default_) private: field<type> field_ = default_; public:
60-
#define GEODE_INTERNAL_FIELD(type, field, name) inline type& name() { return this->*field; }
61-
//#define GEODE_EXTERNAL_FIELD(type, field, name) static inline type& name##From(void* self) { return reinterpret_cast<decltype(this)>(self)->*field; }
62-
#define GEODE_FIELD(type, field, name, default_) GEODE_ONLY_FIELD(type, field, default_) GEODE_INTERNAL_FIELD(type, field, name) //GEODE_EXTERNAL_FIELD(type, field, name)
63-
64-
65-
#define $execute \
66-
template<class> \
67-
void GEODE_CONCAT(geodeExecFunction, __LINE__)(); \
68-
namespace { \
69-
struct GEODE_CONCAT(ExecFuncUnique, __LINE__) {}; \
70-
} \
71-
static inline auto GEODE_CONCAT(Exec, __LINE__) = (Loader::get()->scheduleOnModLoad(\
72-
nullptr, &GEODE_CONCAT(geodeExecFunction, __LINE__)<GEODE_CONCAT(ExecFuncUnique, __LINE__)> \
73-
), 0); \
74-
template<class> \
75-
void GEODE_CONCAT(geodeExecFunction, __LINE__)()

loader/src/cocos2d-ext/zip/zip.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Version 1.1, February 14h, 2010
33
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
44
5-
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
5+
Copyright (C) 1998-2010 Gilles Vollant (minizip) (
6+
http://www.winimage.com/zLibDll/minizip.html )
67
78
Modifications for Zip64 support
89
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
@@ -12,15 +13,17 @@
1213
Changes
1314
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
1415
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
15-
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
16-
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
17-
It is used when recreting zip archive with RAW when deleting items from a zip.
18-
ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
19-
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
20-
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
16+
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of
17+
some functions. Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field
18+
data from its ZIP64 data It is used when recreting zip archive with RAW when deleting items from
19+
a zip. ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to
20+
be removed. Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib
21+
is required) Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
2122
2223
*/
2324

25+
// clang-format off
26+
2427
#ifndef NOCRYPT
2528
#define NOCRYPT
2629
#endif
@@ -1071,7 +1074,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
10711074
int err = ZIP_OK;
10721075

10731076
# ifdef NOCRYPT
1074-
(crcForCrypting);
1077+
(void)(crcForCrypting);
10751078
if (password != NULL)
10761079
return ZIP_PARAMERROR;
10771080
# endif
@@ -2006,3 +2009,5 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
20062009
}
20072010

20082011
} // end of namespace cocos2d
2012+
2013+
// clang-format on

loader/src/main.cpp

+32-43
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "../core/Core.hpp"
22

3+
#include <Geode/loader/IPC.hpp>
34
#include <Geode/loader/Loader.hpp>
45
#include <Geode/loader/Log.hpp>
56
#include <Geode/loader/Mod.hpp>
6-
#include <Geode/loader/SettingEvent.hpp>
77
#include <Geode/loader/Setting.hpp>
8-
#include <Geode/loader/IPC.hpp>
8+
#include <Geode/loader/SettingEvent.hpp>
99
#include <InternalLoader.hpp>
1010
#include <InternalMod.hpp>
1111
#include <array>
@@ -100,55 +100,44 @@ BOOL WINAPI DllMain(HINSTANCE lib, DWORD reason, LPVOID) {
100100
}
101101
#endif
102102

103-
#define $_ GEODE_CONCAT(unnamedVar_, __LINE__)
104-
105-
static auto $_ = listenForSettingChanges<BoolSetting>(
106-
"show-platform-console",
107-
[](BoolSetting* setting) {
103+
$execute {
104+
listenForSettingChanges<BoolSetting>("show-platform-console", [](BoolSetting* setting) {
108105
if (setting->getValue()) {
109106
Loader::get()->openPlatformConsole();
110107
}
111108
else {
112109
Loader::get()->closePlatfromConsole();
113110
}
114-
}
115-
);
116-
117-
static auto $_ = listenForIPC("ipc-test", +[](IPCEvent* event) -> nlohmann::json {
118-
return "Hello from Geode!";
119-
});
120-
121-
static auto $_ = listenForIPC("loader-info", +[](IPCEvent* event) -> nlohmann::json {
122-
return Loader::get()->getInternalMod()->getModInfo();
123-
});
124-
125-
static auto $_ = listenForIPC("list-mods", +[](IPCEvent* event) -> nlohmann::json {
126-
std::vector<nlohmann::json> res;
127-
128-
auto args = event->getMessageData();
129-
JsonChecker checker(args);
130-
auto root = checker.root("").obj();
131-
132-
auto includeRunTimeInfo = root.has("include-runtime-info").template get<bool>();
133-
auto dontIncludeLoader = root.has("dont-include-loader").template get<bool>();
134-
135-
if (!dontIncludeLoader) {
136-
res.push_back(includeRunTimeInfo ?
137-
Loader::get()->getInternalMod()->getRuntimeInfo() :
138-
Loader::get()->getInternalMod()->getModInfo().toJSON()
139-
);
140-
}
111+
});
112+
listenForIPC("ipc-test", [](IPCEvent* event) -> nlohmann::json {
113+
return "Hello from Geode!";
114+
});
115+
listenForIPC("loader-info", [](IPCEvent* event) -> nlohmann::json {
116+
return Loader::get()->getInternalMod()->getModInfo();
117+
});
118+
119+
listenForIPC("list-mods", [](IPCEvent* event) -> nlohmann::json {
120+
std::vector<nlohmann::json> res;
121+
122+
auto args = event->getMessageData();
123+
JsonChecker checker(args);
124+
auto root = checker.root("").obj();
125+
126+
auto includeRunTimeInfo = root.has("include-runtime-info").template get<bool>();
127+
auto dontIncludeLoader = root.has("dont-include-loader").template get<bool>();
128+
129+
if (!dontIncludeLoader) {
130+
auto mod = Loader::get()->getInternalMod();
131+
res.push_back(includeRunTimeInfo ? mod->getRuntimeInfo() : mod->getModInfo().toJSON());
132+
}
141133

142-
for (auto& mod : Loader::get()->getAllMods()) {
143-
res.push_back(
144-
includeRunTimeInfo ?
145-
mod->getRuntimeInfo() :
146-
mod->getModInfo().toJSON()
147-
);
148-
}
134+
for (auto& mod : Loader::get()->getAllMods()) {
135+
res.push_back(includeRunTimeInfo ? mod->getRuntimeInfo() : mod->getModInfo().toJSON());
136+
}
149137

150-
return res;
151-
});
138+
return res;
139+
});
140+
}
152141

153142
int geodeEntry(void* platformData) {
154143
// setup internals

loader/src/utils/JsonValidation.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,12 @@ JsonMaybeValue<Json> JsonMaybeValue<Json>::at(size_t i) {
205205
return *this;
206206
}
207207
return JsonMaybeValue<Json>(
208-
self().m_checker, self().m_json.at(i), self().m_hierarchy + "." + std::to_string(i),
209-
self().m_hasValue
208+
self().m_checker, self().m_json.at(i), self().m_hierarchy + "." + std::to_string(i), self().m_hasValue
210209
);
211210
}
212211

213212
template <class Json>
214-
typename JsonMaybeValue<Json>::template Iterator<JsonMaybeValue<Json>> JsonMaybeValue<
215-
Json>::iterate() {
213+
typename JsonMaybeValue<Json>::template Iterator<JsonMaybeValue<Json>> JsonMaybeValue<Json>::iterate() {
216214
this->as<value_t::array>();
217215
Iterator<JsonMaybeValue<Json>> iter;
218216
if (this->isError()) return iter;
@@ -226,18 +224,16 @@ typename JsonMaybeValue<Json>::template Iterator<JsonMaybeValue<Json>> JsonMaybe
226224
}
227225

228226
template <class Json>
229-
typename JsonMaybeValue<Json>::template Iterator<std::pair<std::string, JsonMaybeValue<Json>>>
230-
JsonMaybeValue<Json>::items() {
227+
typename JsonMaybeValue<Json>::template Iterator<std::pair<std::string, JsonMaybeValue<Json>>> JsonMaybeValue<
228+
Json>::items() {
231229
this->as<value_t::object>();
232230
Iterator<std::pair<std::string, JsonMaybeValue<Json>>> iter;
233231
if (this->isError()) return iter;
234232

235233
for (auto& [k, v] : self().m_json.items()) {
236234
iter.m_values.emplace_back(
237235
k,
238-
JsonMaybeValue<Json>(
239-
self().m_checker, v, self().m_hierarchy + "." + k, self().m_hasValue
240-
)
236+
JsonMaybeValue<Json>(self().m_checker, v, self().m_hierarchy + "." + k, self().m_hasValue)
241237
);
242238
}
243239

0 commit comments

Comments
 (0)