Skip to content

Instantly share code, notes, and snippets.

@phire
Last active September 16, 2021 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phire/c288eac4bc71aab32c730e88b77ade50 to your computer and use it in GitHub Desktop.
Save phire/c288eac4bc71aab32c730e88b77ade50 to your computer and use it in GitHub Desktop.
#include <FEXThunkDefs.h> // provides fexgen_config in this model
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
// For each exported function:
fexgen_config exports[] = {
// Variadic functions: The variadic parameters are automatically packed into an unsigned long array
{ fexgen_config(XCreateIC)
.uniform_va_type<unsigned long>()
},
{ fexgen_config(XGetICValues)
.uniform_va_type<unsigned long>()
},
// Factory function returning objects with vtables: Automatically makes the contained function pointers guest-callable
{ fexgen_config(XCreateImage)
.fixup_vtable_in_return<unsigned long>()
},
// Functions with no customization needed
XFree,
XFetchBytes,
XLocaleOfIM,
XLocaleOfOM,
XmbResetIC,
Xpermalloc,
Xutf8ResetIC,
XrmLocaleOfDatabase,
XDisplayOfOM,
XChangeKeyboardMapping,
XCloseOM,
XDrawText16,
XDrawText,
XInternalConnectionNumbers,
XMaskEvent,
XmbTextExtents,
XmbTextPerCharExtents,
_Xmbtowc,
XNoOp,
XOffsetRegion,
XPointInRegion,
XQueryBestCursor,
XQueryBestSize,
XQueryBestStipple,
XQueryBestTile,
XQueryKeymap,
XQueryTextExtents16,
XQueryTextExtents,
XReadBitmapFile,
XReconfigureWMWindow,
XRestackWindows,
XRotateWindowProperties,
XSetClassHint,
XSetFontPath,
XSetIconName,
XSetModifierMapping,
XSetPointerMapping,
XSetScreenSaver,
XSetSizeHints,
XSetState,
XSetWMColormapWindows,
XSetZoomHints,
XShrinkRegion,
XStoreBuffer,
XStoreColor,
XStoreNamedColor,
XStringListToTextProperty,
XTextExtents,
XTextPropertyToStringList,
XUninstallColormap,
Xutf8TextEscapement,
Xutf8TextExtents,
Xutf8TextPerCharExtents,
XwcTextExtents,
XwcTextPerCharExtents,
_Xwctomb,
XWriteBitmapFile,
XXorRegion,
XKeysymToKeycode,
XKeycodeToKeysym,
XDisplayMotionBufferSize,
XDestroyOC,
XmbDrawText,
XmbSetWMProperties,
XrmPutFileDatabase,
XrmPutResource,
XrmQPutStringResource,
XrmStringToQuarkList,
XSetStandardColormap,
XSetTextProperty,
XSetWMClientMachine,
XSetWMSizeHints,
Xutf8DrawImageString,
Xutf8DrawString,
Xutf8DrawText,
XwcDrawText,
XwcResetIC,
XIMOfIC,
XDeleteModifiermapEntry,
XInsertModifiermapEntry,
XNewModifiermap,
XOMOfOC,
XOpenOM,
XPolygonRegion,
XDefaultString,
XAllocClassHint,
XAllocWMHints,
XListProperties,
XBaseFontNameListOfFontSet,
XGetFontPath,
XListFontsWithInfo,
XLocaleOfFontSet,
XServerVendor,
XCopyColormapAndFree,
XDefaultColormapOfScreen,
XListInstalledColormaps,
XActivateScreenSaver,
XAddHosts,
XAddToExtensionList,
XAddToSaveSet,
XAllocColorPlanes,
XAllowEvents,
XAutoRepeatOff,
XAutoRepeatOn,
XBitmapBitOrder,
XBitmapPad,
XBitmapUnit,
XCellsOfScreen,
XChangeKeyboardControl,
XChangePointerControl,
XChangeSaveSet,
XCheckMaskEvent,
XCheckTypedEvent,
XCheckTypedWindowEvent,
XCirculateSubwindows,
XCirculateSubwindowsDown,
XCirculateSubwindowsUp,
XConnectionNumber,
XContextDependentDrawing,
XContextualDrawing,
XCopyGC,
XDefaultDepthOfScreen,
XDestroySubwindows,
XDirectionalDependentDrawing,
XDisplayCells,
XDisplayHeightMM,
XDisplayPlanes,
XDisplayWidthMM,
XDoesBackingStore,
XDoesSaveUnders,
XDrawImageString16,
XDrawRectangles,
XForceScreenSaver,
XFreeFontInfo,
XFreeFontNames,
XFreeFontPath,
XGeometry,
XGetAtomNames,
XGetCommand,
XGetIconName,
XGetIconSizes,
XGetKeyboardControl,
XGetNormalHints,
XGetPointerControl,
XGetPointerMapping,
XGetScreenSaver,
XGetSizeHints,
XGetStandardColormap,
XGetTextProperty,
XGetTransientForHint,
XGetWMColormapWindows,
XGetWMIconName,
XGetWMSizeHints,
XGetZoomHints,
XHeightMMOfScreen,
XHeightOfScreen,
XImageByteOrder,
XInstallColormap,
XMaxCmapsOfScreen,
XMinCmapsOfScreen,
XPlanesOfScreen,
XProtocolRevision,
XProtocolVersion,
XQLength,
XRebindKeysym,
XRemoveFromSaveSet,
XRemoveHosts,
XScreenCount,
XSetAccessControl,
XSetWindowColormap,
XVendorRelease,
XWidthMMOfScreen,
XWidthOfScreen,
XEventMaskOfScreen,
XAllPlanes,
XBlackPixel,
XBlackPixelOfScreen,
XLastKnownRequestProcessed,
XWhitePixel,
XWhitePixelOfScreen,
XScreenOfDisplay,
XDefaultVisualOfScreen,
XFlushGC,
XRootWindowOfScreen,
XEHeadOfExtensionList,
XFindOnExtensionList,
XDefaultGC,
XDefaultGCOfScreen,
XGetSubImage,
XGetMotionEvents,
XInitImage,
XrmQuarkToString,
XrmCombineFileDatabase,
XrmGetResource,
XrmQGetResource,
XrmQGetSearchList,
XrmQGetSearchResource,
XrmCombineDatabase,
XrmDestroyDatabase,
XrmMergeDatabases,
XrmParseCommand,
XrmPutLineResource,
XrmPutStringResource,
XrmQPutResource,
XrmSetDatabase,
XrmStringToBindingQuarkList,
XrmGetDatabase,
XrmGetFileDatabase,
XrmGetStringDatabase,
XrmUniqueQuark,
XrmStringToQuark,
XrmPermStringToQuark,
XDisplayName,
XDisplayString,
XFetchBuffer,
XGetAtomName,
XGetDefault,
XKeysymToString,
XListFonts,
XResourceManagerString,
XScreenResourceString,
XDefaultColormap,
XCreateFontCursor,
XCreateGlyphCursor,
XDisplayOfIM,
XDisplayOfScreen,
XLoadFont,
XGContextFromGC,
// XAddConnectionWatch,
XAddHost,
XAllocColorCells,
XAllocColor,
XAllocNamedColor,
XBell,
XChangeActivePointerGrab,
XChangeGC,
XChangeWindowAttributes,
XClearArea,
XClearWindow,
XClipBox,
XConfigureWindow,
XConvertSelection,
XCopyArea,
XCopyPlane,
XDefaultDepth,
XDeleteContext,
XDeleteProperty,
XDestroyRegion,
XDisableAccessControl,
XDisplayKeycodes,
XDrawArc,
XDrawArcs,
XDrawImageString,
XDrawLine,
XDrawLines,
XDrawPoint,
XDrawPoints,
XDrawRectangle,
XDrawSegments,
XDrawString,
XEmptyRegion,
XEnableAccessControl,
XEqualRegion,
XFetchName,
XFillArc,
XFillArcs,
XFillPolygon,
XFillRectangles,
XFindContext,
XFontsOfFontSet,
XFreeColors,
XFreeModifiermap,
XGetClassHint,
XGetFontProperty,
XGetGCValues,
XGetGeometry,
XGetInputFocus,
XGetRGBColormaps,
XGetWindowAttributes,
XGetWMClientMachine,
XGetWMName,
XGetWMNormalHints,
XGetWMProtocols,
XGrabButton,
XGrabKeyboard,
XGrabKey,
XInternAtoms,
XIntersectRegion,
XKillClient,
XListDepths,
XLookupColor,
XLowerWindow,
XMapSubwindows,
XmbLookupString,
XmbTextEscapement,
XmbTextListToTextProperty,
XmbTextPropertyToTextList,
XParseColor,
XPutBackEvent,
XQueryColor,
XQueryColors,
XRaiseWindow,
XReadBitmapFileData,
XRecolorCursor,
XRectInRegion,
XRefreshKeyboardMapping,
XRemoveHost,
XReparentWindow,
XRotateBuffers,
XSaveContext,
XScreenNumberOfScreen,
XSetArcMode,
XSetBackground,
XSetClipMask,
XSetClipOrigin,
XSetClipRectangles,
XSetCloseDownMode,
XSetCommand,
XSetDashes,
XSetFillRule,
XSetFillStyle,
XSetFont,
XSetForeground,
XSetFunction,
XSetGraphicsExposures,
XSetIconSizes,
XSetInputFocus,
XSetLineAttributes,
XSetPlaneMask,
XSetRegion,
XSetSelectionOwner,
XSetStipple,
XSetSubwindowMode,
XSetTile,
XSetTSOrigin,
XSetWindowBackground,
XSetWindowBackgroundPixmap,
XSetWindowBorder,
XSetWindowBorderPixmap,
XSetWindowBorderWidth,
XSetWMHints,
XStoreBytes,
XStoreColors,
XStoreName,
XSubtractRegion,
XSupportsLocale,
XTextWidth16,
XTextWidth,
XUngrabButton,
XUngrabKeyboard,
XUngrabKey,
XUnionRectWithRegion,
XUnionRegion,
XUnloadFont,
XUnmapSubwindows,
Xutf8TextListToTextProperty,
Xutf8TextPropertyToTextList,
XwcLookupString,
XwcTextEscapement,
XwcTextListToTextProperty,
XwcTextPropertyToTextList,
XWithdrawWindow,
XWMGeometry,
XGetKeyboardMapping,
XStringToKeysym,
XExtendedMaxRequestSize,
XMaxRequestSize,
XNextRequest,
XCreatePixmapFromBitmapData,
XVisualIDFromVisual,
XDefaultVisual,
XConvertCase,
XFreeFontSet,
XFreeStringList,
XmbDrawImageString,
XmbDrawString,
XProcessInternalConnection,
XrmInitialize,
XSetAuthorization,
XSetRGBColormaps,
XSetWMIconName,
XSetWMName,
XSetWMProperties,
XUnsetICFocus,
XwcDrawImageString,
XwcDrawString,
XwcFreeStringList,
XCreateSimpleWindow,
XDefaultRootWindow,
XGetSelectionOwner,
XRootWindow,
XAddExtension,
XInitExtension,
XExtentsOfFontSet,
XQueryFont,
XListHosts,
XAllocIconSize,
XGetModifierMapping,
XCreateFontSet,
XListPixmapFormats,
XCreateRegion,
XAllocSizeHints,
XAllocStandardColormap,
XGetVisualInfo,
XGetWMHints,
XMapWindow,
XLookupKeysym,
XParseGeometry,
XSetNormalHints,
XSetStandardProperties,
XInternAtom,
XListExtensions,
XSetLocaleModifiers,
XCreateColormap,
XCreatePixmapCursor,
XOpenDisplay,
XChangeProperty,
XCloseDisplay,
XCloseIM,
XDefineCursor,
XDestroyWindow,
XDrawString16,
XEventsQueued,
XFillRectangle,
XFilterEvent,
XFlush,
XFreeColormap,
XFreeCursor,
XFreeExtensionList,
XFreeFont,
XFreeGC,
XFreePixmap,
XGetErrorDatabaseText,
XGetErrorText,
XGetEventData,
XGetWindowProperty,
XGrabPointer,
XGrabServer,
XIconifyWindow,
XLookupString,
XMapRaised,
XMoveResizeWindow,
XMoveWindow,
XNextEvent,
XPeekEvent,
XPending,
XQueryExtension,
XQueryPointer,
XQueryTree,
XResetScreenSaver,
XResizeWindow,
XSelectInput,
XSendEvent,
XSetTransientForHint,
XSetWMProtocols,
XSync,
XTextExtents16,
XTranslateCoordinates,
XUngrabPointer,
XUngrabServer,
XUnmapWindow,
Xutf8LookupString,
XWarpPointer,
XWindowEvent,
XCreateBitmapFromData,
XCreatePixmap,
XDestroyIC,
XFreeEventData,
XLockDisplay,
XSetICFocus,
XSetWMNormalHints,
XUnlockDisplay,
Xutf8SetWMProperties,
XCreateWindow,
XLoadQueryFont,
XCreateGC,
XGetImage,
XOpenIM,
XCheckWindowEvent,
XUndefineCursor,
XDefaultScreenOfDisplay,
XDefaultScreen,
XDisplayWidth,
XMatchVisualInfo,
XPutImage,
XDisplayHeight,
};
// Functions with callback arguments: _internal variants of these are created for guest<->host marshalling; the Host/Guest entrypoints are implemented manually
fexgen_config callbacks[] {
XSetErrorHandler,
XIfEvent
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment