ReactOS 0.4.16-dev-1946-g52006dd
attribute.c File Reference
#include "config.h"
#include "widl.h"
#include "typetree.h"
#include "parser.tab.h"
Include dependency graph for attribute.c:

Go to the source code of this file.

Classes

struct  allowed_attr
 

Functions

attr_tattr_int (struct location where, enum attr_type attr_type, unsigned int val)
 
attr_tattr_ptr (struct location where, enum attr_type attr_type, void *val)
 
int is_attr (const attr_list_t *list, enum attr_type attr_type)
 
int is_ptrchain_attr (const var_t *var, enum attr_type attr_type)
 
int is_aliaschain_attr (const type_t *type, enum attr_type attr_type)
 
unsigned int get_attrv (const attr_list_t *list, enum attr_type attr_type)
 
voidget_attrp (const attr_list_t *list, enum attr_type attr_type)
 
voidget_aliaschain_attrp (const type_t *type, enum attr_type attr_type)
 
static const charget_attr_display_name (enum attr_type attr_type)
 
attr_list_tappend_attr (attr_list_t *list, attr_t *attr)
 
attr_list_tappend_attr_list (attr_list_t *new_list, attr_list_t *old_list)
 
attr_list_tappend_attribs (attr_list_t *l1, attr_list_t *l2)
 
attr_list_tmap_attrs (const attr_list_t *list, map_attrs_filter_t filter)
 
attr_list_tmove_attr (attr_list_t *dst, attr_list_t *src, enum attr_type type)
 
attr_list_tcheck_apicontract_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_coclass_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_dispiface_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_enum_attrs (attr_list_t *attrs)
 
attr_list_tcheck_enum_member_attrs (attr_list_t *attrs)
 
attr_list_tcheck_field_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_function_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_interface_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_library_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_module_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_runtimeclass_attrs (const char *name, attr_list_t *attrs)
 
attr_list_tcheck_struct_attrs (attr_list_t *attrs)
 
attr_list_tcheck_typedef_attrs (attr_list_t *attrs)
 
attr_list_tcheck_union_attrs (attr_list_t *attrs)
 
void check_arg_attrs (const var_t *arg)
 

Variables

struct allowed_attr allowed_attr []
 

Function Documentation

◆ append_attr()

attr_list_t * append_attr ( attr_list_t list,
attr_t attr 
)

Definition at line 255 of file attribute.c.

256{
257 attr_t *attr_existing;
258 if (!attr) return list;
259 if (!list)
260 {
261 list = xmalloc( sizeof(*list) );
262 list_init( list );
263 }
264 if (!allowed_attr[attr->type].multiple)
265 {
266 LIST_FOR_EACH_ENTRY( attr_existing, list, attr_t, entry )
267 {
268 if (attr_existing->type != attr->type) continue;
269 warning_at( &attr->where, "duplicate attribute %s\n", get_attr_display_name( attr->type ) );
270 /* use the last attribute, like MIDL does */
271 list_remove( &attr_existing->entry );
272 break;
273 }
274 }
275 list_add_tail( list, &attr->entry );
276 return list;
277}
void * xmalloc(int size)
Definition: uimain.c:747
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
Definition: list.h:37
uint32_t entry
Definition: isohybrid.c:63
#define list
Definition: rosglue.h:35
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static const char * get_attr_display_name(enum attr_type attr_type)
Definition: attribute.c:250
void warning_at(const struct location *where, const char *s,...)
Definition: utils.c:67
struct list entry
Definition: widltypes.h:347
enum attr_type type
Definition: widltypes.h:341
unsigned int multiple
Definition: attribute.c:110
Definition: cookie.c:202

Referenced by append_attr_list(), compute_interface_signature_uuid(), and move_attr().

◆ append_attr_list()

attr_list_t * append_attr_list ( attr_list_t new_list,
attr_list_t old_list 
)

Definition at line 279 of file attribute.c.

280{
281 struct list *entry;
282
283 if (!old_list) return new_list;
284
285 while ((entry = list_head( old_list )))
286 {
289 new_list = append_attr( new_list, attr );
290 }
291 return new_list;
292}
attr_list_t * append_attr(attr_list_t *list, attr_t *attr)
Definition: attribute.c:255
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

◆ append_attribs()

attr_list_t * append_attribs ( attr_list_t l1,
attr_list_t l2 
)

Definition at line 294 of file attribute.c.

295{
296 if (!l2) return l1;
297 if (!l1 || l1 == l2) return l2;
298 list_move_tail( l1, l2 );
299 return l1;
300}
static void list_move_tail(struct list_head *list, struct list_head *head)
Definition: list.h:122

◆ attr_int()

