mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gdbus: fix generated code to not warn under -Wfloat-equal
https://bugzilla.gnome.org/show_bug.cgi?id=678333
This commit is contained in:
parent
599d1a430e
commit
7d0db04223
@ -66,7 +66,9 @@ class CodeGenerator:
|
||||
'#endif\n'
|
||||
'\n'
|
||||
'#include "%s"\n'
|
||||
'\n'%(self.h.name))
|
||||
'\n'
|
||||
'#include <string.h>\n'
|
||||
%(self.h.name))
|
||||
|
||||
self.c.write('#ifdef G_OS_UNIX\n'
|
||||
'# include <gio/gunixfdlist.h>\n'
|
||||
@ -192,7 +194,12 @@ class CodeGenerator:
|
||||
' ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));\n'
|
||||
' break;\n'
|
||||
' case G_TYPE_DOUBLE:\n'
|
||||
' ret = (g_value_get_double (a) == g_value_get_double (b));\n'
|
||||
' {\n'
|
||||
' /* Avoid -Wfloat-equal warnings by doing a direct bit compare */\n'
|
||||
' gdouble da = g_value_get_double (a);\n'
|
||||
' gdouble db = g_value_get_double (b);\n'
|
||||
' ret = memcmp (&da, &db, sizeof (gdouble)) == 0;\n'
|
||||
' }\n'
|
||||
' break;\n'
|
||||
' case G_TYPE_STRING:\n'
|
||||
' ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);\n'
|
||||
|
@ -1729,11 +1729,24 @@ on_object_proxy_removed (GDBusObjectManagerClient *manager,
|
||||
om_data), ==, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
property_d_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean *changed = user_data;
|
||||
|
||||
*changed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
om_check_property_and_signal_emission (GMainLoop *loop,
|
||||
FooiGenBar *skeleton,
|
||||
FooiGenBar *proxy)
|
||||
{
|
||||
gboolean d_changed = FALSE;
|
||||
guint handler;
|
||||
|
||||
/* First PropertiesChanged */
|
||||
g_assert_cmpint (foo_igen_bar_get_i (skeleton), ==, 0);
|
||||
g_assert_cmpint (foo_igen_bar_get_i (proxy), ==, 0);
|
||||
@ -1742,6 +1755,24 @@ om_check_property_and_signal_emission (GMainLoop *loop,
|
||||
g_assert_cmpint (foo_igen_bar_get_i (skeleton), ==, 1);
|
||||
g_assert_cmpint (foo_igen_bar_get_i (proxy), ==, 1);
|
||||
|
||||
/* Double-check the gdouble case */
|
||||
g_assert_cmpfloat (foo_igen_bar_get_d (skeleton), ==, 0.0);
|
||||
g_assert_cmpfloat (foo_igen_bar_get_d (proxy), ==, 0.0);
|
||||
foo_igen_bar_set_d (skeleton, 1.0);
|
||||
_g_assert_property_notify (proxy, "d");
|
||||
|
||||
/* Verify that re-setting it to the same value doesn't cause a
|
||||
* notify on the proxy, by taking advantage of the fact that
|
||||
* notifications are serialized.
|
||||
*/
|
||||
handler = g_signal_connect (proxy, "notify::d",
|
||||
G_CALLBACK (property_d_changed), &d_changed);
|
||||
foo_igen_bar_set_d (skeleton, 1.0);
|
||||
foo_igen_bar_set_i (skeleton, 2);
|
||||
_g_assert_property_notify (proxy, "i");
|
||||
g_assert (d_changed == FALSE);
|
||||
g_signal_handler_disconnect (proxy, handler);
|
||||
|
||||
/* Then just a regular signal */
|
||||
foo_igen_bar_emit_another_signal (skeleton, "word");
|
||||
_g_assert_signal_received (proxy, "another-signal");
|
||||
|
Loading…
Reference in New Issue
Block a user