[Xcb] python bindings

Thomas Hunger hto at arcor.de
Tue Jul 3 06:41:27 PDT 2007


Hello

I've put online a _very_ unstable version of my Python bindings. Some 
documentation and the source:

http://htom.de/gitweb?p=python-libxcb.git;a=blob_plain;f=doc/quickintro.html;hb=HEAD
http://htom.de/gitweb/

I've mainly published now because there are some problems which I am 
not sure how to address:

1) <request name="GetAtomName" opcode="17"> has reply with a list:
      <list type="CARD8" name="name">
        <fieldref>name_len</fieldref>
      </list>

   I think this should be changed to type="char" because it is a
   STRING8. 

2) The iterator-API is really hard to handle & understand. I tried to
   explain it to a friend of mine and it took him hours to "get it". 
   (And I believe that he is pretty smart ;)

   In the Python binding I prefetch all values into a tuple when the 
   list is accessed the first time. That means that there is a member
   in the struct/reply/event/error for each list.

   We could reproduce that in c with the following system:

     1) List items are fixed length: Just put pointer intro the 
        struct which points to the start of the array. Analog to 
        
        xcb_visualtype_t*
        xcb_depth_visuals (const xcb_depth_t *R)

        we have 
        xcb_visualtype_t* depth_visuals;

     2) List items are variable length: Introduce a double-pointer
        list which points to the start of each element and is
        initialized when the structure is returned.

        xcb_depth_t** allowed_depth;

     3) Keep the XXX_length functions, but add one for fixed length 
        lists like  e.g.:

          <list type="char" name="event">
          <value>32</value></list>

     4) Introduce a XXX_free function which frees structs with
        double-pointer lists and just calls a normal free for fixed
        length structs.

   I do understand that this would probably change too much and
   therefore cannot be done. It was just an idea. 
        
3) Lists of type "void". There are some lists which have CARD8, 16 
   or 32 as their type, depending on one of the arguments. This is
   solved by using a "void" pointer in c. This cannot be mapped to 
   Python. So I introduced some special cases for "ChangeProperty" 
   and "GetProperty" which are the only places with void lists so 
   far. Are there better ideas?

Tom


More information about the Xcb mailing list