ReactOS 0.4.16-dev-1948-gd260c1d
typetree.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "typetree.h"
#include "header.h"
#include "hash.h"
Include dependency graph for typetree.c:

Go to the source code of this file.

Functions

type_tduptype (type_t *t, int dupname)
 
type_tmake_type (enum type_type type)
 
static const var_tfind_arg (const var_list_t *args, const char *name)
 
const chartype_get_decl_name (const type_t *type, enum name_type name_type)
 
const chartype_get_name (const type_t *type, enum name_type name_type)
 
static size_t append_namespace (char **buf, size_t *len, size_t pos, struct namespace *namespace, const char *separator, const char *abi_prefix)
 
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)
 
static size_t append_pointer_stars (char **buf, size_t *len, size_t pos, type_t *type)
 
static size_t append_type_signature (char **buf, size_t *len, size_t pos, type_t *type)
 
static size_t append_var_list_signature (char **buf, size_t *len, size_t pos, var_list_t *var_list)
 
charformat_namespace (struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, const char *abi_prefix)
 
charformat_parameterized_type_name (type_t *type, typeref_list_t *params)
 
static charformat_parameterized_type_c_name (type_t *type, typeref_list_t *params, const char *prefix, const char *separator)
 
static charformat_parameterized_type_signature (type_t *type, typeref_list_t *params)
 
static charformat_parameterized_type_short_name (type_t *type, typeref_list_t *params, const char *prefix)
 
static charformat_parameterized_type_impl_name (type_t *type, typeref_list_t *params, const char *prefix)
 
type_ttype_new_function (var_list_t *args)
 
type_ttype_new_pointer (type_t *ref)
 
type_ttype_new_alias (const decl_spec_t *t, const char *name)
 
type_ttype_new_array (const char *name, const decl_spec_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is)
 
type_ttype_new_basic (enum type_basic_type basic_type)
 
type_ttype_new_int (enum type_basic_type basic_type, int sign)
 
type_ttype_new_void (void)
 
static void define_type (type_t *type, const struct location *where)
 
type_ttype_new_enum (const char *name, struct namespace *namespace, int defined, var_list_t *enums, const struct location *where)
 
type_ttype_new_struct (char *name, struct namespace *namespace, int defined, var_list_t *fields, const struct location *where)
 
type_ttype_new_nonencapsulated_union (const char *name, struct namespace *namespace, int defined, var_list_t *fields, const struct location *where)
 
type_ttype_new_encapsulated_union (char *name, var_t *switch_field, var_t *union_field, var_list_t *cases, const struct location *where)
 
static int is_valid_bitfield_type (const type_t *type)
 
type_ttype_new_bitfield (type_t *field, const expr_t *bits)
 
static unsigned int compute_method_indexes (type_t *iface)
 
type_ttype_interface_declare (char *name, struct namespace *namespace)
 
type_ttype_interface_define (type_t *iface, attr_list_t *attrs, type_t *inherit, statement_list_t *stmts, typeref_list_t *requires, const struct location *where)
 
type_ttype_dispinterface_declare (char *name)
 
type_ttype_dispinterface_define (type_t *iface, attr_list_t *attrs, var_list_t *props, var_list_t *methods, const struct location *where)
 
type_ttype_dispinterface_define_from_iface (type_t *dispiface, attr_list_t *attrs, type_t *iface, const struct location *where)
 
type_ttype_module_declare (char *name)
 
type_ttype_module_define (type_t *module, attr_list_t *attrs, statement_list_t *stmts, const struct location *where)
 
type_ttype_coclass_declare (char *name)
 
type_ttype_coclass_define (type_t *coclass, attr_list_t *attrs, typeref_list_t *ifaces, const struct location *where)
 
type_ttype_runtimeclass_declare (char *name, struct namespace *namespace)
 
type_ttype_runtimeclass_define (type_t *runtimeclass, attr_list_t *attrs, typeref_list_t *ifaces, const struct location *where)
 
type_ttype_apicontract_declare (char *name, struct namespace *namespace)
 
type_ttype_apicontract_define (type_t *apicontract, attr_list_t *attrs, const struct location *where)
 
static void compute_delegate_iface_names (type_t *delegate, type_t *type, typeref_list_t *params)
 
type_ttype_delegate_declare (char *name, struct namespace *namespace)
 
