[gobject-introspection: 3/4] Add marshalling tests for ByteArray property.



commit 1de82ab87cd80117d914cc458bdcc6af8bc8d63d
Author: Tomasz Miąsko <tomasz miasko gmail com>
Date:   Sun Apr 15 00:00:00 2018 +0000

    Add marshalling tests for ByteArray property.
    
    Note this is currently supported by neither [PyGObject][0] nor GJS.
    
    [0] https://gitlab.gnome.org/GNOME/pygobject/issues/37

 tests/gimarshallingtests.c | 16 ++++++++++++++++
 tests/gimarshallingtests.h |  1 +
 2 files changed, 17 insertions(+)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index f6ac1c57..92c181a4 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -5355,6 +5355,7 @@ enum
   SOME_OBJECT_PROPERTY,
   SOME_FLAGS_PROPERTY,
   SOME_ENUM_PROPERTY,
+  SOME_BYTE_ARRAY_PROPERTY,
 };
 
 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
@@ -5447,6 +5448,9 @@ gi_marshalling_tests_properties_object_get_property (GObject *object,
     case SOME_ENUM_PROPERTY:
       g_value_set_enum (value, self->some_enum);
       break;
+    case SOME_BYTE_ARRAY_PROPERTY:
+      g_value_set_boxed (value, self->some_byte_array);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -5529,6 +5533,11 @@ gi_marshalling_tests_properties_object_set_property (GObject *object,
     case SOME_ENUM_PROPERTY:
       self->some_enum = g_value_get_enum (value);
       break;
+    case SOME_BYTE_ARRAY_PROPERTY:
+      if (self->some_byte_array != NULL)
+        g_byte_array_unref (self->some_byte_array);
+      self->some_byte_array = g_value_dup_boxed (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -5682,6 +5691,13 @@ static void gi_marshalling_tests_properties_object_class_init (GIMarshallingTest
                                                       GI_MARSHALLING_TESTS_TYPE_GENUM,
                                                       GI_MARSHALLING_TESTS_GENUM_VALUE1,
                                                       G_PARAM_READABLE | G_PARAM_WRITABLE | 
G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (object_class, SOME_BYTE_ARRAY_PROPERTY,
+                                   g_param_spec_boxed ("some-byte-array",
+                                                       "some-byte-array",
+                                                       "some-byte-array",
+                                                       G_TYPE_BYTE_ARRAY,
+                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 }
 
 GIMarshallingTestsPropertiesObject *
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 345f1538..95e52403 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -1975,6 +1975,7 @@ struct _GIMarshallingTestsPropertiesObject {
     GObject *some_object;
     GIMarshallingTestsFlags some_flags;
     GIMarshallingTestsGEnum some_enum;
+    GByteArray *some_byte_array;
 };
 
 struct _GIMarshallingTestsPropertiesObjectClass {


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