mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
GDBus: Add G_DBUS_METHOD_INVOCATION_HANDLED, _UNHANDLED
Like G_SOURCE_REMOVE and G_SOURCE_CONTINUE, these make it clearer what it means to return TRUE or FALSE. In particular, in GDBus methods that fail, the failure case still needs to return TRUE (unlike the typical GError pattern), leading to comments like this: g_dbus_method_invocation_return_error (invocation, ...); return TRUE; /* handled */ which can now be replaced by: g_dbus_method_invocation_return_error (invocation, ...); return G_DUS_METHOD_INVOCATION_HANDLED; G_DBUS_METHOD_INVOCATION_UNHANDLED is added for symmetry, but is very rarely (perhaps never?) useful in practice. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
500d065f3d
commit
d65c8c30a9
@ -3026,6 +3026,8 @@ g_dbus_method_invocation_return_gerror
|
||||
g_dbus_method_invocation_return_dbus_error
|
||||
g_dbus_method_invocation_take_error
|
||||
g_dbus_method_invocation_return_value_with_unix_fd_list
|
||||
G_DBUS_METHOD_INVOCATION_HANDLED
|
||||
G_DBUS_METHOD_INVOCATION_UNHANDLED
|
||||
<SUBSECTION Standard>
|
||||
G_DBUS_METHOD_INVOCATION
|
||||
G_IS_DBUS_METHOD_INVOCATION
|
||||
|
@ -1522,7 +1522,7 @@ class CodeGenerator:
|
||||
' *\n'
|
||||
' * If a signal handler returns %%TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call %s_complete_%s() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %%G_DBUS_ERROR_UNKNOWN_METHOD error is returned.\n'
|
||||
' *\n'
|
||||
' * Returns: %%TRUE if the invocation was handled, %%FALSE to let other signal handlers run.\n'
|
||||
' * Returns: %%G_DBUS_METHOD_INVOCATION_HANDLED or %%TRUE if the invocation was handled, %%G_DBUS_METHOD_INVOCATION_UNHANDLED or %%FALSE to let other signal handlers run.\n'
|
||||
%(i.name, m.name, i.name_lower, m.name_lower), False))
|
||||
self.write_gtkdoc_deprecated_and_since_and_close(m, self.outfile, 2)
|
||||
if m.unix_fd:
|
||||
|
@ -33,6 +33,41 @@ G_BEGIN_DECLS
|
||||
#define G_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocation))
|
||||
#define G_IS_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_METHOD_INVOCATION))
|
||||
|
||||
/**
|
||||
* G_DBUS_METHOD_INVOCATION_HANDLED:
|
||||
*
|
||||
* The value returned by handlers of the signals generated by
|
||||
* the `gdbus-codegen` tool to indicate that a method call has been
|
||||
* handled by an implementation. It is equal to %TRUE, but using
|
||||
* this macro is sometimes more readable.
|
||||
*
|
||||
* In code that needs to be backwards-compatible with older GLib,
|
||||
* use %TRUE instead, often written like this:
|
||||
*
|
||||
* |[
|
||||
* g_dbus_method_invocation_return_error (invocation, ...);
|
||||
* return TRUE; // handled
|
||||
* ]|
|
||||
*
|
||||
* Since: 2.68
|
||||
*/
|
||||
#define G_DBUS_METHOD_INVOCATION_HANDLED TRUE GLIB_AVAILABLE_MACRO_IN_2_68
|
||||
|
||||
/**
|
||||
* G_DBUS_METHOD_INVOCATION_UNHANDLED:
|
||||
*
|
||||
* The value returned by handlers of the signals generated by
|
||||
* the `gdbus-codegen` tool to indicate that a method call has not been
|
||||
* handled by an implementation. It is equal to %FALSE, but using
|
||||
* this macro is sometimes more readable.
|
||||
*
|
||||
* In code that needs to be backwards-compatible with older GLib,
|
||||
* use %FALSE instead.
|
||||
*
|
||||
* Since: 2.68
|
||||
*/
|
||||
#define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE GLIB_AVAILABLE_MACRO_IN_2_68
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GType g_dbus_method_invocation_get_type (void) G_GNUC_CONST;
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
|
Loading…
x
Reference in New Issue
Block a user