[Xcb] [PATCH 2/2] Remove now useless files as everything is implemented in xcbgen.
Arnaud Fontaine
arnaud at andesi.org
Tue Jan 24 23:57:46 PST 2012
From: Arnaud Fontaine <arnau at debian.org>
---
src/import.py | 66 -------------------------------------------------
src/size.py | 76 ---------------------------------------------------------
src/type.py | 74 -------------------------------------------------------
3 files changed, 0 insertions(+), 216 deletions(-)
delete mode 100755 src/import.py
delete mode 100755 src/size.py
delete mode 100755 src/type.py
diff --git a/src/import.py b/src/import.py
deleted file mode 100755
index eb58f55..0000000
--- a/src/import.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python
-
-from xml.sax.saxutils import XMLFilterBase, XMLGenerator
-from xml.sax import make_parser
-import sys, os
-
-path = [os.path.curdir, 'extensions']
-def find_file_on_path(name):
- for d in path:
- test = os.path.join(d, name)
- if os.path.isfile(test):
- return test
- raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), name)
-
-seen = {}
-
-class ProcessImports(XMLFilterBase):
- def setContentHandler(self, handler):
- self.handler = handler
- XMLFilterBase.setContentHandler(self, handler)
-
- def ensure(self, name):
- if not seen.has_key(name):
- child = ProcessImports(make_parser())
- child.setContentHandler(self.handler)
- child.parse(find_file_on_path(name + '.xml'))
-
- def startDocument(self):
- pass
- def endDocument(self):
- pass
-
- inimport = None
-
- def startElement(self, name, attrs):
- assert self.inimport is None
- if name == 'import':
- self.inimport = ""
- return
- XMLFilterBase.startElement(self, name, attrs)
- if name == 'xcb':
- seen[attrs['header']] = True
- self.ensure('xproto')
-
- def characters(self, content):
- if self.inimport is not None:
- self.inimport += content
- else:
- XMLFilterBase.characters(self, content)
-
- def endElement(self, name):
- if name == 'import':
- self.ensure(self.inimport)
- self.inimport = None
- return
- XMLFilterBase.endElement(self, name)
-
-out = XMLGenerator()
-importer = ProcessImports(make_parser())
-importer.setContentHandler(out)
-out.startDocument()
-if len(sys.argv) > 1:
- importer.parse(sys.argv[1])
-else:
- importer.parse(sys.stdin)
-out.endDocument()
diff --git a/src/size.py b/src/size.py
deleted file mode 100755
index 5ead8b2..0000000
--- a/src/size.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/python
-
-from xml.sax.saxutils import XMLFilterBase, XMLGenerator
-from xml.sax.xmlreader import AttributesImpl
-from xml.sax import make_parser
-import sys
-
-def AttributesUnion(base, **values):
- baseitems = dict(base)
- baseitems.update(values)
- return AttributesImpl(baseitems)
-
-class AnnotateSize(XMLFilterBase):
- types = {
- 'BYTE': 1, 'BOOL': 1,
- 'CARD8': 1, 'CARD16': 2, 'CARD32': 4,
- 'INT8': 1, 'INT16': 2, 'INT32': 4,
- 'char': 1, 'void': 1,
- 'float': 4, 'double': 8,
- 'XID': 4,
- }
- header = []
- def setTypeSize(self, name, size):
- assert not self.types.has_key(name), "size of " + name + " declared as both " + str(size) + " and " + str(self.types[name])
- self.types[name] = size
-
- struct = None
- union = None
- def startElement(self, name, attrs):
- if name == 'xcb':
- self.header.insert(0, attrs['header'])
- elif name == 'field':
- size = self.types.get(attrs['type'], 0)
- if self.struct is not None:
- self.totalsize += size
- elif self.union is not None:
- self.totalsize = max(self.totalsize, size)
- attrs = AttributesUnion(attrs, bytes=str(size))
- elif name == 'pad':
- assert self.union is None
- if self.struct is not None:
- self.totalsize += int(attrs['bytes'])
- elif name == 'xidtype':
- self.setTypeSize(attrs['name'], 4)
- elif name == 'typedef':
- self.setTypeSize(attrs['newname'], self.types[attrs['oldname']])
- elif name == 'struct' or name == 'union':
- assert self.struct is None and self.union is None
- setattr(self, name, attrs['name'])
- self.totalsize = 0
-
- if len(self.header) == 1 or name == 'xcb':
- XMLFilterBase.startElement(self, name, attrs)
-
- def characters(self, content):
- if len(self.header) == 1:
- XMLFilterBase.characters(self, content)
-
- def endElement(self, name):
- if len(self.header) == 1 or name == 'xcb':
- XMLFilterBase.endElement(self, name)
-
- if name == 'xcb':
- self.header.pop(0)
- elif name == 'struct' or name == 'union':
- assert getattr(self, name) is not None
- self.setTypeSize(getattr(self, name), self.totalsize)
- setattr(self, name, None)
- del self.totalsize
-
-annotator = AnnotateSize(make_parser())
-annotator.setContentHandler(XMLGenerator())
-if len(sys.argv) > 1:
- annotator.parse(sys.argv[1])
-else:
- annotator.parse(sys.stdin)
diff --git a/src/type.py b/src/type.py
deleted file mode 100755
index 8338232..0000000
--- a/src/type.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/python
-
-from xml.sax.saxutils import XMLFilterBase, XMLGenerator
-from xml.sax.xmlreader import AttributesImpl
-from xml.sax import make_parser
-import sys
-
-def AttributesUnion(base, **values):
- baseitems = dict(base)
- baseitems.update(values)
- return AttributesImpl(baseitems)
-
-class AnnotateType(XMLFilterBase):
- scopes = []
- map = dict([(name, [name]) for name in [
- 'BOOL', 'BYTE',
- 'CARD8', 'CARD16', 'CARD32',
- 'INT8', 'INT16', 'INT32',
- 'char', 'void',
- 'float', 'double',
- 'XID',
- ]])
- def startScope(self, name):
- self.scopes.insert(0, name)
- def declareType(self, name):
- assert ':' not in name
- qname = self.scopes[0] + ':' + name
- self.map.setdefault(name, []).insert(0, qname)
- def getQualifiedType(self, name):
- if ':' in name:
- return name
- names = self.map.get(name, [])
- return names[0]
- def endScope(self):
- self.scopes.pop(0)
-
- def startElement(self, name, attrs):
- attnames = []
- if name == 'xcb':
- self.startScope(attrs['header'])
- elif name in ['struct', 'union', 'xidtype', 'enum', 'event', 'eventcopy', 'error', 'errorcopy']:
- self.declareType(attrs['name'])
- attnames = ['name']
- if name.endswith('copy'):
- attnames.append('ref')
- elif name == 'typedef':
- self.declareType(attrs['newname'])
- attnames = ['oldname', 'newname']
- elif name == 'valueparam':
- attnames = ['value-mask-type']
- elif attrs.has_key('type'):
- attnames = ['type']
- newattrs = {}
- for attname in attnames:
- newattrs[attname] = self.getQualifiedType(attrs[attname])
- if newattrs:
- attrs = AttributesUnion(attrs, **newattrs)
- XMLFilterBase.startElement(self, name, attrs)
-
- def endElement(self, name):
- XMLFilterBase.endElement(self, name)
- if name == 'xcb':
- self.endScope()
-
-annotator = AnnotateType(make_parser())
-annotator.setContentHandler(XMLGenerator())
-if len(sys.argv) > 1:
- annotator.parse(sys.argv[1])
-else:
- annotator.parse(sys.stdin)
-
-for name,names in annotator.map.iteritems():
- if len(names) != 1:
- print "<!-- warning:", name, "has the following definitions:", names, "-->"
--
1.7.8.3
More information about the Xcb
mailing list