Skip to content

Commit

Permalink
Update .clang-format rules for ObjC files for version 16
Browse files Browse the repository at this point in the history
  • Loading branch information
PatTheMav authored and RytoEX committed Aug 10, 2023
1 parent 64139a6 commit 7628265
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 32 deletions.
44 changes: 18 additions & 26 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,13 @@ AlignArrayOfStructures: Right
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: AcrossComments
#AlignConsecutiveMacros:
# Enabled: true
# AcrossEmptyLines: false
# AcrossComments: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AllowShortBlocksOnASingleLine: Never
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AttributeMacros: ['__unused', '__autoreleasing', '_Nonnull', '__bridge']
Expand All @@ -144,11 +143,10 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
#BreakAfterAttributes: Never # clang-format 16
#BreakArrays: false # clang-format 16
#BreakBeforeConceptDeclarations: Allowed
BreakBeforeConceptDeclarations: true
#BreakBeforeInlineASMColon: OnlyMultiline # clang-format 16
BreakAfterAttributes: Never
BreakArrays: false
BreakBeforeConceptDeclarations: Allowed
BreakBeforeInlineASMColon: OnlyMultiline
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterComma
ColumnLimit: 120
Expand All @@ -163,33 +161,27 @@ IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
#IndentRequiresClause: true # clang-format 15
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
#InsertBraces: false # clang-format 15
#InsertNewlineAtEOF: true # clang-format 16
#IntegerLiteralSeparator: # clang-format 16
# Binary: 0
# Decimal: 3
# Hex: -1
InsertBraces: false
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
#LineEnding: LF # clang-format 16
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PPIndentWidth: -1
#PackConstructorInitializers: NextLine # clang-format 14
#QualifierAlignment: Left # clang-format 14
#QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ] # clang-format 14
PackConstructorInitializers: NextLine
QualifierAlignment: Leave
ReferenceAlignment: Right
#RemoveSemicolon: false # clang-format 16
#RequiresClausePosition: WithPreceding # clang-format 15
#RequiresExpressionIndentation: OuterScope # clang-format 16
#SeparateDefinitionBlocks: Always # clang-format 14
RemoveSemicolon: false
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 1
SortIncludes: false
#SortUsingDeclarations: LexicographicNumeric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ void GetCurrentWindowTitle(string &title)
}
}

void CleanupSceneSwitcher()
{}
void CleanupSceneSwitcher() {}
9 changes: 7 additions & 2 deletions UI/platform-osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ @interface DockView : NSView {
@end

@implementation DockView

- (id)initWithIcon:(QIcon)icon
{
self = [super init];
_icon = icon;
return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
CGSize size = dirtyRect.size;
Expand All @@ -205,6 +207,7 @@ - (void)drawRect:(NSRect)dirtyRect
context, CGRectMake(size.width * (1 - iconSize), 0, size.width * iconSize, size.height * iconSize), image);
CGImageRelease(image);
}

@end

MacPermissionStatus CheckPermissionWithPrompt(MacPermissionType type, bool prompt_for_permission)
Expand Down Expand Up @@ -304,8 +307,8 @@ void SetMacOSDarkMode(bool dark)
}
}

void TaskbarOverlayInit()
{}
void TaskbarOverlayInit() {}

void TaskbarOverlaySetStatus(TaskbarOverlayStatus status)
{
QIcon icon;
Expand Down Expand Up @@ -335,12 +338,14 @@ @interface OBSApplication : NSApplication <CrAppProtocol>
@end

@implementation OBSApplication

- (void)sendEvent:(NSEvent *)event
{
_handlingSendEvent = YES;
[super sendEvent:event];
_handlingSendEvent = NO;
}

@end

void InstallNSThreadLocks()
Expand Down
5 changes: 5 additions & 0 deletions libobs/obs-cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ static void hotkeys_retain(struct obs_hotkeys_platform *plat)
}

static inline void free_hotkeys_platform(obs_hotkeys_platform_t *plat);

static void hotkeys_release(struct obs_hotkeys_platform *plat)
{
if (os_atomic_dec_long(&plat->refs) == -1)
Expand Down Expand Up @@ -556,6 +557,7 @@ void obs_key_to_str(obs_key_t key, struct dstr *str)
}

#define OBS_COCOA_MODIFIER_SIZE 7

