Commit f36fbb37 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

widl: Move attribute related functions to attribute.c.

parent f79ae4a9
...@@ -2,6 +2,7 @@ PROGRAMS = widl ...@@ -2,6 +2,7 @@ PROGRAMS = widl
PARENTSRC = ../wrc PARENTSRC = ../wrc
C_SRCS = \ C_SRCS = \
attribute.c \
client.c \ client.c \
expr.c \ expr.c \
hash.c \ hash.c \
......
...@@ -65,63 +65,6 @@ static void write_line(FILE *f, int delta, const char *fmt, ...) ...@@ -65,63 +65,6 @@ static void write_line(FILE *f, int delta, const char *fmt, ...)
fprintf(f, "\n"); fprintf(f, "\n");
} }
int is_ptrchain_attr(const var_t *var, enum attr_type t)
{
if (is_attr(var->attrs, t))
return 1;
else
{
type_t *type = var->declspec.type;
for (;;)
{
if (is_attr(type->attrs, t))
return 1;
else if (type_is_alias(type))
type = type_alias_get_aliasee_type(type);
else if (is_ptr(type))
type = type_pointer_get_ref_type(type);
else return 0;
}
}
}
int is_aliaschain_attr(const type_t *type, enum attr_type attr)
{
const type_t *t = type;
for (;;)
{
if (is_attr(t->attrs, attr))
return 1;
else if (type_is_alias(t))
t = type_alias_get_aliasee_type(t);
else return 0;
}
}
int is_attr(const attr_list_t *list, enum attr_type t)
{
const attr_t *attr;
if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry )
if (attr->type == t) return 1;
return 0;
}
void *get_attrp(const attr_list_t *list, enum attr_type t)
{
const attr_t *attr;
if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry )
if (attr->type == t) return attr->u.pval;
return NULL;
}
unsigned int get_attrv(const attr_list_t *list, enum attr_type t)
{
const attr_t *attr;
if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry )
if (attr->type == t) return attr->u.ival;
return 0;
}
static char *format_parameterized_type_args(const type_t *type, const char *prefix, const char *suffix) static char *format_parameterized_type_args(const type_t *type, const char *prefix, const char *suffix)
{ {
typeref_list_t *params; typeref_list_t *params;
......
...@@ -23,10 +23,6 @@ ...@@ -23,10 +23,6 @@
#include "typetree.h" #include "typetree.h"
extern int is_ptrchain_attr(const var_t *var, enum attr_type t);
extern int is_aliaschain_attr(const type_t *var, enum attr_type t);
extern void *get_attrp(const attr_list_t *list, enum attr_type t);
extern unsigned int get_attrv(const attr_list_t *list, enum attr_type t);
extern const char* get_name(const var_t *v); extern const char* get_name(const var_t *v);
extern void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, int declonly, int write_callconv); extern void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, int declonly, int write_callconv);
extern void write_type_right(FILE *h, type_t *t, int is_field); extern void write_type_right(FILE *h, type_t *t, int is_field);
......
...@@ -185,19 +185,6 @@ static const char *string_of_type(unsigned char type) ...@@ -185,19 +185,6 @@ static const char *string_of_type(unsigned char type)
} }
} }
static void *get_aliaschain_attrp(const type_t *type, enum attr_type attr)
{
const type_t *t = type;
for (;;)
{
if (is_attr(t->attrs, attr))
return get_attrp(t->attrs, attr);
else if (type_is_alias(t))
t = type_alias_get_aliasee_type(t);
else return NULL;
}
}
unsigned char get_basic_fc(const type_t *type) unsigned char get_basic_fc(const type_t *type)
{ {
int sign = type_basic_get_sign(type); int sign = type_basic_get_sign(type);
......
...@@ -32,13 +32,6 @@ enum name_type { ...@@ -32,13 +32,6 @@ enum name_type {
NAME_C NAME_C
}; };
attr_list_t *check_apicontract_attrs(const char *name, attr_list_t *attrs);
attr_list_t *check_coclass_attrs(const char *name, attr_list_t *attrs);
attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs);
attr_list_t *check_interface_attrs(const char *name, attr_list_t *attrs);
attr_list_t *check_module_attrs(const char *name, attr_list_t *attrs);
attr_list_t *check_runtimeclass_attrs(const char *name, attr_list_t *attrs);
type_t *find_parameterized_type(type_t *type, typeref_list_t *params); type_t *find_parameterized_type(type_t *type, typeref_list_t *params);
type_t *type_new_function(var_list_t *args); type_t *type_new_function(var_list_t *args);
...@@ -80,12 +73,9 @@ int type_is_equal(const type_t *type1, const type_t *type2); ...@@ -80,12 +73,9 @@ int type_is_equal(const type_t *type1, const type_t *type2);
const char *type_get_decl_name(const type_t *type, enum name_type name_type); const char *type_get_decl_name(const type_t *type, enum name_type name_type);
const char *type_get_name(const type_t *type, enum name_type name_type); const char *type_get_name(const type_t *type, enum name_type name_type);
char *gen_name(void); char *gen_name(void);
extern int is_attr(const attr_list_t *list, enum attr_type t);
typeref_t *make_typeref(type_t *type); typeref_t *make_typeref(type_t *type);
typeref_list_t *append_typeref(typeref_list_t *list, typeref_t *ref); typeref_list_t *append_typeref(typeref_list_t *list, typeref_t *ref);
attr_t *make_attrp(enum attr_type type, void *val);
attr_list_t *append_attr(attr_list_t *list, attr_t *attr);
/* FIXME: shouldn't need to export this */ /* FIXME: shouldn't need to export this */
type_t *duptype(type_t *t, int dupname); type_t *duptype(type_t *t, int dupname);
...@@ -356,6 +346,11 @@ static inline int type_is_alias(const type_t *type) ...@@ -356,6 +346,11 @@ static inline int type_is_alias(const type_t *type)
return type->type_type == TYPE_ALIAS; return type->type_type == TYPE_ALIAS;
} }
static inline int type_is_ptr( const type_t *type )
{
return type->type_type == TYPE_POINTER;
}
static inline const decl_spec_t *type_alias_get_aliasee(const type_t *type) static inline const decl_spec_t *type_alias_get_aliasee(const type_t *type)
{ {
assert(type_is_alias(type)); assert(type_is_alias(type));
......
...@@ -95,4 +95,42 @@ extern void write_dlldata(const statement_list_t *stmts); ...@@ -95,4 +95,42 @@ extern void write_dlldata(const statement_list_t *stmts);
extern void start_cplusplus_guard(FILE *fp); extern void start_cplusplus_guard(FILE *fp);
extern void end_cplusplus_guard(FILE *fp); extern void end_cplusplus_guard(FILE *fp);
/* attribute.c */
extern attr_t *make_attr( enum attr_type attr_type );
extern attr_t *make_attrv( enum attr_type attr_type, unsigned int val );
extern attr_t *make_attrp( enum attr_type attr_type, void *val );
extern attr_t *make_custom_attr( struct uuid *id, expr_t *pval );
extern int is_attr( const attr_list_t *list, enum attr_type attr_type );
extern int is_ptrchain_attr( const var_t *var, enum attr_type attr_type );
extern int is_aliaschain_attr( const type_t *type, enum attr_type attr_type );
extern unsigned int get_attrv( const attr_list_t *list, enum attr_type attr_type );
extern void *get_attrp( const attr_list_t *list, enum attr_type attr_type );
extern void *get_aliaschain_attrp( const type_t *type, enum attr_type attr_type );
typedef int (*map_attrs_filter_t)( attr_list_t *, const attr_t * );
extern attr_list_t *append_attr( attr_list_t *list, attr_t *attr );
extern attr_list_t *append_attr_list( attr_list_t *new_list, attr_list_t *old_list );
extern attr_list_t *append_attribs( attr_list_t *, attr_list_t * );
extern attr_list_t *map_attrs( const attr_list_t *list, map_attrs_filter_t filter );
extern attr_list_t *move_attr( attr_list_t *dst, attr_list_t *src, enum attr_type type );
extern attr_list_t *check_apicontract_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_coclass_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_dispiface_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_enum_attrs( attr_list_t *attrs );
extern attr_list_t *check_enum_member_attrs( attr_list_t *attrs );
extern attr_list_t *check_field_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_function_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_interface_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_library_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_module_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_runtimeclass_attrs( const char *name, attr_list_t *attrs );
extern attr_list_t *check_struct_attrs( attr_list_t *attrs );
extern attr_list_t *check_typedef_attrs( attr_list_t *attrs );
extern attr_list_t *check_union_attrs( attr_list_t *attrs );
extern void check_arg_attrs( const var_t *arg );
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment