[gtk+] Start using NSInteger and NSUInteger



commit b2b70e5a8d275c8412709c9f077fb136078cd416
Author: Kristian Rietveld <kris gtk org>
Date:   Sun Dec 27 17:01:25 2009 +0100

    Start using NSInteger and NSUInteger
    
    These have been introduced in Leopard and default to int and unsigned int.
    In 64-bit Snow Leopard they are long and unsigned long.  This caused issues
    with the getRectsBeingDrawn message which needs a pointer to a NSInteger
    (long on 64-bit!) but we passed in an integer.  Surprisingly this problem
    was visible when compiling with -O0 (segfault), but *not* when compiling
    with -O1.  Other messages were NSInteger is now needed have also been
    adapted.
    
    Since NSInteger and NSUInteger are not available on Tiger, a define
    has been added to add typedefs for these when they have not been defined
    by the system headers.

 gdk/quartz/GdkQuartzView.c    |    3 ++-
 gdk/quartz/gdkcursor-quartz.c |    4 ++--
 gdk/quartz/gdkevents-quartz.c |    2 +-
 gdk/quartz/gdkwindow-quartz.c |    6 +++---
 gdk/quartz/gdkwindow-quartz.h |    8 ++++++++
 5 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzView.c b/gdk/quartz/GdkQuartzView.c
index 5d643eb..4ae010c 100644
--- a/gdk/quartz/GdkQuartzView.c
+++ b/gdk/quartz/GdkQuartzView.c
@@ -60,7 +60,8 @@
   GdkWindowObject *private = GDK_WINDOW_OBJECT (gdk_window);
   GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
   const NSRect *drawn_rects;
-  int count, i;
+  NSInteger count;
+  int i;
   GdkRegion *region;
 
   if (GDK_WINDOW_DESTROYED (gdk_window))
diff --git a/gdk/quartz/gdkcursor-quartz.c b/gdk/quartz/gdkcursor-quartz.c
index 651952f..e875969 100644
--- a/gdk/quartz/gdkcursor-quartz.c
+++ b/gdk/quartz/gdkcursor-quartz.c
@@ -84,7 +84,7 @@ create_builtin_cursor (GdkCursorType cursor_type)
 {
   GdkCursor *cursor;
   NSBitmapImageRep *bitmap_rep;
-  gint mask_width, mask_height;
+  NSInteger mask_width, mask_height;
   gint src_width, src_height;
   gint dst_stride;
   const guchar *mask_start, *src_start;
@@ -249,7 +249,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap      *source,
   NSImage *image;
   NSCursor *nscursor;
   GdkCursor *cursor;
-  gint width, height;
+  NSInteger width, height;
   gint tmp_x, tmp_y;
   guchar *dst_data, *mask_data, *src_data;
   guchar *mask_start, *src_start;
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 24044b3..0f14385 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -213,7 +213,7 @@ get_time_from_ns_event (NSEvent *event)
 static int
 get_mouse_button_from_ns_event (NSEvent *event)
 {
-  int button;
+  NSInteger button;
 
   button = [event buttonNumber];
 
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 7b47e7f..91e5e18 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -730,7 +730,7 @@ find_child_window_helper (GdkWindow *window,
         {
           NSRect frame = NSMakeRect (0, 0, 100, 100);
           NSRect content;
-          int mask;
+          NSUInteger mask;
           int titlebar_height;
 
           mask = [child_impl->toplevel styleMask];
@@ -996,7 +996,7 @@ _gdk_window_impl_new (GdkWindow     *window,
         NSScreen *screen;
         NSRect screen_rect;
         NSRect content_rect;
-        int style_mask;
+        NSUInteger style_mask;
         int nx, ny;
         const char *title;
 
@@ -2644,7 +2644,7 @@ gdk_window_set_decorations (GdkWindow       *window,
 			    GdkWMDecoration  decorations)
 {
   GdkWindowImplQuartz *impl;
-  int old_mask, new_mask;
+  NSUInteger old_mask, new_mask;
   NSView *old_view;
 
   if (GDK_WINDOW_DESTROYED (window) ||
diff --git a/gdk/quartz/gdkwindow-quartz.h b/gdk/quartz/gdkwindow-quartz.h
index 8d47512..f16c3af 100644
--- a/gdk/quartz/gdkwindow-quartz.h
+++ b/gdk/quartz/gdkwindow-quartz.h
@@ -25,6 +25,14 @@
 #import <gdk/quartz/GdkQuartzView.h>
 #import <gdk/quartz/GdkQuartzWindow.h>
 
+/* NSInteger only exists in Leopard and newer.  This check has to be
+ * done after inclusion of the system headers.  If NSInteger has not
+ * been defined, we know for sure that we are on 32-bit.
+ */
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#endif
 
 G_BEGIN_DECLS
 



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