type_ttype_delegate_define (type_t *delegate, attr_list_t *attrs, statement_list_t *stmts, const struct location *where)
 
type_ttype_parameterized_interface_declare (char *name, struct namespace *namespace, typeref_list_t *params)
 
type_ttype_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)
 
type_ttype_parameterized_delegate_declare (char *name, struct namespace *namespace, typeref_list_t *params)
 
type_ttype_parameterized_delegate_define (type_t *type, attr_list_t *attrs, statement_list_t *stmts, const struct location *where)
 
type_ttype_parameterized_type_specialize_partial (type_t *type, typeref_list_t *params)
 
static type_treplace_type_parameters_in_type (type_t *type, typeref_list_t *orig, typeref_list_t *repl)
 
static typeref_list_treplace_type_parameters_in_type_list (typeref_list_t *list, typeref_list_t *orig, typeref_list_t *repl)
 
static var_treplace_type_parameters_in_var (var_t *var, typeref_list_t *orig, typeref_list_t *repl)
 
static var_list_treplace_type_parameters_in_var_list (var_list_t *var_list, typeref_list_t *orig, typeref_list_t *repl)
 
static statement_treplace_type_parameters_in_statement (statement_t *stmt, typeref_list_t *orig, typeref_list_t *repl, struct location *where)
 
static statement_list_treplace_type_parameters_in_statement_list (statement_list_t *stmt_list, typeref_list_t *orig, typeref_list_t *repl, struct location *where)
 
static void type_parameterized_interface_specialize (type_t *tmpl, type_t *iface, typeref_list_t *orig, typeref_list_t *repl)
 
static void type_parameterized_delegate_specialize (type_t *tmpl, type_t *delegate, typeref_list_t *orig, typeref_list_t *repl)
 
type_ttype_parameterized_type_specialize_declare (type_t *type, typeref_list_t *params)
 
static void compute_interface_signature_uuid (type_t *iface)
 
type_ttype_parameterized_type_specialize_define (type_t *type)
 
int type_is_equal (const type_t *type1, const type_t *type2)
 

Variables

static char constparameterized_type_shorthands [][2]
 

Function Documentation

◆ append_namespace()

static size_t append_namespace ( char **  buf,
size_t len,
size_t  pos,
struct namespace namespace,
const char separator,
const char abi_prefix 
)
static

Definition at line 114 of file typetree.c.

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}
static const WCHAR separator[]
Definition: asmname.c:65
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
UINT WINAPI nested(MSIHANDLE hinst)
Definition: custom.c:565
size_t strappend(char **buf, size_t *len, size_t pos, const char *fmt,...)
Definition: utils.c:120
Definition: name.c:39
struct namespace * parent
Definition: widltypes.h:470
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
static int is_global_namespace(const struct namespace *namespace)
Definition: widltypes.h:701

Referenced by append_namespace(), and append_namespaces().

◆ append_namespaces()

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 
)
static

Definition at line 125 of file typetree.c.

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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by append_type_signature(), format_namespace(), and format_parameterized_type_c_name().

◆ append_pointer_stars()

static size_t append_pointer_stars ( char **  buf,
size_t len,
size_t  pos,
type_t type 
)
static

Definition at line 141 of file typetree.c.

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}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static type_t * type_pointer_get_ref_type(const type_t *type)
Definition: typetree.h:424
@ TYPE_POINTER
Definition: widltypes.h:489

Referenced by format_parameterized_type_impl_name(), and format_parameterized_type_name().

◆ append_type_signature()

static size_t append_type_signature ( char **  buf,
size_t len,
size_t  pos,
type_t type 
)
static

Definition at line 165 of file typetree.c.

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}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define assert(x)
Definition: debug.h:53
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
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
int is_attr(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:45
void error_at(const struct location *where, const char *s,...)
Definition: utils.c:35
static size_t append_var_list_signature(char **buf, size_t *len, size_t pos, var_list_t *var_list)
Definition: typetree.c:150
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
static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t *type)
Definition: typetree.c:165
static type_t * type_runtimeclass_get_default_iface(const type_t *type, int check)
Definition: typetree.h:393
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 enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:118
@ 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_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_FLAGS
Definition: widltypes.h:116
@ 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

Referenced by append_type_signature(), append_var_list_signature(), and format_parameterized_type_signature().

◆ append_var_list_signature()

static size_t append_var_list_signature ( char **  buf,
size_t len,
size_t  pos,
var_list_t var_list 
)
static

