1
0
Эх сурвалжийг харах

CI: Update to clang-format 16

This commit also modifies UI, libobs, and plugins.
Ryan Foster 2 жил өмнө
parent
commit
64139a6bbd

+ 3 - 3
.clang-format

@@ -1,4 +1,4 @@
-# please use clang-format version 13 or later
+# please use clang-format version 16 or later
 
 Standard: c++17
 AccessModifierOffset: -8
@@ -52,8 +52,8 @@ ContinuationIndentWidth: 8
 Cpp11BracedListStyle: true
 DerivePointerAlignment: false
 DisableFormat: false
-FixNamespaceComments: false
-ForEachMacros: 
+FixNamespaceComments: true
+ForEachMacros:
   - 'json_object_foreach'
   - 'json_object_foreach_safe'
   - 'json_array_foreach'

+ 4 - 4
.github/actions/run-clang-format/action.yaml

@@ -28,7 +28,7 @@ runs:
         echo ::group::Install Dependencies
         eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
         echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
-        echo "/home/linuxbrew/.linuxbrew/opt/clang-format@13/bin" >> $GITHUB_PATH
+        echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH
         brew install --quiet zsh
         echo ::endgroup::
 
@@ -53,11 +53,11 @@ runs:
         }
 
         if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) {
-          print ::group::Install clang-format-13
-          brew install --quiet obsproject/tools/clang-format@13
+          print ::group::Install clang-format-16
+          brew install --quiet obsproject/tools/clang-format@16
           print ::endgroup::
 
-          print ::group::Run clang-format-13
+          print ::group::Run clang-format-16
           ./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check
           print ::endgroup::
         }

+ 2 - 2
UI/properties-view.cpp

@@ -83,7 +83,7 @@ struct common_frame_rate {
 	media_frames_per_second fps;
 };
 
-}
+} // namespace
 
 Q_DECLARE_METATYPE(frame_rate_tag);
 Q_DECLARE_METATYPE(media_frames_per_second);
@@ -919,7 +919,7 @@ template<> struct default_delete<obs_data_item_t> {
 	void operator()(obs_data_item_t *item) { obs_data_item_release(&item); }
 };
 
-}
+} // namespace std
 
 template<typename T> static double make_epsilon(T val)
 {

+ 1 - 1
UI/win-update/updater/manifest.hpp

@@ -91,4 +91,4 @@ struct PatchResponse {
 };
 
 using PatchesResponse = std::vector<PatchResponse>;
-}
+} // namespace updater

+ 1 - 1
UI/win-update/updater/updater.cpp

@@ -276,7 +276,7 @@ template<> struct hash<B2Hash> {
 			string_view((const char *)value.data(), value.size()));
 	}
 };
-}
+} // namespace std
 
 enum state_t {
 	STATE_INVALID,

+ 1 - 1
UI/window-basic-main.cpp

@@ -126,7 +126,7 @@ template<typename OBSRef> struct SignalContainer {
 	OBSRef ref;
 	vector<shared_ptr<OBSSignal>> handlers;
 };
-}
+} // namespace
 
 extern volatile long insideEventLoop;
 

+ 1 - 1
UI/window-basic-settings.cpp

@@ -4863,7 +4863,7 @@ template<> struct hash<obs_key_combination_t> {
 		return h2;
 	}
 };
