DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Pending]

Link: http://www.fltk.org/str.php?L2308
Version: 1.3.0


Please see attached file fl_intptr_t-r7907.diff for my modified patch. This
does not change the API and uses a similar typedef as Yuri's patch. I
decided to call it 'fl_intptr_t' instead of 'fl_long', because it's
similar to intptr_t, but that's maybe a matter of taste. I used argument()
instead of a cast, where applicable. Since this doesn't change the API, the
effective patch is also much smaller.

I tested it on Windows (native and Cygwin/mingw-w64) and Ubuntu (32 and 64
bit version) successfully. There are two "FIXME's" included, because this
may be changed, if we can find a better place for the typedef than in
Fl_Widget.H.

Comments and test results welcome.


Link: http://www.fltk.org/str.php?L2308
Version: 1.3.0
Index: src/fl_open_uri.cxx
===================================================================
--- src/fl_open_uri.cxx (revision 7907)
+++ src/fl_open_uri.cxx (working copy)
@@ -45,6 +45,8 @@
 #  include <unistd.h>
 #endif // WIN32
 
+// FIXME: This should not be here (Win64 ** testing only **) - A.S.
+#include <FL/Fl_Widget.H>
 
 //
 // Local functions...
@@ -124,7 +126,7 @@
 #ifdef WIN32
   if (msg) snprintf(msg, msglen, "open %s", uri);
 
-  return (int)ShellExecute(HWND_DESKTOP, "open", uri, NULL, NULL, SW_SHOW) > 
32;
+  return (fl_intptr_t)ShellExecute(HWND_DESKTOP, "open", uri, NULL, NULL, 
SW_SHOW) > 32;
 
 #elif defined(__APPLE__)
   char *argv[3];                       // Command-line arguments
Index: src/fl_ask.cxx
===================================================================
--- src/fl_ask.cxx      (revision 7907)
+++ src/fl_ask.cxx      (working copy)
@@ -72,7 +72,7 @@
 // pointer to one of the buttons or an Fl_Window* pointer to the
 // message window (message_form).
 static void button_cb(Fl_Widget *, void *val) {
-  ret_val = (int)(long)val;
+  ret_val = (fl_intptr_t)val;
   message_form->hide();
 }
 
Index: FL/Fl_Menu_Item.H
===================================================================
--- FL/Fl_Menu_Item.H   (revision 7907)
+++ FL/Fl_Menu_Item.H   (working copy)
@@ -241,7 +241,7 @@
     and casting the long to a void* and may not be
     portable to some machines.
   */
-  long argument() const {return (long)user_data_;}
+  long argument() const {return (long)(fl_intptr_t)user_data_;}
   /**
     For convenience you can also define the callback as taking a long
     argument.  This is implemented by casting this to a Fl_Callback
Index: FL/Fl_Widget.H
===================================================================
--- FL/Fl_Widget.H      (revision 7907)
+++ FL/Fl_Widget.H      (working copy)
@@ -33,6 +33,17 @@
 
 #include "Enumerations.H"
 
+// FIXME: This should not be here, but elsewhere (where?)
+// needed in *some* files for Windows 64-bit systems
+#ifdef _WIN64
+#include <stdint.h>
+typedef intptr_t fl_intptr_t;
+typedef uintptr_t fl_uintptr_t;
+#else
+typedef long fl_intptr_t;
+typedef unsigned long fl_uintptr_t;
+#endif
+
 class Fl_Widget;
 class Fl_Window;
 class Fl_Group;
@@ -596,7 +607,7 @@
 
   /** Gets the current user data (long) argument that is passed to the 
callback function.
    */
