Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
BasedOnStyle: LLVM

# Tabs, matching existing Xcode configuration
UseTab: Always
IndentWidth: 4
TabWidth: 4
ContinuationIndentWidth: 4
ObjCBlockIndentWidth: 4

# No column limit — avoids reformatting existing long lines.
# Tighten to 120 once the codebase is cleaned up, if desired.
ColumnLimit: 0

# K&R brace style
BreakBeforeBraces: Attach

# int *x, NSString *name
PointerAlignment: Right

# Case labels indented inside switch
IndentCaseLabels: true

# Imports and includes
SortIncludes: Never

# Objective-C
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true

# Spacing
SpaceAfterCStyleCast: false
SpaceBeforeParens: ControlStatements
SpacesInContainerLiterals: false

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignTrailingComments: true

# Short constructs — keep blocks and control flow multi-line
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false

# Line breaks
BreakBeforeBinaryOperators: None
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.{m,h}]
indent_style = tab
indent_size = 4

[*.py]
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions .github/workflows/objective-c-xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Check Formatting
run: |
brew install clang-format
Scripts/format.sh --check

- name: Prepare Keychain For Signing
env:
SECRET_MACOS_CERTIFICATE_B64: ${{ secrets.MACOS_CERTIFICATE }}
Expand Down
2 changes: 1 addition & 1 deletion CoreZen/Database/DatabaseTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
- (ZENResultSet *)allRows:(ZENDatabase *)database;

- (ZENResultSet *)rowByIdentifier:(ZENIdentifier)identifier
database:(ZENDatabase *)database;
database:(ZENDatabase *)database;

#pragma mark - Count

Expand Down
6 changes: 3 additions & 3 deletions CoreZen/Domain/DomainCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ void ZENCallAsyncContinueBlockOnMainThread(ZENAsyncContinueBlock continueBlock);
// ========================================

// Call a ZENAsyncCompletionBlock on a thread pool
void ZENCallAsyncCompletionBlockOnThreadPool(ZENAsyncCompletionBlock completionBlock, NSError* error);
void ZENCallAsyncCompletionBlockOnThreadPool(ZENAsyncCompletionBlock completionBlock, NSError *error);

// Call a ZENAsyncCompletionBlock on the main thread
void ZENCallAsyncCompletionBlockOnMainThread(ZENAsyncCompletionBlock completionBlock, NSError* error);
void ZENCallAsyncCompletionBlockOnMainThread(ZENAsyncCompletionBlock completionBlock, NSError *error);

