def build(fname): global _pylines, _pylevel, _ns, _py_fmt_fmt, _py_fmt_size, _py_fmt_list _pylines = [] _pylevel = 0 _ns = None _py_fmt_fmt = '' _py_fmt_size = 0 _py_fmt_list = [] # Parse the xml header module = Module(fname, __main__.output) # Build type-registry and resolve type dependencies module.register() module.resolve() # Output the code module.generate()
parser.add_argument('output') args = parser.parse_args() output = {'open' : cxx_open, 'close' : cxx_close, 'simple' : cxx_simple, 'enum' : cxx_enum, 'struct' : cxx_struct, 'union' : cxx_union, 'request' : cxx_request, 'event' : cxx_event, 'error' : cxx_error, } if args.xml: from xcbgen.state import Module from xcbgen.xtypes import * module = Module(args.xml, output) c_client.module = module module.register() module.resolve() module.generate() else: future_error = cxx_request_wrapper("future_error", "xcb_void_cookie_t") cxx_request_checked(future_error) xcb_ns.children.append(future_error) std_ns.children.append(CxxTemplate("struct iterator_traits;\n", "typename Iterator")) cxx_close(None)
from xcbgen import xtypes from xcbgen.xtypes import SimpleType, Struct xtypes.tcard8 = SimpleType(('uint8',), 1) xtypes.tcard16 = SimpleType(('uint16',), 2) xtypes.tcard32 = SimpleType(('uint32',), 4) xtypes.tint8 = SimpleType(('int8',), 1) xtypes.tint16 = SimpleType(('int16',), 2) xtypes.tint32 = SimpleType(('int32',), 4) xtypes.tchar = SimpleType(('char',), 1) xtypes.tfloat = SimpleType(('float',), 4) xtypes.tdouble = SimpleType(('double',), 8) tbool = SimpleType(('bool',), 1) tid = SimpleType(('Id',), 4) module = Module(args[0], output) module.types = {} module.add_type('CARD8', '', ('byte',), xtypes.tcard8) module.add_type('CARD16', '', ('uint16',), xtypes.tcard16) module.add_type('CARD32', '', ('uint32',), xtypes.tcard32) module.add_type('INT8', '', ('int8',), xtypes.tint8) module.add_type('INT16', '', ('int16',), xtypes.tint16) module.add_type('INT32', '', ('int32',), xtypes.tint32) module.add_type('BYTE', '', ('byte',), xtypes.tcard8) module.add_type('BOOL', '', ('bool',), tbool) module.add_type('char', '', ('byte',), xtypes.tchar) module.add_type('float', '', ('float',), xtypes.tfloat) module.add_type('double', '', ('double',), xtypes.tdouble) module.add_type('void', '', ('byte',), xtypes.tcard8) module.add_type('Id', '', ('Id',), tid) module.add_type('FONTABLE', '', ('Id',), tid)
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 except ImportError: 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 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(args[0], output) # Build type-registry and resolve type dependencies module.register() module.resolve() # Output the code module.generate()
# We must create an "output" dictionary before any xcbgen imports output = { 'open': rs_open, 'close': rs_close, 'simple': rs_simple, 'enum': rs_enum, 'struct': rs_struct, 'union': rs_union, 'request': rs_request, 'eventstruct': rs_eventstruct, 'event': rs_event, 'error': rs_error, } from xcbgen.state import Module # noqa names = glob.glob(input_dir + "/*.xml") for name in names: module = Module(name, None) module.register() module.resolve() try: module.generate() except Exception: sys.stderr.write('Error occurred while generating: %s\n' % module.namespace.header) raise output_file = os.path.join(output_dir, "%s.rs" % main_module) main_output_file.write_file(output_file)
from xcbgen import xtypes from xcbgen.xtypes import SimpleType, Struct xtypes.tcard8 = SimpleType(('uint8', ), 1) xtypes.tcard16 = SimpleType(('uint16', ), 2) xtypes.tcard32 = SimpleType(('uint32', ), 4) xtypes.tint8 = SimpleType(('int8', ), 1) xtypes.tint16 = SimpleType(('int16', ), 2) xtypes.tint32 = SimpleType(('int32', ), 4) xtypes.tchar = SimpleType(('char', ), 1) xtypes.tfloat = SimpleType(('float', ), 4) xtypes.tdouble = SimpleType(('double', ), 8) tbool = SimpleType(('bool', ), 1) tid = SimpleType(('Id', ), 4) module = Module(args[0], output) module.types = {} module.add_type('CARD8', '', ('byte', ), xtypes.tcard8) module.add_type('CARD16', '', ('uint16', ), xtypes.tcard16) module.add_type('CARD32', '', ('uint32', ), xtypes.tcard32) module.add_type('INT8', '', ('int8', ), xtypes.tint8) module.add_type('INT16', '', ('int16', ), xtypes.tint16) module.add_type('INT32', '', ('int32', ), xtypes.tint32) module.add_type('BYTE', '', ('byte', ), xtypes.tcard8) module.add_type('BOOL', '', ('bool', ), tbool) module.add_type('char', '', ('byte', ), xtypes.tchar) module.add_type('float', '', ('float', ), xtypes.tfloat) module.add_type('double', '', ('double', ), xtypes.tdouble) module.add_type('void', '', ('byte', ), xtypes.tcard8) module.add_type('Id', '', ('Id', ), tid) module.add_type('FONTABLE', '', ('Id', ), tid)
l('const %s = %d', code_name, code) error_types.append(type_name) if code > max_error_code: max_error_code = code output = { 'open': go_open, 'close': go_close, 'simple': go_simple, 'enum': go_enum, 'struct': go_struct, 'union': go_union, 'request': go_request, 'event': go_event, 'error': go_error, } # Import the module class from xcbgen.state import Module from xcbgen.xtypes import * # Parse the xml header module = Module(args.xml_file, output) # Build type-registry and resolve type dependencies module.register() module.resolve() # Output the code module.generate()