-  long argument() const {return (long)user_data_;}
+  long argument() const {return (long)(fl_intptr_t)user_data_;}
 
   /** Sets the current user data (long) argument that is passed to the 
callback function.
       \todo The user data value must be implemented using a \em union to avoid 
Index: test/tree.fl
===================================================================
--- test/tree.fl        (revision 7907)
+++ test/tree.fl        (working copy)
@@ -152,7 +152,7 @@
 if ( item ) {
   fprintf(stderr, "TREE CALLBACK: label='%s' userdata=%ld reason=%s\\n",
           item->label(),
-          (long)tree->user_data(),
+          (fl_intptr_t)tree->user_data(),
          reason_as_name(tree->callback_reason()));
 } else {
   fprintf(stderr, "TREE CALLBACK: reason=%s item=(no item -- probably multiple 
items were changed at once)\\n",
Index: test/input.cxx
===================================================================
--- test/input.cxx      (revision 7907)
+++ test/input.cxx      (working copy)
@@ -65,7 +65,7 @@
 
 void color_cb(Fl_Widget* button, void* v) {
   Fl_Color c;
-  switch ((long)v) {
+  switch ((fl_intptr_t)v) {
   case 0: c = FL_BACKGROUND2_COLOR; break;
   case 1: c = FL_SELECTION_COLOR; break;
   default: c = FL_FOREGROUND_COLOR; break;
Index: test/arc.cxx
===================================================================
--- test/arc.cxx        (revision 7907)
+++ test/arc.cxx        (working copy)
@@ -66,7 +66,7 @@
 
 void slider_cb(Fl_Widget* o, void* v) {
   Fl_Slider* s = (Fl_Slider*)o;
-  args[long(v)] = s->value();
+  args[fl_intptr_t(v)] = s->value();
   d->redraw();
 }
 
Index: test/curve.cxx
===================================================================
--- test/curve.cxx      (revision 7907)
+++ test/curve.cxx      (working copy)
@@ -83,7 +83,7 @@
 
 void slider_cb(Fl_Widget* o, void* v) {
   Fl_Slider* s = (Fl_Slider*)o;
-  args[long(v)] = s->value();
+  args[fl_intptr_t(v)] = s->value();
   d->redraw();
 }
 
Index: test/line_style.cxx
===================================================================
--- test/line_style.cxx (revision 7907)
+++ test/line_style.cxx (working copy)
@@ -58,9 +58,9 @@
   dashes[3] = char(sliders[8]->value());
   dashes[4] = 0;
   fl_line_style(
-    (long)(choice[0]->mvalue()->user_data()) +
-    (long)(choice[1]->mvalue()->user_data()) +
-    (long)(choice[2]->mvalue()->user_data()),
+    (long)(choice[0]->mvalue()->argument()) +
+    (long)(choice[1]->mvalue()->argument()) +
+    (long)(choice[2]->mvalue()->argument()),
     (long)(sliders[3]->value()), // width
     dashes);
 
Index: test/cursor.cxx
===================================================================
--- test/cursor.cxx     (revision 7907)
+++ test/cursor.cxx     (working copy)
@@ -39,7 +39,7 @@
 Fl_Hor_Value_Slider *cursor_slider;
 
 void choice_cb(Fl_Widget *, void *v) {
-  cursor = (Fl_Cursor)(long)v;
+  cursor = (Fl_Cursor)(fl_intptr_t)v;
   cursor_slider->value(cursor);
   fl_cursor(cursor,fg,bg);
 }
Index: test/table.cxx
===================================================================
--- test/table.cxx      (revision 7907)
+++ test/table.cxx      (working copy)
@@ -273,19 +273,19 @@
 
 void tablebox_choice_cb(Fl_Widget *w, void *data)
 {
-    G_table->table_box((Fl_Boxtype)(long)data);
+    G_table->table_box((Fl_Boxtype)(fl_intptr_t)data);
     G_table->redraw();
 }
 
 void widgetbox_choice_cb(Fl_Widget *w, void *data)
 {
-    G_table->box((Fl_Boxtype)(long)data);
+    G_table->box((Fl_Boxtype)(fl_intptr_t)data);
     G_table->resize(G_table->x(), G_table->y(), G_table->w(), G_table->h());
 }
 
 void type_choice_cb(Fl_Widget *w, void *data)
 {
-    G_table->type((Fl_Table_Row::TableRowSelectMode)(long)data);
+    G_table->type((Fl_Table_Row::TableRowSelectMode)(fl_intptr_t)data);
 }
 
 Fl_Menu_Item tablebox_choices[] = {
Index: test/scroll.cxx
===================================================================
--- test/scroll.cxx     (revision 7907)
+++ test/scroll.cxx     (working copy)
@@ -71,7 +71,7 @@
 }
 
 void type_cb(Fl_Widget*, void* v) {
-  thescroll->type((uchar)((long)v));
+  thescroll->type((uchar)((fl_intptr_t)v));
   thescroll->redraw();
 }
 
@@ -87,7 +87,7 @@
 };
 
 void align_cb(Fl_Widget*, void* v) {
-  thescroll->scrollbar.align((uchar)((long)v));
+  thescroll->scrollbar.align((uchar)((fl_intptr_t)v));
   thescroll->redraw();
 }
 
Index: test/fractals.cxx
===================================================================
--- test/fractals.cxx   (revision 7907)
+++ test/fractals.cxx   (working copy)
@@ -768,11 +768,11 @@
 /***************************************************************/
 
 // FLTK-style callbacks to Glut menu callback translators:
