#!/usr/bin/env python
from xml.etree.cElementTree import *
-from sys import argv
from os.path import basename
+import getopt
+import sys
import re
# Jump to the bottom of this file for the main routine
_h('extern xcb_extension_t %s;', _ns.c_ext_global_name)
_c('')
- _c('xcb_extension_t %s = { "%s" };', _ns.c_ext_global_name, _ns.ext_xname)
+ _c('xcb_extension_t %s = { "%s", 0 };', _ns.c_ext_global_name, _ns.ext_xname)
def c_close(self):
'''
struct_fields = []
maxtypelen = 0
+ varfield = None
for field in self.fields:
if not field.type.fixed_size():
- break
+ varfield = field.c_field_name
+ continue
+ if varfield != None and not field.type.is_pad:
+ errmsg = '%s: warning: variable field %s followed by fixed field %s\n' % (self.c_type, varfield, field.c_field_name)
+ sys.stderr.write(errmsg)
+ # sys.exit(1)
if field.wire:
struct_fields.append(field)
# Boilerplate below this point
+# Check for the argument that specifies path to the xcbgen python package.
+try:
+ opts, args = getopt.getopt(sys.argv[1:], 'p:')
+except getopt.GetoptError, err:
+ print str(err)
+ print 'Usage: c_client.py [-p path] file.xml'
+ sys.exit(1)
+
+for (opt, arg) in opts:
+ if opt == '-p':
+ sys.path.append(arg)
+
# Import the module class
try:
from xcbgen.state import Module
print ''
print 'Failed to load the xcbgen Python package!'
print 'Make sure that xcb/proto installed it on your Python path.'
- print 'If not, you will need to create a .pth file to extend the path.'
+ print 'If not, you will need to create a .pth file or define $PYTHONPATH'
+ print 'to extend the path.'
print 'Refer to the README file in xcb/proto for more info.'
print ''
raise
# Parse the xml header
-module = Module(argv[1], output)
+module = Module(args[0], output)
# Build type-registry and resolve type dependencies
module.register()