diff --git a/plugins/windows-notification/api/include/ginvoke.hpp b/plugins/windows-notification/api/include/ginvoke.hpp index 9d0b53ab..ef235229 100644 --- a/plugins/windows-notification/api/include/ginvoke.hpp +++ b/plugins/windows-notification/api/include/ginvoke.hpp @@ -55,25 +55,33 @@ namespace impl std::optional get_if_hresult_error(std::exception_ptr) noexcept; } -template,int> = 0> -inline auto &describe_argument(OStream &s, const T &a) { return s << a; } -template,int> = 0> -inline auto &describe_argument(OStream &s, const T &a) { return s << static_cast>(a); } +template,int> = 0> +inline auto &describe_argument(OStream &s, const T &a) +{ return s << a; } +template,int> = 0> +inline auto &describe_argument(OStream &s, const T &a) +{ return s << static_cast>(a); } template -inline auto &describe_argument(OStream &s, std::string_view const a) { return s << std::quoted(a); } +inline auto &describe_argument(OStream &s, std::string_view const a) +{ return s << std::quoted(a); } template -inline auto &describe_argument(OStream &s, const std::string & a) { return s << std::quoted(a); } +inline auto &describe_argument(OStream &s, const std::string & a) +{ return s << std::quoted(a); } template -inline auto &describe_argument(OStream &s, const char * const a) { return s << std::quoted(a); } +inline auto &describe_argument(OStream &s, const char * const a) +{ return s << std::quoted(a); } // TODO: overload for const GString * + +// not implemented (TODO maybe): template -inline auto &describe_argument(OStream &s, std::wstring_view const a) = delete; // not implemented +inline auto &describe_argument(OStream &s, std::wstring_view const a) = delete; template -inline auto &describe_argument(OStream &s, const std::wstring & a) = delete; // not implemented +inline auto &describe_argument(OStream &s, const std::wstring & a) = delete; template -inline auto &describe_argument(OStream &s, const wchar_t * const a) = delete; // not implemented -// TODO: handle wide strings maybe +inline auto &describe_argument(OStream &s, const wchar_t * const a) = delete; inline impl::varstring describe_arguments() noexcept { return {""}; } @@ -94,13 +102,15 @@ catch (...) #define FORMAT "%s(%s) failed: %s" template -inline void log_invocation_failure(const char *e, const char *func_name, const Arg &... a) noexcept +inline void log_invocation_failure(const char *e, + const char *func_name, const Arg &... a) noexcept { const auto args = describe_arguments(a...); g_warning(FORMAT, func_name, args.c_str(), e); } template -inline void log_invocation_failure_desc(const char* e, const char* e_desc, const char* func_name, const Arg&... a) noexcept +inline void log_invocation_failure_desc(const char *e, const char *e_desc, + const char *func_name, const Arg &... a) noexcept { const auto args = describe_arguments(a...); g_warning(FORMAT": %s", func_name, args.c_str(), e, e_desc); @@ -112,7 +122,8 @@ struct regular_void {}; template inline auto invoke(Invokable &&i, const Arg &... a) { - if constexpr (std::is_void_v(i), a...))>) + using R = decltype(std::invoke(std::forward(i), a...)); + if constexpr (std::is_void_v) { std::invoke(std::forward(i), a...); return regular_void{}; @@ -122,7 +133,8 @@ inline auto invoke(Invokable &&i, const Arg &... a) } template -inline auto try_invoke(const char *func_name, Invokable &&i, const Arg &... a) noexcept +inline auto try_invoke( + const char *func_name, Invokable &&i, const Arg &... a) noexcept -> std::optional(i), a...))> try { @@ -139,7 +151,8 @@ catch (...) { auto hr = make_array("hresult 0x01234567\0"); hexify32(static_cast(e->code), std::end(hr)-1); - log_invocation_failure_desc(std::begin(hr), e->message.c_str(), func_name, a...); + log_invocation_failure_desc( + std::begin(hr), e->message.c_str(), func_name, a...); } else log_invocation_failure("unknown error", func_name, a...); @@ -150,7 +163,10 @@ catch (...) } // namespace glib -#define g_try_invoke(invokable, ...) glib::try_invoke(#invokable, invokable, __VA_ARGS__) -#define g_try_invoke0(invokable) glib::try_invoke(#invokable, invokable) +#define g_try_invoke(invokable, ...) \ + glib::try_invoke(#invokable, invokable, __VA_ARGS__) + +#define g_try_invoke0(invokable) \ + glib::try_invoke(#invokable, invokable) #endif diff --git a/plugins/windows-notification/api/include/gobject/winrt-enums.h b/plugins/windows-notification/api/include/gobject/winrt-enums.h index 73abeccf..27891a79 100644 --- a/plugins/windows-notification/api/include/gobject/winrt-enums.h +++ b/plugins/windows-notification/api/include/gobject/winrt-enums.h @@ -5,7 +5,8 @@ G_BEGIN_DECLS -#define WINRT_TYPE_WINDOWS_UI_NOTIFICATIONS_TOAST_DISMISSAL_REASON (winrtWindowsUINotificationsToastDismissalReason_get_type ()) +#define WINRT_TYPE_WINDOWS_UI_NOTIFICATIONS_TOAST_DISMISSAL_REASON \ + (winrtWindowsUINotificationsToastDismissalReason_get_type()) /** * winrt_Windows_UI_Notifications_Toast_Dismissal_Reason: @@ -23,9 +24,10 @@ typedef enum { WINRT_WINDOWS_UI_NOTIFICATIONS_TOAST_DISMISSAL_REASON_TimedOut, } winrtWindowsUINotificationsToastDismissalReason; -GType winrt_windows_ui_notifications_toast_dismissal_reason_get_type (void); +GType winrt_windows_ui_notifications_toast_dismissal_reason_get_type(); -#define WINRT_TYPE_WINDOWS_UI_NOTIFICATIONS_TOAST_TEMPLATE_TYPE (winrt_windows_ui_notifications_toast_template_type_get_type ()) +#define WINRT_TYPE_WINDOWS_UI_NOTIFICATIONS_TOAST_TEMPLATE_TYPE \ + (winrt_windows_ui_notifications_toast_template_type_get_type()) /** * winrtWindowsUINotificationsToastTemplateType: @@ -52,7 +54,7 @@ typedef enum { WINRT_WINDOWS_UI_NOTIFICATIONS_TOAST_TEMPLATE_TYPE_ToastText04, } winrtWindowsUINotificationsToastTemplateType; -GType winrt_windows_ui_notifications_toast_template_type_get_type (void); +GType winrt_windows_ui_notifications_toast_template_type_get_type(); G_END_DECLS diff --git a/plugins/windows-notification/api/src/ginvoke.cpp b/plugins/windows-notification/api/src/ginvoke.cpp index 646467cc..cb792c06 100644 --- a/plugins/windows-notification/api/src/ginvoke.cpp +++ b/plugins/windows-notification/api/src/ginvoke.cpp @@ -7,11 +7,12 @@ namespace glib::impl { - std::optional get_if_hresult_error(const std::exception_ptr p) noexcept try + std::optional get_if_hresult_error( + const std::exception_ptr p) noexcept try { std::rethrow_exception(p); } - catch (const winrt::hresult_error& e) + catch (const winrt::hresult_error &e) { const char *ptr = nullptr; try @@ -23,7 +24,8 @@ namespace glib::impl if (not ptr) throw 42; std::string msg{ptr}; - g_free(const_cast(ptr)); // WTF? Deletion is not modification! + g_free(const_cast(ptr)); + // ^ WTF? Deletion is not modification! ^ return {{ e.code(), std::move(msg) }}; } else diff --git a/plugins/windows-notification/api/src/gobject/winrt-enums.cpp b/plugins/windows-notification/api/src/gobject/winrt-enums.cpp index 7038c730..aff82329 100644 --- a/plugins/windows-notification/api/src/gobject/winrt-enums.cpp +++ b/plugins/windows-notification/api/src/gobject/winrt-enums.cpp @@ -1,17 +1,17 @@ #include "winrt-enums.h" -#define WINRT_GLIB_DEFINE_ENUM_VALUE(value,nick) \ +#define WINRT_GLIB_DEFINE_ENUM_VALUE(value, nick) \ { value, #value, nick }, -#define WINRT_GLIB_DEFINE_ENUM_TYPE(TypeName,type_name,values) \ -GType \ -type_name ## _get_type (void) \ +#define WINRT_GLIB_DEFINE_ENUM_TYPE(TypeName, type_name, values) \ +GType type_name##_get_type() \ { \ static constexpr GEnumValue v[] = { \ values \ { 0, NULL, NULL }, \ }; \ - static const auto enum_type_id = g_enum_register_static (g_intern_static_string (#TypeName), v); \ + static const auto enum_type_id = \ + g_enum_register_static(g_intern_static_string(#TypeName), v); \ return enum_type_id; \ }