[gobject-introspection/ebassi/property-annotation: 1/4] Property accessors work for interfaces and objects




commit b2bdcf45e57115fc0a8ef91e9cb0dedd93f0e35c
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Jun 16 19:15:05 2021 +0100

    Property accessors work for interfaces and objects
    
    We need to check the container type before trying to obtain a
    GIPropertyInfo for GIFunctionInfos that have a SETTER or a GETTER flag
    set.

 girepository/gifunctioninfo.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c
index 366850d5..b042b4e1 100644
--- a/girepository/gifunctioninfo.c
+++ b/girepository/gifunctioninfo.c
@@ -165,18 +165,30 @@ g_function_info_get_flags (GIFunctionInfo *info)
 GIPropertyInfo *
 g_function_info_get_property (GIFunctionInfo *info)
 {
-  GIRealInfo *rinfo;
+  GIRealInfo *rinfo, *container_rinfo;
   FunctionBlob *blob;
-  GIInterfaceInfo *container;
 
   g_return_val_if_fail (info != NULL, NULL);
   g_return_val_if_fail (GI_IS_FUNCTION_INFO (info), NULL);
 
   rinfo = (GIRealInfo *)info;
   blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
-  container = (GIInterfaceInfo *)rinfo->container;
+  container_rinfo = (GIRealInfo *)rinfo->container;
+
+  if (container_rinfo->type == GI_INFO_TYPE_INTERFACE)
+    {
+      GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container;
 
-  return g_interface_info_get_property (container, blob->index);
+      return g_interface_info_get_property (container, blob->index);
+    }
+  else if (container_rinfo->type == GI_INFO_TYPE_OBJECT)
+    {
+      GIObjectInfo *container = (GIObjectInfo *)rinfo->container;
+
+      return g_object_info_get_property (container, blob->index);
+    }
+  else
+    return NULL;
 }
 
 /**


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