Definition at line 150 of file typetree.c.

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}
uint32_t entry
Definition: isohybrid.c:63
const char * var
Definition: shader.c:5666
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198

Referenced by append_type_signature().

◆ compute_delegate_iface_names()

static void compute_delegate_iface_names ( type_t delegate,
type_t type,
typeref_list_t params 
)
static

Definition at line 903 of file typetree.c.

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}
GLenum const GLfloat * params
Definition: glext.h:5645
char * strmake(size_t *lenp,...)
Definition: util.c:82
const char * param_name
Definition: widltypes.h:525
union _type_t::@5357 details
const char * c_name
Definition: widltypes.h:521
const char * qualified_name
Definition: widltypes.h:523
struct delegate_details delegate
Definition: widltypes.h:519
const char * name
Definition: widltypes.h:500
static char * format_parameterized_type_c_name(type_t *type, typeref_list_t *params, const char *prefix, const char *separator)
Definition: typetree.c:313
char * format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, const char *abi_prefix)
Definition: typetree.c:279
int use_abi_namespace
Definition: widl.c:113

Referenced by type_delegate_define(), type_parameterized_delegate_define(), and type_parameterized_type_specialize_declare().

◆ compute_interface_signature_uuid()

static void compute_interface_signature_uuid ( type_t iface)
static

Definition at line 1244 of file typetree.c.

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}
void * xmalloc(int size)
Definition: uimain.c:747
#define sha1_init
Definition: compat-1.3.h:2266
#define sha1_update
Definition: compat-1.3.h:2270
static const WCHAR version[]
Definition: asmname.c:66
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 memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define offsetof(TYPE, MEMBER)
attr_t * attr_ptr(struct location where, enum attr_type attr_type, void *val)
Definition: attribute.c:36
attr_list_t * append_attr(attr_list_t *list, attr_t *attr)
Definition: attribute.c:255
void sha1_finalize(struct sha1_context *ctx, unsigned int result[5])
Definition: hash.c:703
attr_list_t * attrs
Definition: widltypes.h:503
struct location where
Definition: widltypes.h:530
const char * signature
Definition: widltypes.h:522
Definition: _hash_fun.h:40

Referenced by type_parameterized_type_specialize_define().

◆ compute_method_indexes()

static unsigned int compute_method_indexes ( type_t iface)
static

Definition at line 707 of file typetree.c.

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}
unsigned int idx
Definition: utils.c:41
GLenum func
Definition: glext.h:6028
const var_t * is_callas(const attr_list_t *a)
Definition: header.c:987
var_t * var
Definition: widltypes.h:631
union _statement_t::@5358 u
struct iface_details * iface
Definition: widltypes.h:509
unsigned int func_idx
Definition: widltypes.h:549
static unsigned int compute_method_indexes(type_t *iface)
Definition: typetree.c:707
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:208
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:201
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:684

Referenced by compute_method_indexes(), type_delegate_define(), type_dispinterface_define(), type_dispinterface_define_from_iface(), type_interface_define(), and type_parameterized_type_specialize_define().

◆ define_type()

static void define_type ( type_t type,
const struct location where 
)
static

Definition at line 536 of file typetree.c.

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}
int parse_only
#define error_loc(...)
Definition: utils.h:29

Referenced by type_apicontract_define(), type_coclass_define(), type_delegate_define(), type_dispinterface_define(), type_dispinterface_define_from_iface(), type_interface_define(), type_module_define(), type_new_encapsulated_union(), type_new_enum(), type_new_nonencapsulated_union(), type_new_struct(), type_parameterized_delegate_define(), type_parameterized_interface_define(), and type_runtimeclass_define().

◆ duptype()

type_t * duptype ( type_t t,
int  dupname 
)

Definition at line 37 of file typetree.c.

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}
char * xstrdup(const char *s)
Definition: uimain.c:768
GLdouble GLdouble t
Definition: gl.h:2047
#define d
Definition: ke_i.h:81
char * name
Definition: compiler.c:66
type_t * alloc_type(void)

Referenced by replace_type_parameters_in_type(), type_parameterized_type_specialize_declare(), and type_parameterized_type_specialize_partial().

◆ find_arg()

static const var_t * find_arg ( const var_list_t args,
const char name 
)
static

Definition at line 75 of file typetree.c.

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}
Definition: match.c:390
void * arg
Definition: msvc.h:10

