[Xcb] bind from XML (was: Objective-C binding)

Ian Osgood iano at quirkster.com
Fri May 12 18:53:46 PDT 2006


On May 12, 2006, at 2:48 PM, Florent Monnier wrote:

> Hi,
> I'm continuing to bind the xlib for OCaml even if I'll stop to  
> switch on
> another way to make OCaml X clients. For beginning it's the easiest  
> way to
> get used to X programming since the xlib is installed yet and there  
> are a lot
> of tutorials, demos to see and documentations everywhere on the web.
>
> (I still haven't understood where to get the modular proto.pc, if  
> you could
> give me a pointer on it, I would appreciate.)

  Get via CVS as explained on the xcb DevelopersGuide page,
or install the individual xproto tarball (latest version is 7.0.5) from

http://xorg.freedesktop.org/releases/individual/proto/

>>>> I would probably need to use something other than xslt, such as
>>>> perl, for processing the files, since xslt doesn't look very
>>>> conductive to outputting Objective-C, and a quick google search
>>>> hasn't turned up any equivalents.
>>>
>>> Well, XSLT doesn't seem any less conducive to outputting Objective-C
>>> than C. :)
>>
>> If you don't like XSLT for this -- for which I can't blame you -- my
>> favorite would probably be HaXML or CDuce. (I have yet to actually  
>> try
>> either, but they look awesome.) But do whatever works for you.
>
> CDuce is written in OCaml and in my humble opinion is quite hard.
> There is XMLite in OCaml too that is very easy to use, and its  
> source code is
> very small, so you can modify it easily for your needs.
> XMLite uses ocamlyacc and ocamllex (which are close to yacc and lex).
>
> In a previous email you have suggested that I could take the XML  
> files of XCB
> to produce an X clients for my favorite language.
> I guess it is the better idea, and the best thing to do in my case.
>
> So I've found:
> ./xcb-proto-0.9/doc/xml-xcb.txt
> ./xcb-proto-0.9/src/xcb_types.xml
> ./xcb-proto-0.9/src/xproto.xml
> ./xcb-proto-0.9/src/extensions/*.xml
>
> I haven't found "c-client.xsl"

That lives in the xcb-0.9 package.

> And I would like to know where is the X protocol specs I should use?
> Is it this one:  http://www.ietf.org/rfc/rfc1013.txt  ?

They claim that is out of date. The source documents are in

> For exemple OCaml is very strict with types, so I have noticed in RFC
> in  SECTION 12.  EVENTS  for KeyPress there is:
>            root, event: WINDOW
>            child: WINDOW or None
> while in  ./xcb-proto-0.9/src/xproto.xml  there is:
>   <event name="KeyPress" number="2">
>       <field type="WINDOW" name="root" />
>       <field type="WINDOW" name="event" />
>       <field type="WINDOW" name="child" />
>       <!--  [...]  -->
>   </event>
>
> I am not sure at all of this but perhaps it should be a little bit  
> more strict
> for OCaml users, for exemple switching to:
>       <field type="WINDOW option" name="child" />

I think this is a very fine idea!

I think in general fields must be described by two attributes:

1) size in bytes (1, 2, 4) [possibly optional except for enumerations]
2) allowed types

The types must be allowed to be multiple, since fields can be:

a) simple (CARD32, INT16, BOOL, etc.)
b) an enumeration (a named <enum>, such as EventMask)
c) derived (WINDOW == id == CARD32)

as well as a combination of some of the above:

d) a combination of derived types (drawable, which means WINDOW or  
PIXMAP)
e) a combination of enumerations (ButtonMask or KeyMask)
f) a derived type or None  (WINDOW or None, depth or CopyFromParent)
g) a derived type or an enumeration
h) different types depending on the value of a *different* field  
(Events and Errors are like this)

I'm not sure which XML constructs can best describe all these kinds  
of types. Possibly:

  <field type="WINDOW" type2="None" name="child" />

or a compound type entity:

  <typeunion name="WINDOWorNone" size="4">
     <type>WINDOW</type>
     <type>None</type>
  </typeunion>
  <field type="WINDOWorNone" name="child" />

Currently, there are lots of protocol descriptions that could use  
information about the
enumerations or exceptions that are allowed for their fields.

The other type hole is in value lists.  They consist of CARD/INT32s,  
but the
meaning of each item in the list is dependent on the bits set in the  
mask.  Xlib hides
value lists behind structures, so the individual fields are typed,  
but the raw lists
are exposed in XCB.

> Well I'm not sure at all of everthing since I'm a newbee, but if  
> there would
> be a need for little changes on the XML files to make these  
> compatible with
> other X bindings, would it be possible or not ?
>
> -- flo
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>



More information about the Xcb mailing list