// ========================================
// ZENFetchResultsBlock
Expand Down Expand Up @@ -63,4 +63,4 @@ void ZENCallAsyncCountCompletionBlockOnMainThread(ZENAsyncCountCompletionBlock c
// ========================================

// Deliver a notification on the main thread
void ZENDeliverNotificationOnMainThread(NSString* notification, id sender, NSDictionary *userData);
void ZENDeliverNotificationOnMainThread(NSString *notification, id sender, NSDictionary *userData);
4 changes: 2 additions & 2 deletions CoreZen/Domain/DomainObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@protocol ZENDataModel
@end

@protocol ZENDomainObject<NSObject, ZENIdentifiable>
@protocol ZENDomainObject <NSObject, ZENIdentifiable>

- (instancetype)initWithDTO:(ZENDataTransferObject *)dto;

Expand All @@ -23,7 +23,7 @@

@end

@interface ZENDomainObject : NSObject<ZENDomainObject>
@interface ZENDomainObject : NSObject <ZENDomainObject>

@property (nonatomic, strong, readonly) ZENDataTransferObject *basicDTO;

Expand Down
20 changes: 10 additions & 10 deletions CoreZen/Domain/ObjectRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ typedef enum : NSUInteger {

// Runs asynchronously. Result callback block happens on a thread pool.
- (void)fetchObjectByIdentifier:(ZENIdentifier)identifier
completion:(ZENFetchResultsBlock)resultsBlock;
completion:(ZENFetchResultsBlock)resultsBlock;

// Same as above, but uiCompletion block happens on the main thread.
- (void)fetchObjectByIdentifier:(ZENIdentifier)identifier
uiCompletion:(ZENFetchResultsBlock)resultsBlock;
uiCompletion:(ZENFetchResultsBlock)resultsBlock;

// Runs asynchronously. Result callback block happens on a thread pool.
- (void)fetchAllObjects:(ZENFetchResultsBlock)resultsBlock;
Expand All @@ -69,12 +69,12 @@ typedef enum : NSUInteger {

// Helper method to call DomainObject +asyncInit: on object before
// adding to repository.
- (void) asyncInitAndAdd:(ZENDomainObject *)domainObject
completion:(ZENAsyncContinueBlock)completion;
- (void)asyncInitAndAdd:(ZENDomainObject *)domainObject
completion:(ZENAsyncContinueBlock)completion;

// Same as above, but uiCompletion block happens on the main thread.
- (void) asyncInitAndAdd:(ZENDomainObject *)domainObject
uiCompletion:(ZENAsyncContinueBlock)completion;
- (void)asyncInitAndAdd:(ZENDomainObject *)domainObject
uiCompletion:(ZENAsyncContinueBlock)completion;

#pragma mark - Update

Expand Down Expand Up @@ -107,8 +107,8 @@ typedef enum : NSUInteger {
@end


extern NSString * const ZENObjectRepositoryNotificationObjectKey;
extern NSString *const ZENObjectRepositoryNotificationObjectKey;

extern NSString * const ZENObjectRepositoryObjectAddedNotification;
extern NSString * const ZENObjectRepositoryObjectUpdatedNotification;
extern NSString * const ZENObjectRepositoryObjectDeletedNotification;
extern NSString *const ZENObjectRepositoryObjectAddedNotification;
extern NSString *const ZENObjectRepositoryObjectUpdatedNotification;
extern NSString *const ZENObjectRepositoryObjectDeletedNotification;
110 changes: 55 additions & 55 deletions CoreZen/Media/MPV/MPVConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,72 @@
//

// Version properties
extern const char* const kMPVProperty_ffmpeg_version;
extern const char* const kMPVProperty_libass_version;
extern const char* const kMPVProperty_mpv_version;
extern const char *const kMPVProperty_ffmpeg_version;
extern const char *const kMPVProperty_libass_version;
extern const char *const kMPVProperty_mpv_version;

// Read-only properties
extern const char* const kMPVProperty_audio_bitrate;
extern const char* const kMPVProperty_audio_codec;
extern const char* const kMPVProperty_audio_codec_name;
extern const char* const kMPVProperty_dheight;
extern const char* const kMPVProperty_duration;
extern const char* const kMPVProperty_dwidth;
extern const char* const kMPVProperty_estimated_frame_count;
extern const char* const kMPVProperty_estimated_frame_number;
extern const char* const kMPVProperty_file_format;
extern const char* const kMPVProperty_file_size;
extern const char* const kMPVProperty_filename;
extern const char* const kMPVProperty_filename_no_ext;
extern const char* const kMPVProperty_height;
extern const char* const kMPVProperty_media_title;
extern const char* const kMPVProperty_path;
extern const char* const kMPVProperty_pause;
extern const char* const kMPVProperty_playlist_count;
extern const char* const kMPVProperty_playlist_playing_pos;
extern const char* const kMPVProperty_sub_bitrate;
extern const char* const kMPVProperty_time_remaining;
extern const char* const kMPVProperty_video_bitrate;
extern const char* const kMPVProperty_video_codec;
extern const char* const kMPVProperty_video_format;
extern const char* const kMPVProperty_video_params_aspect;
extern const char* const kMPVProperty_width;
extern const char *const kMPVProperty_audio_bitrate;
extern const char *const kMPVProperty_audio_codec;
extern const char *const kMPVProperty_audio_codec_name;
extern const char *const kMPVProperty_dheight;
extern const char *const kMPVProperty_duration;
extern const char *const kMPVProperty_dwidth;
extern const char *const kMPVProperty_estimated_frame_count;
extern const char *const kMPVProperty_estimated_frame_number;
extern const char *const kMPVProperty_file_format;
extern const char *const kMPVProperty_file_size;
extern const char *const kMPVProperty_filename;
extern const char *const kMPVProperty_filename_no_ext;
extern const char *const kMPVProperty_height;
extern const char *const kMPVProperty_media_title;
extern const char *const kMPVProperty_path;
extern const char *const kMPVProperty_pause;
extern const char *const kMPVProperty_playlist_count;
extern const char *const kMPVProperty_playlist_playing_pos;
extern const char *const kMPVProperty_sub_bitrate;
extern const char *const kMPVProperty_time_remaining;
extern const char *const kMPVProperty_video_bitrate;
extern const char *const kMPVProperty_video_codec;
extern const char *const kMPVProperty_video_format;
extern const char *const kMPVProperty_video_params_aspect;
extern const char *const kMPVProperty_width;

// Read-write properties
extern const char* const kMPVProperty_ao_mute;
extern const char* const kMPVProperty_ao_volume;
extern const char* const kMPVProperty_percent_pos;
extern const char* const kMPVProperty_playback_time;
extern const char* const kMPVProperty_playlist_pos;
extern const char* const kMPVProperty_time_pos;
extern const char* const kMPVProperty_sid;
extern const char *const kMPVProperty_ao_mute;
extern const char *const kMPVProperty_ao_volume;
extern const char *const kMPVProperty_percent_pos;
extern const char *const kMPVProperty_playback_time;
extern const char *const kMPVProperty_playlist_pos;
extern const char *const kMPVProperty_time_pos;
extern const char *const kMPVProperty_sid;

// Property keys
extern const char* const kMPVPropertyKey_name;
extern const char* const kMPVPropertyKey_data;
extern const char* const kMPVPropertyKey_id;
extern const char* const kMPVPropertyKey_no;
extern const char *const kMPVPropertyKey_name;
extern const char *const kMPVPropertyKey_data;
extern const char *const kMPVPropertyKey_id;
extern const char *const kMPVPropertyKey_no;

// Config options
extern const char* const kMPVOption_hwdec;
extern const char* const kMPVOption_vo;
extern const char *const kMPVOption_hwdec;
extern const char *const kMPVOption_vo;

// Config option params
extern const char* const kMPVOptionParam_libmpv;
extern const char* const kMPVOptionParam_videotoolbox;
extern const char *const kMPVOptionParam_libmpv;
extern const char *const kMPVOptionParam_videotoolbox;

// Commands
extern const char* const kMPVCommand_loadfile;
extern const char* const kMPVCommand_quit;
extern const char* const kMPVCommand_playlist_play_index;
extern const char* const kMPVCommand_frame_step;
extern const char* const kMPVCommand_frame_back_step;
extern const char* const kMPVCommand_seek;
extern const char *const kMPVCommand_loadfile;
extern const char *const kMPVCommand_quit;
extern const char *const kMPVCommand_playlist_play_index;
extern const char *const kMPVCommand_frame_step;
extern const char *const kMPVCommand_frame_back_step;
extern const char *const kMPVCommand_seek;

// Command params
extern const char* const kMPVCommandParam_relative;
extern const char* const kMPVCommandParam_absolute;
extern const char* const kMPVCommandParam_absolute_percent;
extern const char* const kMPVCommandParam_keyframes;
extern const char* const kMPVCommandParam_exact;
extern const char* const kMPVCommandParam_replace;
extern const char *const kMPVCommandParam_relative;
extern const char *const kMPVCommandParam_absolute;
extern const char *const kMPVCommandParam_absolute_percent;
extern const char *const kMPVCommandParam_keyframes;
extern const char *const kMPVCommandParam_exact;
extern const char *const kMPVCommandParam_replace;
11 changes: 5 additions & 6 deletions CoreZen/Media/MPV/MPVFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ const char *zen_double_to_mpv_string(double d);

typedef struct mpv_handle mpv_handle;

void zen_mpv_set_bool_property(mpv_handle* mpv, const char* const property, BOOL value);
void zen_mpv_set_string_property(mpv_handle* mpv, const char* const property, const char* const value);
void zen_mpv_set_bool_property(mpv_handle *mpv, const char *const property, BOOL value);
void zen_mpv_set_string_property(mpv_handle *mpv, const char *const property, const char *const value);

BOOL zen_mpv_compare_strings(const char* const one, const char* const two);
BOOL zen_mpv_compare_strings(const char *const one, const char *const two);

void zen_mpv_init_pthread_mutex_cond(pthread_mutex_t* mutex, pthread_cond_t* cond);
void zen_mpv_destroy_pthread_mutex_cond(pthread_mutex_t* mutex, pthread_cond_t* cond);
void zen_mpv_init_pthread_mutex_cond(pthread_mutex_t *mutex, pthread_cond_t *cond);
void zen_mpv_destroy_pthread_mutex_cond(pthread_mutex_t *mutex, pthread_cond_t *cond);

void *zen_mpv_get_opengl_proc_address(void *ctx, const char *name);

2 changes: 1 addition & 1 deletion CoreZen/Media/MediaFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@property (nonatomic, strong, readonly) NSURL *fileURL;

+ (instancetype)mediaFileWithURL:(NSURL*)url;
+ (instancetype)mediaFileWithURL:(NSURL *)url;

// Terminate frame renderer (and frame render controller) if one was created,
// then terminate media file format context
Expand Down
1 change: 0 additions & 1 deletion CoreZenTests/Classes/TestIdentifiable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
- (instancetype)initWithIdentifier:(ZENIdentifier)identifier;

@end

52 changes: 52 additions & 0 deletions Scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SOURCE_DIRS=("CoreZen" "CoreZenTests")

if ! command -v clang-format &>/dev/null; then
echo "error: clang-format not found"
echo " Install with: brew install clang-format"
exit 1
fi

files=()
for dir in "${SOURCE_DIRS[@]}"; do
target="$REPO_ROOT/$dir"
[ -d "$target" ] || continue
while IFS= read -r -d '' f; do
files+=("$f")
done < <(find "$target" -name '*.m' -o -name '*.h' -print0 2>/dev/null || true)
done

if [ ${#files[@]} -eq 0 ]; then
echo "No source files found."
exit 0
fi

check_only=false
for arg in "$@"; do
case "$arg" in
--check) check_only=true ;;
*)
echo "usage: $(basename "$0") [--check]"
echo " --check Report violations without modifying files (exit 1 if any found)"
exit 1
;;
esac
done

if $check_only; then
echo "Checking formatting of ${#files[@]} files..."
if ! clang-format --dry-run --Werror "${files[@]}"; then
echo ""
echo "Formatting violations found. Run Scripts/format.sh to fix."
exit 1
fi
echo "All files formatted correctly."
else
echo "Formatting ${#files[@]} files..."
clang-format -i "${files[@]}"
echo "Done."
fi
Loading