Referenced by type_new_function().

◆ format_namespace()

char * format_namespace ( struct namespace namespace,
const char prefix,
const char separator,
const char suffix,
const char abi_prefix 
)

Definition at line 279 of file typetree.c.

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}

Referenced by compute_delegate_iface_names(), format_apicontract_macro(), write_runtimeclass(), write_runtimeclasses_registry(), and write_widl_using_macros().

◆ format_parameterized_type_c_name()

static char * format_parameterized_type_c_name ( type_t type,
typeref_list_t params,
const char prefix,
const char separator 
)
static

Definition at line 313 of file typetree.c.

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}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define ARRAY_SIZE(A)
Definition: main.h:20
GLuint GLuint GLsizei count
Definition: gl.h:1545
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 memmove(s1, s2, n)
Definition: mkisofs.h:881
strcpy
Definition: string.h:131
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
Definition: send.c:48
static char const * parameterized_type_shorthands[][2]
Definition: typetree.c:306
static type_t * type_pointer_get_root_type(type_t *type)
Definition: typetree.h:429

Referenced by compute_delegate_iface_names(), and type_parameterized_type_specialize_declare().

◆ format_parameterized_type_impl_name()

static char * format_parameterized_type_impl_name ( type_t type,
typeref_list_t params,
const char prefix 
)
static

Definition at line 388 of file typetree.c.

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}
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
static size_t append_pointer_stars(char **buf, size_t *len, size_t pos, type_t *type)
Definition: typetree.c:141

Referenced by type_parameterized_type_specialize_define().

◆ format_parameterized_type_name()

char * format_parameterized_type_name ( type_t type,
typeref_list_t params 
)

Definition at line 287 of file typetree.c.

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}

Referenced by type_parameterized_type_specialize_declare().

◆ format_parameterized_type_short_name()

static char * format_parameterized_type_short_name ( type_t type,
typeref_list_t params,
const char prefix 
)
static

Definition at line 371 of file typetree.c.

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}

Referenced by type_parameterized_type_specialize_declare().

◆ format_parameterized_type_signature()

static char * format_parameterized_type_signature ( type_t type,
typeref_list_t params 
)
static

Definition at line 347 of file typetree.c.

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}

Referenced by type_parameterized_type_specialize_define().

◆ is_valid_bitfield_type()

static int is_valid_bitfield_type ( const type_t type)
static

Definition at line 656 of file typetree.c.

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}
#define FALSE
Definition: types.h:117
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113

Referenced by type_new_bitfield().

◆ make_type()

type_t * make_type ( enum type_type  type)

Definition at line 48 of file typetree.c.

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}
#define memset(x, y, z)
Definition: compat.h:39
void init_location(struct location *copy, const struct location *begin, const struct location *end)

Referenced by type_delegate_define(), type_new_alias(), type_new_array(), type_new_basic(), type_new_bitfield(), type_new_encapsulated_union(), type_new_enum(), type_new_function(), type_new_nonencapsulated_union(), type_new_pointer(), type_new_struct(), type_new_void(), type_parameterized_delegate_declare(), type_parameterized_delegate_define(), and type_parameterized_interface_declare().

◆ replace_type_parameters_in_statement()

static statement_t * replace_type_parameters_in_statement ( statement_t stmt,
typeref_list_t orig,
typeref_list_t repl,
struct location where 
)
static

Definition at line 1086 of file typetree.c.

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}
static void list_init(struct list_entry *head)
Definition: list.h:51
statement_type_t type
Definition: parser.h:124
struct list entry
Definition: widltypes.h:625
typeref_list_t * type_list
Definition: widltypes.h:633
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 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
@ 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

Referenced by replace_type_parameters_in_statement_list().

◆ replace_type_parameters_in_statement_list()

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 
)
static

Definition at line 1118 of file typetree.c.

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}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
Definition: list.h:37
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

Referenced by type_parameterized_interface_specialize().

◆ replace_type_parameters_in_type()

static type_t * replace_type_parameters_in_type ( type_t type,
typeref_list_t orig,
typeref_list_t repl 
)
static

Definition at line 1138 of file typetree.c.

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}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175
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
type_t * duptype(type_t *t, int dupname)
Definition: typetree.c:37
type_t * find_parameterized_type(type_t *type, typeref_list_t *params)

