Skip to content

Commit 5fc39ef

Browse files
committed
base: Apply latest clang-format changes from upstream
Minus, some customizations, of course
1 parent 74719ce commit 5fc39ef

19 files changed

+229
-85
lines changed

.clang-format

Lines changed: 116 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# please use clang-format version 8 or later
1+
# please use clang-format version 16 or later
22

3-
Standard: Cpp11
3+
Standard: c++17
44
AccessModifierOffset: -8
55
AlignAfterOpenBracket: Align
66
AlignConsecutiveAssignments: false
77
AlignConsecutiveDeclarations: false
88
AlignEscapedNewlines: Left
99
AlignOperands: true
1010
AlignTrailingComments: true
11-
#AllowAllArgumentsOnNextLine: false # requires clang-format 9
12-
#AllowAllConstructorInitializersOnNextLine: false # requires clang-format 9
11+
AllowAllArgumentsOnNextLine: false
12+
AllowAllConstructorInitializersOnNextLine: false
1313
AllowAllParametersOfDeclarationOnNextLine: false
1414
AllowShortBlocksOnASingleLine: false
1515
AllowShortCaseLabelsOnASingleLine: false
1616
AllowShortFunctionsOnASingleLine: Inline
1717
AllowShortIfStatementsOnASingleLine: false
18-
#AllowShortLambdasOnASingleLine: Inline # requires clang-format 9
18+
AllowShortLambdasOnASingleLine: Inline
1919
AllowShortLoopsOnASingleLine: false
2020
AlwaysBreakAfterDefinitionReturnType: None
2121
AlwaysBreakAfterReturnType: None
@@ -53,10 +53,11 @@ Cpp11BracedListStyle: true
5353
DerivePointerAlignment: false
5454
DisableFormat: false
5555
FixNamespaceComments: false
56-
ForEachMacros:
56+
ForEachMacros:
5757
- 'json_object_foreach'
5858
- 'json_object_foreach_safe'
5959
- 'json_array_foreach'
60+
- 'HASH_ITER'
6061
IncludeBlocks: Preserve
6162
IndentCaseLabels: false
6263
IndentPPDirectives: None
@@ -65,7 +66,7 @@ IndentWrappedFunctionNames: false
6566
KeepEmptyLinesAtTheStartOfBlocks: true
6667
MaxEmptyLinesToKeep: 1
6768
NamespaceIndentation: All
68-
#ObjCBinPackProtocolList: Auto # requires clang-format 7
69+
ObjCBinPackProtocolList: Auto
6970
ObjCBlockIndentWidth: 8
7071
ObjCSpaceAfterProperty: true
7172
ObjCSpaceBeforeProtocolList: true
@@ -83,25 +84,125 @@ ReflowComments: false
8384
SortIncludes: false
8485
SortUsingDeclarations: false
8586
SpaceAfterCStyleCast: false
86-
#SpaceAfterLogicalNot: false # requires clang-format 9
87+
SpaceAfterLogicalNot: false
8788
SpaceAfterTemplateKeyword: false
8889
SpaceBeforeAssignmentOperators: true
89-
#SpaceBeforeCtorInitializerColon: true # requires clang-format 7
90-
#SpaceBeforeInheritanceColon: true # requires clang-format 7
90+
SpaceBeforeCtorInitializerColon: true
91+
SpaceBeforeInheritanceColon: true
9192
SpaceBeforeParens: ControlStatements
92-
#SpaceBeforeRangeBasedForLoopColon: true # requires clang-format 7
93+
SpaceBeforeRangeBasedForLoopColon: true
9394
SpaceInEmptyParentheses: false
9495
SpacesBeforeTrailingComments: 1
9596
SpacesInAngles: false
9697
SpacesInCStyleCastParentheses: false
9798
SpacesInContainerLiterals: false
9899
SpacesInParentheses: false
99100
SpacesInSquareBrackets: false
100-
#StatementMacros: # requires clang-format 8
101-
# - 'Q_OBJECT'
101+
StatementMacros:
102+
- 'Q_OBJECT'
102103
TabWidth: 8
103-
#TypenameMacros: # requires clang-format 9
104-
# - 'DARRAY'
104+
TypenameMacros:
105+
- 'DARRAY'
105106
UseTab: ForContinuationAndIndentation
106107
---
107108
Language: ObjC
109+
AccessModifierOffset: 2
110+
AlignArrayOfStructures: Right
111+
AlignConsecutiveAssignments: None
112+
AlignConsecutiveBitFields: None
113+
AlignConsecutiveDeclarations: None
114+
AlignConsecutiveMacros:
115+
Enabled: true
116+
AcrossEmptyLines: false
117+
AcrossComments: true
118+
AllowShortBlocksOnASingleLine: Never
119+
AllowShortEnumsOnASingleLine: false
120+
AllowShortFunctionsOnASingleLine: Empty
121+
AllowShortIfStatementsOnASingleLine: Never
122+
AllowShortLambdasOnASingleLine: None
123+
AttributeMacros: ['__unused', '__autoreleasing', '_Nonnull', '__bridge']
124+
BitFieldColonSpacing: Both
125+
#BreakBeforeBraces: Webkit
126+
BreakBeforeBraces: Custom
127+
BraceWrapping:
128+
AfterCaseLabel: false
129+
AfterClass: true
130+
AfterControlStatement: Never
131+
AfterEnum: false
132+
AfterFunction: true
133+
AfterNamespace: false
134+
AfterObjCDeclaration: false
135+
AfterStruct: false
136+
AfterUnion: false
137+
AfterExternBlock: false
138+
BeforeCatch: false
139+
BeforeElse: false
140+
BeforeLambdaBody: false
141+
BeforeWhile: false
142+
IndentBraces: false
143+
SplitEmptyFunction: false
144+
SplitEmptyRecord: false
145+
SplitEmptyNamespace: true
146+
BreakAfterAttributes: Never
147+
BreakArrays: false
148+
BreakBeforeConceptDeclarations: Allowed
149+
BreakBeforeInlineASMColon: OnlyMultiline
150+
BreakConstructorInitializers: AfterColon
151+
BreakInheritanceList: AfterComma
152+
ColumnLimit: 120
153+
ConstructorInitializerIndentWidth: 4
154+
ContinuationIndentWidth: 4
155+
EmptyLineAfterAccessModifier: Never
156+
EmptyLineBeforeAccessModifier: LogicalBlock
157+
ExperimentalAutoDetectBinPacking: false
158+
FixNamespaceComments: true
159+
IndentAccessModifiers: false
160+
IndentCaseBlocks: false
161+
IndentCaseLabels: true
162+
IndentExternBlock: Indent
163+
IndentGotoLabels: false
164+
IndentRequiresClause: true
165+
IndentWidth: 4
166+
IndentWrappedFunctionNames: true
167+
InsertBraces: false
168+
InsertNewlineAtEOF: true
169+
KeepEmptyLinesAtTheStartOfBlocks: false
170+
LambdaBodyIndentation: Signature
171+
NamespaceIndentation: All
172+
ObjCBinPackProtocolList: Auto
173+
ObjCBlockIndentWidth: 4
174+
ObjCBreakBeforeNestedBlockParam: false
175+
ObjCSpaceAfterProperty: true
176+
ObjCSpaceBeforeProtocolList: true
177+
PPIndentWidth: -1
178+
PackConstructorInitializers: NextLine
179+
QualifierAlignment: Leave
180+
ReferenceAlignment: Right
181+
RemoveSemicolon: false
182+
RequiresClausePosition: WithPreceding
183+
RequiresExpressionIndentation: OuterScope
184+
SeparateDefinitionBlocks: Always
185+
ShortNamespaceLines: 1
186+
SortIncludes: false
187+
#SortUsingDeclarations: LexicographicNumeric
188+
SortUsingDeclarations: true
189+
SpaceAfterCStyleCast: true
190+
SpaceAfterLogicalNot: false
191+
SpaceAroundPointerQualifiers: Default
192+
SpaceBeforeCaseColon: false
193+
SpaceBeforeCpp11BracedList: true
194+
SpaceBeforeCtorInitializerColon: true
195+
SpaceBeforeInheritanceColon: true
196+
SpaceBeforeParens: ControlStatements
197+
SpaceBeforeRangeBasedForLoopColon: true
198+
SpaceBeforeSquareBrackets: false
199+
SpaceInEmptyBlock: false
200+
SpaceInEmptyParentheses: false
201+
SpacesBeforeTrailingComments: 2
202+
SpacesInConditionalStatement: false
203+
SpacesInLineCommentPrefix:
204+
Minimum: 1
205+
Maximum: -1
206+
Standard: c++17
207+
TabWidth: 4
208+
UseTab: Never

