[Xcb] Proposal: Link fields to enums in the protocol XML files
Peter Harris
pharris at opentext.com
Mon Jan 5 14:14:53 PST 2009
Antoine Latter wrote:
> On Mon, Jan 5, 2009 at 2:45 PM, Peter Harris <pharris at opentext.com> wrote:
>>> ; an enum
>>> or an XID;
>> <field type="PIXMAP" enum="Enum" /> seems pretty clear to me.
>
> The thing I don't like about this is that it looks that same as:
> <field type="CARD32" enum="Enum" />
>
> But means something entirely different.
See below.
> What might be clearer is for the enum values to be marked as "This
> enum value is a valid value of type PIXMAP".
That runs into problems when the same enum is used in each of a CARD8,
CARD16, and CARD32 context. I grant that this will never happen with
PIXMAP as a base type. But as long as the type must be specified with
the field some of the time, we ought to be consistent and specify the
type all of the time.
More importantly, making this change would break all of the current parsers.
> Then the more-typeful
> programming languages can generate typed constants.
When I read type="PIXMAP" with my more-typeful programming language
glasses on, it looks nothing at all like type="CARD32". They only look
somewhat similar if I forget and leave my less-typeful glasses on. So
the more-typeful language parsers should have no trouble.
If you're suggesting that the base type should be attached to the <enum>
in addition to the type attached to each <field>, so that the generator
knows the (possible) xidtype of the enum before parsing the requests
that use it, that is a good suggestion. Fortunately, it can be looked at
separately from the current discussion.
>> <import> has already solved this one, no? XCB extensions have been
>> referencing typedefs from xcbproto and other extensions forever. I don't
>> see how enums are any different.
>
> Presumably it would look like:
>
> <field type="CARD32" enum="reference:Enum" />
>
> Like we do in other cross-namespace types. Is that what you were thinking?
Yes. Except we omit "reference:" when the name is not ambiguous (which
is most of the time outside glx).
Peter Harris
--
Open Text Connectivity Solutions Group
Peter Harris http://www.opentext.com/connectivity
Research and Development Phone: +1 905 762 6001
pharris at opentext.com Toll Free: 1 877 359 4866
More information about the Xcb
mailing list