24enumerate_interface_type(
struct webidl_node *interface_node,
34 while (members_node != NULL) {
52compute_inherit_refcount(
struct ir_entry *entries,
int entryc)
57 for (idx = 0; idx < entryc; idx++ ) {
59 for (inf = 0; inf < entryc; inf++ ) {
62 (entries[idx].inherit_name != NULL ) &&
63 (strcmp(entries[idx].inherit_name,
64 entries[inf].name) == 0)) {
85entry_topoligical_sort(
struct ir_entry *srcinf,
int infc)
91 dstinf = calloc(infc,
sizeof(
struct ir_entry));
96 for (idx = infc - 1; idx >= 0; idx--) {
99 while ((inf < infc) &&
100 ((srcinf[inf].
name == NULL) ||
110 dstinf[idx].
name = srcinf[inf].
name;
111 dstinf[idx].
node = srcinf[inf].
node;
114 dstinf[idx].
type = srcinf[inf].
type;
115 dstinf[idx].
u = srcinf[inf].
u;
123 srcinf[inf].
name = NULL;
137 for (opc = 0; opc < operationc; opc++) {
138 cure = operationv + opc;
144 if ((cure->
name != NULL) &&
168 if (argumentc == 0) {
170 *argumentv_out = NULL;
174 argumentv = calloc(argumentc,
sizeof(*argumentv));
182 while (argument != NULL) {
190 cure->
node = argument;
208 *argumentc_out = argumentc;
209 *argumentv_out = argumentv;
226 int overloadc = *overloadc_out;
234 overloadv = realloc(*overloadv_out, overloadc *
sizeof(*overloadv));
235 if (overloadv == NULL) {
240 cure = overloadv + (overloadc - 1);
243 cure = memset(cure, 0,
sizeof(*cure));
253 if (arg_list_node != NULL) {
254 argument_map_new(arg_list_node,
259 for (argc = 0; argc < cure->argumentc; argc++) {
261 arge = cure->argumentv + argc;
267 *overloadc_out = overloadc;
268 *overloadv_out = overloadv;
286 operationc = enumerate_interface_type(interface,
289 if (operationc < 1) {
292 *operationv_out = NULL;
296 operationv = calloc(operationc,
298 if (operationv == NULL) {
309 while (list_node != NULL) {
316 while (op_node != NULL) {
317 const char *operation_name;
329 finde = find_operation_name(operationv,
335 cure->
name = operation_name;
337 cure->
node = op_node;
345 overload_map_new(op_node,
351 overload_map_new(op_node,
374 *operationc_out = operationc;
375 *operationv_out = operationv;
395 while (ext_attr != NULL) {
403 if ((ident != NULL) && (strcmp(ident, key) == 0)) {
412 if ((ident != NULL) && (*ident ==
'=')) {
453 typev = calloc(typec,
sizeof(*typev));
460 while (type_node != NULL) {
530 attributec = enumerate_interface_type(interface,
532 *attributec_out = attributec;
534 if (attributec < 1) {
535 *attributev_out = NULL;
540 if (attributev == NULL) {
551 while (list_node != NULL) {
558 while (at_node != NULL) {
563 cure->
node = at_node;
578 type_map_new(at_node, &cure->
typec, &cure->
typev);
606 "putforwards on a writable attribute (%s) is prohibited",
629 *attributev_out = attributev;
646 constantc = enumerate_interface_type(interface,
651 *constantv_out = NULL;
655 *constantc_out = constantc;
657 constantv = calloc(constantc,
659 if (constantv == NULL) {
670 while (list_node != NULL) {
677 while (constant_node != NULL) {
678 cure->
node = constant_node;
701 *constantv_out = constantv;
719 memberc = enumerate_interface_type(dictionary,
729 if (memberv == NULL) {
740 while (list_node != NULL) {
747 while (member_node != NULL) {
748 cure->
node = member_node;
779 *memberc_out = memberc;
780 *memberv_out = memberv;
805 printf(
"Mapping %d interfaces\n", interfacec);
806 printf(
"Mapping %d dictionaries\n", dictionaryc);
809 entryc = interfacec + dictionaryc;
811 entries = calloc(entryc,
sizeof(
struct ir_entry));
812 if (entries == NULL) {
821 while (
node != NULL) {
854 "NoInterfaceObject") != NULL) {
866 "PrimaryGlobal") != NULL) {
875 operation_map_new(
node,
881 attribute_map_new(
node,
887 constant_map_new(
node,
902 while (
node != NULL) {
944 compute_inherit_refcount(entries, entryc);
947 sorted_entries = entry_topoligical_sort(entries, entryc);
949 if (sorted_entries == NULL) {
954 compute_inherit_refcount(sorted_entries, entryc);
956 *interfacec_out = entryc;
957 *interfacev_out = sorted_entries;
980 ret = entry_map_new(genbind,
994static int ir_dump_dictionary(FILE *dumpf,
struct ir_entry *ecur)
1006 fprintf(dumpf,
"\t\t%s\n", arge->
name);
1010 "\t\t\toptional:%d\n",
1016 "\t\t\telipsis:%d\n",
1024static int ir_dump_interface(FILE *dumpf,
struct ir_entry *ecur)
1029 fprintf(dumpf,
"\t%d operations\n",
1042 "\t\t\tmethod:%p\n",
1044 for(ovlc = 0; ovlc < ope->
overloadc;ovlc++) {
1050 "\t\t\toverload:%d\n", ovlc);
1053 "\t\t\t\treturn type:%p\n",
1057 "\t\t\t\targuments:%d\n",
1061 "\t\t\t\toptionals:%d\n",
1065 "\t\t\t\telipsis:%d\n",
1068 for (argc = 0; argc < ovle->
argumentc; argc++) {
1078 "\t\t\t\t\t\toptional:%d\n",
1084 "\t\t\t\t\t\telipsis:%d\n",
1097 fprintf(dumpf,
"\t%d attributes\n", attrc);
1100 while (attre != NULL) {
1101 fprintf(dumpf,
"\t\t%s %p",
1105 fprintf(dumpf,
" %p\n", attre->
setter);
1107 fprintf(dumpf,
"\n");
1119 fprintf(dumpf,
"\t%d constants\n",
1125 fprintf(dumpf,
"\t\t%s\n", cone->
name);
1143 if (dumpf == NULL) {
1148 for (eidx = 0; eidx <
ir->
entryc; eidx++) {
1149 fprintf(dumpf,
"%d %s\n", eidx, ecur->
name);
1153 if (ecur->
class != NULL) {
1154 fprintf(dumpf,
"\tclass:%p\n", ecur->
class);
1157 switch (ecur->
type) {
1159 ir_dump_interface(dumpf, ecur);
1163 ir_dump_dictionary(dumpf, ecur);
1187 if (dumpf == NULL) {
1191 fprintf(dumpf,
"digraph interfaces {\n");
1193 fprintf(dumpf,
"node [shape=box]\n");
1196 for (eidx = 0; eidx < index->
entryc; eidx++) {
1197 fprintf(dumpf,
"%04d [label=\"%s\"", eidx, ecur->
name);
1201 fprintf(dumpf,
"fontcolor=\"red\"");
1202 }
else if (ecur->
class != NULL) {
1204 fprintf(dumpf,
"fontcolor=\"blue\"");
1207 fprintf(dumpf,
"];\n");
1212 for (eidx = 0; eidx < index->
entryc; eidx++) {
1214 fprintf(dumpf,
"%04d -> %04d;\n",
1219 fprintf(dumpf,
"}\n");
1232 if ((entry != NULL) &&
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)
struct ir_entry * ir_inherit_entry(struct ir *map, struct ir_entry *entry)
@ IR_ENTRY_TYPE_DICTIONARY
@ IR_ENTRY_TYPE_INTERFACE
struct genbind_node * genbind_node_find_type(struct genbind_node *node, struct genbind_node *prev, enum genbind_node_type type)
struct genbind_node * genbind_node_find_method_ident(struct genbind_node *node, struct genbind_node *prev, enum genbind_method_type nodetype, const char *ident)
struct genbind_node * genbind_node_find_type_ident(struct genbind_node *node, struct genbind_node *prev, enum genbind_node_type type, const char *ident)
@ GENBIND_METHOD_TYPE_METHOD
@ GENBIND_METHOD_TYPE_SETTER
@ GENBIND_METHOD_TYPE_GETTER
@ GENBIND_NODE_TYPE_BINDING
@ GENBIND_NODE_TYPE_CLASS
#define WARN(flags, msg, args...)
enum webidl_type_modifier modifier
struct ir_type_entry * typev
struct genbind_node * setter
struct webidl_node * node
struct genbind_node * getter
struct webidl_node * node
struct ir_operation_argument_entry * memberv
struct webidl_node * node
struct ir_dictionary_entry dictionary
struct genbind_node * class
struct ir_interface_entry interface
const char * inherit_name
struct ir_attribute_entry * attributev
struct ir_operation_entry * operationv
struct ir_constant_entry * constantv
struct webidl_node * node
struct ir_operation_overload_entry * overloadv
struct webidl_node * node
struct genbind_node * method
struct webidl_node * type
struct ir_operation_argument_entry * argumentv
enum webidl_type_modifier modifier
struct genbind_node * binding_node
struct webidl_node * webidl
struct ir_entry * entries
struct webidl_node * node
FILE * genb_fopen(const char *fname, const char *mode)
struct webidl_node * webidl_node_getnode(struct webidl_node *node)
int webidl_node_enumerate_type(struct webidl_node *node, enum webidl_node_type type)
struct webidl_node * webidl_node_find_type_ident(struct webidl_node *root_node, enum webidl_node_type type, const char *ident)
char * webidl_node_gettext(struct webidl_node *node)
int * webidl_node_getint(struct webidl_node *node)
struct webidl_node * webidl_node_find_type(struct webidl_node *node, struct webidl_node *prev, enum webidl_node_type type)
@ WEBIDL_NODE_TYPE_DICTIONARY
@ WEBIDL_NODE_TYPE_TYPE_BASE
@ WEBIDL_NODE_TYPE_OPERATION
@ WEBIDL_NODE_TYPE_INTERFACE
@ WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE
@ WEBIDL_NODE_TYPE_TYPE_NULLABLE
@ WEBIDL_NODE_TYPE_INHERITANCE
@ WEBIDL_NODE_TYPE_ATTRIBUTE
@ WEBIDL_NODE_TYPE_MODIFIER
@ WEBIDL_NODE_TYPE_OPTIONAL
@ WEBIDL_NODE_TYPE_ARGUMENT
@ WEBIDL_NODE_TYPE_ELLIPSIS
@ WEBIDL_TYPE_MODIFIER_NONE
@ WEBIDL_TYPE_MODIFIER_READONLY