From 54bc366be872256a0f40ae292e14900c3a764f5d Mon Sep 17 00:00:00 2001 From: frese Date: Mon, 21 May 2001 15:33:59 +0000 Subject: [PATCH] Minor changes. --- c/xlib/type.c | 775 ++++++++++++++++++++++++++------------------------ 1 file changed, 410 insertions(+), 365 deletions(-) diff --git a/c/xlib/type.c b/c/xlib/type.c index 1fdcb48..32c0bf6 100644 --- a/c/xlib/type.c +++ b/c/xlib/type.c @@ -1,5 +1,415 @@ #include "xlib.h" +/* Types, functions and variables for the conversion between XLib constants + and the scheme symbols: +*/ + +s48_value Bits_To_Symbols(unsigned long bits, int mask_flag, SYMDESCR* table) { + S48_DECLARE_GC_PROTECT(1); + s48_value res = S48_NULL; + S48_GC_PROTECT_1(res); + + char* name; + int val; + int i = 0; + while (table[i].name != (char*)0) { + name = table[i].name; + val = table[i].val; + + if ((val & bits) != 0) { + if (mask_flag == 0) { + res = s48_enter_symbol(name); + break; + } else { + res = s48_cons(s48_enter_symbol(name), res); + } + } + i++; + } + if ((mask_flag == 0) && S48_NULL_P(res)) + res = s48_enter_integer(bits); // or an exception?? + + S48_GC_UNPROTECT(); + return res; +} + +typedef struct { + char *name; + unsigned long val; +} SYMDESCR; + +SYMDESCR Func_Syms[] = { + { "clear", GXclear }, + { "and", GXand }, + { "and-reverse", GXandReverse }, + { "copy", GXcopy }, + { "and-inverted", GXandInverted }, + { "no-op", GXnoop }, + { "xor", GXxor }, + { "or", GXor }, + { "nor", GXnor }, + { "equiv", GXequiv }, + { "invert", GXinvert }, + { "or-reverse", GXorReverse }, + { "copy-inverted", GXcopyInverted }, + { "or-inverted", GXorInverted }, + { "nand", GXnand }, + { "set", GXset }, + { 0, 0 } +}; + +SYMDESCR Bit_Grav_Syms[] = { + { "forget", ForgetGravity }, + { "north-west", NorthWestGravity }, + { "north", NorthGravity }, + { "north-east", NorthEastGravity }, + { "west", WestGravity }, + { "center", CenterGravity }, + { "east", EastGravity }, + { "south-west", SouthWestGravity }, + { "south", SouthGravity }, + { "south-east", SouthEastGravity }, + { "static", StaticGravity }, + { 0, 0 } +}; + +SYMDESCR Grav_Syms[] = { + { "unmap", UnmapGravity }, + { "north-west", NorthWestGravity }, + { "north", NorthGravity }, + { "north-east", NorthEastGravity }, + { "west", WestGravity }, + { "center", CenterGravity }, + { "east", EastGravity }, + { "south-west", SouthWestGravity }, + { "south", SouthGravity }, + { "south-east", SouthEastGravity }, + { "static", StaticGravity }, + { 0, 0 } +}; + +SYMDESCR Backing_Store_Syms[] = { + { "not-useful", NotUseful }, + { "when-mapped", WhenMapped }, + { "always", Always }, + { 0, 0 } +}; + +SYMDESCR Stack_Mode_Syms[] = { + { "above", Above }, + { "below", Below }, + { "top-if", TopIf }, + { "bottom-if", BottomIf }, + { "opposite", Opposite }, + { 0, 0 } +}; + +SYMDESCR Line_Style_Syms[] = { + { "solid", LineSolid }, + { "dash", LineOnOffDash }, + { "double-dash", LineDoubleDash }, + { 0, 0 } +}; + +SYMDESCR Cap_Style_Syms[] = { + { "not-last", CapNotLast }, + { "butt", CapButt }, + { "round", CapRound }, + { "projecting", CapProjecting }, + { 0, 0 } +}; + +SYMDESCR Join_Style_Syms[] = { + { "miter", JoinMiter }, + { "round", JoinRound }, + { "bevel", JoinBevel }, + { 0, 0 } +}; + +SYMDESCR Fill_Style_Syms[] = { + { "solid", FillSolid }, + { "tiled", FillTiled }, + { "stippled", FillStippled }, + { "opaque-stippled", FillOpaqueStippled }, + { 0, 0 } +}; + +SYMDESCR Fill_Rule_Syms[] = { + { "even-odd", EvenOddRule }, + { "winding", WindingRule }, + { 0, 0 } +}; + +SYMDESCR Arc_Mode_Syms[] = { + { "chord", ArcChord }, + { "pie-slice", ArcPieSlice }, + { 0, 0 } +}; + +SYMDESCR Subwin_Mode_Syms[] = { + { "clip-by-children", ClipByChildren }, + { "include-inferiors", IncludeInferiors }, + { 0, 0 } +}; + +SYMDESCR Class_Syms[] = { + { "input-output", InputOutput }, + { "input-only", InputOnly }, + { 0, 0 } +}; + +SYMDESCR Map_State_Syms[] = { + { "unmapped", IsUnmapped }, + { "unviewable", IsUnviewable }, + { "viewable", IsViewable }, + { 0, 0 } +}; + +SYMDESCR State_Syms[] = { + { "shift", ShiftMask }, + { "lock", LockMask }, + { "control", ControlMask }, + { "mod1", Mod1Mask }, + { "mod2", Mod2Mask }, + { "mod3", Mod3Mask }, + { "mod4", Mod4Mask }, + { "mod5", Mod5Mask }, + { "button1", Button1Mask }, + { "button2", Button2Mask }, + { "button3", Button3Mask }, + { "button4", Button4Mask }, + { "button5", Button5Mask }, + { "any-modifier", AnyModifier }, + { 0, 0 } +}; + +SYMDESCR Button_Syms[] = { + { "any-button", AnyButton }, + { "button1", Button1 }, + { "button2", Button2 }, + { "button3", Button3 }, + { "button4", Button4 }, + { "button5", Button5 }, + { 0, 0 } +}; + +SYMDESCR Cross_Mode_Syms[] = { + { "normal", NotifyNormal }, + { "grab", NotifyGrab }, + { "ungrab", NotifyUngrab }, + { 0, 0 } +}; + +SYMDESCR Cross_Detail_Syms[] = { + { "ancestor", NotifyAncestor }, + { "virtual", NotifyVirtual }, + { "inferior", NotifyInferior }, + { "nonlinear", NotifyNonlinear }, + { "nonlinear-virtual", NotifyNonlinearVirtual }, + { 0, 0 } +}; + +SYMDESCR Focus_Detail_Syms[] = { + { "ancestor", NotifyAncestor }, + { "virtual", NotifyVirtual }, + { "inferior", NotifyInferior }, + { "nonlinear", NotifyNonlinear }, + { "nonlinear-virtual", NotifyNonlinearVirtual }, + { "pointer", NotifyPointer }, + { "pointer-root", NotifyPointerRoot }, + { "none", NotifyDetailNone }, + { 0, 0 } +}; + +SYMDESCR Visibility_Syms[] = { + { "unobscured", VisibilityUnobscured }, + { "partially-obscured", VisibilityPartiallyObscured }, + { "fully-obscured", VisibilityFullyObscured }, + { 0, 0 } +}; + +SYMDESCR Place_Syms[] = { + { "top", PlaceOnTop }, + { "bottom", PlaceOnBottom }, + { 0, 0 } +}; + +SYMDESCR Prop_Syms[] = { + { "new-value", PropertyNewValue }, + { "deleted", PropertyDelete }, + { 0, 0 } +}; + +SYMDESCR Mapping_Syms[] = { + { "modifier", MappingModifier }, + { "keyboard", MappingKeyboard }, + { "pointer", MappingPointer }, + { 0, 0 } +}; + +SYMDESCR Direction_Syms[] = { + { "left-to-right", FontLeftToRight }, + { "right-to-left", FontRightToLeft }, + { 0, 0 } +}; + +SYMDESCR Polyshape_Syms[] = { + { "complex", Complex }, + { "non-convex", Nonconvex }, + { "convex", Convex }, + { 0, 0 } +}; + +SYMDESCR Propmode_Syms[] = { + { "replace", PropModeReplace }, + { "prepend", PropModePrepend }, + { "append", PropModeAppend }, + { 0, 0 } +}; + +SYMDESCR Grabstatus_Syms[] = { + { "success", Success }, + { "not-viewable", GrabNotViewable }, + { "already-grabbed", AlreadyGrabbed }, + { "frozen", GrabFrozen }, + { "invalid-time", GrabInvalidTime }, + { 0, 0 } +}; + +SYMDESCR Bitmapstatus_Syms[] = { + { "success", BitmapSuccess }, + { "open-failed", BitmapOpenFailed }, + { "file-invalid", BitmapFileInvalid }, + { "no-memory", BitmapNoMemory }, + { 0, 0 } +}; + +SYMDESCR Circulate_Syms[] = { + { "raise-lowest", RaiseLowest }, + { "lower-highest", LowerHighest }, + { 0, 0 } +}; + +SYMDESCR Allow_Events_Syms[] = { + { "async-pointer", AsyncPointer }, + { "sync-pointer", SyncPointer }, + { "replay-pointer", ReplayPointer }, + { "async-keyboard", AsyncKeyboard }, + { "sync-keyboard", SyncKeyboard }, + { "replay-keyboard", ReplayKeyboard }, + { "async-both", AsyncBoth }, + { "sync-both", SyncBoth }, + { 0, 0 } +}; + +SYMDESCR Revert_Syms[] = { + { "none", RevertToNone }, + { "pointer-root", RevertToPointerRoot }, + { "parent", RevertToParent }, + { 0, 0 } +}; + +SYMDESCR Shape_Syms[] = { + { "cursor", CursorShape }, + { "tile", TileShape }, + { "stipple", StippleShape }, + { 0, 0 } +}; + +SYMDESCR Initial_State_Syms[] = { + { "dont-care", DontS48_CAReState }, + { "normal", NormalState }, + { "zoom", ZoomState }, + { "iconic", IconicState }, + { "inactive", InactiveState }, + { 0, 0 } +}; + +SYMDESCR Ordering_Syms[] = { + { "unsorted", Unsorted }, + { "y-sorted", YSorted }, + { "yx-sorted", YXSorted }, + { "yx-banded", YXBanded }, + { 0, 0 } +}; + +SYMDESCR Byte_Order_Syms[] = { + { "lsb-first", LSBFirst }, + { "msb-first", MSBFirst }, + { 0, 0 } +}; + +SYMDESCR Saveset_Syms[] = { + { "insert", SetModeInsert }, + { "delete", SetModeDelete }, + { 0, 0 } +}; + +SYMDESCR Closemode_Syms[] = { + { "destroy-all", DestroyAll }, + { "retain-permanent", RetainPermanent }, + { "retain-temporary", RetainTemporary }, + { 0, 0 } +}; + +SYMDESCR Event_Syms[] = { + { "key-press", KeyPressMask }, + { "key-release", KeyReleaseMask }, + { "button-press", ButtonPressMask }, + { "button-release", ButtonReleaseMask }, + { "enter-window", EnterWindowMask }, + { "leave-window", LeaveWindowMask }, + { "pointer-motion", PointerMotionMask }, + { "pointer-motion-hint", PointerMotionHintMask }, + { "button-1-motion", Button1MotionMask }, + { "button-2-motion", Button2MotionMask }, + { "button-3-motion", Button3MotionMask }, + { "button-4-motion", Button4MotionMask }, + { "button-5-motion", Button5MotionMask }, + { "button-motion", ButtonMotionMask }, + { "keymap-state", KeymapStateMask }, + { "exposure", ExposureMask }, + { "visibility-change", VisibilityChangeMask }, + { "structure-notify", StructureNotifyMask }, + { "resize-redirect", ResizeRedirectMask }, + { "substructure-notify", SubstructureNotifyMask }, + { "substructure-redirect", SubstructureRedirectMask }, + { "focus-change", FocusChangeMask }, + { "property-change", PropertyChangeMask }, + { "colormap-change", ColormapChangeMask }, + { "owner-grab-button", OwnerGrabButtonMask }, + { "all-events", ~(unsigned long)0 }, + { 0, 0 } +}; + +SYMDESCR Error_Syms[] = { + { "bad-request", BadRequest }, + { "bad-value", BadValue }, + { "bad-window", BadWindow }, + { "bad-pixmap", BadPixmap }, + { "bad-atom", BadAtom }, + { "bad-cursor", BadCursor }, + { "bad-font", BadFont }, + { "bad-match", BadMatch }, + { "bad-drawable", BadDrawable }, + { "bad-access", BadAccess }, + { "bad-alloc", BadAlloc }, + { "bad-color", BadColor }, + { "bad-gcontext", BadGC }, + { "bad-id-choice", BadIDChoice }, + { "bad-name", BadName }, + { "bad-length", BadLength }, + { "bad-implementation", BadImplementation }, + { 0, 0 } +}; + +/************************************************************************* + Other things +*************************************************************************/ + + + + static s48_value Set_Attr_Slots; static s48_value Conf_Slots; static s48_value GC_Slots; @@ -398,371 +808,6 @@ s48_value Record_To_Vector (rp, len, sym, dpy, flags) s48_value sym; return v; } -SYMDESCR Func_Syms[] = { - { "clear", GXclear }, - { "and", GXand }, - { "and-reverse", GXandReverse }, - { "copy", GXcopy }, - { "and-inverted", GXandInverted }, - { "no-op", GXnoop }, - { "xor", GXxor }, - { "or", GXor }, - { "nor", GXnor }, - { "equiv", GXequiv }, - { "invert", GXinvert }, - { "or-reverse", GXorReverse }, - { "copy-inverted", GXcopyInverted }, - { "or-inverted", GXorInverted }, - { "nand", GXnand }, - { "set", GXset }, - { 0, 0 } -}; - -SYMDESCR Bit_Grav_Syms[] = { - { "forget", ForgetGravity }, - { "north-west", NorthWestGravity }, - { "north", NorthGravity }, - { "north-east", NorthEastGravity }, - { "west", WestGravity }, - { "center", CenterGravity }, - { "east", EastGravity }, - { "south-west", SouthWestGravity }, - { "south", SouthGravity }, - { "south-east", SouthEastGravity }, - { "static", StaticGravity }, - { 0, 0 } -}; - -SYMDESCR Grav_Syms[] = { - { "unmap", UnmapGravity }, - { "north-west", NorthWestGravity }, - { "north", NorthGravity }, - { "north-east", NorthEastGravity }, - { "west", WestGravity }, - { "center", CenterGravity }, - { "east", EastGravity }, - { "south-west", SouthWestGravity }, - { "south", SouthGravity }, - { "south-east", SouthEastGravity }, - { "static", StaticGravity }, - { 0, 0 } -}; - -SYMDESCR Backing_Store_Syms[] = { - { "not-useful", NotUseful }, - { "when-mapped", WhenMapped }, - { "always", Always }, - { 0, 0 } -}; - -SYMDESCR Stack_Mode_Syms[] = { - { "above", Above }, - { "below", Below }, - { "top-if", TopIf }, - { "bottom-if", BottomIf }, - { "opposite", Opposite }, - { 0, 0 } -}; - -SYMDESCR Line_Style_Syms[] = { - { "solid", LineSolid }, - { "dash", LineOnOffDash }, - { "double-dash", LineDoubleDash }, - { 0, 0 } -}; - -SYMDESCR Cap_Style_Syms[] = { - { "not-last", CapNotLast }, - { "butt", CapButt }, - { "round", CapRound }, - { "projecting", CapProjecting }, - { 0, 0 } -}; - -SYMDESCR Join_Style_Syms[] = { - { "miter", JoinMiter }, - { "round", JoinRound }, - { "bevel", JoinBevel }, - { 0, 0 } -}; - -SYMDESCR Fill_Style_Syms[] = { - { "solid", FillSolid }, - { "tiled", FillTiled }, - { "stippled", FillStippled }, - { "opaque-stippled", FillOpaqueStippled }, - { 0, 0 } -}; - -SYMDESCR Fill_Rule_Syms[] = { - { "even-odd", EvenOddRule }, - { "winding", WindingRule }, - { 0, 0 } -}; - -SYMDESCR Arc_Mode_Syms[] = { - { "chord", ArcChord }, - { "pie-slice", ArcPieSlice }, - { 0, 0 } -}; - -SYMDESCR Subwin_Mode_Syms[] = { - { "clip-by-children", ClipByChildren }, - { "include-inferiors", IncludeInferiors }, - { 0, 0 } -}; - -SYMDESCR Class_Syms[] = { - { "input-output", InputOutput }, - { "input-only", InputOnly }, - { 0, 0 } -}; - -SYMDESCR Map_State_Syms[] = { - { "unmapped", IsUnmapped }, - { "unviewable", IsUnviewable }, - { "viewable", IsViewable }, - { 0, 0 } -}; - -SYMDESCR State_Syms[] = { - { "shift", ShiftMask }, - { "lock", LockMask }, - { "control", ControlMask }, - { "mod1", Mod1Mask }, - { "mod2", Mod2Mask }, - { "mod3", Mod3Mask }, - { "mod4", Mod4Mask }, - { "mod5", Mod5Mask }, - { "button1", Button1Mask }, - { "button2", Button2Mask }, - { "button3", Button3Mask }, - { "button4", Button4Mask }, - { "button5", Button5Mask }, - { "any-modifier", AnyModifier }, - { 0, 0 } -}; - -SYMDESCR Button_Syms[] = { - { "any-button", AnyButton }, - { "button1", Button1 }, - { "button2", Button2 }, - { "button3", Button3 }, - { "button4", Button4 }, - { "button5", Button5 }, - { 0, 0 } -}; - -SYMDESCR Cross_Mode_Syms[] = { - { "normal", NotifyNormal }, - { "grab", NotifyGrab }, - { "ungrab", NotifyUngrab }, - { 0, 0 } -}; - -SYMDESCR Cross_Detail_Syms[] = { - { "ancestor", NotifyAncestor }, - { "virtual", NotifyVirtual }, - { "inferior", NotifyInferior }, - { "nonlinear", NotifyNonlinear }, - { "nonlinear-virtual", NotifyNonlinearVirtual }, - { 0, 0 } -}; - -SYMDESCR Focus_Detail_Syms[] = { - { "ancestor", NotifyAncestor }, - { "virtual", NotifyVirtual }, - { "inferior", NotifyInferior }, - { "nonlinear", NotifyNonlinear }, - { "nonlinear-virtual", NotifyNonlinearVirtual }, - { "pointer", NotifyPointer }, - { "pointer-root", NotifyPointerRoot }, - { "none", NotifyDetailNone }, - { 0, 0 } -}; - -SYMDESCR Visibility_Syms[] = { - { "unobscured", VisibilityUnobscured }, - { "partially-obscured", VisibilityPartiallyObscured }, - { "fully-obscured", VisibilityFullyObscured }, - { 0, 0 } -}; - -SYMDESCR Place_Syms[] = { - { "top", PlaceOnTop }, - { "bottom", PlaceOnBottom }, - { 0, 0 } -}; - -SYMDESCR Prop_Syms[] = { - { "new-value", PropertyNewValue }, - { "deleted", PropertyDelete }, - { 0, 0 } -}; - -SYMDESCR Mapping_Syms[] = { - { "modifier", MappingModifier }, - { "keyboard", MappingKeyboard }, - { "pointer", MappingPointer }, - { 0, 0 } -}; - -SYMDESCR Direction_Syms[] = { - { "left-to-right", FontLeftToRight }, - { "right-to-left", FontRightToLeft }, - { 0, 0 } -}; - -SYMDESCR Polyshape_Syms[] = { - { "complex", Complex }, - { "non-convex", Nonconvex }, - { "convex", Convex }, - { 0, 0 } -}; - -SYMDESCR Propmode_Syms[] = { - { "replace", PropModeReplace }, - { "prepend", PropModePrepend }, - { "append", PropModeAppend }, - { 0, 0 } -}; - -SYMDESCR Grabstatus_Syms[] = { - { "success", Success }, - { "not-viewable", GrabNotViewable }, - { "already-grabbed", AlreadyGrabbed }, - { "frozen", GrabFrozen }, - { "invalid-time", GrabInvalidTime }, - { 0, 0 } -}; - -SYMDESCR Bitmapstatus_Syms[] = { - { "success", BitmapSuccess }, - { "open-failed", BitmapOpenFailed }, - { "file-invalid", BitmapFileInvalid }, - { "no-memory", BitmapNoMemory }, - { 0, 0 } -}; - -SYMDESCR Circulate_Syms[] = { - { "raise-lowest", RaiseLowest }, - { "lower-highest", LowerHighest }, - { 0, 0 } -}; - -SYMDESCR Allow_Events_Syms[] = { - { "async-pointer", AsyncPointer }, - { "sync-pointer", SyncPointer }, - { "replay-pointer", ReplayPointer }, - { "async-keyboard", AsyncKeyboard }, - { "sync-keyboard", SyncKeyboard }, - { "replay-keyboard", ReplayKeyboard }, - { "async-both", AsyncBoth }, - { "sync-both", SyncBoth }, - { 0, 0 } -}; - -SYMDESCR Revert_Syms[] = { - { "none", RevertToNone }, - { "pointer-root", RevertToPointerRoot }, - { "parent", RevertToParent }, - { 0, 0 } -}; - -SYMDESCR Shape_Syms[] = { - { "cursor", CursorShape }, - { "tile", TileShape }, - { "stipple", StippleShape }, - { 0, 0 } -}; - -SYMDESCR Initial_State_Syms[] = { - { "dont-care", DontS48_CAReState }, - { "normal", NormalState }, - { "zoom", ZoomState }, - { "iconic", IconicState }, - { "inactive", InactiveState }, - { 0, 0 } -}; - -SYMDESCR Ordering_Syms[] = { - { "unsorted", Unsorted }, - { "y-sorted", YSorted }, - { "yx-sorted", YXSorted }, - { "yx-banded", YXBanded }, - { 0, 0 } -}; - -SYMDESCR Byte_Order_Syms[] = { - { "lsb-first", LSBFirst }, - { "msb-first", MSBFirst }, - { 0, 0 } -}; - -SYMDESCR Saveset_Syms[] = { - { "insert", SetModeInsert }, - { "delete", SetModeDelete }, - { 0, 0 } -}; - -SYMDESCR Closemode_Syms[] = { - { "destroy-all", DestroyAll }, - { "retain-permanent", RetainPermanent }, - { "retain-temporary", RetainTemporary }, - { 0, 0 } -}; - -SYMDESCR Event_Syms[] = { - { "key-press", KeyPressMask }, - { "key-release", KeyReleaseMask }, - { "button-press", ButtonPressMask }, - { "button-release", ButtonReleaseMask }, - { "enter-window", EnterWindowMask }, - { "leave-window", LeaveWindowMask }, - { "pointer-motion", PointerMotionMask }, - { "pointer-motion-hint", PointerMotionHintMask }, - { "button-1-motion", Button1MotionMask }, - { "button-2-motion", Button2MotionMask }, - { "button-3-motion", Button3MotionMask }, - { "button-4-motion", Button4MotionMask }, - { "button-5-motion", Button5MotionMask }, - { "button-motion", ButtonMotionMask }, - { "keymap-state", KeymapStateMask }, - { "exposure", ExposureMask }, - { "visibility-change", VisibilityChangeMask }, - { "structure-notify", StructureNotifyMask }, - { "resize-redirect", ResizeRedirectMask }, - { "substructure-notify", SubstructureNotifyMask }, - { "substructure-redirect", SubstructureRedirectMask }, - { "focus-change", FocusChangeMask }, - { "property-change", PropertyChangeMask }, - { "colormap-change", ColormapChangeMask }, - { "owner-grab-button", OwnerGrabButtonMask }, - { "all-events", ~(unsigned long)0 }, - { 0, 0 } -}; - -SYMDESCR Error_Syms[] = { - { "bad-request", BadRequest }, - { "bad-value", BadValue }, - { "bad-window", BadWindow }, - { "bad-pixmap", BadPixmap }, - { "bad-atom", BadAtom }, - { "bad-cursor", BadCursor }, - { "bad-font", BadFont }, - { "bad-match", BadMatch }, - { "bad-drawable", BadDrawable }, - { "bad-access", BadAccess }, - { "bad-alloc", BadAlloc }, - { "bad-color", BadColor }, - { "bad-gcontext", BadGC }, - { "bad-id-choice", BadIDChoice }, - { "bad-name", BadName }, - { "bad-length", BadLength }, - { "bad-implementation", BadImplementation }, - { 0, 0 } -}; - static Init_Record (rec, size, name, var) RECORD *rec; char *name; s48_value *var; { s48_value list, tail, cell;