From cb2089531d4165786772c5cef17d28dc1a8e28d6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 31 Jul 2015 22:32:12 +0100 Subject: ensure nothing is generated for interfaces marked with NoInterfaceObject --- src/duk-libdom.c | 26 +++++++++++++++++++++++++- src/interface-map.c | 34 +++++++++++++++++++++++++--------- src/interface-map.h | 17 +++++++++++------ 3 files changed, 61 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/duk-libdom.c b/src/duk-libdom.c index 49f100a..590afa2 100644 --- a/src/duk-libdom.c +++ b/src/duk-libdom.c @@ -1002,7 +1002,12 @@ static int output_interface(struct interface_map *interface_map, struct interface_map_entry *inherite; int res = 0; - /* compute clas name */ + /* do not generate class for interfaces marked no output */ + if (interfacee->noobject) { + return 0; + } + + /* compute class name */ interfacee->class_name = gen_class_name(interfacee); /* generate source filename */ @@ -1125,6 +1130,13 @@ output_private_header(struct interface_map *interface_map) interfacee = interface_map->entries + idx; + /* do not generate private structs for interfaces marked no + * output + */ + if (interfacee->noobject) { + continue; + } + /* find parent interface entry */ inherite = interface_map_inherit_entry(interface_map, interfacee); @@ -1201,6 +1213,13 @@ output_prototype_header(struct interface_map *interface_map) interfacee = interface_map->entries + idx; + /* do not generate prototype declarations for interfaces marked + * no output + */ + if (interfacee->noobject) { + continue; + } + /* prototype declaration */ fprintf(protof, "duk_ret_t %s_%s___proto(duk_context *ctx);\n", DLPFX, interfacee->class_name); @@ -1255,6 +1274,11 @@ output_makefile(struct interface_map *interface_map) interfacee = interface_map->entries + idx; + /* no source for interfaces marked no output */ + if (interfacee->noobject) { + continue; + } + fprintf(makef, "%s ", interfacee->filename); } fprintf(makef, "\nNSGENBIND_PREFIX:=%s\n", options->outdirname); diff --git a/src/interface-map.c b/src/interface-map.c index 13d6106..467c0ed 100644 --- a/src/interface-map.c +++ b/src/interface-map.c @@ -110,6 +110,7 @@ interface_topoligical_sort(struct interface_map_entry *srcinf, int infc) dstinf[idx].name = srcinf[inf].name; dstinf[idx].node = srcinf[inf].node; dstinf[idx].inherit_name = srcinf[inf].inherit_name; + dstinf[idx].noobject = srcinf[inf].noobject; dstinf[idx].operationc = srcinf[inf].operationc; dstinf[idx].operationv = srcinf[inf].operationv; dstinf[idx].attributec = srcinf[inf].attributec; @@ -391,7 +392,7 @@ int interface_map_new(struct genbind_node *genbind, WEBIDL_NODE_TYPE_INTERFACE); if (options->verbose) { - printf("Maping %d interfaces\n", interfacec); + printf("Mapping %d interfaces\n", interfacec); } entries = calloc(interfacec, sizeof(struct interface_map_entry)); @@ -421,6 +422,17 @@ int interface_map_new(struct genbind_node *genbind, NULL, WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE)); + if (webidl_node_find_type_ident( + webidl_node_getnode(node), + WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, + "NoInterfaceObject") != NULL) { + /** \todo we should ensure inherit is unset as this + * cannot form part of an inheritance chain if it is + * not generating an output class + */ + ecur->noobject = true; + } + /* matching class from binding */ ecur->class = genbind_node_find_type_ident(genbind, NULL, GENBIND_NODE_TYPE_CLASS, ecur->name); @@ -579,16 +591,20 @@ int interface_map_dumpdot(struct interface_map *index) fprintf(dumpf, "digraph interfaces {\n"); + fprintf(dumpf, "node [shape=box]\n"); + ecur = index->entries; for (eidx = 0; eidx < index->entryc; eidx++) { - if (ecur->class != NULL) { - /* interfaces bound to a class are shown in blue */ - fprintf(dumpf, "%04d [label=\"%s\" fontcolor=\"blue\"];\n", - eidx, ecur->name); - } else { - fprintf(dumpf, "%04d [label=\"%s\"];\n", eidx, ecur->name); - } - ecur++; + fprintf(dumpf, "%04d [label=\"%s\"", eidx, ecur->name); + if (ecur->noobject == true) { + /* noobject interfaces in red */ + fprintf(dumpf, "fontcolor=\"red\""); + } else if (ecur->class != NULL) { + /* interfaces bound to a class are shown in blue */ + fprintf(dumpf, "fontcolor=\"blue\""); + } + fprintf(dumpf, "];\n"); + ecur++; } ecur = index->entries; diff --git a/src/interface-map.h b/src/interface-map.h index e44380a..e07aa19 100644 --- a/src/interface-map.h +++ b/src/interface-map.h @@ -39,6 +39,16 @@ struct interface_map_entry { const char *name; /** interface name */ struct webidl_node *node; /**< AST interface node */ const char *inherit_name; /**< Name of interface inhertited from */ + int inherit_idx; /**< index into map of inherited interface or -1 for + * not in map + */ + int refcount; /**< number of interfacess in map that refer to this + * interface + */ + bool noobject; /**< flag indicating if no interface object should eb + * generated. This allows for interfaces which do not + * generate code. For implements (mixin) interfaces + */ int operationc; /**< number of operations on interface */ struct interface_map_operation_entry *operationv; @@ -49,12 +59,7 @@ struct interface_map_entry { int constantc; /**< number of constants on interface */ struct interface_map_constant_entry *constantv; - int inherit_idx; /**< index into map of inherited interface or -1 for - * not in map - */ - int refcount; /**< number of interfacess in map that refer to this - * interface - */ + struct genbind_node *class; /**< class from binding (if any) */ /* The variables are created and used by the output generation but -- cgit v1.2.3