int main(int argc, char **argv) { int res; struct genbind_node *genbind_root; options = process_cmdline(argc, argv); if (options == NULL) { return 1; /* bad commandline */ } if (options->verbose && (options->outfilename == NULL)) { fprintf(stderr, "Error: output to stdout with verbose logging would fail\n"); return 2; } if (options->depfilename != NULL && options->outfilename == NULL) { fprintf(stderr, "Error: output to stdout with dep generation would fail\n"); return 3; } if (options->depfilename != NULL && options->infilename == NULL) { fprintf(stderr, "Error: input from stdin with dep generation would fail\n"); return 3; } if (options->depfilename != NULL) { options->depfilehandle = fopen(options->depfilename, "w"); if (options->depfilehandle == NULL) { fprintf(stderr, "Error: unable to open dep file\n"); return 4; } fprintf(options->depfilehandle, "%s %s :", options->depfilename, options->outfilename); } res = genbind_parsefile(options->infilename, &genbind_root); if (res != 0) { fprintf(stderr, "Error: parse failed with code %d\n", res); return res; } if (options->verbose) { genbind_ast_dump(genbind_root, 0); } res = jsapi_libdom_output(options->outfilename, options->hdrfilename, genbind_root); if (res != 0) { fprintf(stderr, "Error: output failed with code %d\n", res); if (options->outfilename != NULL) { unlink(options->outfilename); } if (options->hdrfilename != NULL) { unlink(options->hdrfilename); } return res; } if (options->depfilehandle != NULL) { fputc('\n', options->depfilehandle); fclose(options->depfilehandle); } return 0; }
int main(int argc, char **argv) { int res; struct genbind_node *genbind_root = NULL; struct webidl_node *webidl_root = NULL; struct ir *ir = NULL; enum bindingtype_e bindingtype; options = process_cmdline(argc, argv); if (options == NULL) { return 1; /* bad commandline */ } /* parse binding */ res = genbind_parsefile(options->infilename, &genbind_root); if (res != 0) { fprintf(stderr, "Error: parse failed with code %d\n", res); return res; } /* dump the binding AST */ genbind_dump_ast(genbind_root); /* get type of binding */ bindingtype = genbind_get_type(genbind_root); if (bindingtype == BINDINGTYPE_UNKNOWN) { return 3; } /* load the IDL files specified in the binding */ res = genbind_load_idl(genbind_root, &webidl_root); if (res != 0) { return 4; } /* debug dump of web idl AST */ webidl_dump_ast(webidl_root); /* generate intermediate representation */ res = ir_new(genbind_root, webidl_root, &ir); if (res != 0) { return 5; } /* dump the intermediate representation */ ir_dump(ir); ir_dumpdot(ir); /* generate binding */ switch (bindingtype) { case BINDINGTYPE_DUK_LIBDOM: res = duk_libdom_output(ir); break; default: fprintf(stderr, "Unable to generate binding of this type\n"); res = 7; } return res; }