attr_t * attr_int ( struct location  where,
enum attr_type attr_type attr_type  ,
unsigned int  val 
)

Definition at line 27 of file attribute.c.

28{
29 attr_t *a = xmalloc( sizeof(attr_t) );
30 a->where = where;
31 a->type = attr_type;
32 a->u.ival = val;
33 return a;
34}
GLuint GLfloat * val
Definition: glext.h:7180
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
attr_type
Definition: widltypes.h:72

◆ attr_ptr()

attr_t * attr_ptr ( struct location  where,
enum attr_type attr_type attr_type  ,
void val 
)

Definition at line 36 of file attribute.c.

37{
38 attr_t *a = xmalloc( sizeof(attr_t) );
39 a->where = where;
40 a->type = attr_type;
41 a->u.pval = val;
42 return a;
43}

Referenced by compute_interface_signature_uuid().

◆ check_apicontract_attrs()

attr_list_t * check_apicontract_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 337 of file attribute.c.

338{
339 const attr_t *attr;
340 if (!attrs) return NULL;
341 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
342 {
343 if (!allowed_attr[attr->type].on_apicontract)
344 error_at( &attr->where, "inapplicable attribute %s for apicontract %s\n",
346 }
347 return attrs;
348}
#define NULL
Definition: types.h:112
void error_at(const struct location *where, const char *s,...)
Definition: utils.c:35
const char * display_name
Definition: attribute.c:127
unsigned int on_apicontract
Definition: attribute.c:125
Definition: name.c:39

Referenced by type_apicontract_define().

◆ check_arg_attrs()

void check_arg_attrs ( const var_t arg)

Definition at line 530 of file attribute.c.

531{
532 const attr_t *attr;
533 if (!arg->attrs) return;
534 LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry )
535 {
536 if (!allowed_attr[attr->type].on_arg)
537 error_at( &attr->where, "inapplicable attribute %s for argument %s\n",
538 allowed_attr[attr->type].display_name, arg->name );
539 }
540}
unsigned int on_arg
Definition: attribute.c:114

◆ check_coclass_attrs()

attr_list_t * check_coclass_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 350 of file attribute.c.

