mirror of
https://gitlab.freedesktop.org/xorg/proto/xcbproto.git
synced 2025-12-20 04:40:09 +01:00
Add missing fields to errors
All X11 errors have the same fields. There are no differences. In a perfect world, the XML could thus just say "define an error" and xcbgen would do all the rest. However, the world is imperfect and we already have a mixture of fields defined in the XML. Some of the XML even defines trailing padding, while most does not. This commit makes xcbgen add all fields to X11 errors, but those that are already defined in the XML are skipped and left as-is. Due to the structure of the code, this requires pretending that a different XML was read, i.e. the code now modifies the in-memory structure of ElementTree to add the missing fields to the in-memory representation of the XML. This is the simplest way that I found to append elements. The existing mechanisms can only prepend fields. The approach taken by this commit was suggested by Peter Harris. Thanks a lot for this idea, it's a lot simpler than my previous approach. Fixes: https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/issues/16 Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
151ee69847
commit
6d72110e1e
1 changed files with 10 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ This module contains the classes which represent XCB data types.
|
|||
'''
|
||||
from xcbgen.expr import Field, Expression
|
||||
from xcbgen.align import Alignment, AlignmentLog
|
||||
from xml.etree.ElementTree import SubElement
|
||||
import __main__
|
||||
|
||||
verbose_align_log = False
|
||||
|
|
@ -1352,6 +1353,15 @@ class Error(ComplexType):
|
|||
if self.required_start_align is None:
|
||||
self.required_start_align = Alignment(4,0)
|
||||
|
||||
# All errors are basically the same, but they still got different XML
|
||||
# for historic reasons. This 'invents' the missing parts.
|
||||
if len(self.elt) < 1:
|
||||
SubElement(self.elt, "field", type="CARD32", name="bad_value")
|
||||
if len(self.elt) < 2:
|
||||
SubElement(self.elt, "field", type="CARD16", name="minor_opcode")
|
||||
if len(self.elt) < 3:
|
||||
SubElement(self.elt, "field", type="CARD8", name="major_opcode")
|
||||
|
||||
def add_opcode(self, opcode, name, main):
|
||||
self.opcodes[name] = opcode
|
||||
if main:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue