summaryrefslogtreecommitdiff
path: root/src/jsapi-libdom.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-01-03 02:07:11 +0000
committerVincent Sanders <vince@kyllikki.org>2014-05-16 14:38:56 +0100
commit26e5be085e5c7a17cea4af7cb9e13502ffb0ebd1 (patch)
treebcf6bd9e83cdf03c851d3878c1141b0f2337ea60 /src/jsapi-libdom.c
parent202be5081e4b201a3937407b2aff3328139ef1a3 (diff)
downloadnsgenbind-26e5be085e5c7a17cea4af7cb9e13502ffb0ebd1.tar.gz
nsgenbind-26e5be085e5c7a17cea4af7cb9e13502ffb0ebd1.tar.bz2
complete implementation of interface map generation and split out to own module
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r--src/jsapi-libdom.c162
1 files changed, 0 insertions, 162 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 547e66e..f011342 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -820,168 +820,6 @@ binding_has_private(struct genbind_node *binding_list)
}
-/** count the number of methods or properties for an interface */
-static int
-enumerate_interface_own(struct webidl_node *interface_node,
- enum webidl_node_type node_type)
-{
- int count = 0;
- struct webidl_node *members_node;
-
- members_node = webidl_node_find_type(
- webidl_node_getnode(interface_node),
- NULL,
- WEBIDL_NODE_TYPE_LIST);
- while (members_node != NULL) {
- count += webidl_node_enumerate_type(
- webidl_node_getnode(members_node),
- node_type);
-
- members_node = webidl_node_find_type(
- webidl_node_getnode(interface_node),
- members_node,
- WEBIDL_NODE_TYPE_LIST);
- }
-
- return count;
-}
-
-/* build interface map and return the first interface */
-static struct genbind_node *
-build_interface_map(struct genbind_node *binding_node,
- struct webidl_node *webidl_ast,
- int *interfacec_out,
- struct binding_interface **interfaces_out)
-{
- int interfacec;
- int idx;
- struct binding_interface *interfaces;
- struct genbind_node *node = NULL;
-
- /* count number of interfaces listed in binding */
- interfacec = genbind_node_enumerate_type(
- genbind_node_getnode(binding_node),
- GENBIND_NODE_TYPE_BINDING_INTERFACE);
-
- if (interfacec == 0) {
- return NULL;
- }
- if (options->verbose) {
- printf("Binding has %d interfaces\n", interfacec);
- }
-
- interfaces = malloc(interfacec * sizeof(struct binding_interface));
- if (interfaces == NULL) {
- return NULL;
- }
-
- /* fill in map with node data */
- for (idx = 0; idx < interfacec; idx++ ) {
- node = genbind_node_find_type(
- genbind_node_getnode(binding_node),
- node,
- GENBIND_NODE_TYPE_BINDING_INTERFACE);
- if (node == NULL) {
- free(interfaces);
- return NULL;
- }
-
- interfaces[idx].node = node;
-
- /* get interface name */
- interfaces[idx].name = genbind_node_gettext(
- genbind_node_find_type(genbind_node_getnode(node),
- NULL,
- GENBIND_NODE_TYPE_IDENT));
- if (interfaces[idx].name == NULL) {
- free(interfaces);
- return NULL;
- }
-
- /* get web IDL node for interface */
- interfaces[idx].widl_node = webidl_node_find_type_ident(
- webidl_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interfaces[idx].name);
- if (interfaces[idx].widl_node == NULL) {
- free(interfaces);
- return NULL;
- }
-
- /* enumerate the number of functions */
- interfaces[idx].own_functions = enumerate_interface_own(
- interfaces[idx].widl_node,
- WEBIDL_NODE_TYPE_OPERATION);
-
- /* enumerate the number of properties */
- interfaces[idx].own_properties = enumerate_interface_own(
- interfaces[idx].widl_node,
- WEBIDL_NODE_TYPE_ATTRIBUTE);
-
- /* extract the name of the inherited interface (if any) */
- interfaces[idx].inherit_name = webidl_node_gettext(
- webidl_node_find_type(
- webidl_node_getnode(interfaces[idx].widl_node),
- NULL,
- WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE));
-
- interfaces[idx].refcount = 0;
- }
-
- /* find index of inherited node if it is one of those listed
- * in the binding also maintain refcounts
- */
- for (idx = 0; idx < interfacec; idx++ ) {
- int inf;
- interfaces[idx].inherit_idx = -1;
- for (inf = 0; inf < interfacec; inf++ ) {
- /* cannot inherit from self and name must match */
- if ((inf != idx) &&
- (strcmp(interfaces[idx].inherit_name,
- interfaces[inf].name) == 0)) {
- interfaces[idx].inherit_idx = inf;
- interfaces[inf].refcount++;
- break;
- }
- }
- }
-
- /** @todo There should be a topoligical sort based on the refcount
- *
- * do not need to consider loops as constructed graph is a acyclic
- *
- * alloc a second copy of the map
- * repeat until all entries copied:
- * walk source mapping until first entry with zero refcount
- * put the entry at the end of the output map
- * reduce refcount on inherit index if !=-1
- * remove entry from source map
- */
-
- /* show the interface map */
- if (options->verbose) {
- for (idx = 0; idx < interfacec; idx++ ) {
- printf("interface num:%d\n"
- " name:%s node:%p widl:%p\n"
- " inherit:%s inherit idx:%d refcount:%d\n"
- " own functions:%d own properties:%d\n",
- idx,
- interfaces[idx].name,
- interfaces[idx].node,
- interfaces[idx].widl_node,
- interfaces[idx].inherit_name,
- interfaces[idx].inherit_idx,
- interfaces[idx].refcount,
- interfaces[idx].own_functions,
- interfaces[idx].own_properties);
- }
- }
-
- *interfacec_out = interfacec;
- *interfaces_out = interfaces;
-
- return interfaces[0].node;
-}
static struct binding *
binding_new(struct options *options,