def codegen_main():
    arg_parser = optparse.OptionParser('%prog [options]')
    arg_parser.add_option('', '--xml-files', metavar='FILE', action='append',
                          help='D-Bus introspection XML file')
    arg_parser.add_option('', '--interface-prefix', metavar='PREFIX', default='',
                            help='String to strip from D-Bus interface names for code and docs')
    arg_parser.add_option('', '--c-namespace', metavar='NAMESPACE', default='',
                            help='The namespace to use for generated C code')
    arg_parser.add_option('', '--c-generate-object-manager', action='store_true',
                            help='Generate a GDBusObjectManagerClient subclass when generating C code')
    arg_parser.add_option('', '--generate-c-code', metavar='OUTFILES',
                          help='Generate C code in OUTFILES.[ch]')
    arg_parser.add_option('', '--generate-docbook', metavar='OUTFILES',
                          help='Generate Docbook in OUTFILES-org.Project.IFace.xml')
    arg_parser.add_option('', '--annotate', nargs=3, action='append', metavar='WHAT KEY VALUE',
                          help='Add annotation (may be used several times)')
    (opts, args) = arg_parser.parse_args();

    all_ifaces = []
    for fname in args:
        f = open(fname)
        xml_data = f.read()
        f.close()
        parsed_ifaces = parser.parse_dbus_xml(xml_data)
        all_ifaces.extend(parsed_ifaces)

    if opts.annotate != None:
        apply_annotations(all_ifaces, opts.annotate)

    for i in parsed_ifaces:
        i.post_process(opts.interface_prefix, opts.c_namespace)

    docbook = opts.generate_docbook
    docbook_gen = codegen_docbook.DocbookCodeGenerator(all_ifaces, docbook);
    if docbook:
        ret = docbook_gen.generate()

    c_code = opts.generate_c_code
    if c_code:
        h = file(c_code + '.h', 'w')
        c = file(c_code + '.c', 'w')
        gen = codegen.CodeGenerator(all_ifaces,
                                    opts.c_namespace,
                                    opts.interface_prefix,
                                    opts.c_generate_object_manager,
                                    docbook_gen,
                                    h, c);
        ret = gen.generate()

    sys.exit(0)
Beispiel #2
0
arg_parser.add_option('', '--generate-c-code', metavar='OUTFILES',
                          help='Generate C code in OUTFILES.[ch]')
arg_parser.add_option('', '--generate-docbook', metavar='OUTFILES',
                          help='Generate Docbook in OUTFILES-org.Project.IFace.xml')
arg_parser.add_option('', '--annotate', nargs=3, action='append', metavar='WHAT KEY VALUE',
                          help='Add annotation (may be used several times)')
arg_parser.add_option('', '--cim-namespace', metavar='CIMNAMESPACE', default='LMI',
                            help='The namespace to use for generated mof code')
(opts, args) = arg_parser.parse_args();

all_ifaces = []
for fname in args:
    f = open(fname, 'rb')
    xml_data = f.read()
    f.close()
    parsed_ifaces = parser.parse_dbus_xml(xml_data)
    all_ifaces.extend(parsed_ifaces)

if opts.annotate != None:
    apply_annotations(all_ifaces, opts.annotate)

for i in all_ifaces:
    i.post_process(opts.interface_prefix, opts.c_namespace)
    docbook = opts.generate_docbook
docbook_gen = codegen_docbook.DocbookCodeGenerator(all_ifaces, docbook);
if docbook:
    ret = docbook_gen.generate()

c_code = opts.generate_c_code
if c_code:
    h = open(c_code + '.h', 'w')
Beispiel #3
0
def codegen_main():
    arg_parser = optparse.OptionParser('%prog [options]')
    arg_parser.add_option('',
                          '--xml-files',
                          metavar='FILE',
                          action='append',
                          help='D-Bus introspection XML file')
    arg_parser.add_option(
        '',
        '--interface-prefix',
        metavar='PREFIX',
        default='',
        help='String to strip from D-Bus interface names for code and docs')
    arg_parser.add_option('',
                          '--c-namespace',
                          metavar='NAMESPACE',
                          default='',
                          help='The namespace to use for generated C code')
    arg_parser.add_option(
        '',
        '--c-generate-object-manager',
        action='store_true',
        help=
        'Generate a GDBusObjectManagerClient subclass when generating C code')
    arg_parser.add_option('',
                          '--generate-c-code',
                          metavar='OUTFILES',
                          help='Generate C code in OUTFILES.[ch]')
    arg_parser.add_option(
        '',
        '--generate-docbook',
        metavar='OUTFILES',
        help='Generate Docbook in OUTFILES-org.Project.IFace.xml')
    arg_parser.add_option('',
                          '--annotate',
                          nargs=3,
                          action='append',
                          metavar='WHAT KEY VALUE',
                          help='Add annotation (may be used several times)')
    (opts, args) = arg_parser.parse_args()

    all_ifaces = []
    for fname in args:
        f = open(fname)
        xml_data = f.read()
        f.close()
        parsed_ifaces = parser.parse_dbus_xml(xml_data)
        all_ifaces.extend(parsed_ifaces)

    if opts.annotate != None:
        apply_annotations(all_ifaces, opts.annotate)

    for i in parsed_ifaces:
        i.post_process(opts.interface_prefix, opts.c_namespace)

    docbook = opts.generate_docbook
    docbook_gen = codegen_docbook.DocbookCodeGenerator(all_ifaces, docbook)
    if docbook:
        ret = docbook_gen.generate()

    c_code = opts.generate_c_code
    if c_code:
        h = file(c_code + '.h', 'w')
        c = file(c_code + '.c', 'w')
        gen = codegen.CodeGenerator(all_ifaces, opts.c_namespace,
                                    opts.interface_prefix,
                                    opts.c_generate_object_manager,
                                    docbook_gen, h, c)
        ret = gen.generate()

    sys.exit(0)