Referenced by replace_type_parameters_in_statement(), replace_type_parameters_in_type(), replace_type_parameters_in_type_list(), replace_type_parameters_in_var(), and type_parameterized_interface_specialize().

◆ replace_type_parameters_in_type_list()

static typeref_list_t * replace_type_parameters_in_type_list ( typeref_list_t list,
typeref_list_t orig,
typeref_list_t repl 
)
static

Definition at line 1042 of file typetree.c.

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}
#define list
Definition: rosglue.h:35
typeref_t * make_typeref(type_t *type)
typeref_list_t * append_typeref(typeref_list_t *list, typeref_t *ref)

Referenced by replace_type_parameters_in_statement(), and replace_type_parameters_in_type().

◆ replace_type_parameters_in_var()

static var_t * replace_type_parameters_in_var ( var_t var,
typeref_list_t orig,
typeref_list_t repl 
)
static

Definition at line 1058 of file typetree.c.

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}
type_t * type
Definition: widltypes.h:334
struct list entry
Definition: widltypes.h:557
decl_spec_t declspec
Definition: widltypes.h:542

Referenced by replace_type_parameters_in_statement(), replace_type_parameters_in_type(), and replace_type_parameters_in_var_list().

◆ replace_type_parameters_in_var_list()

static var_list_t * replace_type_parameters_in_var_list ( var_list_t var_list,
typeref_list_t orig,
typeref_list_t repl 
)
static

Definition at line 1067 of file typetree.c.

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}

Referenced by replace_type_parameters_in_type().

◆ type_apicontract_declare()

type_t * type_apicontract_declare ( char name,
struct namespace namespace 
)

Definition at line 887 of file typetree.c.

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}
struct hlsl_type * get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN
Definition: utils.c:841
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:679

◆ type_apicontract_define()

type_t * type_apicontract_define ( type_t apicontract,
attr_list_t attrs,
const struct location where 
)

Definition at line 896 of file typetree.c.

897{
898 apicontract->attrs = check_apicontract_attrs(apicontract->name, attrs);
899 define_type(apicontract, where);
900 return apicontract;
901}
attr_list_t * check_apicontract_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:337
static void define_type(type_t *type, const struct location *where)
Definition: typetree.c:536

◆ type_coclass_declare()

type_t * type_coclass_declare ( char name)

Definition at line 823 of file typetree.c.

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}

◆ type_coclass_define()

type_t * type_coclass_define ( type_t coclass,
attr_list_t attrs,
typeref_list_t ifaces,
const struct location where 
)

Definition at line 832 of file typetree.c.

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}
attr_list_t * check_coclass_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:350
struct coclass_details coclass
Definition: widltypes.h:512

◆ type_delegate_declare()

type_t * type_delegate_declare ( char name,
struct namespace namespace 
)

Definition at line 915 of file typetree.c.

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}

◆ type_delegate_define()

type_t * type_delegate_define ( type_t delegate,
attr_list_t attrs,
statement_list_t stmts,
const struct location where 
)

Definition at line 924 of file typetree.c.

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}
attr_list_t * check_interface_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:428
unsigned int defined
Definition: widltypes.h:532
static void compute_delegate_iface_names(type_t *delegate, type_t *type, typeref_list_t *params)
Definition: typetree.c:903
type_t * make_type(enum type_type type)
Definition: typetree.c:48
type_t * find_type(const char *name, struct namespace *namespace, int t)

◆ type_dispinterface_declare()

type_t * type_dispinterface_declare ( char name)

Definition at line 759 of file typetree.c.

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}

◆ type_dispinterface_define()

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 at line 768 of file typetree.c.

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}
attr_list_t * check_dispiface_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:363
static const WCHAR props[]
Definition: wbemdisp.c:288

◆ type_dispinterface_define_from_iface()

type_t * type_dispinterface_define_from_iface ( type_t dispiface,
attr_list_t attrs,
type_t iface,
const struct location where 
)

Definition at line 786 of file typetree.c.

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}

◆ type_get_decl_name()

const char * type_get_decl_name ( const type_t type,
enum name_type name_type name_type   
)

Definition at line 88 of file typetree.c.

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}
name_type
Definition: typetree.h:30
@ NAME_C
Definition: typetree.h:32
@ NAME_DEFAULT
Definition: typetree.h:31

Referenced by write_type_left().

◆ type_get_name()