static void unichar_to_utf8(const UniChar *c, char *buff)
{
CFStringRef string = CFStringCreateWithCharactersNoCopy(NULL, c, 2, kCFAllocatorNull);
Expand All @@ -578,6 +580,7 @@ static void unichar_to_utf8(const UniChar *c, char *buff)
static char opt_str[OBS_COCOA_MODIFIER_SIZE];
static char shift_str[OBS_COCOA_MODIFIER_SIZE];
static char cmd_str[OBS_COCOA_MODIFIER_SIZE];

static void init_utf_8_strings(void)
{
const UniChar ctrl_uni[] = {kControlUnicode, 0};
Expand All @@ -592,6 +595,7 @@ static void init_utf_8_strings(void)
}

static pthread_once_t strings_token = PTHREAD_ONCE_INIT;

void obs_key_combination_to_str(obs_key_combination_t key, struct dstr *str)
{
struct dstr key_str = {0};
Expand Down Expand Up @@ -785,6 +789,7 @@ void obs_hotkeys_platform_free(struct obs_core_hotkeys *hotkeys)
}

typedef unsigned long NSUInteger;

static bool mouse_button_pressed(obs_key_t key, bool *pressed)
{
int button = 0;
Expand Down
7 changes: 5 additions & 2 deletions plugins/mac-avcapture/av-capture.mm
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
struct observer_handle : unique_ptr<remove_pointer<id>::type, decltype(remove_observer)> {
using base = unique_ptr<remove_pointer<id>::type, decltype(remove_observer)>;

explicit observer_handle(id observer = nullptr) : base(observer, remove_observer)
{}
explicit observer_handle(id observer = nullptr) : base(observer, remove_observer) {}
};

struct av_video_info {
Expand Down Expand Up @@ -636,6 +635,7 @@ static inline bool update_audio(obs_source_audio *audio, CMSampleBufferRef sampl
}

@implementation OBSAVCaptureDelegate

- (void)captureOutput:(AVCaptureOutput *)out
didDropSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
Expand Down Expand Up @@ -688,6 +688,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
obs_source_output_audio(capture->source, audio);
}
}

@end

static void av_capture_enable_buffering(av_capture *capture, bool enabled)
Expand Down Expand Up @@ -1579,6 +1580,7 @@ static media_frames_per_second convert(CMTime time_)
}

using frame_rates_t = vector<pair<media_frames_per_second, media_frames_per_second>>;

static frame_rates_t enumerate_frame_rates(AVCaptureDevice *dev, const CMVideoDimensions *dims = nullptr)
{
frame_rates_t res;
Expand Down Expand Up @@ -2159,6 +2161,7 @@ static void av_capture_update(void *data, obs_data_t *settings)

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("mac-avcapture", "en-US")

MODULE_EXPORT const char *obs_module_description(void)
{
return "MacOS AVFoundation Capture source";
Expand Down
1 change: 1 addition & 0 deletions plugins/mac-syphon/SyphonOBSClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ - (IOSurfaceRef)newFrameImage
{
return [self newSurface];
}

@end
1 change: 1 addition & 0 deletions plugins/mac-virtualcam/src/dal-plugin/OBSDALMachClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@interface OBSDALMachClient () <NSPortDelegate> {
NSPort *_receivePort;
}

@end

@implementation OBSDALMachClient
Expand Down
1 change: 1 addition & 0 deletions plugins/mac-virtualcam/src/dal-plugin/OBSDALPlugIn.mm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ @interface OBSDALPlugin () <MachClientDelegate> {
//! Timeout timer when we haven't received frames for 5s
dispatch_source_t _timeoutTimer;
}

@property OBSDALPlugInState state;
@property OBSDALMachClient *machClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ OSStatus HardwarePlugIn_ObjectSetPropertyData(CMIOHardwarePlugInRef self, CMIOOb
}

#pragma mark CMIOStream Operations

OSStatus HardwarePlugIn_StreamCopyBufferQueue(CMIOHardwarePlugInRef self, CMIOStreamID streamID,
CMIODeviceStreamQueueAlteredProc queueAlteredProc,
void *queueAlteredRefCon, CMSimpleQueueRef *queue)
Expand All @@ -262,6 +263,7 @@ OSStatus HardwarePlugIn_StreamCopyBufferQueue(CMIOHardwarePlugInRef self, CMIOSt
}

#pragma mark CMIODevice Operations

OSStatus HardwarePlugIn_DeviceStartStream(CMIOHardwarePlugInRef self, CMIODeviceID deviceID, CMIOStreamID streamID)
{
DLogFunc(@"self=%p device=%d stream=%d", self, deviceID, streamID);
Expand Down
1 change: 1 addition & 0 deletions plugins/mac-virtualcam/src/obs-plugin/plugin-main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("mac-virtualcam", "en-US")

MODULE_EXPORT const char *obs_module_description(void)
{
return "macOS virtual webcam output";
Expand Down

0 comments on commit 7628265

Please sign in to comment.