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

Florent Monnier fmonnier at linux-nantes.fr.eu.org
Sat May 13 10:57:40 PDT 2006


Hi Jamey,

> > > 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" />
>
> Except of course embedding ML type names is no good. It should clearly
> be "Maybe WINDOW".
>
> /me starts a language war and runs away.
>
> But seriously, note that you should always be able to lift an integer
> into a WINDOW, or else other bad things will happen. So the protocol
> description as it stands doesn't prevent any valid programs from being
> written.
>
> Also, having to parse type strings in the code generator is not good. So
> some more XML-ish approach like those Ian proposes would be necessary,
> and we won't wind up with either ML or Haskell syntax in the protocol
> descriptions. :-)

Sorry I'm not so good in English so I'm not sure to understand everything.
I really don't care if the key-words are something or something else.
The ML style name was the first which came in my mind since I'm an every day 
OCaml user :)
I have seen that everything in the XML files is made for the C language since 
every key words are C ones (enum, union, ...) and I really don't care of it.
My question was only: could it be possible to make little enhancements to 
bring it compatible with other languages than C ? since it seems (I'm not 
sure yet) that it won't be descriptive enough for OCaml.

What I've found interesting in your project was the goal to make it safer and 
closer to the X protocol.
What I have understood was that the X protocol should be universal/portable, 
so perhaps there could be several parts in the code generation, a description 
of the X protocol which is language independent, and then another XML file 
which builds structures (for a specific language) from this first description
and then the templates...

Well I guess this is an Utopia, and that I'm too much a dreamer :) since your 
project is XCB where « C » stands for the C language. Moreover I am a 
beginner so I need to practice, read all the docs on X, and enhance my skills 
to say in a concrete way where there are problems if there are some.

> > I think this is a very fine idea!
>
> I'm hesitant to get too excited about it, since it's not actually
> necessary for any language binding, as far as I know. It may not even be
> usable for its intended purpose unless we're very careful. As a general
> principle it'd be nice for the descriptions to be as complete as
> possible, though, especially for generating documentation and such.

If the first level X protocol description in XML files would be shared between 
several projects, the efforts would be more completed on the shared elements,
don't you think?


> > I'm not sure which XML constructs can best describe all these kinds
> > of types.
>
> A fairly traditional approach would use an attribute for the simplest
> cases, but allow the use of a child element instead for more complex
> ones.
>
> In CreateWindow:
> <field type="WINDOW" name="wid" />
>
> In the KeyPress event:
> <field name="child">
>   <type>WINDOW</type>
>   <const>0</type>
> </field>
s/const/type/ ?

> Or, you know, something.
 <field name="child">
   <type name="WINDOW" />
   <type name="0" />
 </field>
(IMHO attributes are often more easy to parse than PCData,
it's only a personal point of view, maybe not shared with other peoples.)


The value 0 is confusing for other purpose than C, because in C a null pointer 
can be made from the integer value 0, but in other languages 0 is strictly an 
integer value and Null is something else.


++ Whishes
-- flo


More information about the Xcb mailing list