const char * type_get_name ( const type_t type,
enum name_type name_type name_type   
)

Definition at line 101 of file typetree.c.

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}

Referenced by write_type_left().

◆ type_interface_declare()

type_t * type_interface_declare ( char name,
struct namespace namespace 
)

Definition at line 730 of file typetree.c.

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}

◆ type_interface_define()

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 at line 739 of file typetree.c.

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}

◆ type_is_equal()

int type_is_equal ( const type_t type1,
const type_t type2 
)

Definition at line 1319 of file typetree.c.

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}

Referenced by type_runtimeclass_define().

◆ type_module_declare()

type_t * type_module_declare ( char name)

Definition at line 804 of file typetree.c.

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}

◆ type_module_define()

type_t * type_module_define ( type_t module,
attr_list_t attrs,
statement_list_t stmts,
const struct location where 
)

Definition at line 813 of file typetree.c.

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}
attr_list_t * check_module_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:464
IMAGEHLP_MODULEW64 module

◆ type_new_alias()

type_t * type_new_alias ( const decl_spec_t t,
const char name 
)

Definition at line 477 of file typetree.c.

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}
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78

◆ type_new_array()

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 at line 489 of file typetree.c.

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}

◆ type_new_basic()

type_t * type_new_basic ( enum type_basic_type  basic_type)

Definition at line 505 of file typetree.c.

506{
508 t->details.basic.type = basic_type;
509 t->details.basic.sign = 0;
510 return t;
511}

Referenced by resolve_expression(), and type_new_int().

◆ type_new_bitfield()

type_t * type_new_bitfield ( type_t field,
const expr_t bits 
)

Definition at line 689 of file typetree.c.

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}
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
Definition: parser.c:44
static int is_valid_bitfield_type(const type_t *type)
Definition: typetree.c:656

◆ type_new_encapsulated_union()

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 at line 627 of file typetree.c.

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}
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
char * gen_name(void)
var_list_t * append_var(var_list_t *list, var_t *var)
#define tsUNION
Definition: widltypes.h:664
type_t * reg_type(type_t *type, const char *name, struct namespace *namespace, int t)
var_t * make_var(char *name)

◆ type_new_enum()

type_t * type_new_enum ( const char name,
struct namespace namespace,
int  defined,
var_list_t enums,
const struct location where 
)

Definition at line 546 of file typetree.c.

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}
static const struct encodedInt enums[]
Definition: encode.c:361
#define tsENUM
Definition: widltypes.h:662

◆ type_new_function()

type_t * type_new_function ( var_list_t args)

Definition at line 420 of file typetree.c.

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}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define free
Definition: debug_ros.c:5
#define args
Definition: format.c:66
static const var_t * find_arg(const var_list_t *args, const char *name)
Definition: typetree.c:75

◆ type_new_int()

type_t * type_new_int ( enum type_basic_type  basic_type,
int  sign 
)

Definition at line 513 of file typetree.c.

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}
#define sign(x)
Definition: mapdesc.cc:613
struct basic_details basic
Definition: widltypes.h:513
type_t * type_new_basic(enum type_basic_type basic_type)
Definition: typetree.c:505
#define TYPE_BASIC_INT_MAX
Definition: widltypes.h:315

Referenced by resolve_expression().

◆ type_new_nonencapsulated_union()

type_t * type_new_nonencapsulated_union ( const char name,
struct namespace namespace,
int  defined,
var_list_t fields,
const struct location where 
)

Definition at line 600 of file typetree.c.

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}
const char * fields[10]
Definition: parser.c:313

Referenced by type_new_encapsulated_union().

◆ type_new_pointer()

type_t * type_new_pointer ( type_t ref)

Definition at line 470 of file typetree.c.

471{
473 t->details.pointer.ref.type = ref;
474 return t;
475}

Referenced by resolve_expression().

◆ type_new_struct()

type_t * type_new_struct ( char name,
struct namespace namespace,
int  defined,
var_list_t fields,
const struct location where 
)

Definition at line 573 of file typetree.c.

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}
#define tsSTRUCT
Definition: widltypes.h:663

◆ type_new_void()

type_t * type_new_void ( void  )

Definition at line 528 of file typetree.c.

529{
530 static type_t *void_type = NULL;
531 if (!void_type)
532 void_type = make_type(TYPE_VOID);
533 return void_type;
534}

◆ type_parameterized_delegate_declare()

