[seed] Better null warning message checking



commit dbcaa116d1762d28d56cabdf27da750ea3c296b2
Author: Alan Knowles <alan akbkhome com>
Date:   Thu May 6 17:07:24 2010 +0800

    Better null warning message checking
    
    The original assumption that looking for a pointer where an interface was expected produced warnings for
    GValues - this makes a assumption that basic types (not objects) would be allowed where interfaces where
    expected.. - hopefully our casting code produces another warning if the types do not match.

 libseed/seed-engine.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index ff2634f..e6cbe7f 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -524,12 +524,20 @@ seed_gobject_method_invoked (JSContextRef ctx,
 
               if (!is_null && (g_type_info_get_tag (type_info) == GI_TYPE_TAG_INTERFACE)) 
                 {
-                  // see if the pointer is null for struct/unions.
+                  /* see if the pointer is null for struct/unions. */
                   GIBaseInfo *interface = g_type_info_get_interface (type_info);
                   GIInfoType interface_type = g_base_info_get_type (interface);
-
-                  if ((interface_type == GI_INFO_TYPE_STRUCT || interface_type == GI_INFO_TYPE_UNION) &&
-                             seed_pointer_get_pointer (ctx, arguments[i]) == 0) 
+                  
+		  gboolean arg_is_object = JSValueIsObject (ctx, arguments[i]);
+		  gboolean is_struct_or_union = (
+		           interface_type == GI_INFO_TYPE_STRUCT ||
+		           interface_type == GI_INFO_TYPE_UNION
+		  );
+
+	          /* this test ignores non-objects being sent where interfaces are expected 
+	             hopefully our type manipluation code will pick that up. */
+                  if (is_struct_or_union && arg_is_object &&
+                        (seed_pointer_get_pointer (ctx, arguments[i]) == 0)) 
                       is_null = TRUE;
                   
                   g_base_info_unref (interface);



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