comparison src/ui-gtk.c @ 2054:91d4c8c65a0f

[xemacs-hg @ 2004-05-02 04:06:51 by malcolmp] Fix warnings and errors when building GTK using C++ and --use-union-type.
author malcolmp
date Sun, 02 May 2004 04:07:01 +0000
parents c347bc6e2cb3
children 95fee4a1420e
comparison
equal deleted inserted replaced
2053:11e709117623 2054:91d4c8c65a0f
25 #include "window.h" 25 #include "window.h"
26 26
27 /* XEmacs specific GTK types */ 27 /* XEmacs specific GTK types */
28 #include "gtk-glue.c" 28 #include "gtk-glue.c"
29 29
30 /* Is the fundamental type of 't' the xemacs defined fundamental type 'type'? */
31 #define IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t,type) (((GtkType) GTK_FUNDAMENTAL_TYPE(t)) == (type))
32
30 Lisp_Object Qemacs_ffip; 33 Lisp_Object Qemacs_ffip;
31 Lisp_Object Qemacs_gtk_objectp; 34 Lisp_Object Qemacs_gtk_objectp;
32 Lisp_Object Qemacs_gtk_boxedp; 35 Lisp_Object Qemacs_gtk_boxedp;
33 Lisp_Object Qvoid; 36 Lisp_Object Qvoid;
34 Lisp_Object Venumeration_info; 37 Lisp_Object Venumeration_info;
51 static void 54 static void
52 initialize_dll_cache (void) 55 initialize_dll_cache (void)
53 { 56 {
54 if (!dll_cache) 57 if (!dll_cache)
55 { 58 {
59 static char text[] = "---XEmacs Internal Handle---";
60
56 dll_cache = g_hash_table_new (g_str_hash, g_str_equal); 61 dll_cache = g_hash_table_new (g_str_hash, g_str_equal);
57 62
58 g_hash_table_insert (dll_cache, "---XEmacs Internal Handle---", dll_open (Qnil)); 63 g_hash_table_insert (dll_cache, text, dll_open (Qnil));
59 } 64 }
60 } 65 }
61 66
62 DEFUN ("dll-load", Fdll_load, 1, 1, 0, /* 67 DEFUN ("dll-load", Fdll_load, 1, 1, 0, /*
63 Load a shared library DLL into XEmacs. No initialization routines are required. 68 Load a shared library DLL into XEmacs. No initialization routines are required.
83 { 88 {
84 h = dll_open (dll); 89 h = dll_open (dll);
85 90
86 if (h) 91 if (h)
87 { 92 {
88 g_hash_table_insert (dll_cache, g_strdup (XSTRING_DATA (dll)), h); 93 g_hash_table_insert (dll_cache, qxestrdup (XSTRING_DATA (dll)), h);
89 } 94 }
90 else 95 else
91 { 96 {
92 signal_error (Qfile_error, 97 signal_error (Qfile_error, "dll_open error", dll_error());
93 "dll_open error", build_string (dll_error ()));
94 } 98 }
95 } 99 }
96 return (h ? Qt : Qnil); 100 return (h ? Qt : Qnil);
97 } 101 }
98 102
329 0, /*dumpable-flag*/ 333 0, /*dumpable-flag*/
330 mark_ffi_data, ffi_object_printer, 334 mark_ffi_data, ffi_object_printer,
331 0, 0, 0, 335 0, 0, 0,
332 ffi_data_description, emacs_ffi_data); 336 ffi_data_description, emacs_ffi_data);
333 337
334 typedef GtkObject * (*__OBJECT_fn) (); 338 #if defined (__cplusplus)
335 typedef gint (*__INT_fn) (); 339 #define MANY_ARGS ...
336 typedef void (*__NONE_fn) (); 340 #else
337 typedef gchar * (*__STRING_fn) (); 341 #define MANY_ARGS
338 typedef gboolean (*__BOOL_fn) (); 342 #endif
339 typedef gfloat (*__FLOAT_fn) (); 343
340 typedef void * (*__POINTER_fn) (); 344 typedef void (*pfv)();
341 typedef GList * (*__LIST_fn) (); 345 typedef GtkObject * (*__OBJECT_fn) (MANY_ARGS);
346 typedef gint (*__INT_fn) (MANY_ARGS);
347 typedef void (*__NONE_fn) (MANY_ARGS);
348 typedef gchar * (*__STRING_fn) (MANY_ARGS);
349 typedef gboolean (*__BOOL_fn) (MANY_ARGS);
350 typedef gfloat (*__FLOAT_fn) (MANY_ARGS);
351 typedef void * (*__POINTER_fn) (MANY_ARGS);
352 typedef GList * (*__LIST_fn) (MANY_ARGS);
342 353
343 /* An auto-generated file of marshalling functions. */ 354 /* An auto-generated file of marshalling functions. */
344 #include "emacs-marshals.c" 355 #include "emacs-marshals.c"
356 #undef MANY_ARGS
345 357
346 #define CONVERT_SINGLE_TYPE(var,nam,tp) case GTK_TYPE_##nam: GTK_VALUE_##nam (var) = * (tp *) v; break; 358 #define CONVERT_SINGLE_TYPE(var,nam,tp) case GTK_TYPE_##nam: GTK_VALUE_##nam (var) = * (tp *) v; break;
347 #define CONVERT_RETVAL(a,freep) \ 359 #define CONVERT_RETVAL(a,freep) \
348 do { \ 360 do { \
349 void *v = GTK_VALUE_POINTER(a); \ 361 void *v = GTK_VALUE_POINTER(a); \
422 case GTK_TYPE_OBJECT: 434 case GTK_TYPE_OBJECT:
423 s = (sizeof (GtkObject *)); 435 s = (sizeof (GtkObject *));
424 break; 436 break;
425 437
426 default: 438 default:
427 if (GTK_FUNDAMENTAL_TYPE (t) == GTK_TYPE_LISTOF) 439 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_LISTOF))
428 { 440 {
429 s = (sizeof (void *)); 441 s = (sizeof (void *));
430 } 442 }
431 rval = NULL; 443 rval = NULL;
432 break; 444 break;
476 default: 488 default:
477 /* I can't put this in the main switch statement because it is a 489 /* I can't put this in the main switch statement because it is a
478 new fundamental type that is not fixed at compile time. 490 new fundamental type that is not fixed at compile time.
479 *sigh* 491 *sigh*
480 */ 492 */
481 if (GTK_FUNDAMENTAL_TYPE (t) == GTK_TYPE_ARRAY) 493 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_ARRAY))
482 return (build_string ("ARRAY")); 494 return (build_string ("ARRAY"));
483 495
484 if (GTK_FUNDAMENTAL_TYPE (t) == GTK_TYPE_LISTOF) 496 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_LISTOF))
485 return (build_string ("LIST")); 497 return (build_string ("LIST"));
486 return (Qnil); 498 return (Qnil);
487 } 499 }
488 } 500 }
489 501
490 struct __dll_mapper_closure { 502 struct __dll_mapper_closure {
491 void * (*func) (dll_handle, const char *); 503 void * (*func) (dll_handle, const CIbyte *);
492 const char *obj_name; 504 Ibyte *obj_name;
493 void **storage; 505 void **storage;
494 }; 506 };
495 507
496 static void __dll_mapper (gpointer key, gpointer value, gpointer user_data) 508 static void __dll_mapper (gpointer key, gpointer value, gpointer user_data)
497 { 509 {
498 struct __dll_mapper_closure *closure = (struct __dll_mapper_closure *) user_data; 510 struct __dll_mapper_closure *closure = (struct __dll_mapper_closure *) user_data;
499 511
500 if (*(closure->storage) == NULL) 512 if (*(closure->storage) == NULL)
501 { 513 {
502 /* Need to see if it is in this one */ 514 /* Need to see if it is in this one */
503 *(closure->storage) = closure->func ((dll_handle) value, closure->obj_name); 515 *(closure->storage) = closure->func ((dll_handle) value, (CIbyte*) closure->obj_name);
504 } 516 }
505 } 517 }
506 518
507 DEFUN ("gtk-import-variable-internal", Fgtk_import_variable_internal, 2, 2, 0, /* 519 DEFUN ("gtk-import-variable-internal", Fgtk_import_variable_internal, 2, 2, 0, /*
508 Import a variable into the XEmacs namespace. 520 Import a variable into the XEmacs namespace.
655 gui_error ("Could not locate marshaller function", marshaller); 667 gui_error ("Could not locate marshaller function", marshaller);
656 } 668 }
657 669
658 data->n_args = n_args; 670 data->n_args = n_args;
659 data->function_name = name; 671 data->function_name = name;
660 data->function_ptr = name_func; 672 data->function_ptr = (dll_func) name_func;
661 data->marshal = marshaller_func; 673 data->marshal = marshaller_func;
662 674
663 rval = wrap_emacs_ffi (data); 675 rval = wrap_emacs_ffi (data);
664 return (rval); 676 return (rval);
665 } 677 }
754 /* Need to free any array or list pointers */ 766 /* Need to free any array or list pointers */
755 { 767 {
756 int i; 768 int i;
757 for (i = 0; i < n_args; i++) 769 for (i = 0; i < n_args; i++)
758 { 770 {
759 if (GTK_FUNDAMENTAL_TYPE (the_args[i].type) == GTK_TYPE_ARRAY) 771 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(the_args[i].type, GTK_TYPE_ARRAY))
760 { 772 {
761 g_free (GTK_VALUE_POINTER (the_args[i])); 773 g_free (GTK_VALUE_POINTER (the_args[i]));
762 } 774 }
763 else if (GTK_FUNDAMENTAL_TYPE (the_args[i].type) == GTK_TYPE_LISTOF) 775 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(the_args[i].type, GTK_TYPE_LISTOF))
764 { 776 {
765 /* g_list_free (GTK_VALUE_POINTER (the_args[i])); */ 777 /* g_list_free (GTK_VALUE_POINTER (the_args[i])); */
766 } 778 }
767 } 779 }
768 } 780 }
1235 type = Fsymbol_name (type); 1247 type = Fsymbol_name (type);
1236 } 1248 }
1237 1249
1238 if (STRINGP (type)) 1250 if (STRINGP (type))
1239 { 1251 {
1240 t = gtk_type_from_name (XSTRING_DATA (type)); 1252 t = gtk_type_from_name ((gchar*) XSTRING_DATA (type));
1241 if (t == GTK_TYPE_INVALID) 1253 if (t == GTK_TYPE_INVALID)
1242 { 1254 {
1243 invalid_argument ("Not a GTK type", type); 1255 invalid_argument ("Not a GTK type", type);
1244 } 1256 }
1245 } 1257 }
1516 1528
1517 return (rval); 1529 return (rval);
1518 } 1530 }
1519 1531
1520 default: 1532 default:
1521 if (GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_LISTOF) 1533 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
1522 { 1534 {
1523 if (!GTK_VALUE_POINTER (*arg)) 1535 if (!GTK_VALUE_POINTER (*arg))
1524 return (Qnil); 1536 return (Qnil);
1525 else 1537 else
1526 { 1538 {
1777 invalid_argument ("Attempting to pass dead object to GTK function", obj); 1789 invalid_argument ("Attempting to pass dead object to GTK function", obj);
1778 } 1790 }
1779 break; 1791 break;
1780 1792
1781 default: 1793 default:
1782 if (GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_ARRAY) 1794 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_ARRAY))
1783 { 1795 {
1784 if (NILP (obj)) 1796 if (NILP (obj))
1785 GTK_VALUE_POINTER(*arg) = NULL; 1797 GTK_VALUE_POINTER(*arg) = NULL;
1786 else 1798 else
1787 { 1799 {
1788 xemacs_list_to_array (obj, arg); 1800 xemacs_list_to_array (obj, arg);
1789 } 1801 }
1790 } 1802 }
1791 else if (GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_LISTOF) 1803 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
1792 { 1804 {
1793 if (NILP (obj)) 1805 if (NILP (obj))
1794 GTK_VALUE_POINTER(*arg) = NULL; 1806 GTK_VALUE_POINTER(*arg) = NULL;
1795 else 1807 else
1796 { 1808 {
2057 invalid_argument ("Attempting to pass dead object to GTK function", obj); 2069 invalid_argument ("Attempting to pass dead object to GTK function", obj);
2058 } 2070 }
2059 break; 2071 break;
2060 2072
2061 default: 2073 default:
2062 if (GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_ARRAY) 2074 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_ARRAY))
2063 { 2075 {
2064 if (NILP (obj)) 2076 if (NILP (obj))
2065 *(GTK_RETLOC_POINTER(*arg)) = NULL; 2077 *(GTK_RETLOC_POINTER(*arg)) = NULL;
2066 else 2078 else
2067 { 2079 {
2068 xemacs_list_to_array (obj, arg); 2080 xemacs_list_to_array (obj, arg);
2069 } 2081 }
2070 } 2082 }
2071 else if (GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_LISTOF) 2083 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
2072 { 2084 {
2073 if (NILP (obj)) 2085 if (NILP (obj))
2074 *(GTK_RETLOC_POINTER(*arg)) = NULL; 2086 *(GTK_RETLOC_POINTER(*arg)) = NULL;
2075 else 2087 else
2076 { 2088 {