unit X11_Objects; {$MODE OBJFPC} {$M+} {$DEFINE X11} interface uses x, xlib, sysutils, type_fixes; type TExternalHandle = TUINT32; TMessageMap = object // FIXME end; {$DEFINE in_interface} {$INCLUDE OS_Objects.INC} {$UNDEF in_interface} type EX11Error = class(Exception) constructor Create(aCode : LongWord); end; function CheckError(aStatus : TUINT32) : TUINT32; procedure EnsureOK(aStatus : TUINT32); implementation {$DEFINE in_implementation} {$INCLUDE OS_Objects.INC} {$UNDEF in_implementation} procedure EnsureOK(aStatus : TUINT32); begin if aStatus = 0 then // <> Success then raise EX11Error.Create(aStatus); { BadAlloc The server failed to allocate the requested resource or server memory. BadColor A value for a Colormap argument does not name a defined Colormap. BadCursor A value for a Cursor argument does not name a defined Cursor. BadMatch The values do not exist for an InputOnly window. BadMatch Some argument or pair of arguments has the correct type and range but fails to match in some other way required by the request. BadPixmap A value for a Pixmap argument does not name a defined Pixmap. BadValue Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error. BadWindow A value for a Window argument does not name a defined Window. } end; function CheckError(aStatus : TUINT32) : TUINT32; begin EnsureOK(aStatus); Result := aStatus; end; constructor EX11Error.Create(aCode : LongWord); var vMessage : UTF8String; begin vMessage := IntToStr(aCode); // FIXME use some nicer function. inherited Create(vMessage); end; end.