351{
352 const attr_t *attr;
353 if (!attrs) return NULL;
354 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
355 {
356 if (!allowed_attr[attr->type].on_coclass)
357 error_at( &attr->where, "inapplicable attribute %s for coclass %s\n",
359 }
360 return attrs;
361}
unsigned int on_coclass
Definition: attribute.c:124

Referenced by type_coclass_define().

◆ check_dispiface_attrs()

attr_list_t * check_dispiface_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 363 of file attribute.c.

364{
365 const attr_t *attr;
366 if (!attrs) return NULL;
367 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
368 {
370 error_at( &attr->where, "inapplicable attribute %s for dispinterface %s\n",
372 }
373 return attrs;
374}
unsigned int on_dispinterface
Definition: attribute.c:122

Referenced by type_dispinterface_define(), and type_dispinterface_define_from_iface().

◆ check_enum_attrs()

attr_list_t * check_enum_attrs ( attr_list_t attrs)

Definition at line 376 of file attribute.c.

377{
378 const attr_t *attr;
379 if (!attrs) return NULL;
380 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
381 {
382 if (!allowed_attr[attr->type].on_enum)
383 error_at( &attr->where, "inapplicable attribute %s for enum\n",
385 }
386 return attrs;
387}
unsigned int on_enum
Definition: attribute.c:116

◆ check_enum_member_attrs()

attr_list_t * check_enum_member_attrs ( attr_list_t attrs)

Definition at line 389 of file attribute.c.

390{
391 const attr_t *attr;
392 if (!attrs) return NULL;
393 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
394 {
395 if (!allowed_attr[attr->type].on_enum_member)
396 error_at( &attr->where, "inapplicable attribute %s for enum member\n",
398 }
399 return attrs;
400}
unsigned int on_enum_member
Definition: attribute.c:117

◆ check_field_attrs()

attr_list_t * check_field_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 402 of file attribute.c.

403{
404 const attr_t *attr;
405 if (!attrs) return NULL;
406 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
407 {
408 if (!allowed_attr[attr->type].on_field)
409 error_at( &attr->where, "inapplicable attribute %s for field %s\n",
411 }
412 return attrs;
413}
unsigned int on_field
Definition: attribute.c:120

◆ check_function_attrs()

attr_list_t * check_function_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 415 of file attribute.c.

416{
417 const attr_t *attr;
418 if (!attrs) return NULL;
419 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
420 {
421 if (!allowed_attr[attr->type].on_function)
422 error_at( &attr->where, "inapplicable attribute %s for function %s\n",
424 }
425 return attrs;
426}
unsigned int on_function
Definition: attribute.c:113

◆ check_interface_attrs()

attr_list_t * check_interface_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 428 of file attribute.c.

429{
430 const attr_t *attr;
431 if (!attrs) return NULL;
432 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
433 {
434 if (!allowed_attr[attr->type].on_interface)
435 error_at( &attr->where, "inapplicable attribute %s for interface %s\n",
437 if (attr->type == ATTR_IMPLICIT_HANDLE)
438 {
439 const var_t *var = attr->u.pval;
440 if (type_get_type( var->declspec.type ) == TYPE_BASIC &&
441 type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE)
442 continue;
443 if (is_aliaschain_attr( var->declspec.type, ATTR_HANDLE )) continue;
444 error_at( &attr->where, "attribute %s requires a handle type in interface %s\n",
446 }
447 }
448 return attrs;
449}
const char * var
Definition: shader.c:5666
int is_aliaschain_attr(const type_t *type, enum attr_type attr_type)
Definition: attribute.c:67
unsigned int on_interface
Definition: attribute.c:112
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:118
@ TYPE_BASIC
Definition: widltypes.h:479
@ ATTR_HANDLE
Definition: widltypes.h:118
@ ATTR_IMPLICIT_HANDLE
Definition: widltypes.h:130
@ TYPE_BASIC_HANDLE
Definition: widltypes.h:310

Referenced by type_delegate_define(), type_interface_define(), type_parameterized_delegate_define(), and type_parameterized_interface_define().

◆ check_library_attrs()

attr_list_t * check_library_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 451 of file attribute.c.

452{
453 const attr_t *attr;
454 if (!attrs) return NULL;
455 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
456 {
457 if (!allowed_attr[attr->type].on_library)
458 error_at( &attr->where, "inapplicable attribute %s for library %s\n",
460 }
461 return attrs;
462}
unsigned int on_library
Definition: attribute.c:121

◆ check_module_attrs()

attr_list_t * check_module_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 464 of file attribute.c.

465{
466 const attr_t *attr;
467 if (!attrs) return NULL;
468 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
469 {
470 if (!allowed_attr[attr->type].on_module)
471 error_at( &attr->where, "inapplicable attribute %s for module %s\n",
473 }
474 return attrs;
475}
unsigned int on_module
Definition: attribute.c:123

Referenced by type_module_define().

◆ check_runtimeclass_attrs()

attr_list_t * check_runtimeclass_attrs ( const char name,
attr_list_t attrs 
)

Definition at line 477 of file attribute.c.

478{
479 const attr_t *attr;
480 if (!attrs) return NULL;
481 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
482 {
484 error_at( &attr->where, "inapplicable attribute %s for runtimeclass %s\n",
486 }
487 return attrs;
488}
unsigned int on_runtimeclass
Definition: attribute.c:126

Referenced by type_runtimeclass_define().

◆ check_struct_attrs()

attr_list_t * check_struct_attrs ( attr_list_t attrs)

Definition at line 490 of file attribute.c.

491{
492 int mask = winrt_mode ? 3 : 1;
493 const attr_t *attr;
494 if (!attrs) return NULL;
495 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
496 {
497 if (!(allowed_attr[attr->type].on_struct & mask))
498 error_at( &attr->where, "inapplicable attribute %s for struct\n",
500 }
501 return attrs;
502}
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int on_struct
Definition: attribute.c:118
int winrt_mode
Definition: widl.c:111

◆ check_typedef_attrs()

attr_list_t * check_typedef_attrs ( attr_list_t attrs)

Definition at line 504 of file attribute.c.

505{
506 const attr_t *attr;
507 if (!attrs) return NULL;
508 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
509 {
510 if (!allowed_attr[attr->type].on_type)
511 error_at( &attr->where, "inapplicable attribute %s for typedef\n",
513 }
514 return attrs;
515}
unsigned int on_type
Definition: attribute.c:115

◆ check_union_attrs()

attr_list_t * check_union_attrs ( attr_list_t attrs)

Definition at line 517 of file attribute.c.

518{
519 const attr_t *attr;
520 if (!attrs) return NULL;
521 LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry )
522 {
523 if (!allowed_attr[attr->type].on_union)
524 error_at( &attr->where, "inapplicable attribute %s for union\n",
526 }
527 return attrs;
528}
unsigned int on_union
Definition: attribute.c:119

◆ get_aliaschain_attrp()

void * get_aliaschain_attrp ( const type_t type,
enum attr_type attr_type attr_type   
)

Definition at line 96 of file attribute.c.

97{
98 for (;;)
99 {
100 if (is_attr( type->attrs, attr_type )) return get_attrp( type->attrs, attr_type );
101 if (!type_is_alias( type )) return NULL;
103 }
104}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
static type_t * type_alias_get_aliasee_type(const type_t *type)
Definition: typetree.h:373
static int type_is_alias(const type_t *type)
Definition: typetree.h:357

Referenced by write_remoting_arg(), and write_type_tfs().

◆ get_attr_display_name()

static const char * get_attr_display_name ( enum attr_type  attr_type)
static

Definition at line 250 of file attribute.c.

251{
253}

Referenced by append_attr().

◆ get_attrp()

void * get_attrp ( const attr_list_t list,
enum attr_type attr_type attr_type   
)

Definition at line 87 of file attribute.c.

88{
89 const attr_t *attr;
90 if (!list) return NULL;
92 if (attr->type == attr_type) return attr->u.pval;
93 return NULL;
94}

Referenced by add_typeinfo_block(), append_type_signature(), cmp_iid(), compute_interface_signature_uuid(), do_write_c_method_def(), encode_type(), format_parameterized_type_signature(), gen_proxy(), get_aliaschain_attrp(), get_func_handle_var(), get_user_type(), is_callas(), is_interpreted_func(), output_typelib_regscript(), save_all_changes(), set_doc_string(), set_guid(), set_help_context(), set_help_file_name(), set_help_string_context(), set_help_string_dll(), set_lcid(), type_runtimeclass_define(), write_args(), write_client_func_decl(), write_clientinterfacedecl(), write_coclass(), write_com_interface_end(), write_com_interface_start(), write_cpp_method_def(), write_descriptors(), write_enums(), write_fields(), write_function_proto(), write_function_stubs(), write_id_data_stmts(), write_implicithandledecl(), write_interface(), write_ip_tfs(), write_library(), write_method_proto(), write_parameter_conf_or_var_exprs(), write_pointer_left(), write_progid(), write_remoting_arg(), write_rpc_interface_end(), write_rpc_interface_start(), write_runtimeclass(), write_runtimeclasses_registry(), write_serverinterfacedecl(), write_stubdescriptor(), write_type_definition(), write_type_left(), write_type_tfs(), write_typelib_interface(), write_union_tfs(), and write_widl_using_macros().

◆ get_attrv()

◆ is_aliaschain_attr()

int is_aliaschain_attr ( const type_t type,
enum attr_type attr_type attr_type   
)

Definition at line 67 of file attribute.c.

68{
69 const type_t *t = type;
70 for (;;)
71 {
72 if (is_attr( t->attrs, attr_type )) return 1;
74 else return 0;
75 }
76}
GLdouble GLdouble t
Definition: gl.h:2047

Referenced by check_interface_attrs(), get_enum_fc(), is_string_type(), typegen_detect_type(), write_function_stub(), and write_remoting_arg().

◆ is_attr()

int is_attr ( const attr_list_t list,
enum attr_type attr_type attr_type   
)

◆ is_ptrchain_attr()

int is_ptrchain_attr ( const var_t var,
enum attr_type attr_type attr_type   
)

Definition at line 54 of file attribute.c.

55{
56 type_t *type = var->declspec.type;
57 if (is_attr( var->attrs, attr_type )) return 1;
58 for (;;)
59 {
60 if (is_attr( type->attrs, attr_type )) return 1;
63 else return 0;
64 }
65}
static int type_is_ptr(const type_t *type)
Definition: typetree.h:362
static type_t * type_pointer_get_ref_type(const type_t *type)
Definition: typetree.h:424

Referenced by get_required_buffer_size().

◆ map_attrs()

attr_list_t * map_attrs ( const attr_list_t list,
map_attrs_filter_t  filter 
)

Definition at line 302 of file attribute.c.

303{
304 attr_list_t *new_list;
305 const attr_t *attr;
306 attr_t *new_attr;
307
308 if (!list) return NULL;
309
310 new_list = xmalloc( sizeof(*list) );
311 list_init( new_list );
313 {
314 if (filter && !filter( new_list, attr )) continue;
315 new_attr = xmalloc( sizeof(*new_attr) );
316 *new_attr = *attr;
317 list_add_tail( new_list, &new_attr->entry );
318 }
319 return new_list;
320}
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ move_attr()

attr_list_t * move_attr ( attr_list_t dst,
attr_list_t src,
enum attr_type  type 
)

Definition at line 322 of file attribute.c.

323{
324 attr_t *attr;
325 if (!src) return dst;
327 {
328 if (attr->type == type)
329 {
330 list_remove( &attr->entry );
331 return append_attr( dst, attr );
332 }
333 }
334 return dst;
335}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Variable Documentation

◆ allowed_attr

Definition at line 130 of file attribute.c.