src/Config.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,14 @@ bool MigratePersistentData()
195195
if (!std::filesystem::exists(moduleConfigDirectory, ec))
196196
std::filesystem::create_directories(moduleConfigDirectory, ec);
197197
if (ec) {
198-
blog(LOG_ERROR, "[MigratePersistentData] Failed to create directory `%s`: %s", moduleConfigDirectory.c_str(), ec.message().c_str());
198+
blog(LOG_ERROR, "[MigratePersistentData] Failed to create directory `%s`: %s", moduleConfigDirectory.c_str(),
199+
ec.message().c_str());
199200
return false;
200201
}
201202

202203
// Move any existing persistent data to module config directory, then delete old file
203-
std::string oldPersistentDataPath = Utils::Obs::StringHelper::GetCurrentProfilePath() + "/../../../obsWebSocketPersistentData.json";
204+
std::string oldPersistentDataPath =
205+
Utils::Obs::StringHelper::GetCurrentProfilePath() + "/../../../obsWebSocketPersistentData.json";
204206
if (std::filesystem::exists(oldPersistentDataPath, ec)) {
205207
std::string persistentDataPath = Utils::Obs::StringHelper::GetModuleConfigPath("persistent_data.json");
206208
std::filesystem::copy_file(oldPersistentDataPath, persistentDataPath, ec);

src/eventhandler/EventHandler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ void EventHandler::ProcessSubscriptionChange(bool type, uint64_t eventSubscripti
8080
if ((eventSubscriptions & EventSubscription::InputVolumeMeters) != 0) {
8181
if (_inputVolumeMetersRef.fetch_add(1) == 0) {
8282
if (_inputVolumeMetersHandler)
83-
blog(LOG_WARNING, "[EventHandler::ProcessSubscription] Input volume meter handler already exists!");
83+
blog(LOG_WARNING,
84+
"[EventHandler::ProcessSubscription] Input volume meter handler already exists!");
8485
else
8586
_inputVolumeMetersHandler = std::make_unique<Utils::Obs::VolumeMeter::Handler>(
8687
std::bind(&EventHandler::HandleInputVolumeMeters, this, std::placeholders::_1));

src/eventhandler/EventHandler.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,10 @@ class EventHandler {
3636

3737
typedef std::function<void(uint64_t, std::string, json, uint8_t)>
3838
BroadcastCallback; // uint64_t requiredIntent, std::string eventType, json eventData, uint8_t rpcVersion
39-
inline void SetBroadcastCallback(BroadcastCallback cb)
40-
{
41-
_broadcastCallback = cb;
42-
}
39+
inline void SetBroadcastCallback(BroadcastCallback cb) { _broadcastCallback = cb; }
4340

4441
typedef std::function<void(bool)> ObsReadyCallback; // bool ready
45-
inline void SetObsReadyCallback(ObsReadyCallback cb)
46-
{
47-
_obsReadyCallback = cb;
48-
}
42+
inline void SetObsReadyCallback(ObsReadyCallback cb) { _obsReadyCallback = cb; }
4943

5044
void ProcessSubscriptionChange(bool type, uint64_t eventSubscriptions);
5145

@@ -130,7 +124,7 @@ class EventHandler {
130124
calldata_t *data); // Direct callback
131125
static void HandleInputAudioMonitorTypeChanged(void *param,
132126
calldata_t *data); // Direct callback
133-
void HandleInputVolumeMeters(std::vector<json> inputs); // AudioMeter::Handler callback
127+
void HandleInputVolumeMeters(std::vector<json> inputs); // AudioMeter::Handler callback
134128

135129
// Transitions
136130
void HandleCurrentSceneTransitionChanged();
@@ -152,7 +146,7 @@ class EventHandler {
152146
void HandleSourceFilterCreated(obs_source_t *source, obs_source_t *filter);
153147
void HandleSourceFilterRemoved(obs_source_t *source, obs_source_t *filter);
154148
static void HandleSourceFilterNameChanged(void *param,
155-
calldata_t *data); // Direct callback
149+
calldata_t *data); // Direct callback
156150
void HandleSourceFilterSettingsChanged(obs_source_t *source);
157151
static void HandleSourceFilterEnableStateChanged(void *param, calldata_t *data); // Direct callback
158152

src/forms/SettingsDialog.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ void SettingsDialog::SaveFormData()
177177
}
178178
}
179179

180-
bool needsRestart =
181-
(conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) ||
182-
(conf->ServerPort != ui->serverPortSpinBox->value()) ||
183-
(ui->enableAuthenticationCheckBox->isChecked() && conf->ServerPassword != ui->serverPasswordLineEdit->text().toStdString());
180+
bool needsRestart = (conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) ||
181+
(conf->ServerPort != ui->serverPortSpinBox->value()) ||
182+
(ui->enableAuthenticationCheckBox->isChecked() &&
183+
conf->ServerPassword != ui->serverPasswordLineEdit->text().toStdString());
184184

185185
conf->ServerEnabled = ui->enableWebSocketServerCheckBox->isChecked();
186186
conf->AlertsEnabled = ui->enableSystemTrayAlertsCheckBox->isChecked();

src/obs-websocket.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ bool obs_module_load(void)
8282
_webSocketServer = std::make_shared<WebSocketServer>();
8383

8484
// Attach event handlers between WebSocket server and event handler
85-
_eventHandler->SetBroadcastCallback(std::bind(&WebSocketServer::BroadcastEvent, _webSocketServer.get(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
85+
_eventHandler->SetBroadcastCallback(std::bind(&WebSocketServer::BroadcastEvent, _webSocketServer.get(),
86+
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
87+
std::placeholders::_4));
8688
_eventHandler->SetObsReadyCallback(std::bind(&WebSocketServer::SetObsReady, _webSocketServer.get(), std::placeholders::_1));
87-
_webSocketServer->SetClientSubscriptionCallback(std::bind(&EventHandler::ProcessSubscriptionChange, _eventHandler.get(), std::placeholders::_1, std::placeholders::_2));
89+
_webSocketServer->SetClientSubscriptionCallback(std::bind(&EventHandler::ProcessSubscriptionChange, _eventHandler.get(),
90+
std::placeholders::_1, std::placeholders::_2));
8891

8992
// Initialize the settings dialog
9093
obs_frontend_push_ui_translation(obs_module_get_string);

src/requesthandler/RequestBatchHandler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ struct SerialFrameBatch {
3737
std::condition_variable condition;
3838

3939
SerialFrameBatch(RequestHandler &requestHandler, json &variables, bool haltOnFailure)
40-
: requestHandler(requestHandler), variables(variables), haltOnFailure(haltOnFailure)
40+
: requestHandler(requestHandler),
41+
variables(variables),
42+
haltOnFailure(haltOnFailure)
4143
{
4244
}
4345
};

0 commit comments

Comments
 (0)