Skip to content

Commit

Permalink
clang-format: Update to clang-format 17.0.3
Browse files Browse the repository at this point in the history
Also port clang-format settings from obs-studio. Use these settings for
consistency with obs-studio code style.
  • Loading branch information
RytoEX committed Oct 17, 2024
1 parent be035cd commit 362b9a3
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 34 deletions.
136 changes: 118 additions & 18 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# please use clang-format version 16 or later

# please use clang-format version 8 or later

Standard: Cpp11
Standard: c++17
AccessModifierOffset: -8
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
#AllowAllArgumentsOnNextLine: false # requires clang-format 9
#AllowAllConstructorInitializersOnNextLine: false # requires clang-format 9
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
#AllowShortLambdasOnASingleLine: Inline # requires clang-format 9
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
Expand Down Expand Up @@ -53,11 +52,12 @@ ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: false
ForEachMacros:
FixNamespaceComments: true
ForEachMacros:
- 'json_object_foreach'
- 'json_object_foreach_safe'
- 'json_array_foreach'
- 'HASH_ITER'
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: None
Expand All @@ -66,7 +66,7 @@ IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
#ObjCBinPackProtocolList: Auto # requires clang-format 7
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
Expand All @@ -84,25 +84,125 @@ ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
#SpaceAfterLogicalNot: false # requires clang-format 9
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
#SpaceBeforeCtorInitializerColon: true # requires clang-format 7
#SpaceBeforeInheritanceColon: true # requires clang-format 7
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true # requires clang-format 7
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
#StatementMacros: # requires clang-format 8
# - 'Q_OBJECT'
StatementMacros:
- 'Q_OBJECT'
TabWidth: 8
#TypenameMacros: # requires clang-format 9
# - 'DARRAY'
TypenameMacros:
- 'DARRAY'
UseTab: ForContinuationAndIndentation
---
Language: ObjC
Language: ObjC
AccessModifierOffset: 2
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AllowShortBlocksOnASingleLine: Never
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AttributeMacros: ['__unused', '__autoreleasing', '_Nonnull', '__bridge']
BitFieldColonSpacing: Both
#BreakBeforeBraces: Webkit
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakAfterAttributes: Never
BreakArrays: false
BreakBeforeConceptDeclarations: Allowed
BreakBeforeInlineASMColon: OnlyMultiline
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterComma
ColumnLimit: 120
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertBraces: false
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PPIndentWidth: -1
PackConstructorInitializers: NextLine
QualifierAlignment: Leave
ReferenceAlignment: Right
RemoveSemicolon: false
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: false
#SortUsingDeclarations: LexicographicNumeric
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInConditionalStatement: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
Standard: c++17
TabWidth: 4
UseTab: Never
3 changes: 2 additions & 1 deletion browser-app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class BrowserApp : public CefApp, public CefRenderProcessHandler, public CefBrow
inline BrowserApp(bool shared_texture_available_ = false) : shared_texture_available(shared_texture_available_)
#else
inline BrowserApp(bool shared_texture_available_ = false, bool wayland_ = false)
: shared_texture_available(shared_texture_available_), wayland(wayland_)
: shared_texture_available(shared_texture_available_),
wayland(wayland_)
#endif
{
}
Expand Down
44 changes: 33 additions & 11 deletions obs-browser-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,32 @@ void RegisterBrowserSource()
info.get_defaults = browser_source_get_defaults;
info.icon_type = OBS_ICON_TYPE_BROWSER;

