Friday, January 18, 2019

A great simplification of xcb interface

typedef int XCBMethod(XCB * ); 

Andhere is an XCB:

typedef struct XCB { 
xcb_connection_t *conn;
xcb_screen_t *screen;
xcb_window_t  win;
xcb_gcontext_t gc;
xcb_void_cookie_t cookie;
uint32_t values[2]; 
uint32_t mask; 
struct XCB * xcb;
} XCB;

 Now we can define simplified entry table:

 struct methods {
XCBMethod* Connec;
XCBMethod* Window;
XCBMethod* GC;
XCBMethod* RGB);
}


Our code takes on the simple form:
methods.Conn(xcb);
methods.Window(xcb);

But, mare important, the table of entries can be filled in at load time, on request from xchars. Xchars code simply fills in the blanks from the myriads of cutnpase examples for each xcb call. And further, one can do this intelligently, supplying  short list for the light projects in coding, short enough that the code can put the method list right there in a comment, at least, without the baggage of header files and libraries.  Xchas does this anyway, here is a very shard divide between the xcb call and the universal interface, but a straight forward map at that divide. Supplying the list of xcb entries is easy.

No comments: