mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
widl: Move the pointer referent, array element, function return type and interface inheritance properties from type_t to details structures for the appropriate types.
This commit is contained in:
parent
277e0617d5
commit
4866026d7f
@ -1240,29 +1240,6 @@ void clear_all_offsets(void)
|
||||
node->data.typestring_offset = node->data.ptrdesc = 0;
|
||||
}
|
||||
|
||||
type_t *make_type(enum type_type type, type_t *ref)
|
||||
{
|
||||
type_t *t = alloc_type();
|
||||
t->name = NULL;
|
||||
t->type_type = type;
|
||||
t->ref = ref;
|
||||
t->attrs = NULL;
|
||||
t->orig = NULL;
|
||||
memset(&t->details, 0, sizeof(t->details));
|
||||
t->typestring_offset = 0;
|
||||
t->ptrdesc = 0;
|
||||
t->ignore = (parse_only != 0);
|
||||
t->defined = FALSE;
|
||||
t->written = FALSE;
|
||||
t->user_types_registered = FALSE;
|
||||
t->tfswrite = FALSE;
|
||||
t->checked = FALSE;
|
||||
t->is_alias = FALSE;
|
||||
t->typelib_idx = -1;
|
||||
init_loc_info(&t->loc_info);
|
||||
return t;
|
||||
}
|
||||
|
||||
static type_t *type_new_enum(char *name, var_list_t *enums)
|
||||
{
|
||||
type_t *t = get_type(TYPE_ENUM, name, tsENUM);
|
||||
@ -1280,7 +1257,7 @@ static type_t *type_new_enum(char *name, var_list_t *enums)
|
||||
static type_t *type_new_struct(char *name, int defined, var_list_t *fields)
|
||||
{
|
||||
type_t *tag_type = name ? find_type(name, tsSTRUCT) : NULL;
|
||||
type_t *t = make_type(TYPE_STRUCT, NULL);
|
||||
type_t *t = make_type(TYPE_STRUCT);
|
||||
t->name = name;
|
||||
if (defined || (tag_type && tag_type->details.structure))
|
||||
{
|
||||
@ -1316,7 +1293,7 @@ static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_
|
||||
{
|
||||
type_t *t = get_type(TYPE_ENCAPSULATED_UNION, name, tsUNION);
|
||||
if (!union_field) union_field = make_var( xstrdup("tagged_union") );
|
||||
union_field->type = make_type(TYPE_UNION, NULL);
|
||||
union_field->type = make_type(TYPE_UNION);
|
||||
union_field->type->details.structure = xmalloc(sizeof(*union_field->type->details.structure));
|
||||
union_field->type->details.structure->fields = cases;
|
||||
union_field->type->defined = TRUE;
|
||||
@ -1342,9 +1319,10 @@ static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type)
|
||||
type_t *ptrchain_type;
|
||||
if (!ptrchain)
|
||||
return type;
|
||||
for (ptrchain_type = ptrchain; ptrchain_type->ref; ptrchain_type = ptrchain_type->ref)
|
||||
for (ptrchain_type = ptrchain; type_pointer_get_ref(ptrchain_type); ptrchain_type = type_pointer_get_ref(ptrchain_type))
|
||||
;
|
||||
ptrchain_type->ref = type;
|
||||
assert(ptrchain_type->type_type == TYPE_POINTER);
|
||||
ptrchain_type->details.pointer.ref = type;
|
||||
return ptrchain;
|
||||
}
|
||||
|
||||
@ -1482,8 +1460,11 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
|
||||
error_loc("%s: size_is attribute applied to illegal type\n", v->name);
|
||||
}
|
||||
|
||||
ptype = &(*ptype)->ref;
|
||||
if (*ptype == NULL)
|
||||
if (is_ptr(*ptype))
|
||||
ptype = &(*ptype)->details.pointer.ref;
|
||||
else if (is_array(*ptype))
|
||||
ptype = &(*ptype)->details.array.elem;
|
||||
else
|
||||
error_loc("%s: too many expressions in size_is attribute\n", v->name);
|
||||
}
|
||||
|
||||
@ -1505,8 +1486,11 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
|
||||
error_loc("%s: length_is attribute applied to illegal type\n", v->name);
|
||||
}
|
||||
|
||||
ptype = &(*ptype)->ref;
|
||||
if (*ptype == NULL)
|
||||
if (is_ptr(*ptype))
|
||||
ptype = &(*ptype)->details.pointer.ref;
|
||||
else if (is_array(*ptype))
|
||||
ptype = &(*ptype)->details.array.elem;
|
||||
else
|
||||
error_loc("%s: too many expressions in length_is attribute\n", v->name);
|
||||
}
|
||||
|
||||
@ -1521,7 +1505,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
|
||||
for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft))
|
||||
;
|
||||
assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION);
|
||||
ft->ref = return_type;
|
||||
ft->details.function->rettype = return_type;
|
||||
/* move calling convention attribute, if present, from pointer nodes to
|
||||
* function node */
|
||||
for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))
|
||||
@ -1876,7 +1860,7 @@ static type_t *get_type(enum type_type type, char *name, int t)
|
||||
return tp;
|
||||
}
|
||||
}
|
||||
tp = make_type(type, NULL);
|
||||
tp = make_type(type);
|
||||
tp->name = name;
|
||||
if (!name) return tp;
|
||||
return reg_type(tp, name, t);
|
||||
|
@ -41,9 +41,31 @@ type_t *duptype(type_t *t, int dupname)
|
||||
return d;
|
||||
}
|
||||
|
||||
type_t *make_type(enum type_type type)
|
||||
{
|
||||
type_t *t = alloc_type();
|
||||
t->name = NULL;
|
||||
t->type_type = type;
|
||||
t->attrs = NULL;
|
||||
t->orig = NULL;
|
||||
memset(&t->details, 0, sizeof(t->details));
|
||||
t->typestring_offset = 0;
|
||||
t->ptrdesc = 0;
|
||||
t->ignore = (parse_only != 0);
|
||||
t->defined = FALSE;
|
||||
t->written = FALSE;
|
||||
t->user_types_registered = FALSE;
|
||||
t->tfswrite = FALSE;
|
||||
t->checked = FALSE;
|
||||
t->is_alias = FALSE;
|
||||
t->typelib_idx = -1;
|
||||
init_loc_info(&t->loc_info);
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_function(var_list_t *args)
|
||||
{
|
||||
type_t *t = make_type(TYPE_FUNCTION, NULL);
|
||||
type_t *t = make_type(TYPE_FUNCTION);
|
||||
t->details.function = xmalloc(sizeof(*t->details.function));
|
||||
t->details.function->args = args;
|
||||
t->details.function->idx = -1;
|
||||
@ -52,8 +74,9 @@ type_t *type_new_function(var_list_t *args)
|
||||
|
||||
type_t *type_new_pointer(type_t *ref, attr_list_t *attrs)
|
||||
{
|
||||
type_t *t = make_type(TYPE_POINTER, ref);
|
||||
type_t *t = make_type(TYPE_POINTER);
|
||||
t->details.pointer.fc = pointer_default;
|
||||
t->details.pointer.ref = ref;
|
||||
t->attrs = attrs;
|
||||
return t;
|
||||
}
|
||||
@ -75,7 +98,7 @@ type_t *type_new_alias(type_t *t, const char *name)
|
||||
|
||||
type_t *type_new_module(const char *name)
|
||||
{
|
||||
type_t *type = make_type(TYPE_MODULE, NULL);
|
||||
type_t *type = make_type(TYPE_MODULE);
|
||||
type->name = name;
|
||||
/* FIXME: register type to detect multiple definitions */
|
||||
return type;
|
||||
@ -83,7 +106,7 @@ type_t *type_new_module(const char *name)
|
||||
|
||||
type_t *type_new_coclass(const char *name)
|
||||
{
|
||||
type_t *c = make_type(TYPE_COCLASS, NULL);
|
||||
type_t *c = make_type(TYPE_COCLASS);
|
||||
c->name = name;
|
||||
/* FIXME: register type to detect multiple definitions */
|
||||
return c;
|
||||
@ -93,7 +116,7 @@ type_t *type_new_coclass(const char *name)
|
||||
type_t *type_new_array(const char *name, type_t *element, int declptr,
|
||||
unsigned int dim, expr_t *size_is, expr_t *length_is)
|
||||
{
|
||||
type_t *t = make_type(TYPE_ARRAY, element);
|
||||
type_t *t = make_type(TYPE_ARRAY);
|
||||
if (name) t->name = xstrdup(name);
|
||||
t->details.array.declptr = declptr;
|
||||
t->details.array.length_is = length_is;
|
||||
@ -101,12 +124,13 @@ type_t *type_new_array(const char *name, type_t *element, int declptr,
|
||||
t->details.array.size_is = size_is;
|
||||
else
|
||||
t->details.array.dim = dim;
|
||||
t->details.array.elem = element;
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_basic(enum type_basic_type basic_type)
|
||||
{
|
||||
type_t *t = make_type(TYPE_BASIC, NULL);
|
||||
type_t *t = make_type(TYPE_BASIC);
|
||||
t->details.basic.type = basic_type;
|
||||
t->details.basic.sign = 0;
|
||||
return t;
|
||||
@ -131,7 +155,7 @@ type_t *type_new_void(void)
|
||||
{
|
||||
static type_t *void_type = NULL;
|
||||
if (!void_type)
|
||||
void_type = make_type(TYPE_VOID, NULL);
|
||||
void_type = make_type(TYPE_VOID);
|
||||
return void_type;
|
||||
}
|
||||
|
||||
@ -160,23 +184,23 @@ static int compute_method_indexes(type_t *iface)
|
||||
|
||||
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
|
||||
{
|
||||
iface->ref = inherit;
|
||||
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
|
||||
iface->details.iface->disp_props = NULL;
|
||||
iface->details.iface->disp_methods = NULL;
|
||||
iface->details.iface->stmts = stmts;
|
||||
iface->details.iface->inherit = inherit;
|
||||
iface->defined = TRUE;
|
||||
compute_method_indexes(iface);
|
||||
}
|
||||
|
||||
void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods)
|
||||
{
|
||||
iface->ref = find_type("IDispatch", 0);
|
||||
if (!iface->ref) error_loc("IDispatch is undefined\n");
|
||||
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
|
||||
iface->details.iface->disp_props = props;
|
||||
iface->details.iface->disp_methods = methods;
|
||||
iface->details.iface->stmts = NULL;
|
||||
iface->details.iface->inherit = find_type("IDispatch", 0);
|
||||
if (!iface->details.iface->inherit) error_loc("IDispatch is undefined\n");
|
||||
iface->defined = TRUE;
|
||||
compute_method_indexes(iface);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ static inline type_t *type_function_get_rettype(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_FUNCTION);
|
||||
return type->ref;
|
||||
return type->details.function->rettype;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_enum_get_values(const type_t *type)
|
||||
@ -167,7 +167,7 @@ static inline type_t *type_iface_get_inherit(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_INTERFACE);
|
||||
return type->ref;
|
||||
return type->details.iface->inherit;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_dispiface_get_props(const type_t *type)
|
||||
@ -254,7 +254,7 @@ static inline type_t *type_array_get_element(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->ref;
|
||||
return type->details.array.elem;
|
||||
}
|
||||
|
||||
static inline int type_array_is_decl_as_ptr(const type_t *type)
|
||||
@ -286,7 +286,7 @@ static inline type_t *type_pointer_get_ref(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_POINTER);
|
||||
return type->ref;
|
||||
return type->details.pointer.ref;
|
||||
}
|
||||
|
||||
#endif /* WIDL_TYPE_TREE_H */
|
||||
|
@ -295,6 +295,7 @@ struct enumeration_details
|
||||
struct func_details
|
||||
{
|
||||
var_list_t *args;
|
||||
struct _type_t *rettype;
|
||||
int idx;
|
||||
};
|
||||
|
||||
@ -303,6 +304,7 @@ struct iface_details
|
||||
statement_list_t *stmts;
|
||||
func_list_t *disp_methods;
|
||||
var_list_t *disp_props;
|
||||
struct _type_t *inherit;
|
||||
};
|
||||
|
||||
struct module_details
|
||||
@ -313,9 +315,10 @@ struct module_details
|
||||
|
||||
struct array_details
|
||||
{
|
||||
unsigned int dim;
|
||||
expr_t *size_is;
|
||||
expr_t *length_is;
|
||||
struct _type_t *elem;
|
||||
unsigned int dim;
|
||||
unsigned int declptr; /* if declared as a pointer */
|
||||
};
|
||||
|
||||
@ -332,6 +335,7 @@ struct basic_details
|
||||
|
||||
struct pointer_details
|
||||
{
|
||||
struct _type_t *ref;
|
||||
unsigned char fc;
|
||||
};
|
||||
|
||||
@ -355,7 +359,6 @@ enum type_type
|
||||
struct _type_t {
|
||||
const char *name;
|
||||
enum type_type type_type;
|
||||
struct _type_t *ref;
|
||||
attr_list_t *attrs;
|
||||
union
|
||||
{
|
||||
@ -502,7 +505,7 @@ int is_union(unsigned char tc);
|
||||
|
||||
var_t *find_const(const char *name, int f);
|
||||
type_t *find_type(const char *name, int t);
|
||||
type_t *make_type(enum type_type type, type_t *ref);
|
||||
type_t *make_type(enum type_type type);
|
||||
|
||||
void init_loc_info(loc_info_t *);
|
||||
|
||||
|
@ -1032,8 +1032,7 @@ static int encode_type(
|
||||
|
||||
static void dump_type(type_t *t)
|
||||
{
|
||||
chat("dump_type: %p name %s type %d ref %p attrs %p\n", t, t->name, type_get_type(t), t->ref, t->attrs);
|
||||
if(t->ref) dump_type(t->ref);
|
||||
chat("dump_type: %p name %s type %d attrs %p\n", t, t->name, type_get_type(t), t->attrs);
|
||||
}
|
||||
|
||||
static int encode_var(
|
||||
@ -1057,8 +1056,8 @@ static int encode_var(
|
||||
if (!decoded_size) decoded_size = &scratch;
|
||||
*decoded_size = 0;
|
||||
|
||||
chat("encode_var: var %p type %p type->name %s type->ref %p\n",
|
||||
var, type, type->name ? type->name : "NULL", type->ref);
|
||||
chat("encode_var: var %p type %p type->name %s\n",
|
||||
var, type, type->name ? type->name : "NULL");
|
||||
|
||||
if (is_array(type) && !type_array_is_decl_as_ptr(type)) {
|
||||
int num_dims, elements = 1, arrayoffset;
|
||||
|
Loading…
Reference in New Issue
Block a user