Skip to content

Commit ca5ff3a

Browse files
committed
Switch to C++23 standard and using enum/designated initializers
1 parent 99a0118 commit ca5ff3a

File tree

7 files changed

+28
-37
lines changed

7 files changed

+28
-37
lines changed

.clang-format

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

3-
Standard: Cpp11
3+
Standard: c++20
44
AccessModifierOffset: -8
55
AlignAfterOpenBracket: Align
66
AlignConsecutiveAssignments: false
@@ -53,7 +53,7 @@ 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'

.github/scripts/check-changes.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/scripts/check-format.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ elif [[ ${OS} = "Darwin" ]] ; then
2626
fi
2727

2828
# Discover clang-format
29-
if type clang-format-13 2> /dev/null ; then
30-
CLANG_FORMAT=clang-format-13
29+
if type clang-format-15 2> /dev/null ; then
30+
CLANG_FORMAT=clang-format-15
3131
elif type clang-format 2> /dev/null ; then
3232
# Clang format found, but need to check version
3333
CLANG_FORMAT=clang-format
3434
V=$(clang-format --version)
35-
if [[ $V != *"version 13.0"* ]]; then
36-
echo "clang-format is not 13.0 (returned ${V})"
35+
if [[ $V != *"version 15.0"* ]]; then
36+
echo "clang-format is not 15.0 (returned ${V})"
3737
exit 1
3838
fi
3939
else
40-
echo "No appropriate clang-format found (expected clang-format-13.0.0, or clang-format)"
40+
echo "No appropriate clang-format found (expected clang-format-15.0.0, or clang-format)"
4141
exit 1
4242
fi
4343

@@ -57,4 +57,4 @@ find . -type d \( \
5757
-name '*.mm' -or \
5858
-name '*.c' -or \
5959
-name '*.cpp' \
60-
| xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -i -style=file -fallback-style=none
60+
| xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -style=file -fallback-style=none --dry-run --Werror

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
submodules: recursive
3131

3232
- name: Install clang-format
33-
run: sudo apt-get install -y clang-format-13
33+
run: sudo apt-get install -y clang-format-15
3434

3535
- name: Run clang-format
36-
run: ./.github/scripts/check-format.sh && ./.github/scripts/check-changes.sh
36+
run: ./.github/scripts/check-format.sh
3737

3838
- name: Install cmake-format
3939
run: sudo pip install cmakelang

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.16.3)
1+
cmake_minimum_required(VERSION 3.22)
22

33
project(advanced-scene-switcher VERSION 1.0.0)
44
set(LIB_NAME "${PROJECT_NAME}-lib")
@@ -375,8 +375,8 @@ set_target_properties(
375375
AUTORCC ON
376376
AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/forms")
377377

378-
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
379-
target_compile_features(${LIB_NAME} PUBLIC cxx_std_17)
378+
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
379+
target_compile_features(${LIB_NAME} PUBLIC cxx_std_23)
380380

381381
add_definitions(-DASIO_STANDALONE)
382382
target_include_directories(

src/macro-core/macro-action-clipboard.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,15 @@ static void copyImageFromUrl(void *param)
9696
bool MacroActionClipboard::PerformAction()
9797
{
9898
switch (_action) {
99-
case Action::COPY_TEXT: {
100-
ClipboardTextQueueParams params{"", "", _text};
99+
using enum Action;
100+
case COPY_TEXT: {
101+
ClipboardTextQueueParams params{.text = _text};
101102
obs_queue_task(OBS_TASK_UI, copyText, &params, true);
102103
SetTempVarValues(params);
103104
break;
104105
}
105-
case Action::COPY_IMAGE: {
106-
ClipboardImageQueueParams params{"", "", _url};
106+
case COPY_IMAGE: {
107+
ClipboardImageQueueParams params{.url = _url};
107108
obs_queue_task(OBS_TASK_UI, copyImageFromUrl, &params, true);
108109
SetTempVarValues(params);
109110
break;

src/macro-core/macro-action-media.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,34 @@ bool MacroActionMedia::PerformAction()
4848
obs_media_state state = obs_source_media_get_state(source);
4949

5050
switch (_action) {
51-
case Action::PLAY:
51+
using enum Action;
52+
case PLAY:
5253
if (state == OBS_MEDIA_STATE_STOPPED ||
5354
state == OBS_MEDIA_STATE_ENDED) {
5455
obs_source_media_restart(source);
5556
} else {
5657
obs_source_media_play_pause(source, false);
5758
}
5859
break;
59-
case Action::PAUSE:
60+
case PAUSE:
6061
obs_source_media_play_pause(source, true);
6162
break;
62-
case Action::STOP:
63+
case STOP:
6364
obs_source_media_stop(source);
6465
break;
65-
case Action::RESTART:
66+
case RESTART:
6667
obs_source_media_restart(source);
6768
break;
68-
case Action::NEXT:
69+
case NEXT:
6970
obs_source_media_next(source);
7071
break;
71-
case Action::PREVIOUS:
72+
case PREVIOUS:
7273
obs_source_media_previous(source);
7374
break;
74-
case Action::SEEK_DURATION:
75+
case SEEK_DURATION:
7576
obs_source_media_set_time(source, _seekDuration.Milliseconds());
7677
break;
77-
case Action::SEEK_PERCENTAGE:
78+
case SEEK_PERCENTAGE:
7879
SeekToPercentage(source);
7980
break;
8081
default:

0 commit comments

Comments
 (0)