clang format: add objective c++ formatting
This commit is contained in:
parent
940ec70f13
commit
d5a4988f9e
@ -291,15 +291,15 @@ if (CLANG_FORMAT)
|
|||||||
set(CCOMMENT "Running clang format against all the .h and .cpp files in src/")
|
set(CCOMMENT "Running clang format against all the .h and .cpp files in src/")
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_custom_target(clang-format
|
add_custom_target(clang-format
|
||||||
COMMAND powershell.exe -Command "Get-ChildItem '${SRCS}/*' -Include *.cpp,*.h -Recurse | Foreach {&'${CLANG_FORMAT}' -i $_.fullname}"
|
COMMAND powershell.exe -Command "Get-ChildItem '${SRCS}/*' -Include *.cpp,*.h,*.mm -Recurse | Foreach {&'${CLANG_FORMAT}' -i $_.fullname}"
|
||||||
COMMENT ${CCOMMENT})
|
COMMENT ${CCOMMENT})
|
||||||
elseif(MINGW)
|
elseif(MINGW)
|
||||||
add_custom_target(clang-format
|
add_custom_target(clang-format
|
||||||
COMMAND find `cygpath -u ${SRCS}` -iname *.h -o -iname *.cpp | xargs `cygpath -u ${CLANG_FORMAT}` -i
|
COMMAND find `cygpath -u ${SRCS}` -iname *.h -o -iname *.cpp -o -iname *.mm | xargs `cygpath -u ${CLANG_FORMAT}` -i
|
||||||
COMMENT ${CCOMMENT})
|
COMMENT ${CCOMMENT})
|
||||||
else()
|
else()
|
||||||
add_custom_target(clang-format
|
add_custom_target(clang-format
|
||||||
COMMAND find ${SRCS} -iname *.h -o -iname *.cpp | xargs ${CLANG_FORMAT} -i
|
COMMAND find ${SRCS} -iname *.h -o -iname *.cpp -o -iname *.mm | xargs ${CLANG_FORMAT} -i
|
||||||
COMMENT ${CCOMMENT})
|
COMMENT ${CCOMMENT})
|
||||||
endif()
|
endif()
|
||||||
unset(SRCS)
|
unset(SRCS)
|
||||||
|
@ -169,4 +169,88 @@ SpacesInParentheses: false
|
|||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
---
|
||||||
|
Language: ObjC
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlinesLeft: false
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
ColumnLimit: 100
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^\<[^Q][^/.>]*\>'
|
||||||
|
Priority: -2
|
||||||
|
- Regex: '^\<'
|
||||||
|
Priority: -1
|
||||||
|
- Regex: '^\"'
|
||||||
|
Priority: 0
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 150
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
...
|
...
|
||||||
|
@ -11,57 +11,54 @@ namespace AppleAuthorization {
|
|||||||
|
|
||||||
static bool authorized = false;
|
static bool authorized = false;
|
||||||
|
|
||||||
enum class AuthMediaType {
|
enum class AuthMediaType { Camera, Microphone };
|
||||||
Camera,
|
|
||||||
Microphone
|
|
||||||
};
|
|
||||||
|
|
||||||
// Based on https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos
|
// Based on
|
||||||
|
// https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos
|
||||||
void CheckAuthorization(AuthMediaType type) {
|
void CheckAuthorization(AuthMediaType type) {
|
||||||
if (@available(macOS 10.14, *)) {
|
if (@available(macOS 10.14, *)) {
|
||||||
NSString *media_type;
|
NSString* media_type;
|
||||||
if(type == AuthMediaType::Camera) {
|
if (type == AuthMediaType::Camera) {
|
||||||
media_type = AVMediaTypeVideo;
|
media_type = AVMediaTypeVideo;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
media_type = AVMediaTypeAudio;
|
media_type = AVMediaTypeAudio;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request permission to access the camera and microphone.
|
// Request permission to access the camera and microphone.
|
||||||
switch ([AVCaptureDevice authorizationStatusForMediaType:media_type]) {
|
switch ([AVCaptureDevice authorizationStatusForMediaType:media_type]) {
|
||||||
case AVAuthorizationStatusAuthorized:
|
case AVAuthorizationStatusAuthorized:
|
||||||
// The user has previously granted access to the camera.
|
// The user has previously granted access to the camera.
|
||||||
authorized = true;
|
authorized = true;
|
||||||
break;
|
break;
|
||||||
case AVAuthorizationStatusNotDetermined:
|
case AVAuthorizationStatusNotDetermined: {
|
||||||
{
|
// The app hasn't yet asked the user for camera access.
|
||||||
// The app hasn't yet asked the user for camera access.
|
[AVCaptureDevice requestAccessForMediaType:media_type
|
||||||
[AVCaptureDevice requestAccessForMediaType:media_type completionHandler:^(BOOL) {
|
completionHandler:^(BOOL) {
|
||||||
authorized = true;
|
authorized = true;
|
||||||
}];
|
}];
|
||||||
if(type == AuthMediaType::Camera) {
|
if (type == AuthMediaType::Camera) {
|
||||||
LOG_INFO(Frontend, "Camera access requested.");
|
LOG_INFO(Frontend, "Camera access requested.");
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AVAuthorizationStatusDenied:
|
|
||||||
{
|
|
||||||
// The user has previously denied access.
|
|
||||||
authorized = false;
|
|
||||||
if(type == AuthMediaType::Camera) {
|
|
||||||
LOG_WARNING(Frontend, "Camera access denied. To change this you may modify the macos system settings for Citra at 'System Preferences -> Security & Privacy -> Camera'");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case AVAuthorizationStatusRestricted:
|
|
||||||
{
|
|
||||||
// The user can't grant access due to restrictions.
|
|
||||||
authorized = false;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
case AVAuthorizationStatusDenied: {
|
||||||
else {
|
// The user has previously denied access.
|
||||||
|
authorized = false;
|
||||||
|
if (type == AuthMediaType::Camera) {
|
||||||
|
LOG_WARNING(
|
||||||
|
Frontend,
|
||||||
|
"Camera access denied. To change this you may modify the macos system settings "
|
||||||
|
"for Citra at 'System Preferences -> Security & Privacy -> Camera'");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case AVAuthorizationStatusRestricted: {
|
||||||
|
// The user can't grant access due to restrictions.
|
||||||
|
authorized = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
authorized = true;
|
authorized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,4 +73,4 @@ bool CheckAuthorizationForMicrophone() {
|
|||||||
return authorized;
|
return authorized;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //AppleAuthorization
|
} // AppleAuthorization
|
||||||
|
Loading…
Reference in New Issue
Block a user