4 * Copyright 2008 Robert Shearman
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.
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.
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
34 type_t
*duptype(type_t
*t
, int dupname
)
36 type_t
*d
= alloc_type();
39 if (dupname
&& t
->name
)
40 d
->name
= xstrdup(t
->name
);
45 type_t
*make_type(enum type_type type
)
47 type_t
*t
= alloc_type();
54 t
->qualified_name
= NULL
;
57 memset(&t
->details
, 0, sizeof(t
->details
));
58 t
->typestring_offset
= 0;
60 t
->ignore
= (parse_only
!= 0);
63 t
->user_types_registered
= FALSE
;
67 init_loc_info(&t
->loc_info
);
71 static const var_t
*find_arg(const var_list_t
*args
, const char *name
)
75 if (args
) LIST_FOR_EACH_ENTRY(arg
, args
, const var_t
, entry
)
77 if (arg
->name
&& !strcmp(name
, arg
->name
))
84 const char *type_get_name(const type_t
*type
, enum name_type name_type
)
90 return type
->c_name
? type
->c_name
: type
->name
;
97 const char *type_get_qualified_name(const type_t
*type
, enum name_type name_type
)
101 return type
->qualified_name
;
110 static size_t append_namespace(char **buf
, size_t *len
, size_t pos
, struct namespace *namespace, const char *separator
, const char *abi_prefix
)
112 int nested
= namespace && !is_global_namespace(namespace);
113 const char *name
= nested
? namespace->name
: abi_prefix
;
116 if (nested
) n
+= append_namespace(buf
, len
, pos
+ n
, namespace->parent
, separator
, abi_prefix
);
117 n
+= strappend(buf
, len
, pos
+ n
, "%s%s", name
, separator
);
121 static size_t append_namespaces(char **buf
, size_t *len
, size_t pos
, struct namespace *namespace, const char *prefix
,
122 const char *separator
, const char *suffix
, const char *abi_prefix
)
124 int nested
= namespace && !is_global_namespace(namespace);
126 n
+= strappend(buf
, len
, pos
+ n
, "%s", prefix
);
127 if (nested
) n
+= append_namespace(buf
, len
, pos
+ n
, namespace, separator
, abi_prefix
);
128 if (suffix
) n
+= strappend(buf
, len
, pos
+ n
, "%s", suffix
);
131 n
-= strlen(separator
);
137 static size_t append_pointer_stars(char **buf
, size_t *len
, size_t pos
, type_t
*type
)
140 for (; type
&& type
->type_type
== TYPE_POINTER
; type
= type_pointer_get_ref_type(type
)) n
+= strappend(buf
, len
, pos
+ n
, "*");
144 static size_t append_type_signature(char **buf
, size_t *len
, size_t pos
, type_t
*type
);
146 static size_t append_var_list_signature(char **buf
, size_t *len
, size_t pos
, var_list_t
*var_list
)
151 if (!var_list
) n
+= strappend(buf
, len
, pos
+ n
, ";");
152 else LIST_FOR_EACH_ENTRY(var
, var_list
, var_t
, entry
)
154 n
+= strappend(buf
, len
, pos
+ n
, ";");
155 n
+= append_type_signature(buf
, len
, pos
+ n
, var
->declspec
.type
);
161 static size_t append_type_signature(char **buf
, size_t *len
, size_t pos
, type_t
*type
)
167 switch (type
->type_type
)
170 if (type
->signature
) n
+= strappend(buf
, len
, pos
+ n
, "%s", type
->signature
);
173 if (!(uuid
= get_attrp(type
->attrs
, ATTR_UUID
)))
174 error_loc_info(&type
->loc_info
, "cannot compute type signature, no uuid found for type %s.\n", type
->name
);
176 n
+= strappend(buf
, len
, pos
+ n
, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
177 uuid
->Data1
, uuid
->Data2
, uuid
->Data3
,
178 uuid
->Data4
[0], uuid
->Data4
[1], uuid
->Data4
[2], uuid
->Data4
[3],
179 uuid
->Data4
[4], uuid
->Data4
[5], uuid
->Data4
[6], uuid
->Data4
[7]);
183 n
+= strappend(buf
, len
, pos
+ n
, "delegate(");
184 n
+= append_type_signature(buf
, len
, pos
+ n
, type_delegate_get_iface(type
));
185 n
+= strappend(buf
, len
, pos
+ n
, ")");
187 case TYPE_RUNTIMECLASS
:
188 n
+= strappend(buf
, len
, pos
+ n
, "rc(");
189 n
+= append_namespaces(buf
, len
, pos
+ n
, type
->namespace, "", ".", type
->name
, NULL
);
190 n
+= strappend(buf
, len
, pos
+ n
, ";");
191 n
+= append_type_signature(buf
, len
, pos
+ n
, type_runtimeclass_get_default_iface(type
, TRUE
));
192 n
+= strappend(buf
, len
, pos
+ n
, ")");
195 n
+= append_type_signature(buf
, len
, pos
+ n
, type
->details
.pointer
.ref
.type
);
198 if (!strcmp(type
->name
, "boolean")) n
+= strappend(buf
, len
, pos
+ n
, "b1");
199 else n
+= append_type_signature(buf
, len
, pos
+ n
, type
->details
.alias
.aliasee
.type
);
202 n
+= strappend(buf
, len
, pos
+ n
, "struct(");
203 n
+= append_namespaces(buf
, len
, pos
+ n
, type
->namespace, "", ".", type
->name
, NULL
);
204 n
+= append_var_list_signature(buf
, len
, pos
+ n
, type
->details
.structure
->fields
);
205 n
+= strappend(buf
, len
, pos
+ n
, ")");
208 switch (type_basic_get_type(type
))
211 case TYPE_BASIC_INT32
:
212 n
+= strappend(buf
, len
, pos
+ n
, type_basic_get_sign(type
) < 0 ? "i4" : "u4");
214 case TYPE_BASIC_INT64
:
215 n
+= strappend(buf
, len
, pos
+ n
, type_basic_get_sign(type
) < 0 ? "i8" : "u8");
217 case TYPE_BASIC_INT8
:
218 assert(type_basic_get_sign(type
) >= 0); /* signature string for signed char isn't specified */
219 n
+= strappend(buf
, len
, pos
+ n
, "u1");
221 case TYPE_BASIC_FLOAT
:
222 n
+= strappend(buf
, len
, pos
+ n
, "f4");
224 case TYPE_BASIC_DOUBLE
:
225 n
+= strappend(buf
, len
, pos
+ n
, "f8");
227 case TYPE_BASIC_INT16
:
228 case TYPE_BASIC_INT3264
:
229 case TYPE_BASIC_LONG
:
230 case TYPE_BASIC_CHAR
:
231 case TYPE_BASIC_HYPER
:
232 case TYPE_BASIC_BYTE
:
233 case TYPE_BASIC_WCHAR
:
234 case TYPE_BASIC_ERROR_STATUS_T
:
235 case TYPE_BASIC_HANDLE
:
236 error_loc_info(&type
->loc_info
, "unimplemented type signature for basic type %d.\n", type_basic_get_type(type
));
240 n
+= strappend(buf
, len
, pos
+ n
, "enum(");
241 n
+= append_namespaces(buf
, len
, pos
+ n
, type
->namespace, "", ".", type
->name
, NULL
);
242 if (is_attr(type
->attrs
, ATTR_FLAGS
)) n
+= strappend(buf
, len
, pos
+ n
, ";u4");
243 else n
+= strappend(buf
, len
, pos
+ n
, ";i4");
244 n
+= strappend(buf
, len
, pos
+ n
, ")");
247 case TYPE_ENCAPSULATED_UNION
:
254 case TYPE_APICONTRACT
:
255 error_loc_info(&type
->loc_info
, "unimplemented type signature for type %s of type %d.\n", type
->name
, type
->type_type
);
257 case TYPE_PARAMETERIZED_TYPE
:
259 assert(0); /* should not be there */
266 char *format_namespace(struct namespace *namespace, const char *prefix
, const char *separator
, const char *suffix
, const char *abi_prefix
)
270 append_namespaces(&buf
, &len
, 0, namespace, prefix
, separator
, suffix
, abi_prefix
);
274 char *format_parameterized_type_name(type_t
*type
, typeref_list_t
*params
)
276 size_t len
= 0, pos
= 0;
280 pos
+= strappend(&buf
, &len
, pos
, "%s<", type
->name
);
281 if (params
) LIST_FOR_EACH_ENTRY(ref
, params
, typeref_t
, entry
)
283 type
= type_pointer_get_root_type(ref
->type
);
284 pos
+= strappend(&buf
, &len
, pos
, "%s", type
->qualified_name
);
285 pos
+= append_pointer_stars(&buf
, &len
, pos
, ref
->type
);
286 if (list_next(params
, &ref
->entry
)) pos
+= strappend(&buf
, &len
, pos
, ",");
288 pos
+= strappend(&buf
, &len
, pos
, " >");
293 static char const *parameterized_type_shorthands
[][2] = {
294 {"Windows_CFoundation_CCollections_C", "__F"},
295 {"Windows_CFoundation_C", "__F"},
298 static char *format_parameterized_type_c_name(type_t
*type
, typeref_list_t
*params
, const char *prefix
)
300 size_t len
= 0, pos
= 0;
301 char *buf
= NULL
, *tmp
;
302 int i
, count
= params
? list_count(params
) : 0;
305 pos
+= append_namespaces(&buf
, &len
, pos
, type
->namespace, "__x_", "_C", "", use_abi_namespace
? "ABI" : NULL
);
306 pos
+= strappend(&buf
, &len
, pos
, "%s%s_%d", prefix
, type
->name
, count
);
307 if (params
) LIST_FOR_EACH_ENTRY(ref
, params
, typeref_t
, entry
)
309 type
= type_pointer_get_root_type(ref
->type
);
310 pos
+= append_namespaces(&buf
, &len
, pos
, type
->namespace, "_", "__C", type
->name
, NULL
);
313 for (i
= 0; i
< ARRAY_SIZE(parameterized_type_shorthands
); ++i
)
315 if ((tmp
= strstr(buf
, parameterized_type_shorthands
[i
][0])) &&
316 (tmp
- buf
) == strlen(use_abi_namespace
? "__x_ABI_C" : "__x_C"))
318 tmp
+= strlen(parameterized_type_shorthands
[i
][0]);
319 strcpy(buf
, parameterized_type_shorthands
[i
][1]);
320 memmove(buf
+ 3, tmp
, len
- (tmp
- buf
));
327 static char *format_parameterized_type_signature(type_t
*type
, typeref_list_t
*params
)
329 size_t len
= 0, pos
= 0;
334 if (!(uuid
= get_attrp(type
->attrs
, ATTR_UUID
)))
335 error_loc_info(&type
->loc_info
, "cannot compute type signature, no uuid found for type %s.\n", type
->name
);
337 pos
+= strappend(&buf
, &len
, pos
, "pinterface({%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
338 uuid
->Data1
, uuid
->Data2
, uuid
->Data3
,
339 uuid
->Data4
[0], uuid
->Data4
[1], uuid
->Data4
[2], uuid
->Data4
[3],
340 uuid
->Data4
[4], uuid
->Data4
[5], uuid
->Data4
[6], uuid
->Data4
[7]);
341 if (params
) LIST_FOR_EACH_ENTRY(ref
, params
, typeref_t
, entry
)
343 pos
+= strappend(&buf
, &len
, pos
, ";");
344 pos
+= append_type_signature(&buf
, &len
, pos
, ref
->type
);
346 pos
+= strappend(&buf
, &len
, pos
, ")");
351 static char *format_parameterized_type_short_name(type_t
*type
, typeref_list_t
*params
, const char *prefix
)
353 size_t len
= 0, pos
= 0;
357 pos
+= strappend(&buf
, &len
, pos
, "%s%s", prefix
, type
->name
);
358 if (params
) LIST_FOR_EACH_ENTRY(ref
, params
, typeref_t
, entry
)
360 type
= type_pointer_get_root_type(ref
->type
);
361 pos
+= strappend(&buf
, &len
, pos
, "_%s", type
->name
);
367 static char *format_parameterized_type_impl_name(type_t
*type
, typeref_list_t
*params
, const char *prefix
)
369 size_t len
= 0, pos
= 0;
374 pos
+= strappend(&buf
, &len
, pos
, "%s%s_impl<", prefix
, type
->name
);
375 if (params
) LIST_FOR_EACH_ENTRY(ref
, params
, typeref_t
, entry
)
377 type
= type_pointer_get_root_type(ref
->type
);
378 if (type
->type_type
== TYPE_RUNTIMECLASS
)
380 pos
+= strappend(&buf
, &len
, pos
, "ABI::Windows::Foundation::Internal::AggregateType<%s", type
->qualified_name
);
381 pos
+= append_pointer_stars(&buf
, &len
, pos
, ref
->type
);
382 iface
= type_runtimeclass_get_default_iface(type
, TRUE
);
383 pos
+= strappend(&buf
, &len
, pos
, ", %s", iface
->qualified_name
);
384 pos
+= append_pointer_stars(&buf
, &len
, pos
, ref
->type
);
385 pos
+= strappend(&buf
, &len
, pos
, " >");
389 pos
+= strappend(&buf
, &len
, pos
, "%s", type
->qualified_name
);
390 pos
+= append_pointer_stars(&buf
, &len
, pos
, ref
->type
);
392 if (list_next(params
, &ref
->entry
)) pos
+= strappend(&buf
, &len
, pos
, ", ");
394 pos
+= strappend(&buf
, &len
, pos
, " >");
399 type_t
*type_new_function(var_list_t
*args
)
407 arg
= LIST_ENTRY(list_head(args
), var_t
, entry
);
408 if (list_count(args
) == 1 && !arg
->name
&& arg
->declspec
.type
&& type_get_type(arg
->declspec
.type
) == TYPE_VOID
)
410 list_remove(&arg
->entry
);
416 if (args
) LIST_FOR_EACH_ENTRY(arg
, args
, var_t
, entry
)
418 if (arg
->declspec
.type
&& type_get_type(arg
->declspec
.type
) == TYPE_VOID
)
419 error_loc("argument '%s' has void type\n", arg
->name
);
423 error_loc("too many unnamed arguments\n");
430 name
[0] = i
> 26 ? 'a' + i
/ 26 : 'a' + i
;
431 name
[1] = i
> 26 ? 'a' + i
% 26 : 0;
433 unique
= !find_arg(args
, name
);
435 arg
->name
= xstrdup(name
);
442 t
= make_type(TYPE_FUNCTION
);
443 t
->details
.function
= xmalloc(sizeof(*t
->details
.function
));
444 t
->details
.function
->args
= args
;
445 t
->details
.function
->retval
= make_var(xstrdup("_RetVal"));
449 type_t
*type_new_pointer(type_t
*ref
)
451 type_t
*t
= make_type(TYPE_POINTER
);
452 t
->details
.pointer
.ref
.type
= ref
;
456 type_t
*type_new_alias(const decl_spec_t
*t
, const char *name
)
458 type_t
*a
= make_type(TYPE_ALIAS
);
460 a
->name
= xstrdup(name
);
462 a
->details
.alias
.aliasee
= *t
;
463 init_loc_info(&a
->loc_info
);
468 type_t
*type_new_array(const char *name
, const decl_spec_t
*element
, int declptr
,
469 unsigned int dim
, expr_t
*size_is
, expr_t
*length_is
)
471 type_t
*t
= make_type(TYPE_ARRAY
);
472 if (name
) t
->name
= xstrdup(name
);
473 t
->details
.array
.declptr
= declptr
;
474 t
->details
.array
.length_is
= length_is
;
476 t
->details
.array
.size_is
= size_is
;
478 t
->details
.array
.dim
= dim
;
480 t
->details
.array
.elem
= *element
;
484 type_t
*type_new_basic(enum type_basic_type basic_type
)
486 type_t
*t
= make_type(TYPE_BASIC
);
487 t
->details
.basic
.type
= basic_type
;
488 t
->details
.basic
.sign
= 0;
492 type_t
*type_new_int(enum type_basic_type basic_type
, int sign
)
494 static type_t
*int_types
[TYPE_BASIC_INT_MAX
+1][3];
496 assert(basic_type
<= TYPE_BASIC_INT_MAX
);
498 /* map sign { -1, 0, 1 } -> { 0, 1, 2 } */
499 if (!int_types
[basic_type
][sign
+ 1])
501 int_types
[basic_type
][sign
+ 1] = type_new_basic(basic_type
);
502 int_types
[basic_type
][sign
+ 1]->details
.basic
.sign
= sign
;
504 return int_types
[basic_type
][sign
+ 1];
507 type_t
*type_new_void(void)
509 static type_t
*void_type
= NULL
;
511 void_type
= make_type(TYPE_VOID
);
515 type_t
*type_new_enum(const char *name
, struct namespace *namespace, int defined
, var_list_t
*enums
)
520 t
= find_type(name
, namespace,tsENUM
);
524 t
= make_type(TYPE_ENUM
);
526 t
->namespace = namespace;
528 reg_type(t
, name
, namespace, tsENUM
);
531 if (!t
->defined
&& defined
)
533 t
->details
.enumeration
= xmalloc(sizeof(*t
->details
.enumeration
));
534 t
->details
.enumeration
->enums
= enums
;
538 error_loc("redefinition of enum %s\n", name
);
543 type_t
*type_new_struct(char *name
, struct namespace *namespace, int defined
, var_list_t
*fields
)
548 t
= find_type(name
, namespace, tsSTRUCT
);
552 t
= make_type(TYPE_STRUCT
);
554 t
->namespace = namespace;
556 reg_type(t
, name
, namespace, tsSTRUCT
);
559 if (!t
->defined
&& defined
)
561 t
->details
.structure
= xmalloc(sizeof(*t
->details
.structure
));
562 t
->details
.structure
->fields
= fields
;
566 error_loc("redefinition of struct %s\n", name
);
571 type_t
*type_new_nonencapsulated_union(const char *name
, int defined
, var_list_t
*fields
)
576 t
= find_type(name
, NULL
, tsUNION
);
580 t
= make_type(TYPE_UNION
);
583 reg_type(t
, name
, NULL
, tsUNION
);
586 if (!t
->defined
&& defined
)
588 t
->details
.structure
= xmalloc(sizeof(*t
->details
.structure
));
589 t
->details
.structure
->fields
= fields
;
593 error_loc("redefinition of union %s\n", name
);
598 type_t
*type_new_encapsulated_union(char *name
, var_t
*switch_field
, var_t
*union_field
, var_list_t
*cases
)
603 t
= find_type(name
, NULL
, tsUNION
);
607 t
= make_type(TYPE_ENCAPSULATED_UNION
);
610 reg_type(t
, name
, NULL
, tsUNION
);
612 t
->type_type
= TYPE_ENCAPSULATED_UNION
;
617 union_field
= make_var(xstrdup("tagged_union"));
618 union_field
->declspec
.type
= type_new_nonencapsulated_union(gen_name(), TRUE
, cases
);
620 t
->details
.structure
= xmalloc(sizeof(*t
->details
.structure
));
621 t
->details
.structure
->fields
= append_var(NULL
, switch_field
);
622 t
->details
.structure
->fields
= append_var(t
->details
.structure
->fields
, union_field
);
626 error_loc("redefinition of union %s\n", name
);
631 static int is_valid_bitfield_type(const type_t
*type
)
633 switch (type_get_type(type
))
638 switch (type_basic_get_type(type
))
640 case TYPE_BASIC_INT8
:
641 case TYPE_BASIC_INT16
:
642 case TYPE_BASIC_INT32
:
643 case TYPE_BASIC_INT64
:
645 case TYPE_BASIC_INT3264
:
646 case TYPE_BASIC_LONG
:
647 case TYPE_BASIC_CHAR
:
648 case TYPE_BASIC_HYPER
:
649 case TYPE_BASIC_BYTE
:
650 case TYPE_BASIC_WCHAR
:
651 case TYPE_BASIC_ERROR_STATUS_T
:
653 case TYPE_BASIC_FLOAT
:
654 case TYPE_BASIC_DOUBLE
:
655 case TYPE_BASIC_HANDLE
:
664 type_t
*type_new_bitfield(type_t
*field
, const expr_t
*bits
)
668 if (!is_valid_bitfield_type(field
))
669 error_loc("bit-field has invalid type\n");
672 error_loc("negative width for bit-field\n");
674 /* FIXME: validate bits->cval <= memsize(field) * 8 */
676 t
= make_type(TYPE_BITFIELD
);
677 t
->details
.bitfield
.field
= field
;
678 t
->details
.bitfield
.bits
= bits
;
682 static unsigned int compute_method_indexes(type_t
*iface
)
687 if (!iface
->details
.iface
)
690 if (type_iface_get_inherit(iface
))
691 idx
= compute_method_indexes(type_iface_get_inherit(iface
));
695 STATEMENTS_FOR_EACH_FUNC( stmt
, type_iface_get_stmts(iface
) )
697 var_t
*func
= stmt
->u
.var
;
698 if (!is_callas(func
->attrs
))
699 func
->func_idx
= idx
++;
705 type_t
*type_interface_declare(char *name
, struct namespace *namespace)
707 type_t
*type
= get_type(TYPE_INTERFACE
, name
, namespace, 0);
708 if (type_get_type_detect_alias(type
) != TYPE_INTERFACE
)
709 error_loc("interface %s previously not declared an interface at %s:%d\n",
710 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
714 type_t
*type_interface_define(type_t
*iface
, attr_list_t
*attrs
, type_t
*inherit
, statement_list_t
*stmts
, typeref_list_t
*requires
)
717 error_loc("interface %s already defined at %s:%d\n",
718 iface
->name
, iface
->loc_info
.input_name
, iface
->loc_info
.line_number
);
719 if (iface
== inherit
)
720 error_loc("interface %s can't inherit from itself\n",
722 iface
->attrs
= check_interface_attrs(iface
->name
, attrs
);
723 iface
->details
.iface
= xmalloc(sizeof(*iface
->details
.iface
));
724 iface
->details
.iface
->disp_props
= NULL
;
725 iface
->details
.iface
->disp_methods
= NULL
;
726 iface
->details
.iface
->stmts
= stmts
;
727 iface
->details
.iface
->inherit
= inherit
;
728 iface
->details
.iface
->disp_inherit
= NULL
;
729 iface
->details
.iface
->async_iface
= NULL
;
730 iface
->details
.iface
->requires
= requires
;
731 iface
->defined
= TRUE
;
732 compute_method_indexes(iface
);
736 type_t
*type_dispinterface_declare(char *name
)
738 type_t
*type
= get_type(TYPE_INTERFACE
, name
, NULL
, 0);
739 if (type_get_type_detect_alias(type
) != TYPE_INTERFACE
)
740 error_loc("dispinterface %s previously not declared a dispinterface at %s:%d\n",
741 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
745 type_t
*type_dispinterface_define(type_t
*iface
, attr_list_t
*attrs
, var_list_t
*props
, var_list_t
*methods
)
748 error_loc("dispinterface %s already defined at %s:%d\n",
749 iface
->name
, iface
->loc_info
.input_name
, iface
->loc_info
.line_number
);
750 iface
->attrs
= check_dispiface_attrs(iface
->name
, attrs
);
751 iface
->details
.iface
= xmalloc(sizeof(*iface
->details
.iface
));
752 iface
->details
.iface
->disp_props
= props
;
753 iface
->details
.iface
->disp_methods
= methods
;
754 iface
->details
.iface
->stmts
= NULL
;
755 iface
->details
.iface
->inherit
= find_type("IDispatch", NULL
, 0);
756 if (!iface
->details
.iface
->inherit
) error_loc("IDispatch is undefined\n");
757 iface
->details
.iface
->disp_inherit
= NULL
;
758 iface
->details
.iface
->async_iface
= NULL
;
759 iface
->details
.iface
->requires
= NULL
;
760 iface
->defined
= TRUE
;
761 compute_method_indexes(iface
);
765 type_t
*type_dispinterface_define_from_iface(type_t
*dispiface
, attr_list_t
*attrs
, type_t
*iface
)
767 if (dispiface
->defined
)
768 error_loc("dispinterface %s already defined at %s:%d\n",
769 dispiface
->name
, dispiface
->loc_info
.input_name
, dispiface
->loc_info
.line_number
);
770 dispiface
->attrs
= check_dispiface_attrs(dispiface
->name
, attrs
);
771 dispiface
->details
.iface
= xmalloc(sizeof(*dispiface
->details
.iface
));
772 dispiface
->details
.iface
->disp_props
= NULL
;
773 dispiface
->details
.iface
->disp_methods
= NULL
;
774 dispiface
->details
.iface
->stmts
= NULL
;
775 dispiface
->details
.iface
->inherit
= find_type("IDispatch", NULL
, 0);
776 if (!dispiface
->details
.iface
->inherit
) error_loc("IDispatch is undefined\n");
777 dispiface
->details
.iface
->disp_inherit
= iface
;
778 dispiface
->details
.iface
->async_iface
= NULL
;
779 dispiface
->details
.iface
->requires
= NULL
;
780 dispiface
->defined
= TRUE
;
781 compute_method_indexes(dispiface
);
785 type_t
*type_module_declare(char *name
)
787 type_t
*type
= get_type(TYPE_MODULE
, name
, NULL
, 0);
788 if (type_get_type_detect_alias(type
) != TYPE_MODULE
)
789 error_loc("module %s previously not declared a module at %s:%d\n",
790 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
794 type_t
*type_module_define(type_t
* module
, attr_list_t
*attrs
, statement_list_t
*stmts
)
797 error_loc("module %s already defined at %s:%d\n",
798 module
->name
, module
->loc_info
.input_name
, module
->loc_info
.line_number
);
799 module
->attrs
= check_module_attrs(module
->name
, attrs
);
800 module
->details
.module
= xmalloc(sizeof(*module
->details
.module
));
801 module
->details
.module
->stmts
= stmts
;
802 module
->defined
= TRUE
;
806 type_t
*type_coclass_declare(char *name
)
808 type_t
*type
= get_type(TYPE_COCLASS
, name
, NULL
, 0);
809 if (type_get_type_detect_alias(type
) != TYPE_COCLASS
)
810 error_loc("coclass %s previously not declared a coclass at %s:%d\n",
811 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
815 type_t
*type_coclass_define(type_t
*coclass
, attr_list_t
*attrs
, typeref_list_t
*ifaces
)
817 if (coclass
->defined
)
818 error_loc("coclass %s already defined at %s:%d\n",
819 coclass
->name
, coclass
->loc_info
.input_name
, coclass
->loc_info
.line_number
);
820 coclass
->attrs
= check_coclass_attrs(coclass
->name
, attrs
);
821 coclass
->details
.coclass
.ifaces
= ifaces
;
822 coclass
->defined
= TRUE
;
826 type_t
*type_runtimeclass_declare(char *name
, struct namespace *namespace)
828 type_t
*type
= get_type(TYPE_RUNTIMECLASS
, name
, namespace, 0);
829 if (type_get_type_detect_alias(type
) != TYPE_RUNTIMECLASS
)
830 error_loc("runtimeclass %s previously not declared a runtimeclass at %s:%d\n",
831 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
835 type_t
*type_runtimeclass_define(type_t
*runtimeclass
, attr_list_t
*attrs
, typeref_list_t
*ifaces
)
837 typeref_t
*ref
, *required
, *tmp
;
838 typeref_list_t
*requires
;
840 if (runtimeclass
->defined
)
841 error_loc("runtimeclass %s already defined at %s:%d\n",
842 runtimeclass
->name
, runtimeclass
->loc_info
.input_name
, runtimeclass
->loc_info
.line_number
);
843 runtimeclass
->attrs
= check_runtimeclass_attrs(runtimeclass
->name
, attrs
);
844 runtimeclass
->details
.runtimeclass
.ifaces
= ifaces
;
845 runtimeclass
->defined
= TRUE
;
846 if (!type_runtimeclass_get_default_iface(runtimeclass
, FALSE
) &&
847 !get_attrp(runtimeclass
->attrs
, ATTR_STATIC
))
848 error_loc("runtimeclass %s must have a default interface or static factory\n", runtimeclass
->name
);
850 if (ifaces
) LIST_FOR_EACH_ENTRY(ref
, ifaces
, typeref_t
, entry
)
852 /* FIXME: this should probably not be allowed, here or in coclass, */
853 /* but for now there's too many places in Wine IDL where it is to */
854 /* even print a warning. */
855 if (!(ref
->type
->defined
)) continue;
856 if (!(requires
= type_iface_get_requires(ref
->type
))) continue;
857 LIST_FOR_EACH_ENTRY(required
, requires
, typeref_t
, entry
)
861 LIST_FOR_EACH_ENTRY(tmp
, ifaces
, typeref_t
, entry
)
862 if ((found
= type_is_equal(tmp
->type
, required
->type
))) break;
865 error_loc("interface '%s' also requires interface '%s', "
866 "but runtimeclass '%s' does not implement it.\n",
867 ref
->type
->name
, required
->type
->name
, runtimeclass
->name
);
874 type_t
*type_apicontract_declare(char *name
, struct namespace *namespace)
876 type_t
*type
= get_type(TYPE_APICONTRACT
, name
, namespace, 0);
877 if (type_get_type_detect_alias(type
) != TYPE_APICONTRACT
)
878 error_loc("apicontract %s previously not declared a apicontract at %s:%d\n",
879 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
883 type_t
*type_apicontract_define(type_t
*apicontract
, attr_list_t
*attrs
)
885 if (apicontract
->defined
)
886 error_loc("apicontract %s already defined at %s:%d\n",
887 apicontract
->name
, apicontract
->loc_info
.input_name
, apicontract
->loc_info
.line_number
);
888 apicontract
->attrs
= check_apicontract_attrs(apicontract
->name
, attrs
);
889 apicontract
->defined
= TRUE
;
893 static void compute_delegate_iface_names(type_t
*delegate
, type_t
*type
, typeref_list_t
*params
)
895 type_t
*iface
= delegate
->details
.delegate
.iface
;
896 iface
->namespace = delegate
->namespace;
897 iface
->name
= strmake("I%s", delegate
->name
);
898 if (type
) iface
->c_name
= format_parameterized_type_c_name(type
, params
, "I");
899 else iface
->c_name
= format_namespace(delegate
->namespace, "__x_", "_C", iface
->name
, use_abi_namespace
? "ABI" : NULL
);
900 iface
->qualified_name
= format_namespace(delegate
->namespace, "", "::", iface
->name
, use_abi_namespace
? "ABI" : NULL
);
903 type_t
*type_delegate_declare(char *name
, struct namespace *namespace)
905 type_t
*type
= get_type(TYPE_DELEGATE
, name
, namespace, 0);
906 if (type_get_type_detect_alias(type
) != TYPE_DELEGATE
)
907 error_loc("delegate %s previously not declared a delegate at %s:%d\n",
908 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
912 type_t
*type_delegate_define(type_t
*delegate
, attr_list_t
*attrs
, statement_list_t
*stmts
)
916 if (delegate
->defined
)
917 error_loc("delegate %s already defined at %s:%d\n",
918 delegate
->name
, delegate
->loc_info
.input_name
, delegate
->loc_info
.line_number
);
920 delegate
->attrs
= check_interface_attrs(delegate
->name
, attrs
);
922 iface
= make_type(TYPE_INTERFACE
);
923 iface
->attrs
= delegate
->attrs
;
924 iface
->details
.iface
= xmalloc(sizeof(*iface
->details
.iface
));
925 iface
->details
.iface
->disp_props
= NULL
;
926 iface
->details
.iface
->disp_methods
= NULL
;
927 iface
->details
.iface
->stmts
= stmts
;
928 iface
->details
.iface
->inherit
= find_type("IUnknown", NULL
, 0);
929 if (!iface
->details
.iface
->inherit
) error_loc("IUnknown is undefined\n");
930 iface
->details
.iface
->disp_inherit
= NULL
;
931 iface
->details
.iface
->async_iface
= NULL
;
932 iface
->details
.iface
->requires
= NULL
;
933 iface
->defined
= TRUE
;
934 compute_method_indexes(iface
);
936 delegate
->details
.delegate
.iface
= iface
;
937 delegate
->defined
= TRUE
;
938 compute_delegate_iface_names(delegate
, NULL
, NULL
);
943 type_t
*type_parameterized_interface_declare(char *name
, struct namespace *namespace, typeref_list_t
*params
)
945 type_t
*type
= get_type(TYPE_PARAMETERIZED_TYPE
, name
, namespace, 0);
946 if (type_get_type_detect_alias(type
) != TYPE_PARAMETERIZED_TYPE
)
947 error_loc("pinterface %s previously not declared a pinterface at %s:%d\n",
948 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
949 type
->details
.parameterized
.type
= make_type(TYPE_INTERFACE
);
950 type
->details
.parameterized
.params
= params
;
954 type_t
*type_parameterized_interface_define(type_t
*type
, attr_list_t
*attrs
, type_t
*inherit
, statement_list_t
*stmts
, typeref_list_t
*requires
)
958 error_loc("pinterface %s already defined at %s:%d\n",
959 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
961 /* The parameterized type UUID is actually a PIID that is then used as a seed to generate
962 * a new type GUID with the rules described in:
963 * https://docs.microsoft.com/en-us/uwp/winrt-cref/winrt-type-system#parameterized-types
964 * TODO: store type signatures for generated interfaces, and generate their GUIDs
966 type
->attrs
= check_interface_attrs(type
->name
, attrs
);
968 iface
= type
->details
.parameterized
.type
;
969 iface
->details
.iface
= xmalloc(sizeof(*iface
->details
.iface
));
970 iface
->details
.iface
->disp_props
= NULL
;
971 iface
->details
.iface
->disp_methods
= NULL
;
972 iface
->details
.iface
->stmts
= stmts
;
973 iface
->details
.iface
->inherit
= inherit
;
974 iface
->details
.iface
->disp_inherit
= NULL
;
975 iface
->details
.iface
->async_iface
= NULL
;
976 iface
->details
.iface
->requires
= requires
;
978 iface
->name
= type
->name
;
980 type
->defined
= TRUE
;
984 type_t
*type_parameterized_delegate_declare(char *name
, struct namespace *namespace, typeref_list_t
*params
)
986 type_t
*type
= get_type(TYPE_PARAMETERIZED_TYPE
, name
, namespace, 0);
987 if (type_get_type_detect_alias(type
) != TYPE_PARAMETERIZED_TYPE
)
988 error_loc("pdelegate %s previously not declared a pdelegate at %s:%d\n",
989 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
990 type
->details
.parameterized
.type
= make_type(TYPE_DELEGATE
);
991 type
->details
.parameterized
.params
= params
;
995 type_t
*type_parameterized_delegate_define(type_t
*type
, attr_list_t
*attrs
, statement_list_t
*stmts
)
997 type_t
*iface
, *delegate
;
1000 error_loc("pdelegate %s already defined at %s:%d\n",
1001 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
1003 type
->attrs
= check_interface_attrs(type
->name
, attrs
);
1005 delegate
= type
->details
.parameterized
.type
;
1006 delegate
->attrs
= type
->attrs
;
1007 delegate
->details
.delegate
.iface
= make_type(TYPE_INTERFACE
);
1009 iface
= delegate
->details
.delegate
.iface
;
1010 iface
->details
.iface
= xmalloc(sizeof(*iface
->details
.iface
));
1011 iface
->details
.iface
->disp_props
= NULL
;
1012 iface
->details
.iface
->disp_methods
= NULL
;
1013 iface
->details
.iface
->stmts
= stmts
;
1014 iface
->details
.iface
->inherit
= find_type("IUnknown", NULL
, 0);
1015 if (!iface
->details
.iface
->inherit
) error_loc("IUnknown is undefined\n");
1016 iface
->details
.iface
->disp_inherit
= NULL
;
1017 iface
->details
.iface
->async_iface
= NULL
;
1018 iface
->details
.iface
->requires
= NULL
;
1020 delegate
->name
= type
->name
;
1021 compute_delegate_iface_names(delegate
, type
, type
->details
.parameterized
.params
);
1023 type
->defined
= TRUE
;
1027 type_t
*type_parameterized_type_specialize_partial(type_t
*type
, typeref_list_t
*params
)
1029 type_t
*new_type
= duptype(type
, 0);
1030 new_type
->details
.parameterized
.type
= type
;
1031 new_type
->details
.parameterized
.params
= params
;
1035 static type_t
*replace_type_parameters_in_type(type_t
*type
, typeref_list_t
*orig
, typeref_list_t
*repl
);
1037 static typeref_list_t
*replace_type_parameters_in_type_list(typeref_list_t
*list
, typeref_list_t
*orig
, typeref_list_t
*repl
)
1039 typeref_list_t
*new_list
= NULL
;
1042 if (!list
) return list
;
1044 LIST_FOR_EACH_ENTRY(ref
, list
, typeref_t
, entry
)
1046 type_t
*new_type
= replace_type_parameters_in_type(ref
->type
, orig
, repl
);
1047 new_list
= append_typeref(new_list
, make_typeref(new_type
));
1053 static var_t
*replace_type_parameters_in_var(var_t
*var
, typeref_list_t
*orig
, typeref_list_t
*repl
)
1055 var_t
*new_var
= xmalloc(sizeof(*new_var
));
1057 list_init(&new_var
->entry
);
1058 new_var
->declspec
.type
= replace_type_parameters_in_type(var
->declspec
.type
, orig
, repl
);
1062 static var_list_t
*replace_type_parameters_in_var_list(var_list_t
*var_list
, typeref_list_t
*orig
, typeref_list_t
*repl
)
1064 var_list_t
*new_var_list
;
1065 var_t
*var
, *new_var
;
1067 if (!var_list
) return var_list
;
1069 new_var_list
= xmalloc(sizeof(*new_var_list
));
1070 list_init(new_var_list
);
1072 LIST_FOR_EACH_ENTRY(var
, var_list
, var_t
, entry
)
1074 new_var
= replace_type_parameters_in_var(var
, orig
, repl
);
1075 list_add_tail(new_var_list
, &new_var
->entry
);
1078 return new_var_list
;
1081 static statement_t
*replace_type_parameters_in_statement(statement_t
*stmt
, typeref_list_t
*orig
, typeref_list_t
*repl
, loc_info_t
*loc
)
1083 statement_t
*new_stmt
= xmalloc(sizeof(*new_stmt
));
1085 list_init(&new_stmt
->entry
);
1089 case STMT_DECLARATION
:
1090 new_stmt
->u
.var
= replace_type_parameters_in_var(stmt
->u
.var
, orig
, repl
);
1094 new_stmt
->u
.type
= replace_type_parameters_in_type(stmt
->u
.type
, orig
, repl
);
1097 new_stmt
->u
.type_list
= replace_type_parameters_in_type_list(stmt
->u
.type_list
, orig
, repl
);
1102 case STMT_IMPORTLIB
:
1105 error_loc_info(loc
, "unimplemented parameterized type replacement for statement type %d.\n", stmt
->type
);
1112 static statement_list_t
*replace_type_parameters_in_statement_list(statement_list_t
*stmt_list
, typeref_list_t
*orig
, typeref_list_t
*repl
, loc_info_t
*loc
)
1114 statement_list_t
*new_stmt_list
;
1115 statement_t
*stmt
, *new_stmt
;
1117 if (!stmt_list
) return stmt_list
;
1119 new_stmt_list
= xmalloc(sizeof(*new_stmt_list
));
1120 list_init(new_stmt_list
);
1122 LIST_FOR_EACH_ENTRY(stmt
, stmt_list
, statement_t
, entry
)
1124 new_stmt
= replace_type_parameters_in_statement(stmt
, orig
, repl
, loc
);
1125 list_add_tail(new_stmt_list
, &new_stmt
->entry
);
1128 return new_stmt_list
;
1131 static type_t
*replace_type_parameters_in_type(type_t
*type
, typeref_list_t
*orig
, typeref_list_t
*repl
)
1136 if (!type
) return type
;
1137 switch (type
->type_type
)
1143 case TYPE_INTERFACE
:
1144 case TYPE_RUNTIMECLASS
:
1147 case TYPE_PARAMETER
:
1148 if (!orig
|| !repl
) return NULL
;
1149 for (o
= list_head(orig
), r
= list_head(repl
); o
&& r
;
1150 o
= list_next(orig
, o
), r
= list_next(repl
, r
))
1151 if (type
== LIST_ENTRY(o
, typeref_t
, entry
)->type
)
1152 return LIST_ENTRY(r
, typeref_t
, entry
)->type
;
1155 t
= replace_type_parameters_in_type(type
->details
.pointer
.ref
.type
, orig
, repl
);
1156 if (t
== type
->details
.pointer
.ref
.type
) return type
;
1157 type
= duptype(type
, 0);
1158 type
->details
.pointer
.ref
.type
= t
;
1161 t
= replace_type_parameters_in_type(type
->details
.alias
.aliasee
.type
, orig
, repl
);
1162 if (t
== type
->details
.alias
.aliasee
.type
) return type
;
1163 type
= duptype(type
, 0);
1164 type
->details
.alias
.aliasee
.type
= t
;
1167 t
= replace_type_parameters_in_type(type
->details
.array
.elem
.type
, orig
, repl
);
1168 if (t
== t
->details
.array
.elem
.type
) return type
;
1169 type
= duptype(type
, 0);
1170 t
->details
.array
.elem
.type
= t
;
1173 t
= duptype(type
, 0);
1174 t
->details
.function
= xmalloc(sizeof(*t
->details
.function
));
1175 t
->details
.function
->args
= replace_type_parameters_in_var_list(type
->details
.function
->args
, orig
, repl
);
1176 t
->details
.function
->retval
= replace_type_parameters_in_var(type
->details
.function
->retval
, orig
, repl
);
1178 case TYPE_PARAMETERIZED_TYPE
:
1179 t
= type
->details
.parameterized
.type
;
1180 if (t
->type_type
!= TYPE_PARAMETERIZED_TYPE
) return find_parameterized_type(type
, repl
);
1181 repl
= replace_type_parameters_in_type_list(type
->details
.parameterized
.params
, orig
, repl
);
1182 return replace_type_parameters_in_type(t
, t
->details
.parameterized
.params
, repl
);
1184 case TYPE_ENCAPSULATED_UNION
:
1188 case TYPE_APICONTRACT
:
1189 error_loc_info(&type
->loc_info
, "unimplemented parameterized type replacement for type %s of type %d.\n", type
->name
, type
->type_type
);
1196 static void type_parameterized_interface_specialize(type_t
*tmpl
, type_t
*iface
, typeref_list_t
*orig
, typeref_list_t
*repl
)
1198 iface
->details
.iface
= xmalloc(sizeof(*iface
->details
.iface
));
1199 iface
->details
.iface
->disp_methods
= NULL
;
1200 iface
->details
.iface
->disp_props
= NULL
;
1201 iface
->details
.iface
->stmts
= replace_type_parameters_in_statement_list(tmpl
->details
.iface
->stmts
, orig
, repl
, &tmpl
->loc_info
);
1202 iface
->details
.iface
->inherit
= replace_type_parameters_in_type(tmpl
->details
.iface
->inherit
, orig
, repl
);
1203 iface
->details
.iface
->disp_inherit
= NULL
;
1204 iface
->details
.iface
->async_iface
= NULL
;
1205 iface
->details
.iface
->requires
= NULL
;
1208 static void type_parameterized_delegate_specialize(type_t
*tmpl
, type_t
*delegate
, typeref_list_t
*orig
, typeref_list_t
*repl
)
1210 type_parameterized_interface_specialize(tmpl
->details
.delegate
.iface
, delegate
->details
.delegate
.iface
, orig
, repl
);
1213 type_t
*type_parameterized_type_specialize_declare(type_t
*type
, typeref_list_t
*params
)
1215 type_t
*tmpl
= type
->details
.parameterized
.type
;
1216 type_t
*new_type
= duptype(tmpl
, 0);
1218 new_type
->namespace = type
->namespace;
1219 new_type
->name
= format_parameterized_type_name(type
, params
);
1220 reg_type(new_type
, new_type
->name
, new_type
->namespace, 0);
1221 new_type
->c_name
= format_parameterized_type_c_name(type
, params
, "");
1222 new_type
->short_name
= format_parameterized_type_short_name(type
, params
, "");
1224 if (new_type
->type_type
== TYPE_DELEGATE
)
1226 new_type
->details
.delegate
.iface
= duptype(tmpl
->details
.delegate
.iface
, 0);
1227 compute_delegate_iface_names(new_type
, type
, params
);
1228 new_type
->details
.delegate
.iface
->short_name
= format_parameterized_type_short_name(type
, params
, "I");
1234 static void compute_interface_signature_uuid(type_t
*iface
)
1236 static const char winrt_pinterface_namespace
[] = {0x11,0xf4,0x7a,0xd5,0x7b,0x73,0x42,0xc0,0xab,0xae,0x87,0x8b,0x1e,0x16,0xad,0xee};
1237 static const int version
= 5;
1238 struct sha1_context ctx
;
1239 unsigned char hash
[20];
1242 if (!(uuid
= get_attrp(iface
->attrs
, ATTR_UUID
)))
1244 uuid
= xmalloc(sizeof(GUID
));
1245 iface
->attrs
= append_attr(iface
->attrs
, make_attrp(ATTR_UUID
, uuid
));
1249 sha1_update(&ctx
, winrt_pinterface_namespace
, sizeof(winrt_pinterface_namespace
));
1250 sha1_update(&ctx
, iface
->signature
, strlen(iface
->signature
));
1251 sha1_finalize(&ctx
, (ULONG
*)hash
);
1253 /* https://tools.ietf.org/html/rfc4122:
1255 * Set the four most significant bits (bits 12 through 15) of the
1256 time_hi_and_version field to the appropriate 4-bit version number
1259 * Set the two most significant bits (bits 6 and 7) of the
1260 clock_seq_hi_and_reserved to zero and one, respectively.
1263 hash
[6] = ((hash
[6] & 0x0f) | (version
<< 4));
1264 hash
[8] = ((hash
[8] & 0x3f) | 0x80);
1266 uuid
->Data1
= ((DWORD
)hash
[0] << 24)|((DWORD
)hash
[1] << 16)|((DWORD
)hash
[2] << 8)|(DWORD
)hash
[3];
1267 uuid
->Data2
= ((WORD
)hash
[4] << 8)|(WORD
)hash
[5];
1268 uuid
->Data3
= ((WORD
)hash
[6] << 8)|(WORD
)hash
[7];
1269 memcpy(&uuid
->Data4
, hash
+ 8, sizeof(*uuid
) - offsetof(GUID
, Data4
));
1272 type_t
*type_parameterized_type_specialize_define(type_t
*type
)
1274 type_t
*tmpl
= type
->details
.parameterized
.type
;
1275 typeref_list_t
*orig
= tmpl
->details
.parameterized
.params
;
1276 typeref_list_t
*repl
= type
->details
.parameterized
.params
;
1277 type_t
*iface
= find_parameterized_type(tmpl
, repl
);
1279 if (type_get_type_detect_alias(type
) != TYPE_PARAMETERIZED_TYPE
||
1280 type_get_type_detect_alias(tmpl
) != TYPE_PARAMETERIZED_TYPE
)
1281 error_loc("cannot define non-parameterized type %s, declared at %s:%d\n",
1282 type
->name
, type
->loc_info
.input_name
, type
->loc_info
.line_number
);
1284 if (type_get_type_detect_alias(tmpl
->details
.parameterized
.type
) == TYPE_INTERFACE
&&
1285 type_get_type_detect_alias(iface
) == TYPE_INTERFACE
)
1286 type_parameterized_interface_specialize(tmpl
->details
.parameterized
.type
, iface
, orig
, repl
);
1287 else if (type_get_type_detect_alias(tmpl
->details
.parameterized
.type
) == TYPE_DELEGATE
&&
1288 type_get_type_detect_alias(iface
) == TYPE_DELEGATE
)
1289 type_parameterized_delegate_specialize(tmpl
->details
.parameterized
.type
, iface
, orig
, repl
);
1291 error_loc("pinterface/pdelegate %s previously not declared a pinterface/pdelegate at %s:%d\n",
1292 iface
->name
, iface
->loc_info
.input_name
, iface
->loc_info
.line_number
);
1294 iface
->impl_name
= format_parameterized_type_impl_name(type
, repl
, "");
1295 iface
->signature
= format_parameterized_type_signature(type
, repl
);
1296 iface
->defined
= TRUE
;
1297 if (iface
->type_type
== TYPE_DELEGATE
)
1299 iface
= iface
->details
.delegate
.iface
;
1300 iface
->impl_name
= format_parameterized_type_impl_name(type
, repl
, "I");
1301 iface
->signature
= format_parameterized_type_signature(type
, repl
);
1302 iface
->defined
= TRUE
;
1304 compute_interface_signature_uuid(iface
);
1305 compute_method_indexes(iface
);
1309 int type_is_equal(const type_t
*type1
, const type_t
*type2
)
1313 if (type_get_type_detect_alias(type1
) != type_get_type_detect_alias(type2
))
1315 if (type1
->namespace != type2
->namespace)
1318 if (type1
->name
&& type2
->name
)
1319 return !strcmp(type1
->name
, type2
->name
);
1320 else if ((!type1
->name
&& type2
->name
) || (type1
->name
&& !type2
->name
))
1323 /* FIXME: do deep inspection of types to determine if they are equal */