'#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'
' 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'
}
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);
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");