-void setlevel(Fl_Widget*, void *value) {setlevel(long(value));}
+void setlevel(Fl_Widget*, void *value) {setlevel(fl_intptr_t(value));}
 
-void choosefract(Fl_Widget*, void *value) {choosefract(long(value));}
+void choosefract(Fl_Widget*, void *value) {choosefract(fl_intptr_t(value));}
 
-void handlemenu(Fl_Widget*, void *value) {handlemenu(long(value));}
+void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_intptr_t(value));}
 
 #include <FL/Fl_Button.H>
 #include <FL/Fl_Group.H>
Index: test/keyboard.cxx
===================================================================
--- test/keyboard.cxx   (revision 7907)
+++ test/keyboard.cxx   (working copy)
@@ -109,14 +109,14 @@
     for (int i = 0; i < window->children(); i++) {
       Fl_Widget* b = window->child(i);
       if (b->callback() == (Fl_Callback*)key_cb) {
-       int i = (long)b->user_data();
+       int i = b->argument();
        if (!i) i = b->label()[0];
         Fl_Button *btn = ((Fl_Button*)b);
         int state = Fl::event_key(i);
         if (btn->value()!=state)
          btn->value(state);
       } else if (b->callback() == (Fl_Callback*)shift_cb) {
-       int i = (long)b->user_data();
+       int i = b->argument();
         Fl_Button *btn = ((Fl_Button*)b);
         int state = Fl::event_state(i);
         if (btn->value()!=state)
Index: fluid/Fl_Widget_Type.cxx
===================================================================
--- fluid/Fl_Widget_Type.cxx    (revision 7907)
+++ fluid/Fl_Widget_Type.cxx    (working copy)
@@ -1142,7 +1142,7 @@
 {0}};
 
 void align_cb(Fl_Button* i, void *v) {
-  Fl_Align b = Fl_Align(long(i->user_data()));
+  Fl_Align b = Fl_Align(fl_uintptr_t(i->user_data()));
   if (v == LOAD) {
     if (current_widget->is_menu_item()) {i->deactivate(); return;} else 
i->activate();
     i->value(current_widget->o->align() & b);
@@ -1190,7 +1190,7 @@
     }
   } else {
     const Fl_Menu_Item *mi = i->menu() + i->value();
-    Fl_Align b = Fl_Align(long(mi->user_data()));
+    Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data()));
     int mod = 0;
     for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
       if (o->selected && o->is_widget()) {
@@ -1219,7 +1219,7 @@
     }
   } else {
     const Fl_Menu_Item *mi = i->menu() + i->value();
-    Fl_Align b = Fl_Align(long(mi->user_data()));
+    Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data()));
     int mod = 0;
     for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
       if (o->selected && o->is_widget()) {
@@ -1311,7 +1311,7 @@
 // "v_attributes" let user type in random code for attribute settings:
 
 void v_input_cb(Fl_Input* i, void* v) {
-  int n = int(long(i->user_data()));
+  int n = fl_intptr_t(i->user_data());
   if (v == LOAD) {
     i->static_value(current_widget->extra_code(n));
   } else {
Index: fluid/fluid.cxx
===================================================================
--- fluid/fluid.cxx     (revision 7907)
+++ fluid/fluid.cxx     (working copy)
@@ -1978,7 +1978,7 @@
     // don't need theses handles inherited by child process:
     clean_close(pin[0]); clean_close(pout[1]); clean_close(perr[1]);
     HANDLE & h = *mode == 'r' ? pout[0] : pin[1];
-    _fpt = _fdopen(_open_osfhandle((long) h,_O_BINARY),mode);
+    _fpt = _fdopen(_open_osfhandle((fl_intptr_t) h,_O_BINARY),mode);
     h= INVALID_HANDLE_VALUE;  // reset the handle pointer that is shared
     // with _fpt so we don't free it twice
   }
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to