summaryrefslogtreecommitdiff
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-04-29 00:54:43 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-04-29 00:54:43 -0700
commit8ac068ac0c00afa85bc4df54032b7a855c639312 (patch)
tree551b5146f8f0c9e5c2f7129eaac0fb9f97d8a866 /src/gtkutil.c
parentc7b270ab8559d9c9ca86ed5887b86b537796042d (diff)
downloademacs-8ac068ac0c00afa85bc4df54032b7a855c639312.tar.gz
Prefer intptr_t/uintptr_t for integers the same widths as pointers.
This removes an assumption that EMACS_INT and long are the same width as pointers. The assumption is true for Emacs porting targets now, but we want to make other targets possible. * lisp.h: Include <inttypes.h>, for INTPTR_MAX, UINTPTR_MAX. (EMACS_INTPTR, EMACS_UINTPTR): New macros. In the rest of the code, change types of integers that hold casted pointers to EMACS_INTPTR and EMACS_UINTPTR, systematically replacing EMACS_INT, long, EMACS_UINT, and unsigned long. (XTYPE): Don't cast arg to EMACS_UINT; normally is not needed. (XSET): Cast type of XTYPE arg to EMACS_INTPTR; it is needed here. No need to cast type when ORing. (XPNTR): Return a value of type EMACS_INTPTR or EMACS_UINTPTR. * alloc.c (lisp_align_malloc): Remove a no-longer-needed cast. * doc.c (store_function_docstring): Use EMACS_INTPTR, so as not to assume EMACS_INT is the same width as char *. * gtkutil.c (xg_gtk_scroll_destroy, xg_tool_bar_button_cb): (xg_tool_bar_callback, xg_tool_bar_help_callback, xg_make_tool_item): Remove no-longer-needed casts. (xg_create_scroll_bar, xg_tool_bar_button_cb, xg_tool_bar_callback): (xg_tool_bar_help_callback, xg_make_tool_item): Use EMACS_INTPTR to hold an integer that will be cast to void *; this can avoid a GCC warning if EMACS_INT is not the same width as void *. * menu.c (find_and_call_menu_selection): Remove no-longer-needed cast. * xdisp.c (display_echo_area_1, resize_mini_window_1): (current_message_1, set_message_1): Use a local to convert to proper width without a cast. * xmenu.c (dialog_selection_callback): Likewise.
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9d3bfe6a89c..ff33a3f3c04 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3354,7 +3354,7 @@ xg_get_scroll_id_for_window (Display *dpy, Window wid)
static void
xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data)
{
- int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */
+ int id = (EMACS_INTPTR) data;
xg_remove_widget_from_map (id);
}
@@ -3375,7 +3375,7 @@ xg_create_scroll_bar (FRAME_PTR f,
{
GtkWidget *wscroll;
GtkWidget *webox;
- int scroll_id;
+ EMACS_INTPTR scroll_id;
#ifdef HAVE_GTK3
GtkAdjustment *vadj;
#else
@@ -3397,11 +3397,10 @@ xg_create_scroll_bar (FRAME_PTR f,
scroll_id = xg_store_widget_in_map (wscroll);
- /* The EMACS_INT cast avoids a warning. */
g_signal_connect (G_OBJECT (wscroll),
"destroy",
G_CALLBACK (xg_gtk_scroll_destroy),
- (gpointer) (EMACS_INT) scroll_id);
+ (gpointer) scroll_id);
g_signal_connect (G_OBJECT (wscroll),
"change-value",
scroll_callback,
@@ -3663,8 +3662,8 @@ xg_tool_bar_button_cb (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
- /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */
- gpointer ptr = (gpointer) (EMACS_INT) event->state;
+ EMACS_INTPTR state = event->state;
+ gpointer ptr = (gpointer) state;
g_object_set_data (G_OBJECT (widget), XG_TOOL_BAR_LAST_MODIFIER, ptr);
return FALSE;
}
@@ -3678,10 +3677,9 @@ xg_tool_bar_button_cb (GtkWidget *widget,
static void
xg_tool_bar_callback (GtkWidget *w, gpointer client_data)
{
- /* The EMACS_INT cast avoids a warning. */
- int idx = (int) (EMACS_INT) client_data;
+ EMACS_INTPTR idx = (EMACS_INTPTR) client_data;
gpointer gmod = g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER);
- int mod = (int) (EMACS_INT) gmod;
+ EMACS_INTPTR mod = (EMACS_INTPTR) gmod;
FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
Lisp_Object key, frame;
@@ -3960,8 +3958,7 @@ xg_tool_bar_help_callback (GtkWidget *w,
GdkEventCrossing *event,
gpointer client_data)
{
- /* The EMACS_INT cast avoids a warning. */
- int idx = (int) (EMACS_INT) client_data;
+ EMACS_INTPTR idx = (EMACS_INTPTR) client_data;
FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
Lisp_Object help, frame;
@@ -4155,14 +4152,16 @@ xg_make_tool_item (FRAME_PTR f,
if (wimage)
{
- /* The EMACS_INT cast avoids a warning. */
+ EMACS_INTPTR ii = i;
+ gpointer gi = (gpointer) ii;
+
g_signal_connect (G_OBJECT (ti), "create-menu-proxy",
G_CALLBACK (xg_tool_bar_menu_proxy),
- (gpointer) (EMACS_INT) i);
+ gi);
g_signal_connect (G_OBJECT (wb), "clicked",
G_CALLBACK (xg_tool_bar_callback),
- (gpointer) (EMACS_INT) i);
+ gi);
g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
@@ -4193,11 +4192,11 @@ xg_make_tool_item (FRAME_PTR f,
g_signal_connect (G_OBJECT (weventbox),
"enter-notify-event",
G_CALLBACK (xg_tool_bar_help_callback),
- (gpointer) (EMACS_INT) i);
+ gi);
g_signal_connect (G_OBJECT (weventbox),
"leave-notify-event",
G_CALLBACK (xg_tool_bar_help_callback),
- (gpointer) (EMACS_INT) i);
+ gi);
}
if (wbutton) *wbutton = wb;