aboutsummaryrefslogtreecommitdiff
path: root/libxcb
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-05-03 15:37:14 +0000
committermarha <marha@users.sourceforge.net>2011-05-03 15:37:14 +0000
commite4bd55e182560fa87af77ee3ec49fc1a907ead85 (patch)
treef77ade9dac153a4f45e08ccaf260de8d8ddbbb17 /libxcb
parente8af1ef3142aaaf2d17f2d3710e23eee1baf8a61 (diff)
parentcc93496bdbb3e7aea51033ece75fa85cfb5845d4 (diff)
downloadvcxsrv-e4bd55e182560fa87af77ee3ec49fc1a907ead85.tar.gz
vcxsrv-e4bd55e182560fa87af77ee3ec49fc1a907ead85.tar.bz2
vcxsrv-e4bd55e182560fa87af77ee3ec49fc1a907ead85.zip
svn merge ^/branches/released .
Diffstat (limited to 'libxcb')
-rw-r--r--libxcb/xcb-proto/xcbgen/matcher.py225
-rw-r--r--libxcb/xcb-proto/xcbgen/state.py332
-rw-r--r--libxcb/xcb-proto/xcbgen/xtypes.py2
3 files changed, 280 insertions, 279 deletions
diff --git a/libxcb/xcb-proto/xcbgen/matcher.py b/libxcb/xcb-proto/xcbgen/matcher.py
index e7958fa44..c4d99fc57 100644
--- a/libxcb/xcb-proto/xcbgen/matcher.py
+++ b/libxcb/xcb-proto/xcbgen/matcher.py
@@ -1,112 +1,113 @@
-'''
-XML parser. One function for each top-level element in the schema.
-
-Most functions just declare a new object and add it to the module.
-For typedefs, eventcopies, xidtypes, and other aliases though,
-we do not create a new type object, we just record the existing one under a new name.
-'''
-
-from os.path import join
-from xml.etree.cElementTree import parse
-
-import state
-from xtypes import *
-
-def import_(node, module, namespace):
- '''
- For imports, we load the file, create a new namespace object,
- execute recursively, then record the import (for header files, etc.)
- '''
- new_file = join(namespace.dir, '%s.xml' % node.text)
- new_root = parse(new_file).getroot()
- new_namespace = state.Namespace(new_file)
- execute(module, new_namespace)
- if not module.has_import(node.text):
- module.add_import(node.text, new_namespace)
-
-def typedef(node, module, namespace):
- id = node.get('newname')
- name = namespace.prefix + (id,)
- type = module.get_type(node.get('oldname'))
- module.add_type(id, namespace.ns, name, type)
-
-def xidtype(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- type = module.get_type('CARD32')
- module.add_type(id, namespace.ns, name, type)
-
-def xidunion(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- type = module.get_type('CARD32')
- module.add_type(id, namespace.ns, name, type)
-
-def enum(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- type = Enum(name, node)
- module.add_type(id, namespace.ns, name, type)
-
-def struct(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- type = Struct(name, node)
- module.add_type(id, namespace.ns, name, type)
-
-def union(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- type = Union(name, node)
- module.add_type(id, namespace.ns, name, type)
-
-def request(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- type = Request(name, node)
- module.add_request(id, name, type)
-
-def event(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- event = Event(name, node)
- event.add_opcode(node.get('number'), name, True)
- module.add_event(id, name, event)
-
-def eventcopy(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- event = module.get_event(node.get('ref'))
- event.add_opcode(node.get('number'), name, False)
- module.add_event(id, name, event)
-
-def error(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- error = Error(name, node)
- error.add_opcode(node.get('number'), name, True)
- module.add_error(id, name, error)
-
-def errorcopy(node, module, namespace):
- id = node.get('name')
- name = namespace.prefix + (id,)
- error = module.get_error(node.get('ref'))
- error.add_opcode(node.get('number'), name, False)
- module.add_error(id, name, error)
-
-funcs = {'import' : import_,
- 'typedef' : typedef,
- 'xidtype' : xidtype,
- 'xidunion' : xidunion,
- 'enum' : enum,
- 'struct' : struct,
- 'union' : union,
- 'request' : request,
- 'event' : event,
- 'eventcopy' : eventcopy,
- 'error' : error,
- 'errorcopy' : errorcopy}
-
-def execute(module, namespace):
- for elt in list(namespace.root):
- funcs[elt.tag](elt, module, namespace)
+'''
+XML parser. One function for each top-level element in the schema.
+
+Most functions just declare a new object and add it to the module.
+For typedefs, eventcopies, xidtypes, and other aliases though,
+we do not create a new type object, we just record the existing one under a new name.
+'''
+
+from os.path import join
+from xml.etree.cElementTree import parse
+
+from xcbgen.xtypes import *
+
+def import_(node, module, namespace):
+ '''
+ For imports, we load the file, create a new namespace object,
+ execute recursively, then record the import (for header files, etc.)
+ '''
+ # To avoid circular import error
+ from xcbgen import state
+ new_file = join(namespace.dir, '%s.xml' % node.text)
+ new_root = parse(new_file).getroot()
+ new_namespace = state.Namespace(new_file)
+ execute(module, new_namespace)
+ if not module.has_import(node.text):
+ module.add_import(node.text, new_namespace)
+
+def typedef(node, module, namespace):
+ id = node.get('newname')
+ name = namespace.prefix + (id,)
+ type = module.get_type(node.get('oldname'))
+ module.add_type(id, namespace.ns, name, type)
+
+def xidtype(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ type = module.get_type('CARD32')
+ module.add_type(id, namespace.ns, name, type)
+
+def xidunion(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ type = module.get_type('CARD32')
+ module.add_type(id, namespace.ns, name, type)
+
+def enum(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ type = Enum(name, node)
+ module.add_type(id, namespace.ns, name, type)
+
+def struct(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ type = Struct(name, node)
+ module.add_type(id, namespace.ns, name, type)
+
+def union(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ type = Union(name, node)
+ module.add_type(id, namespace.ns, name, type)
+
+def request(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ type = Request(name, node)
+ module.add_request(id, name, type)
+
+def event(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ event = Event(name, node)
+ event.add_opcode(node.get('number'), name, True)
+ module.add_event(id, name, event)
+
+def eventcopy(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ event = module.get_event(node.get('ref'))
+ event.add_opcode(node.get('number'), name, False)
+ module.add_event(id, name, event)
+
+def error(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ error = Error(name, node)
+ error.add_opcode(node.get('number'), name, True)
+ module.add_error(id, name, error)
+
+def errorcopy(node, module, namespace):
+ id = node.get('name')
+ name = namespace.prefix + (id,)
+ error = module.get_error(node.get('ref'))
+ error.add_opcode(node.get('number'), name, False)
+ module.add_error(id, name, error)
+
+funcs = {'import' : import_,
+ 'typedef' : typedef,
+ 'xidtype' : xidtype,
+ 'xidunion' : xidunion,
+ 'enum' : enum,
+ 'struct' : struct,
+ 'union' : union,
+ 'request' : request,
+ 'event' : event,
+ 'eventcopy' : eventcopy,
+ 'error' : error,
+ 'errorcopy' : errorcopy}
+
+def execute(module, namespace):
+ for elt in list(namespace.root):
+ funcs[elt.tag](elt, module, namespace)
diff --git a/libxcb/xcb-proto/xcbgen/state.py b/libxcb/xcb-proto/xcbgen/state.py
index 51efc9480..902a86341 100644
--- a/libxcb/xcb-proto/xcbgen/state.py
+++ b/libxcb/xcb-proto/xcbgen/state.py
@@ -1,166 +1,166 @@
-'''
-This module contains the namespace class and the singleton module class.
-'''
-from os.path import dirname, basename
-from xml.etree.cElementTree import parse
-
-import matcher
-from error import *
-from xtypes import *
-
-import __main__
-
-class Namespace(object):
- '''
- Contains the naming information for an extension.
-
- Public fields:
-
- header is the header attribute ("header file" name).
- is_ext is true for extensions, false for xproto.
- major_version and minor_version are extension version info.
- ext_xname is the X extension name string.
- ext_name is the XCB extension name prefix.
- '''
- def __init__(self, filename):
- # Path info
- self.path = filename
- self.dir = dirname(filename)
- self.file = basename(filename)
-
- # Parse XML
- self.root = parse(filename).getroot()
- self.header = self.root.get('header')
- self.ns = self.header + ':'
-
- # Get root element attributes
- if self.root.get('extension-xname', False):
- self.is_ext = True
- self.major_version = self.root.get('major-version')
- self.minor_version = self.root.get('minor-version')
- self.ext_xname = self.root.get('extension-xname')
- self.ext_name = self.root.get('extension-name')
- self.prefix = ('xcb', self.ext_name)
- else:
- self.is_ext = False
- self.ext_name = ''
- self.prefix = ('xcb',)
-
-
-class Module(object):
- '''
- This is the grand, encompassing class that represents an entire XCB specification.
- Only gets instantiated once, in the main() routine.
-
- Don't need to worry about this much except to declare it and to get the namespace.
-
- Public fields:
- namespace contains the namespace info for the spec.
- '''
- open = __main__.output['open']
- close = __main__.output['close']
-
- def __init__(self, filename, output):
- self.namespace = Namespace(filename)
- self.output = output
-
- self.imports = []
- self.types = {}
- self.events = {}
- self.errors = {}
- self.all = []
-
- # Register some common types
- self.add_type('CARD8', '', ('uint8_t',), tcard8)
- self.add_type('CARD16', '', ('uint16_t',), tcard16)
- self.add_type('CARD32', '', ('uint32_t',), tcard32)
- self.add_type('INT8', '', ('int8_t',), tint8)
- self.add_type('INT16', '', ('int16_t',), tint16)
- self.add_type('INT32', '', ('int32_t',), tint32)
- self.add_type('BYTE', '', ('uint8_t',), tcard8)
- self.add_type('BOOL', '', ('uint8_t',), tcard8)
- self.add_type('char', '', ('char',), tchar)
- self.add_type('float', '', ('float',), tfloat)
- self.add_type('double', '', ('double',), tdouble)
- self.add_type('void', '', ('void',), tcard8)
-
- # This goes out and parses the rest of the XML
- def register(self):
- matcher.execute(self, self.namespace)
-
- # Recursively resolve all types
- def resolve(self):
- for (name, item) in self.all:
- item.resolve(self)
-
- # Call all the output methods
- def generate(self):
- self.open()
-
- for (name, item) in self.all:
- item.out(name)
-
- self.close()
-
- # Keeps track of what's been imported so far.
- def add_import(self, name, namespace):
- self.imports.append((name, namespace.header))
-
- def has_import(self, name):
- for (name_, header) in self.imports:
- if name_ == name:
- return True
- return False
-
- # Keeps track of non-request/event/error datatypes
- def add_type(self, id, ns, name, item):
- key = ns + id
- if key in self.types:
- return
- self.types[key] = (name, item)
- if name[:-1] == self.namespace.prefix:
- self.all.append((name, item))
-
- def get_type_impl(self, id, idx):
- key = id
- if key in self.types:
- return self.types[key][idx]
-
- key = self.namespace.ns + id
- if key in self.types:
- return self.types[key][idx]
-
- for key in self.types.keys():
- if key.rpartition(':')[2] == id:
- return self.types[key][idx]
-
- raise ResolveException('Type %s not found' % id)
-
- def get_type(self, id):
- return self.get_type_impl(id, 1)
-
- def get_type_name(self, id):
- return self.get_type_impl(id, 0)
-
- # Keeps track of request datatypes
- def add_request(self, id, name, item):
- if name[:-1] == self.namespace.prefix:
- self.all.append((name, item))
-
- # Keeps track of event datatypes
- def add_event(self, id, name, item):
- self.events[id] = (name, item)
- if name[:-1] == self.namespace.prefix:
- self.all.append((name, item))
-
- def get_event(self, id):
- return self.events[id][1]
-
- # Keeps track of error datatypes
- def add_error(self, id, name, item):
- self.errors[id] = (name, item)
- if name[:-1] == self.namespace.prefix:
- self.all.append((name, item))
-
- def get_error(self, id):
- return self.errors[id][1]
+'''
+This module contains the namespace class and the singleton module class.
+'''
+from os.path import dirname, basename
+from xml.etree.cElementTree import parse
+
+from xcbgen import matcher
+from xcbgen.error import *
+from xcbgen.xtypes import *
+
+import __main__
+
+class Namespace(object):
+ '''
+ Contains the naming information for an extension.
+
+ Public fields:
+
+ header is the header attribute ("header file" name).
+ is_ext is true for extensions, false for xproto.
+ major_version and minor_version are extension version info.
+ ext_xname is the X extension name string.
+ ext_name is the XCB extension name prefix.
+ '''
+ def __init__(self, filename):
+ # Path info
+ self.path = filename
+ self.dir = dirname(filename)
+ self.file = basename(filename)
+
+ # Parse XML
+ self.root = parse(filename).getroot()
+ self.header = self.root.get('header')
+ self.ns = self.header + ':'
+
+ # Get root element attributes
+ if self.root.get('extension-xname', False):
+ self.is_ext = True
+ self.major_version = self.root.get('major-version')
+ self.minor_version = self.root.get('minor-version')
+ self.ext_xname = self.root.get('extension-xname')
+ self.ext_name = self.root.get('extension-name')
+ self.prefix = ('xcb', self.ext_name)
+ else:
+ self.is_ext = False
+ self.ext_name = ''
+ self.prefix = ('xcb',)
+
+
+class Module(object):
+ '''
+ This is the grand, encompassing class that represents an entire XCB specification.
+ Only gets instantiated once, in the main() routine.
+
+ Don't need to worry about this much except to declare it and to get the namespace.
+
+ Public fields:
+ namespace contains the namespace info for the spec.
+ '''
+ open = __main__.output['open']
+ close = __main__.output['close']
+
+ def __init__(self, filename, output):
+ self.namespace = Namespace(filename)
+ self.output = output
+
+ self.imports = []
+ self.types = {}
+ self.events = {}
+ self.errors = {}
+ self.all = []
+
+ # Register some common types
+ self.add_type('CARD8', '', ('uint8_t',), tcard8)
+ self.add_type('CARD16', '', ('uint16_t',), tcard16)
+ self.add_type('CARD32', '', ('uint32_t',), tcard32)
+ self.add_type('INT8', '', ('int8_t',), tint8)
+ self.add_type('INT16', '', ('int16_t',), tint16)
+ self.add_type('INT32', '', ('int32_t',), tint32)
+ self.add_type('BYTE', '', ('uint8_t',), tcard8)
+ self.add_type('BOOL', '', ('uint8_t',), tcard8)
+ self.add_type('char', '', ('char',), tchar)
+ self.add_type('float', '', ('float',), tfloat)
+ self.add_type('double', '', ('double',), tdouble)
+ self.add_type('void', '', ('void',), tcard8)
+
+ # This goes out and parses the rest of the XML
+ def register(self):
+ matcher.execute(self, self.namespace)
+
+ # Recursively resolve all types
+ def resolve(self):
+ for (name, item) in self.all:
+ item.resolve(self)
+
+ # Call all the output methods
+ def generate(self):
+ self.open()
+
+ for (name, item) in self.all:
+ item.out(name)
+
+ self.close()
+
+ # Keeps track of what's been imported so far.
+ def add_import(self, name, namespace):
+ self.imports.append((name, namespace.header))
+
+ def has_import(self, name):
+ for (name_, header) in self.imports:
+ if name_ == name:
+ return True
+ return False
+
+ # Keeps track of non-request/event/error datatypes
+ def add_type(self, id, ns, name, item):
+ key = ns + id
+ if key in self.types:
+ return
+ self.types[key] = (name, item)
+ if name[:-1] == self.namespace.prefix:
+ self.all.append((name, item))
+
+ def get_type_impl(self, id, idx):
+ key = id
+ if key in self.types:
+ return self.types[key][idx]
+
+ key = self.namespace.ns + id
+ if key in self.types:
+ return self.types[key][idx]
+
+ for key in self.types.keys():
+ if key.rpartition(':')[2] == id:
+ return self.types[key][idx]
+
+ raise ResolveException('Type %s not found' % id)
+
+ def get_type(self, id):
+ return self.get_type_impl(id, 1)
+
+ def get_type_name(self, id):
+ return self.get_type_impl(id, 0)
+
+ # Keeps track of request datatypes
+ def add_request(self, id, name, item):
+ if name[:-1] == self.namespace.prefix:
+ self.all.append((name, item))
+
+ # Keeps track of event datatypes
+ def add_event(self, id, name, item):
+ self.events[id] = (name, item)
+ if name[:-1] == self.namespace.prefix:
+ self.all.append((name, item))
+
+ def get_event(self, id):
+ return self.events[id][1]
+
+ # Keeps track of error datatypes
+ def add_error(self, id, name, item):
+ self.errors[id] = (name, item)
+ if name[:-1] == self.namespace.prefix:
+ self.all.append((name, item))
+
+ def get_error(self, id):
+ return self.errors[id][1]
diff --git a/libxcb/xcb-proto/xcbgen/xtypes.py b/libxcb/xcb-proto/xcbgen/xtypes.py
index fd52d6eeb..882acc9b8 100644
--- a/libxcb/xcb-proto/xcbgen/xtypes.py
+++ b/libxcb/xcb-proto/xcbgen/xtypes.py
@@ -1,7 +1,7 @@
'''
This module contains the classes which represent XCB data types.
'''
-from expr import Field, Expression
+from xcbgen.expr import Field, Expression
import __main__
class Type(object):