-}
+} // namespace std
 
 bool OBSBasicSettings::ScanDuplicateHotkeys(QFormLayout *layout)
 {

+ 7 - 7
build-aux/.run-format.zsh

@@ -29,24 +29,24 @@ invoke_formatter() {
 
   case ${1} {
     clang)
-      if (( ${+commands[clang-format-13]} )) {
-        local formatter=clang-format-13
+      if (( ${+commands[clang-format-16]} )) {
+        local formatter=clang-format-16
       } elif (( ${+commands[clang-format]} )) {
         local formatter=clang-format
       } else {
-        log_error "No viable clang-format version found (required 13.0.1)"
+        log_error "No viable clang-format version found (required 16.0.5)"
         exit 2
       }
 
       local -a formatter_version=($(${formatter} --version))
 
-      if ! is-at-least 13.0.1 ${formatter_version[-1]}; then
-        log_error "clang-format is not version 13.0.1 or above (found ${formatter_version[-1]}."
+      if ! is-at-least 16.0.5 ${formatter_version[-1]}; then
+        log_error "clang-format is not version 16.0.5 or above (found ${formatter_version[-1]}."
         exit 2
       fi
 
-      if ! is-at-least ${formatter_version[-1]} 13.0.1; then
-        log_error "clang-format is more recent than version 13.0.1 (found ${formatter_version[-1]})."
+      if ! is-at-least ${formatter_version[-1]} 16.0.5; then
+        log_error "clang-format is more recent than version 16.0.5 (found ${formatter_version[-1]})."
         exit 2
       fi
 

+ 20 - 11
libobs/obs-module.h

@@ -73,16 +73,22 @@ bool obs_module_load(void)
  */
 
 /** Required: Declares a libobs module. */
-#define OBS_DECLARE_MODULE()                                                  \
-	static obs_module_t *obs_module_pointer;                              \
-	MODULE_EXPORT void obs_module_set_pointer(obs_module_t *module);      \
-	void obs_module_set_pointer(obs_module_t *module)                     \
-	{                                                                     \
-		obs_module_pointer = module;                                  \
-	}                                                                     \
-	obs_module_t *obs_current_module(void) { return obs_module_pointer; } \
-	MODULE_EXPORT uint32_t obs_module_ver(void);                          \
-	uint32_t obs_module_ver(void) { return LIBOBS_API_VER; }
+#define OBS_DECLARE_MODULE()                                             \
+	static obs_module_t *obs_module_pointer;                         \
+	MODULE_EXPORT void obs_module_set_pointer(obs_module_t *module); \
+	void obs_module_set_pointer(obs_module_t *module)                \
+	{                                                                \
+		obs_module_pointer = module;                             \
+	}                                                                \
+	obs_module_t *obs_current_module(void)                           \
+	{                                                                \
+		return obs_module_pointer;                               \
+	}                                                                \
+	MODULE_EXPORT uint32_t obs_module_ver(void);                     \
+	uint32_t obs_module_ver(void)                                    \
+	{                                                                \
+		return LIBOBS_API_VER;                                   \
+	}
 
 /**
  * Required: Called when the module is loaded.  Use this function to load all
@@ -166,7 +172,10 @@ MODULE_EXTERN obs_module_t *obs_current_module(void);
  */
 #define OBS_MODULE_AUTHOR(name)                            \
 	MODULE_EXPORT const char *obs_module_author(void); \
-	const char *obs_module_author(void) { return name; }
+	const char *obs_module_author(void)                \
+	{                                                  \
+		return name;                               \
+	}
 
 /** Optional: Returns the full name of the module */
 MODULE_EXPORT const char *obs_module_name(void);

+ 1 - 2
libobs/obs-source.c

@@ -366,8 +366,7 @@ obs_source_create_internal(const char *id, const char *name, const char *uuid,
 		 *
 		 * XXX: Fix design flaws with filters */
 		if (info->type == OBS_SOURCE_TYPE_FILTER)
-		private
-		= true;
+		private = true;
 	}
 
 	source->mute_unmute_key = OBS_INVALID_HOTKEY_PAIR_ID;

+ 2 - 4
libobs/obs.hpp

@@ -136,8 +136,7 @@ class OBSRef : public OBSRefAutoRelease<T, release> {
 		return *this;
 	}
 
-	struct TakeOwnership {
-	};
+	struct TakeOwnership {};
 	inline OBSRef(T val_, TakeOwnership)
 		: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(val_)
 	{
@@ -180,8 +179,7 @@ class OBSSafeRef : public OBSRefAutoRelease<T, release> {
 		return *this;
 	}
 
-	struct TakeOwnership {
-	};
+	struct TakeOwnership {};
 	inline OBSSafeRef(T val_, TakeOwnership)
 		: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(val_)
 	{

+ 5 - 2
libobs/util/profiler.hpp

@@ -42,7 +42,10 @@ struct ScopeProfiler {
 #define ScopeProfiler_Name(x) ScopeProfiler_NameConcat(x, __LINE__)
 #endif
 
-#define ProfileScope(x) \
-	ScopeProfiler ScopeProfiler_Name(SCOPE_PROFILE) { x }
+#define ProfileScope(x)                                 \
+	ScopeProfiler ScopeProfiler_Name(SCOPE_PROFILE) \
+	{                                               \
+		x                                       \
+	}
 
 #endif

+ 1 - 1
plugins/aja/aja-card-manager.cpp

@@ -618,4 +618,4 @@ const CardEntries::iterator CardManager::end()
 	return mCardEntries.end();
 }
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-card-manager.hpp

@@ -103,4 +103,4 @@ private:
 	mutable std::mutex mMutex;
 };
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-common.cpp

@@ -1183,4 +1183,4 @@ std::vector<NTV2DeviceID> MultiViewCards()
 	return {DEVICE_ID_IOX3};
 }
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-common.hpp

@@ -110,4 +110,4 @@ extern VPIDStandard DetermineVPIDStandard(IOSelection io, NTV2VideoFormat vf,
 					  SDITransport4K t4k);
 extern std::vector<NTV2DeviceID> MultiViewCards();
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-presets.cpp

@@ -1836,4 +1836,4 @@ bool RoutingConfigurator::FindFirstPreset(ConnectionKind kind, NTV2DeviceID id,
 	return false;
 }
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-presets.hpp

@@ -46,4 +46,4 @@ private:
 	RoutingPresetMap m_presets;
 };
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-routing.cpp

@@ -608,4 +608,4 @@ void Routing::LogRoutingPreset(const RoutingPreset &rp)
 	}
 }
 
