[gobject-introspection] tests: Added class that has all kinds of properties



commit 6a9b3102a5769714c21032b3c9455e1d5c271393
Author: Sebastian PÃlsterl <sebp k-d-w org>
Date:   Sun Feb 5 11:45:07 2012 +0100

    tests: Added class that has all kinds of properties
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664150

 tests/gimarshallingtests.c |  178 ++++++++++++++++++++++++++++++++++++++++++++
 tests/gimarshallingtests.h |   36 +++++++++
 2 files changed, 214 insertions(+), 0 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 8734a90..56d4838 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -4313,3 +4313,181 @@ gi_marshalling_tests_filename_list_return (void)
     return NULL;
 }
 
+
+enum  {
+    DUMMY_PROPERTY,
+    SOME_BOOLEAN_PROPERTY,
+    SOME_CHAR_PROPERTY,
+    SOME_UCHAR_PROPERTY,
+    SOME_INT_PROPERTY,
+    SOME_UINT_PROPERTY,
+    SOME_LONG_PROPERTY,
+    SOME_ULONG_PROPERTY,
+    SOME_INT64_PROPERTY,
+    SOME_UINT64_PROPERTY,
+    SOME_FLOAT_PROPERTY,
+    SOME_DOUBLE_PROPERTY
+};
+
+G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
+
+static void
+gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self)
+{
+}
+
+static void
+gi_marshalling_tests_properties_object_finalize (GObject* obj)
+{
+    G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
+}
+
+static void
+gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
+{
+    GIMarshallingTestsPropertiesObject * self;
+    self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
+    switch (property_id) {
+        case SOME_BOOLEAN_PROPERTY:
+            g_value_set_boolean (value, self->some_boolean);
+            break;
+        case SOME_CHAR_PROPERTY:
+            g_value_set_schar (value, self->some_char);
+            break;
+        case SOME_UCHAR_PROPERTY:
+            g_value_set_uchar (value, self->some_uchar);
+            break;
+        case SOME_INT_PROPERTY:
+            g_value_set_int (value, self->some_int);
+            break;
+        case SOME_UINT_PROPERTY:
+            g_value_set_uint (value, self->some_uint);
+            break;
+        case SOME_LONG_PROPERTY:
+            g_value_set_long (value, self->some_long);
+            break;
+        case SOME_ULONG_PROPERTY:
+            g_value_set_ulong (value, self->some_ulong);
+            break;
+        case SOME_INT64_PROPERTY:
+            g_value_set_int64 (value, self->some_int64);
+            break;
+        case SOME_UINT64_PROPERTY:
+            g_value_set_uint64 (value, self->some_uint64);
+            break;
+        case SOME_FLOAT_PROPERTY:
+            g_value_set_float (value, self->some_float);
+            break;
+        case SOME_DOUBLE_PROPERTY:
+            g_value_set_double (value, self->some_double);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+            break;
+    }
+}
+
+static void
+gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
+{
+    GIMarshallingTestsPropertiesObject * self;
+    self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
+    switch (property_id) {
+        case SOME_BOOLEAN_PROPERTY:
+            self->some_boolean = g_value_get_boolean (value);
+            break;
+        case SOME_CHAR_PROPERTY:
+            self->some_char = g_value_get_schar (value);
+            break;
+        case SOME_UCHAR_PROPERTY:
+            self->some_uchar = g_value_get_uchar (value);
+            break;
+        case SOME_INT_PROPERTY:
+            self->some_int = g_value_get_int (value);
+            break;
+        case SOME_UINT_PROPERTY:
+            self->some_uint = g_value_get_uint (value);
+            break;
+        case SOME_LONG_PROPERTY:
+            self->some_long = g_value_get_long (value);
+            break;
+        case SOME_ULONG_PROPERTY:
+            self->some_ulong = g_value_get_ulong (value);
+            break;
+        case SOME_INT64_PROPERTY:
+            self->some_int64 = g_value_get_int64 (value);
+            break;
+        case SOME_UINT64_PROPERTY:
+            self->some_uint64 = g_value_get_uint64 (value);
+            break;
+        case SOME_FLOAT_PROPERTY:
+            self->some_float = g_value_get_float (value);
+            break;
+        case SOME_DOUBLE_PROPERTY:
+            self->some_double = g_value_get_double (value);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+            break;
+    }
+}
+
+static void
+gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass)
+{
+    GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = gi_marshalling_tests_properties_object_finalize;
+    object_class->get_property = gi_marshalling_tests_properties_object_get_property;
+    object_class->set_property = gi_marshalling_tests_properties_object_set_property;
+
+    g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
+        g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
+        g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
+        g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_INT_PROPERTY,
+        g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
+        g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
+        g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
+        g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
+        g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
+        g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
+        g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
+        g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0,
+            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+}
+
+GIMarshallingTestsPropertiesObject*
+gi_marshalling_tests_properties_object_new (void)
+{
+    return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);
+}
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 1d66991..782e61c 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -956,4 +956,40 @@ glong gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesO
 
 GIMarshallingTestsOverridesObject *gi_marshalling_tests_overrides_object_returnv (void);
 
+/* Properties Object */
+
+#define GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT (gi_marshalling_tests_properties_object_get_type ())
+#define GI_MARSHALLING_TESTS_PROPERTIES_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, GIMarshallingTestsPropertiesObject))
+#define GI_MARSHALLING_TESTS_PROPERTIES_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, GIMarshallingTestsPropertiesObjectClass))
+#define GI_MARSHALLING_TESTS_IS_PROPERTIES_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT))
+#define GI_MARSHALLING_TESTS_IS_PROPERTIES_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT))
+#define GI_MARSHALLING_TESTS_PROPERTIES_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, GIMarshallingTestsPropertiesObjectClass))
+
+typedef struct _GIMarshallingTestsPropertiesObject GIMarshallingTestsPropertiesObject;
+typedef struct _GIMarshallingTestsPropertiesObjectClass GIMarshallingTestsPropertiesObjectClass;
+
+struct _GIMarshallingTestsPropertiesObject {
+    GObject parent_instance;
+
+    gboolean some_boolean;
+    gchar some_char;
+    guchar some_uchar;
+    gint some_int;
+    guint some_uint;
+    glong some_long;
+    gulong some_ulong;
+    gint64 some_int64;
+    guint64 some_uint64;
+    gfloat some_float;
+    gdouble some_double;
+};
+
+struct _GIMarshallingTestsPropertiesObjectClass {
+    GObjectClass parent_class;
+};
+
+GType gi_marshalling_tests_properties_object_get_type (void) G_GNUC_CONST;
+
+GIMarshallingTestsPropertiesObject *gi_marshalling_tests_properties_object_new (void);
+
 #endif /* _GI_MARSHALLING_TESTS_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]