I would think that these patches should be applied against a X11R5 version
as well, since the major changes are to fix the use of XtGetValues().
While the old code works under R5, it techincally violates the Xt spec.
Code that is specific to R6 will only compile if you define X11R6.
What's changed:
1> Removed reference to Clock, Logo & Mailbox widgets in Xawmodule.c for
R6.
2> Added support for XtSetLanguageProc to Xtgenerated.h & Xtmodule.c for
R6.
3> Fixed XtGetValues() calls in Xtmodule.c & widgetobject.c.
4> Changed Xttypes.c to support char & short returned from XtGetValues().
Some of these may not be in the right location yet - I only have the Motif
header files, no documentation. Please check them over if you have better
documentation!
-- Richard Neitzel thor@thor.atd.ucar.edu Torren med sitt skjegg National Center For Atmospheric Research lokkar borni under sole-vegg Box 3000 Boulder, CO 80307-3000 Gjx'i med sitt shinn 303-497-2057 jagar borni inn. ----------------------------------------------------------------------- --- ../../Extensions/X11/Xawmodule.c Fri Feb 4 06:17:15 1994 +++ ./Xawmodule.c Wed May 25 13:19:08 1994 @@ -8,9 +8,9 @@ /* Methods for Xaw objects */ #include <X11/Xaw/Box.h> - +#ifndef X11R6 #include <X11/Xaw/Clock.h> - +#endif #include <X11/Xaw/Command.h> #include <X11/Xaw/Dialog.h> @@ -22,11 +22,11 @@ #include <X11/Xaw/Label.h> #include <X11/Xaw/List.h> - +#ifndef X11R6 #include <X11/Xaw/Logo.h> #include <X11/Xaw/Mailbox.h> - +#endif #include <X11/Xaw/MenuButton.h> #include <X11/Xaw/Paned.h> @@ -86,9 +86,11 @@ dictinsert(d, "Box", (object*)newwclassobject(boxWidgetClass, wclass_methodlists)); +#ifndef X11R6 dictinsert(d, "Clock", (object*)newwclassobject(clockWidgetClass, wclass_methodlists)); +#endif dictinsert(d, "Command", (object*)newwclassobject(commandWidgetClass, wclass_methodlists)); @@ -107,12 +109,14 @@ dictinsert(d, "List", (object*)newwclassobject(listWidgetClass, wclass_methodlists)); +#ifndef X11R6 dictinsert(d, "Logo", (object*)newwclassobject(logoWidgetClass, wclass_methodlists)); dictinsert(d, "Mailbox", (object*)newwclassobject(mailboxWidgetClass, - wclass_methodlists)); + wclass_methodlists)); +#endif dictinsert(d, "MenuButton", (object*)newwclassobject(menuButtonWidgetClass, wclass_methodlists)); --- ../../Extensions/X11/Xtgenerated.h Fri Feb 4 06:17:13 1994 +++ ./Xtgenerated.h Thu May 26 11:21:45 1994 @@ -240,6 +240,35 @@ return None; } +#ifdef X11R6 +static object * +Xt_SetLanguageProc(self, args) + object *self; + object *args; +{ + object *proc, *data, *passed; + + if (!getargs(args, "(OO)", &proc, &data)) + return NULL; + + passed = mkvalue("(OO)", proc, data); + + if (!setjmp(jump_where)) { + XtLanguageProc func = (XtLanguageProc)univ_setlanguageproc; + if (proc == NULL) { + func = NULL; + passed = NULL; + } + jump_flag = 1; + XtSetLanguageProc(NULL,func,(XtPointer)passed); + jump_flag = 0; + } + if (jump_flag) { jump_flag = 0; return NULL; } + INCREF(None); + return None; +} +#endif + struct methodlist Xt_methods[] = { {"Initialize", Xt_Initialize}, {"CreateApplicationShell", Xt_CreateApplicationShell}, @@ -254,6 +283,9 @@ {"Pending", Xt_Pending}, {"ProcessEvent", Xt_ProcessEvent}, {"MainLoop", Xt_MainLoop}, +#ifdef X11R6 + {"SetLanguageProc", Xt_SetLanguageProc}, +#endif {0, 0} /* Sentinel */ }; --- ../../Extensions/X11/Xtmodule.c Wed Feb 16 03:25:13 1994 +++ ./Xtmodule.c Fri May 27 14:39:08 1994 @@ -37,6 +37,10 @@ #include "Xttypes.h" #include <X11/StringDefs.h> +#ifdef NO_MEMSET +#define memset(a,b,c) bzero(a,c) +#endif + #ifndef offsetof #define offsetof(type, member) ((int) &((type *) 0)->member) #endif @@ -134,21 +138,24 @@ int pos, n; object *key, *value; ArgList a; + XtArgVal *i; if (args == NULL || !is_dictobject(args)) { err_setstr(TypeError, "args must be a dictionary"); return 0; } a = NEW(Arg, 1000); /* Hope that's enough */ + i = NEW(XtArgVal, 1000); pos = 0; n = 0; while (mappinggetnext(args, &pos, &key, &value)) { if (!is_stringobject(key)) { err_setstr(TypeError, "args dictionary keys must be strings"); - return NULL; + return 0; } a[n].name = getstringvalue(key); - if (!python_to_res(wC, w, key, value, &a[n].value)) + a[n].value = (XtArgVal)&i[n]; + if (!python_to_res(wC, w, key, value, &i[n])) return 0; n++; } @@ -164,6 +171,7 @@ { object *result; int i, n; + XtArgVal *values; ArgList a; if (args == NULL || !is_listobject(args)) { err_setstr(TypeError, "list of names expected"); @@ -171,7 +179,9 @@ } n = getlistsize(args); a = NEW(Arg, n); - if (a == NULL) + values = NEW(XtArgVal, n); + memset(values,0,sizeof(XtArgVal) * n + 1); + if ((a == NULL) || (values == NULL)) return err_nomem(); for (i = 0; i < n; i++) { object *item = getlistitem(args, i); @@ -179,7 +189,7 @@ if (!getargs(item, "s;name string expected", &name)) return NULL; a[i].name = name; - a[i].value = 0; + a[i].value = (XtArgVal)&values[i]; } XtGetValues(self->ob_widget, a, n); result = newdictobject(); @@ -188,7 +198,7 @@ int err; name = getlistitem(args, i); value = res_to_python(XtClass(self->ob_widget), - name, a[i].value); + name, values[i]); if (value == NULL) { DECREF(result); result = NULL; @@ -202,6 +212,7 @@ } } DEL(a); + DEL(values); return result; } @@ -633,6 +644,45 @@ DECREF(result); return remove; } + +#ifdef X11R6 +void +univ_setlanguageproc(d, xnl, closure) + Display *d; + String xnl; + object *closure; +{ + object *cbfunc, *cbarg, *cbargs, *result; + + if (!getargs(closure, "(OO)", &cbfunc, &cbarg)) { + if (jump_flag) + longjmp(jump_where, 1); + fprintf(stderr, + "--- bad closure for univ_setlanguageproc ---\n"); + print_error(); + fprintf(stderr, "---\n"); + return; + } + + cbargs = mkvalue("(O)", cbarg); + + if (cbargs == NULL) + result = NULL; + else { + result = call_object_save_jump(cbfunc, cbargs); + DECREF(cbargs); + } + if (result == NULL) { + if (jump_flag) + longjmp(jump_where, 1); + fprintf(stderr, "--- setting locale failed ---\n"); + print_error(); + fprintf(stderr, "---\n"); + } + else + DECREF(result); +} +#endif static object * wclass_GetResourceList(self, args) --- ../../Extensions/X11/Xttypes.c Fri Feb 4 06:17:20 1994 +++ ./Xttypes.c Fri May 27 14:12:30 1994 @@ -60,31 +60,52 @@ return 0; } +static char *chartypes[] = { + "Boolean", + /* Xm specific types: */ + "Alignment", + "ArrowDirection", + "DefaultButtonType", + "DialogType", + "DialogStyle", + "EditMode", + "FileTypeMask", + "IndicatorType", + "LabelType", + "ListSizePolicy", + "MultiClick", + "NavigationType", + "Orientation", + "Packing", + "ProcessingDirection", + "ResizePolicy", + "RowColumnType", + "ScrollBarDisplayPolicy", "ScrollBarPlacement", "ScrollingPolicy", + "SelectionPolicy", + "SeparatorType", + "ShadowType", + "StringDirection", + "VisualPolicy", + NULL +}; + +static char *shorttypes[] = { + "Dimension", "Position", "Short", + /* Xm specific types: */ + "BooleanDimension", + "HorizontalDimension", "HorizontalPosition", + "VerticalDimension", "VerticalPosition", + NULL +}; + static char *inttypes[] = { - "Int", "Short", "Bool", "Boolean", "Dimension", "Position", + "Int", "Bool", "Cardinal", "HorizontalInt", "VerticalInt", "Pixel", "InitialState", "ShellHorizDim", "ShellHorizPos", "ShellVertDim", "ShellVertPos", - /* Xm specific enumeration types: */ - "Alignment", "ArrowDirection", - "BooleanDimension", - "DefaultButtonType", "DialogStyle", "DialogType", - "EditMode", - "FileTypeMask", - "HorizontalDimension", "HorizontalPosition", - "IndicatorType", + /* Xm specific types: */ "KeySym", - "LabelType", "ListSizePolicy", - "MultiClick", - "NavigationType", - "Orientation", - "Packing", "ProcessingDirection", - "ResizePolicy", "RowColumnType", - "ScrollBarDisplayPolicy", "ScrollBarPlacement", "ScrollingPolicy", - "SelectionPolicy", "SeparatorType", "ShadowType", "StringDirection", "TextPosition", - "VerticalDimension", "VerticalPosition", - "VisualPolicy", NULL }; @@ -119,6 +140,15 @@ if (xtvalue->size == 0) { err_setstr(SystemError, "xtvalue2p: size==0"); return NULL; + } + for (t = chartypes; *t != NULL; t++) { + if (strcmp(typename, *t) == 0) + return newintobject((long)*(char*)xtvalue->addr& 0xff); + } + for (t = shorttypes; *t != NULL; t++) { + if (strcmp(typename, *t) == 0) + return newintobject((long)*(short*)xtvalue->addr + & 0xffff); } for (t = inttypes; *t != NULL; t++) { if (strcmp(typename, *t) == 0) --- ../../Extensions/X11/widgetobject.c Fri Feb 4 06:17:21 1994 +++ ./widgetobject.c Fri May 27 12:30:37 1994 @@ -28,15 +28,16 @@ object *value; object *namev; Arg a[1]; + XtArgVal i = 0; if (res != NULL) return res; err_clear(); namev = newstringobject(name); if (namev == NULL) return NULL; - XtSetArg(a[0], name, 0); - XtGetValues(wp->ob_widget, a, 1); - value = res_to_python(XtClass(wp->ob_widget), namev, a[0].value); + XtSetArg(a[0], name, &i); + XtGetValues(wp->ob_widget, a, 1); + value = res_to_python(XtClass(wp->ob_widget), namev, i); DECREF(namev); return value; }