-} // aja
+} // namespace aja

+ 1 - 1
plugins/aja/aja-routing.hpp

@@ -62,4 +62,4 @@ public:
 	static void LogRoutingPreset(const RoutingPreset &rp);
 };
 
-} // aja
+} // namespace aja

+ 3 - 4
plugins/coreaudio-encoder/encoder.cpp

@@ -125,7 +125,7 @@ struct ca_encoder {
 };
 typedef struct ca_encoder ca_encoder;
 
-}
+} // namespace
 
 namespace std {
 
@@ -152,7 +152,7 @@ template<> struct default_delete<remove_pointer<AudioConverterRef>::type> {
 	}
 };
 
-}
+} // namespace std
 
 template<typename T>
 using cf_ptr = unique_ptr<typename remove_pointer<T>::type>;
@@ -1405,8 +1405,7 @@ bool obs_module_load(void)
 	CA_LOG(LOG_INFO, "Adding CoreAudio AAC encoder");
 #endif
 
-	struct obs_encoder_info aac_info {
-	};
+	struct obs_encoder_info aac_info {};
 	aac_info.id = "CoreAudio_AAC";
 	aac_info.type = OBS_ENCODER_AUDIO;
 	aac_info.codec = "aac";

+ 3 - 3
plugins/mac-avcapture/av-capture.mm

@@ -41,7 +41,7 @@ namespace std {
         }
     };
 
-}
+}  // namespace std
 
 #define TEXT_AVCAPTURE     obs_module_text("AVCapture")
 #define TEXT_DEVICE        obs_module_text("Device")
@@ -111,7 +111,7 @@ namespace {
         bool video_params_valid = false;
     };
 
-}
+}  // namespace
 
 struct av_capture {
     OBSAVCaptureDelegate *delegate;
@@ -303,7 +303,7 @@ namespace {
         }
     };
 
-}
+}  // namespace
 
 static av_capture_ref get_ref(obs_properties_t *props)
 {

+ 1 - 1
plugins/mac-avcapture/left-right.hpp

@@ -60,4 +60,4 @@ private:
 	T data[2] = {{}, {}};
 };
 
-}
+} // namespace left_right

+ 1 - 1
plugins/mac-avcapture/scope-guard.hpp

@@ -58,7 +58,7 @@ operator+(detail::ScopeGuardOnExit, FunctionType &&fn)
 		std::forward<FunctionType>(fn));
 }
 
-}
+} // namespace detail
 
 } // namespace scope_guard_util
 

+ 1 - 1
plugins/obs-ffmpeg/obs-ffmpeg-url.h

@@ -139,5 +139,5 @@ enum type {
 };
 }
 class Logger;
-}
+} // namespace srt_logging
 #endif