33static struct options* process_cmdline(
int argc,
char **argv)
39 fprintf(stderr,
"Allocation error\n");
43 while ((opt = getopt(argc, argv,
"vngDW::I:")) != -1) {
66 if ((optarg == NULL) ||
67 (strcmp(optarg,
"all") == 0)) {
70 }
else if (strcmp(optarg,
"unimplemented") == 0) {
72 }
else if (strcmp(optarg,
"duplicated") == 0) {
74 }
else if (strcmp(optarg,
"generated") == 0) {
78 "Unknown warning option \"%s\" valid options are: all, unimplemented,\n"
79 " duplicated, generated\n",
89 "Usage: %s [-v] [-g] [-D] [-W] [-I idlpath] inputfile outputdir\n",
96 if (optind > (argc - 2)) {
98 "Error: expected input filename and output directory\n");
111static int webidl_file_cb(
struct genbind_node *node,
void *ctx)
119 printf(
"Opening IDL file \"%s\"\n",
filename);
125static int genbind_load_idl(
struct genbind_node *genbind,
141 fprintf(stderr,
"Error: failed reading Web IDL\n");
148 fprintf(stderr,
"Error: Failed to intercalate implements\n");
161 const char *binding_type;
166 if (binding_node == NULL) {
176 if (binding_type == NULL) {
177 fprintf(stderr,
"Error: missing binding type\n");
181 if (strcmp(binding_type,
"jsapi_libdom") == 0) {
185 if (strcmp(binding_type,
"duk_libdom") == 0) {
189 fprintf(stderr,
"Error: unsupported binding type \"%s\"\n", binding_type);
199 struct ir *
ir = NULL;
202 options = process_cmdline(argc, argv);
210 fprintf(stderr,
"Error: parse failed with code %d\n", res);
218 bindingtype = genbind_get_type(genbind_root);
224 res = genbind_load_idl(genbind_root, &webidl_root);
233 res =
ir_new(genbind_root, webidl_root, &
ir);
243 switch (bindingtype) {
249 fprintf(stderr,
"Unable to generate binding of this type\n");
int duk_libdom_output(struct ir *ir)
int ir_new(struct genbind_node *genbind, struct webidl_node *webidl, struct ir **map_out)
int ir_dump(struct ir *ir)
int ir_dumpdot(struct ir *index)
int genbind_parsefile(char *infilename, struct genbind_node **ast)
struct genbind_node * genbind_node_find_type(struct genbind_node *node, struct genbind_node *prev, enum genbind_node_type type)
int genbind_dump_ast(struct genbind_node *node)
struct genbind_node * genbind_node_getnode(struct genbind_node *node)
char * genbind_node_gettext(struct genbind_node *node)
int genbind_node_foreach_type(struct genbind_node *node, enum genbind_node_type type, genbind_callback_t *cb, void *ctx)
@ GENBIND_NODE_TYPE_BINDING
@ GENBIND_NODE_TYPE_WEBIDL
@ BINDINGTYPE_JSAPI_LIBDOM
int main(int argc, char **argv)
struct genbind_node * node
struct webidl_node * node
int webidl_intercalate_implements(struct webidl_node *webidl_ast)
int webidl_dump_ast(struct webidl_node *node)
int webidl_parsefile(char *filename, struct webidl_node **webidl_ast)