type_t * type_parameterized_delegate_declare ( char name,
struct namespace namespace,
typeref_list_t params 
)

Definition at line 992 of file typetree.c.

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}

◆ type_parameterized_delegate_define()

type_t * type_parameterized_delegate_define ( type_t type,
attr_list_t attrs,
statement_list_t stmts,
const struct location where 
)

Definition at line 1003 of file typetree.c.

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;
1026 compute_delegate_iface_names(delegate, type, type->details.parameterized.params);
1027
1028 define_type(type, where);
1029 return type;
1030}
struct parameterized_details parameterized
Definition: widltypes.h:518

◆ type_parameterized_delegate_specialize()

static void type_parameterized_delegate_specialize ( type_t tmpl,
type_t delegate,
typeref_list_t orig,
typeref_list_t repl 
)
static

Definition at line 1217 of file typetree.c.

1218{
1219 type_parameterized_interface_specialize(tmpl->details.delegate.iface, delegate->details.delegate.iface, orig, repl);
1220}
static void type_parameterized_interface_specialize(type_t *tmpl, type_t *iface, typeref_list_t *orig, typeref_list_t *repl)
Definition: typetree.c:1204

Referenced by type_parameterized_type_specialize_define().

◆ type_parameterized_interface_declare()

type_t * type_parameterized_interface_declare ( char name,
struct namespace namespace,
typeref_list_t params 
)

Definition at line 953 of file typetree.c.

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}

◆ type_parameterized_interface_define()

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 at line 964 of file typetree.c.

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}

◆ type_parameterized_interface_specialize()

static void type_parameterized_interface_specialize ( type_t tmpl,
type_t iface,
typeref_list_t orig,
typeref_list_t repl 
)
static

Definition at line 1204 of file typetree.c.

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}
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

Referenced by type_parameterized_delegate_specialize(), and type_parameterized_type_specialize_define().

◆ type_parameterized_type_specialize_declare()

type_t * type_parameterized_type_specialize_declare ( type_t type,
typeref_list_t params 
)

Definition at line 1222 of file typetree.c.

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}
const char * short_name
Definition: widltypes.h:526
enum type_type type_type
Definition: widltypes.h:502
static char * format_parameterized_type_short_name(type_t *type, typeref_list_t *params, const char *prefix)
Definition: typetree.c:371
char * format_parameterized_type_name(type_t *type, typeref_list_t *params)
Definition: typetree.c:287

◆ type_parameterized_type_specialize_define()

type_t * type_parameterized_type_specialize_define ( type_t type)

Definition at line 1282 of file typetree.c.

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}
const char * impl_name
Definition: widltypes.h:524
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 char * format_parameterized_type_impl_name(type_t *type, typeref_list_t *params, const char *prefix)
Definition: typetree.c:388
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_parameterized_type_specialize_partial()

type_t * type_parameterized_type_specialize_partial ( type_t type,
typeref_list_t params 
)

Definition at line 1032 of file typetree.c.

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}

◆ type_runtimeclass_declare()

type_t * type_runtimeclass_declare ( char name,
struct namespace namespace 
)

Definition at line 841 of file typetree.c.

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}

◆ type_runtimeclass_define()

type_t * type_runtimeclass_define ( type_t runtimeclass,
attr_list_t attrs,
typeref_list_t ifaces,
const struct location where 
)

Definition at line 850 of file typetree.c.

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}
attr_list_t * check_runtimeclass_attrs(const char *name, attr_list_t *attrs)
Definition: attribute.c:477
struct runtimeclass_details runtimeclass
Definition: widltypes.h:517
type_t * type
Definition: widltypes.h:571
char name[1]
Definition: send.c:52
int type_is_equal(const type_t *type1, const type_t *type2)
Definition: typetree.c:1319
static typeref_list_t * type_iface_get_requires(const type_t *type)
Definition: typetree.h:215
@ ATTR_STATIC
Definition: widltypes.h:172

Variable Documentation

◆ parameterized_type_shorthands

char const* parameterized_type_shorthands[][2]
static
Initial value:
= {
{"Windows__CFoundation__CCollections__C", "__F"},
{"Windows_CFoundation_CCollections_C", "__F"},
{"Windows__CFoundation__C", "__F"},
{"Windows_CFoundation_C", "__F"},
}

Definition at line 306 of file typetree.c.

Referenced by format_parameterized_type_c_name().