ReactOS 0.4.16-dev-1946-g52006dd
typetree.c
Go to the documentation of this file.
1/*
2 * IDL Type Tree
3 *
4 * Copyright 2008 Robert Shearman
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "config.h"
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#ifdef __REACTOS__
27#include <stddef.h>
28#endif
29
30#include "widl.h"
31#include "utils.h"
32#include "parser.h"
33#include "typetree.h"
34#include "header.h"
35#include "hash.h"
36
37type_t *duptype(type_t *t, int dupname)
38{
39 type_t *d = alloc_type();
40
41 *d = *t;
42 if (dupname && t->name)
43 d->name = xstrdup(t->name);
44
45 return d;
46}
47
49{
50 type_t *t = alloc_type();
51 t->name = NULL;
52 t->namespace = NULL;
53 t->type_type = type;
54 t->attrs = NULL;
55 t->c_name = NULL;
56 t->signature = NULL;
57 t->qualified_name = NULL;
58 t->impl_name = NULL;
59 t->param_name = NULL;
60 t->short_name = NULL;
61 memset(&t->details, 0, sizeof(t->details));
62 t->typestring_offset = 0;
63 t->ptrdesc = 0;
64 t->ignore = (parse_only != 0);
65 t->defined = FALSE;
66 t->written = FALSE;
67 t->user_types_registered = FALSE;
68 t->tfswrite = FALSE;
69 t->checked = FALSE;
70 t->typelib_idx = -1;
71 init_location( &t->where, NULL, NULL );
72 return t;
73}
74
75static const var_t *find_arg(const var_list_t *args, const char *name)
76{
77 const var_t *arg;
78
80 {
81 if (arg->name && !strcmp(name, arg->name))
82 return arg;
83 }
84
85 return NULL;
86}
87
89{
90 switch(name_type) {
91 case NAME_DEFAULT:
92 return type->name;
93 case NAME_C:
94 return type->c_name ? type->c_name : type->name;
95 }
96
97 assert(0);
98 return NULL;
99}
100
101const char *type_get_name(const type_t *type, enum name_type name_type)
102{
103 switch(name_type) {
104 case NAME_DEFAULT:
105 return type->qualified_name ? type->qualified_name : type->name;
106 case NAME_C:
107 return type->c_name ? type->c_name : type->name;
108 }
109
110 assert(0);
111 return NULL;
112}
113
114static size_t append_namespace(char **buf, size_t *len, size_t pos, struct namespace *namespace, const char *separator, const char *abi_prefix)
115{
116 int nested = namespace && !is_global_namespace(namespace);
117 const char *name = nested ? namespace->name : abi_prefix;
118 size_t n = 0;
119 if (!name) return 0;
120 if (nested) n += append_namespace(buf, len, pos + n, namespace->parent, separator, abi_prefix);
121 n += strappend(buf, len, pos + n, "%s%s", name, separator);
122 return n;
123}
124
125static size_t append_namespaces(char **buf, size_t *len, size_t pos, struct namespace *namespace, const char *prefix,
126 const char *separator, const char *suffix, const char *abi_prefix)
127{
128 int nested = namespace && !is_global_namespace(namespace);
129 size_t n = 0;
130 n += strappend(buf, len, pos + n, "%s", prefix);
131 if (nested) n += append_namespace(buf, len, pos + n, namespace, separator, abi_prefix);
132 if (suffix) n += strappend(buf, len, pos + n, "%s", suffix);
133 else if (nested)
134 {
135 n -= strlen(separator);
136 (*buf)[n] = 0;
137 }
138 return n;
139}
140
141static size_t append_pointer_stars(char **buf, size_t *len, size_t pos, type_t *type)
142{
143 size_t n = 0;
144 for (; type && type->type_type == TYPE_POINTER; type = type_pointer_get_ref_type(type)) n += strappend(buf, len, pos + n, "*");
145 return n;
146}
147
148static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t *type);
149
150static size_t append_var_list_signature(char **buf, size_t *len, size_t pos, var_list_t *var_list)
151{
152 var_t *var;
153 size_t n = 0;
154
155 if (!var_list) n += strappend(buf, len, pos + n, ";");
156 else LIST_FOR_EACH_ENTRY(var, var_list, var_t, entry)
157 {
158 n += strappend(buf, len, pos + n, ";");
159 n += append_type_signature(buf, len, pos + n, var->declspec.type);
160 }
161
162 return n;
163}
164
165static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t *type)
166{
167 const struct uuid *uuid;
168 size_t n = 0;
169
170 if (!type) return 0;
171 switch (type->type_type)
172 {
173 case TYPE_INTERFACE:
174 if (!strcmp(type->name, "IInspectable")) n += strappend(buf, len, pos + n, "cinterface(IInspectable)");
175 else if (type->signature) n += strappend(buf, len, pos + n, "%s", type->signature);
176 else
177 {
178 if (!(uuid = get_attrp( type->attrs, ATTR_UUID )))
179 error_at( &type->where, "cannot compute type signature, no uuid found for type %s.\n", type->name );
180
181 n += strappend(buf, len, pos + n, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
183 uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3],
184 uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
185 }
186 return n;
187 case TYPE_DELEGATE:
188 n += strappend(buf, len, pos + n, "delegate(");
190 n += strappend(buf, len, pos + n, ")");
191 return n;
193 n += strappend(buf, len, pos + n, "rc(");
194 n += append_namespaces(buf, len, pos + n, type->namespace, "", ".", type->name, NULL);
195 n += strappend(buf, len, pos + n, ";");
197 n += strappend(buf, len, pos + n, ")");
198 return n;
199 case TYPE_POINTER:
200 n += append_type_signature(buf, len, pos + n, type->details.pointer.ref.type);
201 return n;
202 case TYPE_ALIAS:
203 if (!strcmp(type->name, "boolean")) n += strappend(buf, len, pos + n, "b1");
204 else if (!strcmp(type->name, "GUID")) n += strappend(buf, len, pos + n, "g16");
205 else if (!strcmp(type->name, "HSTRING")) n += strappend(buf, len, pos + n, "string");
206 else n += append_type_signature(buf, len, pos + n, type->details.alias.aliasee.type);
207 return n;
208 case TYPE_STRUCT:
209 n += strappend(buf, len, pos + n, "struct(");
210 n += append_namespaces(buf, len, pos + n, type->namespace, "", ".", type->name, NULL);
211 n += append_var_list_signature(buf, len, pos + n, type->details.structure->fields);
212 n += strappend(buf, len, pos + n, ")");
213 return n;
214 case TYPE_BASIC:
215 switch (type_basic_get_type(type))
216 {
217 case TYPE_BASIC_INT16:
218 n += strappend(buf, len, pos + n, type_basic_get_sign(type) <= 0 ? "i2" : "u2");
219 return n;
220 case TYPE_BASIC_INT:
221 case TYPE_BASIC_INT32:
222 case TYPE_BASIC_LONG:
223 n += strappend(buf, len, pos + n, type_basic_get_sign(type) <= 0 ? "i4" : "u4");
224 return n;
225 case TYPE_BASIC_INT64:
226 n += strappend(buf, len, pos + n, type_basic_get_sign(type) <= 0 ? "i8" : "u8");
227 return n;
228 case TYPE_BASIC_INT8:
229 assert(type_basic_get_sign(type) > 0); /* signature string for signed char isn't specified */
230 n += strappend(buf, len, pos + n, "u1");
231 return n;
232 case TYPE_BASIC_FLOAT:
233 n += strappend(buf, len, pos + n, "f4");
234 return n;
236 n += strappend(buf, len, pos + n, "f8");
237 return n;
238 case TYPE_BASIC_BYTE:
239 n += strappend(buf, len, pos + n, "u1");
240 return n;
242 case TYPE_BASIC_CHAR:
243 case TYPE_BASIC_HYPER:
244 case TYPE_BASIC_WCHAR:
247 error_at( &type->where, "unimplemented type signature for basic type %d.\n",
249 break;
250 }
251 case TYPE_ENUM:
252 n += strappend(buf, len, pos + n, "enum(");
253 n += append_namespaces(buf, len, pos + n, type->namespace, "", ".", type->name, NULL);
254 if (is_attr(type->attrs, ATTR_FLAGS)) n += strappend(buf, len, pos + n, ";u4");
255 else n += strappend(buf, len, pos + n, ";i4");
256 n += strappend(buf, len, pos + n, ")");
257 return n;
258 case TYPE_ARRAY:
260 case TYPE_UNION:
261 case TYPE_COCLASS:
262 case TYPE_VOID:
263 case TYPE_FUNCTION:
264 case TYPE_BITFIELD:
265 case TYPE_MODULE:
266 case TYPE_APICONTRACT:
267 error_at( &type->where, "unimplemented type signature for type %s of type %d.\n",
268 type->name, type->type_type );
269 break;
271 case TYPE_PARAMETER:
272 assert(0); /* should not be there */
273 break;
274 }
275
276 return n;
277}
278
279char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, const char *abi_prefix)
280{
281 size_t len = 0;
282 char *buf = NULL;
283 append_namespaces(&buf, &len, 0, namespace, prefix, separator, suffix, abi_prefix);
284 return buf;
285}
286
288{
289 size_t len = 0, pos = 0;
290 char *buf = NULL;
291 typeref_t *ref;
292
293 pos += strappend(&buf, &len, pos, "%s<", type->name);
295 {
297 pos += strappend(&buf, &len, pos, "%s", type->qualified_name);
298 pos += append_pointer_stars(&buf, &len, pos, ref->type);
299 if (list_next(params, &ref->entry)) pos += strappend(&buf, &len, pos, ",");
300 }
301 pos += strappend(&buf, &len, pos, " >");
302
303 return buf;
304}
305
306static char const *parameterized_type_shorthands[][2] = {
307 {"Windows__CFoundation__CCollections__C", "__F"},
308 {"Windows_CFoundation_CCollections_C", "__F"},
309 {"Windows__CFoundation__C", "__F"},
310 {"Windows_CFoundation_C", "__F"},
311};
312
314{
315 const char *tmp, *ns_prefix = "__x_", *abi_prefix = NULL;
316 size_t len = 0, pos = 0;
317 char *buf = NULL;
318 int i, count = params ? list_count(params) : 0;
319 typeref_t *ref;
320
321 if (!strcmp(separator, "__C")) ns_prefix = "_C";
322 else if (use_abi_namespace) abi_prefix = "ABI";
323
324 pos += append_namespaces(&buf, &len, pos, type->namespace, ns_prefix, separator, "", abi_prefix);
325 pos += strappend(&buf, &len, pos, "%s%s_%d", prefix, type->name, count);
327 {
329 if ((tmp = type->param_name)) pos += strappend(&buf, &len, pos, "_%s", tmp);
330 else pos += append_namespaces(&buf, &len, pos, type->namespace, "_", "__C", type->name, NULL);
331 }
332
334 {
335 if ((tmp = strstr(buf, parameterized_type_shorthands[i][0])) &&
336 (tmp - buf) == strlen(ns_prefix) + (abi_prefix ? 5 : 0))
337 {
340 memmove(buf + 3, tmp, len - (tmp - buf));
341 }
342 }
343
344 return buf;
345}
346
348{
349 size_t len = 0, pos = 0;
350 char *buf = NULL;
351 typeref_t *ref;
352 const struct uuid *uuid;
353
354 if (!(uuid = get_attrp( type->attrs, ATTR_UUID )))
355 error_at( &type->where, "cannot compute type signature, no uuid found for type %s.\n", type->name );
356
357 pos += strappend(&buf, &len, pos, "pinterface({%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
359 uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3],
360 uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
362 {
363 pos += strappend(&buf, &len, pos, ";");
364 pos += append_type_signature(&buf, &len, pos, ref->type);
365 }
366 pos += strappend(&buf, &len, pos, ")");
367
368 return buf;
369}
370
372{
373 size_t len = 0, pos = 0;
374 char *buf = NULL;
375 typeref_t *ref;
376
377 pos += strappend(&buf, &len, pos, "%s%s", prefix, type->name);
379 {
381 if (type->short_name) pos += strappend(&buf, &len, pos, "_%s", type->short_name);
382 else pos += strappend(&buf, &len, pos, "_%s", type->name);
383 }
384
385 return buf;
386}
387
389{
390 size_t len = 0, pos = 0;
391 char *buf = NULL;
392 typeref_t *ref;
393 type_t *iface;
394
395 pos += strappend(&buf, &len, pos, "%s%s_impl<", prefix, type->name);
397 {
399 if (type->type_type == TYPE_RUNTIMECLASS)
400 {
401 pos += strappend(&buf, &len, pos, "ABI::Windows::Foundation::Internal::AggregateType<%s", type->qualified_name);
402 pos += append_pointer_stars(&buf, &len, pos, ref->type);
404 pos += strappend(&buf, &len, pos, ", %s", iface->qualified_name);
405 pos += append_pointer_stars(&buf, &len, pos, ref->type);
406 pos += strappend(&buf, &len, pos, " >");
407 }
408 else
409 {
410 pos += strappend(&buf, &len, pos, "%s", type->qualified_name);
411 pos += append_pointer_stars(&buf, &len, pos, ref->type);
412 }
413 if (list_next(params, &ref->entry)) pos += strappend(&buf, &len, pos, ", ");
414 }
415 pos += strappend(&buf, &len, pos, " >");
416
417 return buf;
418}
419
421{
422 var_t *arg;
423 type_t *t;
424 unsigned int i = 0;
425
426 if (args)
427 {
429 if (list_count(args) == 1 && !arg->name && arg->declspec.type && type_get_type(arg->declspec.type) == TYPE_VOID)
430 {
431 list_remove(&arg->entry);
432 free(arg);
433 free(args);
434 args = NULL;
435 }
436 }
438 {
439 if (arg->declspec.type && type_get_type(arg->declspec.type) == TYPE_VOID)
440 error_loc("argument '%s' has void type\n", arg->name);
441 if (!arg->name)
442 {
443 if (i > 26 * 26)
444 error_loc("too many unnamed arguments\n");
445 else
446 {
447 int unique;
448 do
449 {
450 char name[3];
451 name[0] = i > 26 ? 'a' + i / 26 : 'a' + i;
452 name[1] = i > 26 ? 'a' + i % 26 : 0;
453 name[2] = 0;
455 if (unique)
456 arg->name = xstrdup(name);
457 i++;
458 } while (!unique);
459 }
460 }
461 }
462
464 t->details.function = xmalloc(sizeof(*t->details.function));
465 t->details.function->args = args;
466 t->details.function->retval = make_var(xstrdup("_RetVal"));
467 return t;
468}
469
471{
473 t->details.pointer.ref.type = ref;
474 return t;
475}
476
478{
480
481 a->name = xstrdup(name);
482 a->attrs = NULL;
483 a->details.alias.aliasee = *t;
484 init_location( &a->where, NULL, NULL );
485
486 return a;
487}
488
489type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr,
490 unsigned int dim, expr_t *size_is, expr_t *length_is)
491{
493 if (name) t->name = xstrdup(name);
494 t->details.array.declptr = declptr;
495 t->details.array.length_is = length_is;
496 if (size_is)
497 t->details.array.size_is = size_is;
498 else
499 t->details.array.dim = dim;
500 if (element)
501 t->details.array.elem = *element;
502 return t;
503}
504
506{
508 t->details.basic.type = basic_type;
509 t->details.basic.sign = 0;
510 return t;
511}
512
514{
515 static type_t *int_types[TYPE_BASIC_INT_MAX+1][3];
516
517 assert(basic_type <= TYPE_BASIC_INT_MAX);
518
519 /* map sign { -1, 0, 1 } -> { 0, 1, 2 } */
520 if (!int_types[basic_type][sign + 1])
521 {
522 int_types[basic_type][sign + 1] = type_new_basic(basic_type);
523 int_types[basic_type][sign + 1]->details.basic.sign = sign;
524 }
525 return int_types[basic_type][sign + 1];
526}
527
529{
530 static type_t *void_type = NULL;
531 if (!void_type)
532 void_type = make_type(TYPE_VOID);
533 return void_type;
534}
535
536static void define_type(type_t *type, const struct location *where)
537{
538 if (type->defined)
539 error_loc("type %s already defined at %s:%d\n", type->name, type->where.input_name, type->where.first_line );
540
541 type->defined = TRUE;
542 type->defined_in_import = parse_only;
543 type->where = *where;
544}
545
546type_t *type_new_enum(const char *name, struct namespace *namespace,
547 int defined, var_list_t *enums, const struct location *where)
548{
549 type_t *t = NULL;
550
551 if (name)
552 t = find_type(name, namespace,tsENUM);
553
554 if (!t)
555 {
557 t->name = name;
558 t->namespace = namespace;
559 if (name)
560 reg_type(t, name, namespace, tsENUM);
561 }
562
563 if (defined)
564 {
565 t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
566 t->details.enumeration->enums = enums;
567 define_type(t, where);
568 }
569
570 return t;
571}
572
573type_t *type_new_struct(char *name, struct namespace *namespace,
574 int defined, var_list_t *fields, const struct location *where)
575{
576 type_t *t = NULL;
577
578 if (name)
579 t = find_type(name, namespace, tsSTRUCT);
580
581 if (!t)
582 {
584 t->name = name;
585 t->namespace = namespace;
586 if (name)
587 reg_type(t, name, namespace, tsSTRUCT);
588 }
589
590 if (defined)
591 {
592 t->details.structure = xmalloc(sizeof(*t->details.structure));
593 t->details.structure->fields = fields;
594 define_type(t, where);
595 }
596
597 return t;
598}
599
600type_t *type_new_nonencapsulated_union(const char *name, struct namespace *namespace,
601 int defined, var_list_t *fields, const struct location *where)
602{
603 type_t *t = NULL;
604
605 if (name)
606 t = find_type(name, namespace, tsUNION);
607
608 if (!t)
609 {
611 t->name = name;
612 t->namespace = namespace;
613 if (name)
614 reg_type(t, name, namespace, tsUNION);
615 }
616
617 if (!t->defined && defined)
618 {
619 t->details.structure = xmalloc(sizeof(*t->details.structure));
620 t->details.structure->fields = fields;
621 define_type(t, where);
622 }
623
624 return t;
625}
626
628 var_t *union_field, var_list_t *cases, const struct location *where)
629{
630 type_t *t = NULL;
631
632 if (name)
634
635 if (!t)
636 {
638 t->name = name;
639 if (name)
641 }
642 t->type_type = TYPE_ENCAPSULATED_UNION;
643
644 if (!union_field)
645 union_field = make_var(xstrdup("tagged_union"));
646 union_field->declspec.type = type_new_nonencapsulated_union(gen_name(), NULL, TRUE, cases, where);
647
648 t->details.structure = xmalloc(sizeof(*t->details.structure));
649 t->details.structure->fields = append_var(NULL, switch_field);
650 t->details.structure->fields = append_var(t->details.structure->fields, union_field);
651 define_type(t, where);
652
653 return t;
654}
655
657{
658 switch (type_get_type(type))
659 {
660 case TYPE_ENUM:
661 return TRUE;
662 case TYPE_BASIC:
663 switch (type_basic_get_type(type))
664 {
665 case TYPE_BASIC_INT8:
666 case TYPE_BASIC_INT16:
667 case TYPE_BASIC_INT32:
668 case TYPE_BASIC_INT64:
669 case TYPE_BASIC_INT:
671 case TYPE_BASIC_LONG:
672 case TYPE_BASIC_CHAR:
673 case TYPE_BASIC_HYPER:
674 case TYPE_BASIC_BYTE:
675 case TYPE_BASIC_WCHAR:
677 return TRUE;
678 case TYPE_BASIC_FLOAT:
681 return FALSE;
682 }
683 return FALSE;
684 default:
685 return FALSE;
686 }
687}
688
690{
691 type_t *t;
692
694 error_loc("bit-field has invalid type\n");
695
696 if (bits->cval < 0)
697 error_loc("negative width for bit-field\n");
698
699 /* FIXME: validate bits->cval <= memsize(field) * 8 */
700
702 t->details.bitfield.field = field;
703 t->details.bitfield.bits = bits;
704 return t;
705}
706
707static unsigned int compute_method_indexes(type_t *iface)
708{
709 unsigned int idx;
710 statement_t *stmt;
711
712 if (!iface->details.iface)
713 return 0;
714
715 if (type_iface_get_inherit(iface))
717 else
718 idx = 0;
719
721 {
722 var_t *func = stmt->u.var;
723 if (!is_callas(func->attrs))
724 func->func_idx = idx++;
725 }
726
727 return idx;
728}
729
730type_t *type_interface_declare(char *name, struct namespace *namespace)
731{
732 type_t *type = get_type(TYPE_INTERFACE, name, namespace, 0);
734 error_loc( "interface %s previously not declared an interface at %s:%d\n", type->name,
735 type->where.input_name, type->where.first_line );
736 return type;
737}
738
740 statement_list_t *stmts, typeref_list_t *requires, const struct location *where)
741{
742 if (iface == inherit)
743 error_loc("interface %s can't inherit from itself\n",
744 iface->name);
745 iface->attrs = check_interface_attrs(iface->name, attrs);
746 iface->details.iface = xmalloc(sizeof(*iface->details.iface));
747 iface->details.iface->disp_props = NULL;
748 iface->details.iface->disp_methods = NULL;
749 iface->details.iface->stmts = stmts;
750 iface->details.iface->inherit = inherit;
751 iface->details.iface->disp_inherit = NULL;
752 iface->details.iface->async_iface = NULL;
753 iface->details.iface->requires = requires;
754 define_type(iface, where);
756 return iface;
757}
758
760{
763 error_loc( "dispinterface %s previously not declared a dispinterface at %s:%d\n",
764 type->name, type->where.input_name, type->where.first_line );
765 return type;
766}
767
769 var_list_t *props, var_list_t *methods, const struct location *where)
770{
771 iface->attrs = check_dispiface_attrs(iface->name, attrs);
772 iface->details.iface = xmalloc(sizeof(*iface->details.iface));
773 iface->details.iface->disp_props = props;
774 iface->details.iface->disp_methods = methods;
775 iface->details.iface->stmts = NULL;
776 iface->details.iface->inherit = find_type("IDispatch", NULL, 0);
777 if (!iface->details.iface->inherit) error_loc("IDispatch is undefined\n");
778 iface->details.iface->disp_inherit = NULL;
779 iface->details.iface->async_iface = NULL;
780 iface->details.iface->requires = NULL;
781 define_type(iface, where);
783 return iface;
784}
785
787 attr_list_t *attrs, type_t *iface, const struct location *where)
788{
789 dispiface->attrs = check_dispiface_attrs(dispiface->name, attrs);
790 dispiface->details.iface = xmalloc(sizeof(*dispiface->details.iface));
791 dispiface->details.iface->disp_props = NULL;
792 dispiface->details.iface->disp_methods = NULL;
793 dispiface->details.iface->stmts = NULL;
794 dispiface->details.iface->inherit = find_type("IDispatch", NULL, 0);
795 if (!dispiface->details.iface->inherit) error_loc("IDispatch is undefined\n");
796 dispiface->details.iface->disp_inherit = iface;
797 dispiface->details.iface->async_iface = NULL;
798 dispiface->details.iface->requires = NULL;
799 define_type(dispiface, where);
800 compute_method_indexes(dispiface);
801 return dispiface;
802}
803
805{
808 error_loc( "module %s previously not declared a module at %s:%d\n", type->name,
809 type->where.input_name, type->where.first_line );
810 return type;
811}
812
814 statement_list_t *stmts, const struct location *where)
815{
816 module->attrs = check_module_attrs(module->name, attrs);
817 module->details.module = xmalloc(sizeof(*module->details.module));
818 module->details.module->stmts = stmts;
819 define_type(module, where);
820 return module;
821}
822
824{
827 error_loc( "coclass %s previously not declared a coclass at %s:%d\n", type->name,
828 type->where.input_name, type->where.first_line );
829 return type;
830}
831
833 typeref_list_t *ifaces, const struct location *where)
834{
835 coclass->attrs = check_coclass_attrs(coclass->name, attrs);
836 coclass->details.coclass.ifaces = ifaces;
837 define_type(coclass, where);
838 return coclass;
839}
840
841type_t *type_runtimeclass_declare(char *name, struct namespace *namespace)
842{
843 type_t *type = get_type(TYPE_RUNTIMECLASS, name, namespace, 0);
845 error_loc( "runtimeclass %s previously not declared a runtimeclass at %s:%d\n", type->name,
846 type->where.input_name, type->where.first_line );
847 return type;
848}
849
851 typeref_list_t *ifaces, const struct location *where)
852{
853 typeref_t *ref, *required, *tmp;
854 typeref_list_t *requires;
855
856 runtimeclass->attrs = check_runtimeclass_attrs(runtimeclass->name, attrs);
857 runtimeclass->details.runtimeclass.ifaces = ifaces;
858 define_type(runtimeclass, where);
859 if (!type_runtimeclass_get_default_iface(runtimeclass, FALSE) &&
860 !get_attrp(runtimeclass->attrs, ATTR_STATIC))
861 error_loc("runtimeclass %s must have a default interface or static factory\n", runtimeclass->name);
862
863 if (ifaces) LIST_FOR_EACH_ENTRY(ref, ifaces, typeref_t, entry)
864 {
865 /* FIXME: this should probably not be allowed, here or in coclass, */
866 /* but for now there's too many places in Wine IDL where it is to */
867 /* even print a warning. */
868 if (!(ref->type->defined)) continue;
869 if (!(requires = type_iface_get_requires(ref->type))) continue;
870 LIST_FOR_EACH_ENTRY(required, requires, typeref_t, entry)
871 {
872 int found = 0;
873
874 LIST_FOR_EACH_ENTRY(tmp, ifaces, typeref_t, entry)
875 if ((found = type_is_equal(tmp->type, required->type))) break;
876
877 if (!found)
878 error_loc("interface '%s' also requires interface '%s', "
879 "but runtimeclass '%s' does not implement it.\n",
880 ref->type->name, required->type->name, runtimeclass->name);
881 }
882 }
883
884 return runtimeclass;
885}
886
887type_t *type_apicontract_declare(char *name, struct namespace *namespace)
888{
889 type_t *type = get_type(TYPE_APICONTRACT, name, namespace, 0);
891 error_loc( "apicontract %s previously not declared a apicontract at %s:%d\n", type->name,
892 type->where.input_name, type->where.first_line );
893 return type;
894}
895
896type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs, const struct location *where)
897{
898 apicontract->attrs = check_apicontract_attrs(apicontract->name, attrs);
899 define_type(apicontract, where);
900 return apicontract;
901}
902
904{
905 type_t *iface = delegate->details.delegate.iface;
906 iface->namespace = delegate->namespace;
907 iface->name = strmake("I%s", delegate->name);
908 if (type) iface->c_name = format_parameterized_type_c_name(type, params, "I", "_C");
909 else iface->c_name = format_namespace(delegate->namespace, "__x_", "_C", iface->name, use_abi_namespace ? "ABI" : NULL);
910 if (type) iface->param_name = format_parameterized_type_c_name(type, params, "I", "__C");
911 else iface->param_name = format_namespace(delegate->namespace, "_", "__C", iface->name, NULL);
912 iface->qualified_name = format_namespace(delegate->namespace, "", "::", iface->name, use_abi_namespace ? "ABI" : NULL);
913}
914
915type_t *type_delegate_declare(char *name, struct namespace *namespace)
916{
917 type_t *type = get_type(TYPE_DELEGATE, name, namespace, 0);
919 error_loc( "delegate %s previously not declared a delegate at %s:%d\n", type->name,
920 type->where.input_name, type->where.first_line );
921 return type;
922}
923
925 statement_list_t *stmts, const struct location *where)
926{
927 type_t *iface;
928
929 delegate->attrs = check_interface_attrs(delegate->name, attrs);
930
931 iface = make_type(TYPE_INTERFACE);
932 iface->attrs = delegate->attrs;
933 iface->details.iface = xmalloc(sizeof(*iface->details.iface));
934 iface->details.iface->disp_props = NULL;
935 iface->details.iface->disp_methods = NULL;
936 iface->details.iface->stmts = stmts;
937 iface->details.iface->inherit = find_type("IUnknown", NULL, 0);
938 if (!iface->details.iface->inherit) error_loc("IUnknown is undefined\n");
939 iface->details.iface->disp_inherit = NULL;
940 iface->details.iface->async_iface = NULL;
941 iface->details.iface->requires = NULL;
942 define_type(iface, where);
943 iface->defined = TRUE;
945
946 delegate->details.delegate.iface = iface;
947 define_type(delegate, where);
949
950 return delegate;
951}
952
954{
957 error_loc( "pinterface %s previously not declared a pinterface at %s:%d\n", type->name,
958 type->where.input_name, type->where.first_line );
959 type->details.parameterized.type = make_type(TYPE_INTERFACE);
960 type->details.parameterized.params = params;
961 return type;
962}
963
965 statement_list_t *stmts, typeref_list_t *requires, const struct location *where)
966{
967 type_t *iface;
968
969 /* The parameterized type UUID is actually a PIID that is then used as a seed to generate
970 * a new type GUID with the rules described in:
971 * https://docs.microsoft.com/en-us/uwp/winrt-cref/winrt-type-system#parameterized-types
972 * TODO: store type signatures for generated interfaces, and generate their GUIDs
973 */
974 type->attrs = check_interface_attrs(type->name, attrs);
975
976 iface = type->details.parameterized.type;
977 iface->details.iface = xmalloc(sizeof(*iface->details.iface));
978 iface->details.iface->disp_props = NULL;
979 iface->details.iface->disp_methods = NULL;
980 iface->details.iface->stmts = stmts;
981 iface->details.iface->inherit = inherit;
982 iface->details.iface->disp_inherit = NULL;
983 iface->details.iface->async_iface = NULL;
984 iface->details.iface->requires = requires;
985
986 iface->name = type->name;
987
988 define_type(type, where);
989 return type;
990}
991
993{
996 error_loc( "pdelegate %s previously not declared a pdelegate at %s:%d\n", type->name,
997 type->where.input_name, type->where.first_line );
998 type->details.parameterized.type = make_type(TYPE_DELEGATE);
999 type->details.parameterized.params = params;
1000 return type;
1001}
1002
1004 statement_list_t *stmts, const struct location *where)
1005{
1006 type_t *iface, *delegate;
1007
1008 type->attrs = check_interface_attrs(type->name, attrs);
1009
1010 delegate = type->details.parameterized.type;
1011 delegate->attrs = type->attrs;
1012 delegate->details.delegate.iface = make_type(TYPE_INTERFACE);
1013
1014 iface = delegate->details.delegate.iface;
1015 iface->details.iface = xmalloc(sizeof(*iface->details.iface));
1016 iface->details.iface->disp_props = NULL;
1017 iface->details.iface->disp_methods = NULL;
1018 iface->details.iface->stmts = stmts;
1019 iface->details.iface->inherit = find_type("IUnknown", NULL, 0);
1020 if (!iface->details.iface->inherit) error_loc("IUnknown is undefined\n");
1021 iface->details.iface->disp_inherit = NULL;
1022 iface->details.iface->async_iface = NULL;
1023 iface->details.iface->requires = NULL;
1024
1025 delegate->name = type->name;
1027
1028 define_type(type, where);
1029 return type;
1030}
1031
1033{
1034 type_t *new_type = duptype(type, 0);
1035 new_type->details.parameterized.type = type;
1036 new_type->details.parameterized.params = params;
1037 return new_type;
1038}
1039
1041
1043{
1044 typeref_list_t *new_list = NULL;
1045 typeref_t *ref;
1046
1047 if (!list) return list;
1048
1050 {
1051 type_t *new_type = replace_type_parameters_in_type(ref->type, orig, repl);
1052 new_list = append_typeref(new_list, make_typeref(new_type));
1053 }
1054
1055 return new_list;
1056}
1057
1059{
1060 var_t *new_var = xmalloc(sizeof(*new_var));
1061 *new_var = *var;
1062 list_init(&new_var->entry);
1063 new_var->declspec.type = replace_type_parameters_in_type(var->declspec.type, orig, repl);
1064 return new_var;
1065}
1066
1068{
1069 var_list_t *new_var_list;
1070 var_t *var, *new_var;
1071
1072 if (!var_list) return var_list;
1073
1074 new_var_list = xmalloc(sizeof(*new_var_list));
1075 list_init(new_var_list);
1076
1077 LIST_FOR_EACH_ENTRY(var, var_list, var_t, entry)
1078 {
1079 new_var = replace_type_parameters_in_var(var, orig, repl);
1080 list_add_tail(new_var_list, &new_var->entry);
1081 }
1082
1083 return new_var_list;
1084}
1085
1087 typeref_list_t *repl, struct location *where )
1088{
1089 statement_t *new_stmt = xmalloc(sizeof(*new_stmt));
1090 *new_stmt = *stmt;
1091 list_init(&new_stmt->entry);
1092
1093 switch (stmt->type)
1094 {
1095 case STMT_DECLARATION:
1096 new_stmt->u.var = replace_type_parameters_in_var(stmt->u.var, orig, repl);
1097 break;
1098 case STMT_TYPE:
1099 case STMT_TYPEREF:
1100 new_stmt->u.type = replace_type_parameters_in_type(stmt->u.type, orig, repl);
1101 break;
1102 case STMT_TYPEDEF:
1103 new_stmt->u.type_list = replace_type_parameters_in_type_list(stmt->u.type_list, orig, repl);
1104 break;
1105 case STMT_MODULE:
1106 case STMT_LIBRARY:
1107 case STMT_IMPORT:
1108 case STMT_IMPORTLIB:
1109 case STMT_PRAGMA:
1110 case STMT_CPPQUOTE:
1111 error_at( where, "unimplemented parameterized type replacement for statement type %d.\n", stmt->type );
1112 break;
1113 }
1114
1115 return new_stmt;
1116}
1117
1119 typeref_list_t *repl, struct location *where )
1120{
1121 statement_list_t *new_stmt_list;
1122 statement_t *stmt, *new_stmt;
1123
1124 if (!stmt_list) return stmt_list;
1125
1126 new_stmt_list = xmalloc(sizeof(*new_stmt_list));
1127 list_init(new_stmt_list);
1128
1129 LIST_FOR_EACH_ENTRY(stmt, stmt_list, statement_t, entry)
1130 {
1131 new_stmt = replace_type_parameters_in_statement( stmt, orig, repl, where );
1132 list_add_tail(new_stmt_list, &new_stmt->entry);
1133 }
1134
1135 return new_stmt_list;
1136}
1137
1139{
1140 struct list *o, *r;
1141 type_t *t;
1142
1143 if (!type) return type;
1144 switch (type->type_type)
1145 {
1146 case TYPE_VOID:
1147 case TYPE_BASIC:
1148 case TYPE_ENUM:
1149 case TYPE_BITFIELD:
1150 case TYPE_INTERFACE:
1151 case TYPE_RUNTIMECLASS:
1152 case TYPE_DELEGATE:
1153 case TYPE_STRUCT:
1155 case TYPE_UNION:
1156 return type;
1157 case TYPE_PARAMETER:
1158 if (!orig || !repl) return NULL;
1159 for (o = list_head(orig), r = list_head(repl); o && r;
1160 o = list_next(orig, o), r = list_next(repl, r))
1161 if (type == LIST_ENTRY(o, typeref_t, entry)->type)
1162 return LIST_ENTRY(r, typeref_t, entry)->type;
1163 return type;
1164 case TYPE_POINTER:
1165 t = replace_type_parameters_in_type(type->details.pointer.ref.type, orig, repl);
1166 if (t == type->details.pointer.ref.type) return type;
1167 type = duptype(type, 0);
1168 type->details.pointer.ref.type = t;
1169 return type;
1170 case TYPE_ALIAS:
1171 t = replace_type_parameters_in_type(type->details.alias.aliasee.type, orig, repl);
1172 if (t == type->details.alias.aliasee.type) return type;
1173 type = duptype(type, 0);
1174 type->details.alias.aliasee.type = t;
1175 return type;
1176 case TYPE_ARRAY:
1177 t = replace_type_parameters_in_type(type->details.array.elem.type, orig, repl);
1178 if (t == t->details.array.elem.type) return type;
1179 type = duptype(type, 0);
1180 t->details.array.elem.type = t;
1181 return type;
1182 case TYPE_FUNCTION:
1183 t = duptype(type, 0);
1184 t->details.function = xmalloc(sizeof(*t->details.function));
1185 t->details.function->args = replace_type_parameters_in_var_list(type->details.function->args, orig, repl);
1186 t->details.function->retval = replace_type_parameters_in_var(type->details.function->retval, orig, repl);
1187 return t;
1189 t = type->details.parameterized.type;
1190 if (t->type_type != TYPE_PARAMETERIZED_TYPE) return find_parameterized_type(type, repl);
1191 repl = replace_type_parameters_in_type_list(type->details.parameterized.params, orig, repl);
1192 return replace_type_parameters_in_type(t, t->details.parameterized.params, repl);
1193 case TYPE_MODULE:
1194 case TYPE_COCLASS:
1195 case TYPE_APICONTRACT:
1196 error_at( &type->where, "unimplemented parameterized type replacement for type %s of type %d.\n",
1197 type->name, type->type_type );
1198 break;
1199 }
1200
1201 return type;
1202}
1203
1205{
1206 iface->details.iface = xmalloc(sizeof(*iface->details.iface));
1207 iface->details.iface->disp_methods = NULL;
1208 iface->details.iface->disp_props = NULL;
1210 orig, repl, &tmpl->where );
1211 iface->details.iface->inherit = replace_type_parameters_in_type(tmpl->details.iface->inherit, orig, repl);
1212 iface->details.iface->disp_inherit = NULL;
1213 iface->details.iface->async_iface = NULL;
1214 iface->details.iface->requires = NULL;
1215}
1216
1218{
1219 type_parameterized_interface_specialize(tmpl->details.delegate.iface, delegate->details.delegate.iface, orig, repl);
1220}
1221
1223{
1224 type_t *tmpl = type->details.parameterized.type;
1225 type_t *new_type = duptype(tmpl, 0);
1226
1227 new_type->namespace = type->namespace;
1229 reg_type(new_type, new_type->name, new_type->namespace, 0);
1230 new_type->c_name = format_parameterized_type_c_name(type, params, "", "_C");
1232 new_type->param_name = format_parameterized_type_c_name(type, params, "", "__C");
1233
1234 if (new_type->type_type == TYPE_DELEGATE)
1235 {
1236 new_type->details.delegate.iface = duptype(tmpl->details.delegate.iface, 0);
1238 new_type->details.delegate.iface->short_name = format_parameterized_type_short_name(type, params, "I");
1239 }
1240
1241 return new_type;
1242}
1243
1245{
1246 static const char winrt_pinterface_namespace[] = {0x11,0xf4,0x7a,0xd5,0x7b,0x73,0x42,0xc0,0xab,0xae,0x87,0x8b,0x1e,0x16,0xad,0xee};
1247 static const int version = 5;
1248 struct sha1_context ctx;
1249 unsigned char hash[20];
1250 struct uuid *uuid;
1251
1252 if (!(uuid = get_attrp(iface->attrs, ATTR_UUID)))
1253 {
1254 uuid = xmalloc(sizeof(*uuid));
1255 iface->attrs = append_attr( iface->attrs, attr_ptr( iface->where, ATTR_UUID, uuid ) );
1256 }
1257
1258 sha1_init(&ctx);
1259 sha1_update(&ctx, winrt_pinterface_namespace, sizeof(winrt_pinterface_namespace));
1260 sha1_update(&ctx, iface->signature, strlen(iface->signature));
1261 sha1_finalize(&ctx, (unsigned int *)hash);
1262
1263 /* https://tools.ietf.org/html/rfc4122:
1264
1265 * Set the four most significant bits (bits 12 through 15) of the
1266 time_hi_and_version field to the appropriate 4-bit version number
1267 from Section 4.1.3.
1268
1269 * Set the two most significant bits (bits 6 and 7) of the
1270 clock_seq_hi_and_reserved to zero and one, respectively.
1271 */
1272
1273 hash[6] = ((hash[6] & 0x0f) | (version << 4));
1274 hash[8] = ((hash[8] & 0x3f) | 0x80);
1275
1276 uuid->Data1 = ((unsigned int)hash[0] << 24) | ((unsigned int)hash[1] << 16) | ((unsigned int)hash[2] << 8) | hash[3];
1277 uuid->Data2 = ((unsigned short)hash[4] << 8) | hash[5];
1278 uuid->Data3 = ((unsigned short)hash[6] << 8) | hash[7];
1279 memcpy(&uuid->Data4, hash + 8, sizeof(*uuid) - offsetof(struct uuid, Data4));
1280}
1281
1283{
1284 type_t *tmpl = type->details.parameterized.type;
1285 typeref_list_t *orig = tmpl->details.parameterized.params;
1286 typeref_list_t *repl = type->details.parameterized.params;
1287 type_t *iface = find_parameterized_type(tmpl, repl);
1288
1291 error_loc( "cannot define non-parameterized type %s, declared at %s:%d\n", type->name,
1292 type->where.input_name, type->where.first_line );
1293
1296 type_parameterized_interface_specialize(tmpl->details.parameterized.type, iface, orig, repl);
1299 type_parameterized_delegate_specialize(tmpl->details.parameterized.type, iface, orig, repl);
1300 else
1301 error_loc("pinterface/pdelegate %s previously not declared a pinterface/pdelegate at %s:%d\n",
1302 iface->name, iface->where.input_name, iface->where.first_line);
1303
1306 iface->defined = TRUE;
1307 if (iface->type_type == TYPE_DELEGATE)
1308 {
1309 iface = iface->details.delegate.iface;
1312 iface->defined = TRUE;
1313 }
1316 return iface;
1317}
1318
1319int type_is_equal(const type_t *type1, const type_t *type2)
1320{
1321 if (type1 == type2)
1322 return TRUE;
1324 return FALSE;
1325 if (type1->namespace != type2->namespace)
1326 return FALSE;
1327
1328 if (type1->name && type2->name)
1329 return !strcmp(type1->name, type2->name);
1330 else if ((!type1->name && type2->name) || (type1->name && !type2->name))
1331 return FALSE;
1332
1333 /* FIXME: do deep inspection of types to determine if they are equal */
1334
1335 return FALSE;
1336}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * xstrdup(const char *s)
Definition: uimain.c:768
void * xmalloc(int size)
Definition: uimain.c:747
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
Definition: list.h:37
#define sha1_init
Definition: compat-1.3.h:2266
#define sha1_update
Definition: compat-1.3.h:2270
struct hlsl_type * get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN
Definition: utils.c:841
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
static const WCHAR version[]
Definition: asmname.c:66
static const WCHAR separator[]
Definition: asmname.c:65
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define assert(x)
Definition: debug.h:53
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
GLenum func
Definition: glext.h:6028
GLdouble n
Definition: glext.h:7729
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLenum GLsizei len
Definition: glext.h:6722
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define bits
Definition: infblock.c:15
Definition: msctf.idl:532
unsigned short Data3
Definition: widltypes.h:34
unsigned int Data1
Definition: widltypes.h:32
unsigned char Data4[8]
Definition: widltypes.h:35
unsigned short Data2
Definition: widltypes.h:33
uint32_t entry
Definition: isohybrid.c:63
#define d
Definition: ke_i.h:81
#define a
Definition: ke_i.h:78
#define sign(x)
Definition: mapdesc.cc:613
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static const struct encodedInt enums[]
Definition: encode.c:361
const char * var
Definition: shader.c:5666
UINT WINAPI nested(MSIHANDLE hinst)
Definition: custom.c:565
const char * fields[10]
Definition: parser.c:313
char * strmake(size_t *lenp,...)
Definition: util.c:82
#define list
Definition: rosglue.h:35
#define offsetof(TYPE, MEMBER)
strcpy
Definition: string.h:131
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define memset(x, y, z)
Definition: compat.h:39
#define args
Definition: format.c:66
attr_list_t * check_module_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:464
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
attr_list_t * check_apicontract_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:337
attr_t * attr_ptr(struct location where, enum attr_type attr_type, void *val)
Definition: attribute.c:36
attr_list_t * check_dispiface_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:363
attr_list_t * check_runtimeclass_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:477
attr_list_t * check_coclass_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:350
attr_list_t * append_attr(attr_list_t *list, attr_t *attr)
Definition: attribute.c:255
int is_attr(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:45
attr_list_t * check_interface_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:428
void sha1_finalize(struct sha1_context *ctx, unsigned int result[5])
Definition: hash.c:703
const var_t * is_callas(const attr_list_t *a)
Definition: header.c:987
int parse_only
void init_location(struct location *copy, const struct location *begin, const struct location *end)
void error_at(const struct location *where, const char *s,...)
Definition: utils.c:35
size_t strappend(char **buf, size_t *len, size_t pos, const char *fmt,...)
Definition: utils.c:120
#define error_loc(...)
Definition: utils.h:29
type_t * type
Definition: widltypes.h:334
statement_type_t type
Definition: parser.h:124
struct list entry
Definition: widltypes.h:625
var_t * var
Definition: widltypes.h:631
typeref_list_t * type_list
Definition: widltypes.h:633
union _statement_t::@5358 u
const char * param_name
Definition: widltypes.h:525
attr_list_t * attrs
Definition: widltypes.h:503
struct parameterized_details parameterized
Definition: widltypes.h:518
union _type_t::@5357 details
const char * c_name
Definition: widltypes.h:521
struct coclass_details coclass
Definition: widltypes.h:512
const char * short_name
Definition: widltypes.h:526
struct location where
Definition: widltypes.h:530
enum type_type type_type
Definition: widltypes.h:502
const char * qualified_name
Definition: widltypes.h:523
struct delegate_details delegate
Definition: widltypes.h:519
struct iface_details * iface
Definition: widltypes.h:509
unsigned int defined
Definition: widltypes.h:532
const char * impl_name
Definition: widltypes.h:524
const char * signature
Definition: widltypes.h:522
const char * name
Definition: widltypes.h:500
struct runtimeclass_details runtimeclass
Definition: widltypes.h:517
struct basic_details basic
Definition: widltypes.h:513
type_t * type
Definition: widltypes.h:571
struct list entry
Definition: widltypes.h:557
decl_spec_t declspec
Definition: widltypes.h:542
unsigned int func_idx
Definition: widltypes.h:549
Definition: match.c:390
char * name
Definition: compiler.c:66
Definition: parser.c:44
Definition: _hash_fun.h:40
Definition: list.h:15
IMAGEHLP_MODULEW64 module
Definition: name.c:39
struct namespace * parent
Definition: widltypes.h:470
Definition: send.c:48
char name[1]
Definition: send.c:52
#define LIST_ENTRY(type)
Definition: queue.h:175
Character const *const prefix
Definition: tempnam.cpp:195
static void type_parameterized_interface_specialize(type_t *tmpl, type_t *iface, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1204
static void define_type(type_t *type, const struct location *where)
Definition: typetree.c:536
type_t * type_module_define(type_t *module, attr_list_t *attrs, statement_list_t *stmts, const struct location *where)
Definition: typetree.c:813
static var_list_t * replace_type_parameters_in_var_list(var_list_t *var_list, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1067
static typeref_list_t * replace_type_parameters_in_type_list(typeref_list_t *list, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1042
static char * format_parameterized_type_c_name(type_t *type, typeref_list_t *params, const char *prefix, const char *separator)
Definition: typetree.c:313
type_t * type_parameterized_type_specialize_partial(type_t *type, typeref_list_t *params)
Definition: typetree.c:1032
type_t * type_dispinterface_define_from_iface(type_t *dispiface, attr_list_t *attrs, type_t *iface, const struct location *where)
Definition: typetree.c:786
type_t * type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typeref_list_t *ifaces, const struct location *where)
Definition: typetree.c:850
int type_is_equal(const type_t *type1, const type_t *type2)
Definition: typetree.c:1319
static size_t append_var_list_signature(char **buf, size_t *len, size_t pos, var_list_t *var_list)
Definition: typetree.c:150
type_t * type_apicontract_declare(char *name, struct namespace *namespace)
Definition: typetree.c:887
static statement_list_t * replace_type_parameters_in_statement_list(statement_list_t *stmt_list, typeref_list_t *orig, typeref_list_t *repl, struct location *where)
Definition: typetree.c:1118
type_t * type_new_function(var_list_t *args)
Definition: typetree.c:420
type_t * type_parameterized_delegate_declare(char *name, struct namespace *namespace, typeref_list_t *params)
Definition: typetree.c:992
char * format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, const char *abi_prefix)
Definition: typetree.c:279
type_t * type_runtimeclass_declare(char *name, struct namespace *namespace)
Definition: typetree.c:841
static const var_t * find_arg(const var_list_t *args, const char *name)
Definition: typetree.c:75
static unsigned int compute_method_indexes(type_t *iface)
Definition: typetree.c:707
type_t * type_coclass_declare(char *name)
Definition: typetree.c:823
type_t * type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases, const struct location *where)
Definition: typetree.c:627
static char * format_parameterized_type_signature(type_t *type, typeref_list_t *params)
Definition: typetree.c:347
static void compute_interface_signature_uuid(type_t *iface)
Definition: typetree.c:1244
static void compute_delegate_iface_names(type_t *delegate, type_t *type, typeref_list_t *params)
Definition: typetree.c:903
static size_t append_namespaces(char **buf, size_t *len, size_t pos, struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, const char *abi_prefix)
Definition: typetree.c:125
type_t * type_new_bitfield(type_t *field, const expr_t *bits)
Definition: typetree.c:689
type_t * type_new_nonencapsulated_union(const char *name, struct namespace *namespace, int defined, var_list_t *fields, const struct location *where)
Definition: typetree.c:600
type_t * type_parameterized_interface_define(type_t *type, attr_list_t *attrs, type_t *inherit, statement_list_t *stmts, typeref_list_t *requires, const struct location *where)
Definition: typetree.c:964
type_t * type_new_array(const char *name, const decl_spec_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is)
Definition: typetree.c:489
static char * format_parameterized_type_short_name(type_t *type, typeref_list_t *params, const char *prefix)
Definition: typetree.c:371
type_t * type_delegate_declare(char *name, struct namespace *namespace)
Definition: typetree.c:915
type_t * type_parameterized_interface_declare(char *name, struct namespace *namespace, typeref_list_t *params)
Definition: typetree.c:953
type_t * type_parameterized_delegate_define(type_t *type, attr_list_t *attrs, statement_list_t *stmts, const struct location *where)
Definition: typetree.c:1003
type_t * type_module_declare(char *name)
Definition: typetree.c:804
type_t * type_interface_define(type_t *iface, attr_list_t *attrs, type_t *inherit, statement_list_t *stmts, typeref_list_t *requires, const struct location *where)
Definition: typetree.c:739
type_t * type_new_basic(enum type_basic_type basic_type)
Definition: typetree.c:505
const char * type_get_decl_name(const type_t *type, enum name_type name_type)
Definition: typetree.c:88
type_t * type_new_pointer(type_t *ref)
Definition: typetree.c:470
type_t * type_parameterized_type_specialize_define(type_t *type)
Definition: typetree.c:1282
type_t * type_new_void(void)
Definition: typetree.c:528
static size_t append_pointer_stars(char **buf, size_t *len, size_t pos, type_t *type)
Definition: typetree.c:141
type_t * type_interface_declare(char *name, struct namespace *namespace)
Definition: typetree.c:730
static char const * parameterized_type_shorthands[][2]
Definition: typetree.c:306
static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t *type)
Definition: typetree.c:165
static char * format_parameterized_type_impl_name(type_t *type, typeref_list_t *params, const char *prefix)
Definition: typetree.c:388
type_t * type_delegate_define(type_t *delegate, attr_list_t *attrs, statement_list_t *stmts, const struct location *where)
Definition: typetree.c:924
static size_t append_namespace(char **buf, size_t *len, size_t pos, struct namespace *namespace, const char *separator, const char *abi_prefix)
Definition: typetree.c:114
const char * type_get_name(const type_t *type, enum name_type name_type)
Definition: typetree.c:101
type_t * type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields, const struct location *where)
Definition: typetree.c:573
char * format_parameterized_type_name(type_t *type, typeref_list_t *params)
Definition: typetree.c:287
type_t * type_new_int(enum type_basic_type basic_type, int sign)
Definition: typetree.c:513
type_t * duptype(type_t *t, int dupname)
Definition: typetree.c:37
type_t * type_apicontract_define(type_t *apicontract, attr_list_t *attrs, const struct location *where)
Definition: typetree.c:896
static statement_t * replace_type_parameters_in_statement(statement_t *stmt, typeref_list_t *orig, typeref_list_t *repl, struct location *where)
Definition: typetree.c:1086
type_t * type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums, const struct location *where)
Definition: typetree.c:546
type_t * type_dispinterface_declare(char *name)
Definition: typetree.c:759
type_t * type_parameterized_type_specialize_declare(type_t *type, typeref_list_t *params)
Definition: typetree.c:1222
static int is_valid_bitfield_type(const type_t *type)
Definition: typetree.c:656
static var_t * replace_type_parameters_in_var(var_t *var, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1058
static type_t * replace_type_parameters_in_type(type_t *type, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1138
type_t * type_dispinterface_define(type_t *iface, attr_list_t *attrs, var_list_t *props, var_list_t *methods, const struct location *where)
Definition: typetree.c:768
type_t * type_new_alias(const decl_spec_t *t, const char *name)
Definition: typetree.c:477
static void type_parameterized_delegate_specialize(type_t *tmpl, type_t *delegate, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1217
type_t * make_type(enum type_type type)
Definition: typetree.c:48
type_t * type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t *ifaces, const struct location *where)
Definition: typetree.c:832
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
type_t * find_parameterized_type(type_t *type, typeref_list_t *params)
static type_t * type_runtimeclass_get_default_iface(const type_t *type, int check)
Definition: typetree.h:393
typeref_t * make_typeref(type_t *type)
typeref_list_t * append_typeref(typeref_list_t *list, typeref_t *ref)
static type_t * type_delegate_get_iface(const type_t *type)
Definition: typetree.h:410
static int type_basic_get_sign(const type_t *type)
Definition: typetree.h:125
static type_t * type_pointer_get_root_type(type_t *type)
Definition: typetree.h:429
static typeref_list_t * type_iface_get_requires(const type_t *type)
Definition: typetree.h:215
name_type
Definition: typetree.h:30
@ NAME_C
Definition: typetree.h:32
@ NAME_DEFAULT
Definition: typetree.h:31
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:118
static type_t * type_pointer_get_ref_type(const type_t *type)
Definition: typetree.h:424
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:208
char * gen_name(void)
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:201
static const WCHAR props[]
Definition: wbemdisp.c:288
int use_abi_namespace
Definition: widl.c:113
var_list_t * append_var(var_list_t *list, var_t *var)
#define tsENUM
Definition: widltypes.h:662
type_t * alloc_type(void)
#define TYPE_BASIC_INT_MAX
Definition: widltypes.h:315
#define tsUNION
Definition: widltypes.h:664
type_type
Definition: widltypes.h:477
@ TYPE_PARAMETER
Definition: widltypes.h:495
@ TYPE_ENUM
Definition: widltypes.h:480
@ TYPE_BITFIELD
Definition: widltypes.h:491
@ TYPE_BASIC
Definition: widltypes.h:479
@ TYPE_UNION
Definition: widltypes.h:483
@ TYPE_ALIAS
Definition: widltypes.h:484
@ TYPE_PARAMETERIZED_TYPE
Definition: widltypes.h:494
@ TYPE_POINTER
Definition: widltypes.h:489
@ TYPE_VOID
Definition: widltypes.h:478
@ TYPE_ENCAPSULATED_UNION
Definition: widltypes.h:482
@ TYPE_COCLASS
Definition: widltypes.h:486
@ TYPE_STRUCT
Definition: widltypes.h:481
@ TYPE_MODULE
Definition: widltypes.h:485
@ TYPE_DELEGATE
Definition: widltypes.h:496
@ TYPE_RUNTIMECLASS
Definition: widltypes.h:493
@ TYPE_INTERFACE
Definition: widltypes.h:488
@ TYPE_ARRAY
Definition: widltypes.h:490
@ TYPE_FUNCTION
Definition: widltypes.h:487
@ TYPE_APICONTRACT
Definition: widltypes.h:492
@ ATTR_UUID
Definition: widltypes.h:182
@ ATTR_STATIC
Definition: widltypes.h:172
@ ATTR_FLAGS
Definition: widltypes.h:116
type_t * reg_type(type_t *type, const char *name, struct namespace *namespace, int t)
@ STMT_MODULE
Definition: widltypes.h:269
@ STMT_IMPORT
Definition: widltypes.h:271
@ STMT_IMPORTLIB
Definition: widltypes.h:272
@ STMT_TYPE
Definition: widltypes.h:267
@ STMT_DECLARATION
Definition: widltypes.h:266
@ STMT_LIBRARY
Definition: widltypes.h:265
@ STMT_TYPEDEF
Definition: widltypes.h:270
@ STMT_CPPQUOTE
Definition: widltypes.h:274
@ STMT_TYPEREF
Definition: widltypes.h:268
@ STMT_PRAGMA
Definition: widltypes.h:273
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:679
var_t * make_var(char *name)
static int is_global_namespace(const struct namespace *namespace)
Definition: widltypes.h:701
type_basic_type
Definition: widltypes.h:295
@ TYPE_BASIC_DOUBLE
Definition: widltypes.h:308
@ TYPE_BASIC_INT32
Definition: widltypes.h:298
@ TYPE_BASIC_ERROR_STATUS_T
Definition: widltypes.h:309
@ TYPE_BASIC_CHAR
Definition: widltypes.h:303
@ TYPE_BASIC_WCHAR
Definition: widltypes.h:306
@ TYPE_BASIC_INT16
Definition: widltypes.h:297
@ TYPE_BASIC_HYPER
Definition: widltypes.h:304
@ TYPE_BASIC_HANDLE
Definition: widltypes.h:310
@ TYPE_BASIC_INT8
Definition: widltypes.h:296
@ TYPE_BASIC_INT3264
Definition: widltypes.h:301
@ TYPE_BASIC_LONG
Definition: widltypes.h:302
@ TYPE_BASIC_INT64
Definition: widltypes.h:299
@ TYPE_BASIC_BYTE
Definition: widltypes.h:305
@ TYPE_BASIC_INT
Definition: widltypes.h:300
@ TYPE_BASIC_FLOAT
Definition: widltypes.h:307
#define tsSTRUCT
Definition: widltypes.h:663
type_t * find_type(const char *name, struct namespace *namespace, int t)
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:684
void * arg
Definition: msvc.h:10