info.get_name = [](void *) { return obs_module_text("BrowserSource"); };
info.get_name = [](void *) {
return obs_module_text("BrowserSource");
};
info.create = [](obs_data_t *settings, obs_source_t *source) -> void * {
obs_browser_initialize();
return new BrowserSource(settings, source);
};
info.destroy = [](void *data) { static_cast<BrowserSource *>(data)->Destroy(); };
info.destroy = [](void *data) {
static_cast<BrowserSource *>(data)->Destroy();
};
info.missing_files = browser_source_missingfiles;
info.update = [](void *data, obs_data_t *settings) { static_cast<BrowserSource *>(data)->Update(settings); };
info.get_width = [](void *data) { return (uint32_t) static_cast<BrowserSource *>(data)->width; };
info.get_height = [](void *data) { return (uint32_t) static_cast<BrowserSource *>(data)->height; };
info.video_tick = [](void *data, float) { static_cast<BrowserSource *>(data)->Tick(); };
info.video_render = [](void *data, gs_effect_t *) { static_cast<BrowserSource *>(data)->Render(); };
info.update = [](void *data, obs_data_t *settings) {
static_cast<BrowserSource *>(data)->Update(settings);
};
info.get_width = [](void *data) {
return (uint32_t) static_cast<BrowserSource *>(data)->width;
};
info.get_height = [](void *data) {
return (uint32_t) static_cast<BrowserSource *>(data)->height;
};
info.video_tick = [](void *data, float) {
static_cast<BrowserSource *>(data)->Tick();
};
info.video_render = [](void *data, gs_effect_t *) {
static_cast<BrowserSource *>(data)->Render();
};
#if CHROME_VERSION_BUILD < 4103
info.audio_mix = [](void *data, uint64_t *ts_out, struct audio_output_data *audio_output, size_t channels,
size_t sample_rate) {
Expand All @@ -466,19 +480,27 @@ void RegisterBrowserSource()
info.mouse_wheel = [](void *data, const struct obs_mouse_event *event, int x_delta, int y_delta) {
static_cast<BrowserSource *>(data)->SendMouseWheel(event, x_delta, y_delta);
};
info.focus = [](void *data, bool focus) { static_cast<BrowserSource *>(data)->SendFocus(focus); };
info.focus = [](void *data, bool focus) {
static_cast<BrowserSource *>(data)->SendFocus(focus);
};
info.key_click = [](void *data, const struct obs_key_event *event, bool key_up) {
static_cast<BrowserSource *>(data)->SendKeyClick(event, key_up);
};
info.show = [](void *data) { static_cast<BrowserSource *>(data)->SetShowing(true); };
info.hide = [](void *data) { static_cast<BrowserSource *>(data)->SetShowing(false); };
info.show = [](void *data) {
static_cast<BrowserSource *>(data)->SetShowing(true);
};
info.hide = [](void *data) {
static_cast<BrowserSource *>(data)->SetShowing(false);
};
info.activate = [](void *data) {
BrowserSource *bs = static_cast<BrowserSource *>(data);
if (bs->restart)
bs->Refresh();
bs->SetActive(true);
};
info.deactivate = [](void *data) { static_cast<BrowserSource *>(data)->SetActive(false); };
info.deactivate = [](void *data) {
static_cast<BrowserSource *>(data)->SetActive(false);
};

obs_register_source(&info);
}
Expand Down
4 changes: 3 additions & 1 deletion panel/browser-panel-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,9 @@ bool QCefBrowserClient::OnJSDialog(CefRefPtr<CefBrowser>, const CefString &,
title << ": " << obs_module_text("Dialog.BrowserDock");
dlg->setWindowTitle(title.str().c_str());

auto finished = [callback](int result) { callback.get()->Continue(result == QMessageBox::Ok, ""); };
auto finished = [callback](int result) {
callback.get()->Continue(result == QMessageBox::Ok, "");
};

QWidget::connect(dlg, &QMessageBox::finished, finished);

Expand Down
4 changes: 3 additions & 1 deletion panel/browser-panel-client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class QCefBrowserClient : public CefClient,

public:
inline QCefBrowserClient(QCefWidgetInternal *widget_, const std::string &script_, bool allowAllPopups_)
: widget(widget_), script(script_), allowAllPopups(allowAllPopups_)
: widget(widget_),
script(script_),
allowAllPopups(allowAllPopups_)
{
}

Expand Down
7 changes: 5 additions & 2 deletions panel/browser-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class CookieCheck : public CefCookieVisitor {
bool cookie_found = false;

inline CookieCheck(QCefCookieManager::cookie_exists_cb callback_, const std::string target_)
: callback(callback_), target(target_)
: callback(callback_),
target(target_)
{
}

Expand Down Expand Up @@ -131,7 +132,9 @@ struct QCefCookieManagerInternal : QCefCookieManager {
/* ------------------------------------------------------------------------- */

QCefWidgetInternal::QCefWidgetInternal(QWidget *parent, const std::string &url_, CefRefPtr<CefRequestContext> rqc_)
: QCefWidget(parent), url(url_), rqc(rqc_)
: QCefWidget(parent),
url(url_),
rqc(rqc_)
{
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_StaticContents);
Expand Down

0 comments on commit 362b9a3

Please sign in to comment.