def main(argv): args = parse_args(argv[1:]) try: idlparser = cidl.Parser(value_class=Value, param_class=Parameter) idl = idlparser.parse(open(args.idl_file, 'r').read()) def ensure_dir(filename): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) api = None if args.api_file is not None: ensure_dir(args.api_file) with open(args.api_file, 'w') as file: generate_api_file(args.module_name, idl, file) header = None if args.header_file is not None: ensure_dir(args.header_file) with open(args.header_file, 'w') as file: generate_header_file(args.module_name, idl, file) source = None if args.source_file is not None: ensure_dir(args.source_file) with open(args.source_file, 'w') as file: generate_source_file(args.module_name, idl, file) except cidl.Error as e: sys.stderr.write('%s\n' % e)
def startParsing(): try: idlparser = cidl.Parser(param_class=Parameter) idl = idlparser.parse(open(FILE_NAME, 'r').read()) generateJavaFunctions("Functions.java", idl) generateJavaCallbacks("Callbacks.java", idl) generateJavaConstants("Constants.java", idl) print("Parsing process has been finished successfully. " + str(len(idl.functions)) + " functions / callbacks and " + str(len(idl.constants)) + " constants parsed.") except cidl.Error as e: print(e) return
def main(argv): argparser = argparse.ArgumentParser() argparser.add_argument('--module-name', dest='module_name', metavar='name', required=True) argparser.add_argument('--idl-file', dest='idl_file', metavar='path', required=True) argparser.add_argument('--api-file', dest='api_file', metavar='path') argparser.add_argument('--header-file', dest='header_file', metavar='path') argparser.add_argument('--source-file', dest='source_file', metavar='path') args = argparser.parse_args(argv[1:]) try: idlparser = cidl.Parser(value_class=Value, param_class=Parameter) idl = idlparser.parse(open(args.idl_file, 'r').read()) def ensure_dir(filename): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) api = None if args.api_file is not None: ensure_dir(args.api_file) with open(args.api_file, 'w') as file: generate_api_file(args.module_name, idl, file) header = None if args.header_file is not None: ensure_dir(args.header_file) with open(args.header_file, 'w') as file: generate_header_file(args.module_name, idl, file) source = None if args.source_file is not None: ensure_dir(args.source_file) with open(args.source_file, 'w') as file: generate_source_file(args.module_name, idl, file) except cidl.Error as e: sys.stderr.write('%s\n' % e)
def main(argv): args = parse_args(argv[1:]) try: idlparser = cidl.Parser(value_class=Value, param_class=Parameter) idl = idlparser.parse(open(args.idl_file, 'rU').read()) for (path, func) in [(args.api_file, generate_api_file), (args.header_file, generate_header_file), (args.source_file, generate_source_file)]: if path is not None: dir = os.path.dirname(path) if not os.path.exists(dir): os.makedirs(dir) with open(path, 'w') as file: func(args.module_name, idl, file) except cidl.Error as e: sys.stderr.write('%s\n' % e) return 1
def parse_idl(filename): parser = cidl.Parser() return parser.parse(open(filename, 'r').read())