[pygobject] gi/pygi-marshal-from-py.c: Fix build on Visual C++



commit b3a3da37e369f3f5d434c8dc9f3c7f1e74d537ac
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Feb 26 16:15:36 2013 +0800

    gi/pygi-marshal-from-py.c: Fix build on Visual C++
    
    Since Visual C++ does not provide the INFINITY and NAN constants in its
    math.h (they are items defined by C99), provide fallback implementations
    for it here.  The INFINITY constant can be provided with HUGE_VAL, since
    we are using INFINITY to check the value of a variable of double type, and
    we could use a rather simple workaround for NAN.
    
    Also avoid declaring variables in the middle of the block.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692856

 gi/pygi-marshal-from-py.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index 01138bc..15fdcc9 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -32,6 +32,22 @@
 #include "pygi-marshal-cleanup.h"
 #include "pygi-marshal-from-py.h"
 
+#ifdef _WIN32
+#ifdef _MSC_VER
+#include <math.h>
+
+#ifndef NAN
+static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
+#define NAN (*(const float *) __nan)
+#endif
+
+#ifndef INFINITY
+#define INFINITY HUGE_VAL
+#endif
+
+#endif
+#endif
+
 static gboolean
 gi_argument_from_py_ssize_t (GIArgument   *arg_out,
                              Py_ssize_t    size_in,
@@ -1388,10 +1404,11 @@ _pygi_destroy_notify_create (void)
     if (!global_destroy_notify) {
 
         PyGICClosure *destroy_notify = g_slice_new0 (PyGICClosure);
+        GIBaseInfo* glib_destroy_notify;
 
         g_assert (destroy_notify);
 
-        GIBaseInfo* glib_destroy_notify = g_irepository_find_by_name (NULL, "GLib", "DestroyNotify");
+        glib_destroy_notify = g_irepository_find_by_name (NULL, "GLib", "DestroyNotify");
         g_assert (glib_destroy_notify != NULL);
         g_assert (g_base_info_get_type (glib_destroy_notify) == GI_INFO_TYPE_CALLBACK);
 


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