[gobject-introspection] g_field_info_get_field: return correct pointer for C array



commit 57c51b746cb25261a05533010042d535a1749520
Author: Maxim Ermilov <zaspire rambler ru>
Date:   Thu Feb 17 23:27:09 2011 +0300

    g_field_info_get_field: return correct pointer for C array
    
    Also add a test case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=640468

 girepository/gifieldinfo.c             |    5 ++++-
 tests/scanner/Regress-1.0-expected.gir |   10 ++++++++++
 tests/scanner/regress.h                |    5 +++++
 3 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c
index cf5c233..b9b56a4 100644
--- a/girepository/gifieldinfo.c
+++ b/girepository/gifieldinfo.c
@@ -193,7 +193,10 @@ g_field_info_get_field (GIFieldInfo *field_info,
 
   if (g_type_info_is_pointer (type_info))
     {
-      value->v_pointer = G_STRUCT_MEMBER (gpointer, mem, offset);
+      if (g_type_info_get_array_type (type_info) == GI_ARRAY_TYPE_C)
+	value->v_pointer = G_STRUCT_MEMBER_P ((mem), (offset));
+      else
+	value->v_pointer = G_STRUCT_MEMBER (gpointer, mem, offset);
       result = TRUE;
     }
   else
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 2bae748..0798554 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -886,6 +886,16 @@ TpAccount::status-changed</doc>
         </parameters>
       </method>
     </record>
+    <record name="TestStructFixedArray" c:type="RegressTestStructFixedArray">
+      <field name="just_int" writable="1">
+        <type name="gint" c:type="gint"/>
+      </field>
+      <field name="array" writable="1">
+        <array zero-terminated="0" c:type="gint" fixed-size="10">
+          <type name="gint" c:type="gint"/>
+        </array>
+      </field>
+    </record>
     <class name="TestSubObj"
            c:symbol-prefix="test_sub_obj"
            c:type="RegressTestSubObj"
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 89209eb..5937fa5 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -609,6 +609,11 @@ typedef enum {
   REGRESS_TEST_PUBLIC_ENUM_AFTER  = 1 << 2,
 } RegressTestPrivateEnum;
 
+typedef struct {
+  gint just_int;
+  gint array[10];
+} RegressTestStructFixedArray;
+
 #define REGRESS_UTF8_CONSTANT "const \xe2\x99\xa5 utf8"
 
 #endif /* __GITESTTYPES_H__ */



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