#!/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
for (n, h) in self.imports:
_hc('#include "%s.h"', h)
+ _h('')
+ _h('#ifdef __cplusplus')
+ _h('extern "C" {')
+ _h('#endif')
+
+ if _ns.is_ext:
_h('')
_h('#define XCB_%s_MAJOR_VERSION %s', _ns.ext_name.upper(), _ns.major_version)
_h('#define XCB_%s_MINOR_VERSION %s', _ns.ext_name.upper(), _ns.minor_version)
_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):
'''
_h_setlevel(2)
_c_setlevel(2)
_hc('')
+
+ _h('')
+ _h('#ifdef __cplusplus')
+ _h('}')
+ _h('#endif')
+
_h('')
_h('#endif')
_h('')
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 and field.wire:
+ 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
raise
# Parse the xml header
-module = Module(argv[1], output)
+module = Module(args[0], output)
# Build type-registry and resolve type dependencies
module.register()