[gobject-introspection] Remove some unportable integral type size assumptions



commit ad0aeac620eea48fbdfbf3441ffbc0dba6dbc699
Author: Iain Nicol <iain thenicols net>
Date:   Mon Nov 23 18:52:40 2009 +0000

    Remove some unportable integral type size assumptions
    
    https://bugzilla.gnome.org/show_bug.cgi?id=602762

 girepository/gfield.c |   17 +++++++++++++++--
 girepository/girffi.c |   16 ++++++++++++----
 2 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/girepository/gfield.c b/girepository/gfield.c
index 94c2fb5..486211f 100644
--- a/girepository/gfield.c
+++ b/girepository/gfield.c
@@ -2,6 +2,7 @@
 
 #include "girepository.h"
 #include "girffi.h"
+#include "config.h"
 
 /**
  * g_field_info_get_field:
@@ -92,7 +93,13 @@ g_field_info_get_field (GIFieldInfo *field_info,
 	    result = TRUE;
 	    break;
 	  case GI_TYPE_TAG_TIME_T:
-	    value->v_long = G_STRUCT_MEMBER(time_t, mem, offset);
+#if SIZEOF_TIME_T == 4
+	    value->v_int32 = G_STRUCT_MEMBER(time_t, mem, offset);
+#elif SIZEOF_TIME_T == 8
+	    value->v_int64 = G_STRUCT_MEMBER(time_t, mem, offset);
+#else
+#  error "Unexpected size for time_t: not 4 or 8"
+#endif
 	    result = TRUE;
 	    break;
 	  case GI_TYPE_TAG_UTF8:
@@ -292,7 +299,13 @@ g_field_info_set_field (GIFieldInfo     *field_info,
 	    result = TRUE;
 	    break;
 	  case GI_TYPE_TAG_TIME_T:
-	    G_STRUCT_MEMBER(time_t, mem, offset) = value->v_long;
+#if SIZEOF_TIME_T == 4
+            G_STRUCT_MEMBER(time_t, mem, offset) = value->v_int32;
+#elif SIZEOF_TIME_T == 8
+            G_STRUCT_MEMBER(time_t, mem, offset) = value->v_int64;
+#else
+#  error "Unexpected size for time_t: not 4 or 8"
+#endif
 	    result = TRUE;
 	    break;
 	  case GI_TYPE_TAG_UTF8:
diff --git a/girepository/girffi.c b/girepository/girffi.c
index d7c52f6..d67cbf6 100644
--- a/girepository/girffi.c
+++ b/girepository/girffi.c
@@ -152,20 +152,28 @@ g_ir_ffi_convert_arguments(GICallableInfo *callable_info, void **args)
           g_args[i].v_uint32 = *(guint32 *) args[i];
           break;
         case GI_TYPE_TAG_LONG:
+          g_args[i].v_long = *(glong *) args[i];
+          break;
         case GI_TYPE_TAG_INT64:
-          g_args[i].v_int64 = *(glong *) args[i];
+          g_args[i].v_int64 = *(gint64 *) args[i];
           break;
         case GI_TYPE_TAG_ULONG:
+          g_args[i].v_ulong = *(gulong *) args[i];
+          break;
         case GI_TYPE_TAG_UINT64:
-          g_args[i].v_uint64 = *(glong *) args[i];
+          g_args[i].v_uint64 = *(guint64 *) args[i];
           break;
         case GI_TYPE_TAG_INT:
+          g_args[i].v_int = *(gint *) args[i];
+          break;
         case GI_TYPE_TAG_SSIZE:
+          g_args[i].v_ssize = *(gssize *) args[i];
+          break;
         case GI_TYPE_TAG_SIZE:
-          g_args[i].v_int32 = *(gint *) args[i];
+          g_args[i].v_size = *(gsize *) args[i];
           break;
         case GI_TYPE_TAG_UINT:
-          g_args[i].v_uint32 = *(guint *) args[i];
+          g_args[i].v_uint = *(guint *) args[i];
           break;
         case GI_TYPE_TAG_FLOAT:
           g_args[i].v_float = *(gfloat *) args[i];



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