14 #error This library is not supported with this compiler. Use any compiler with __COUNTER__ macro declared 15 #include <metaref_not_supported_with_no___COUNTER__> 18 #ifndef EXOTIC_METAREF_STRUCT 19 #ifdef __STRUCT_FILE__ 20 #ifndef __STRUCT_NAME__ 21 #error You need to declare the struct name value before including metaref.h 23 #define EXOTIC_METAREF_STRUCT 26 #ifndef __STDC_VERSION__ 27 #error This library is not supported in C version less than C99. 28 #include <metaref_not_supported_in_standard_less_than_C99> 33 #if __cplusplus <= 199711L 34 #error This library is not supported in C++ version less than C++11. 35 #include <metaref_not_supported_in_standard_less_than_C++11> 39 #ifdef METAREF_PREPROCESSING_DONE 40 #undef METAREF_PREPROCESSING_DONE 47 #ifndef METAREF_FIELD_PTR_ADDRESS_TYPE 48 #define METAREF_FIELD_PTR_ADDRESS_TYPE void ** 51 #ifndef METAREF_STRUCTS_DECLARED 52 #define METAREF_STRUCTS_DECLARED 57 #define METAREF_CONCAT_IMPL(x,y ) x##y 62 #define METAREF_CONCAT(x,y) METAREF_CONCAT_IMPL(x,y) 69 typedef void *(*func_ptr_)(
const void *);
71 typedef enum metaref_annotation_type_ {
72 METAREF_ANNOTATION_STRING,
73 METAREF_ANNOTATION_INT,
74 METAREF_ANNOTATION_LONG,
75 METAREF_ANNOTATION_FUNCTION,
76 METAREF_ANNOTATION_TERMINATOR
83 typedef struct annotation_struct_ {
84 const size_t line_num;
85 const AnnotationType type;
87 const char *str_value;
135 typedef struct field_struct_ {
136 const size_t line_num;
139 METAREF_FIELD_PTR_ADDRESS_TYPE ptr_address;
140 const Annotation annotations[10];
146 typedef struct metaref_struct_ {
148 const char *file_name;
150 const Field *fields_array;
151 const Annotation *annotations_array;
157 static unsigned metaref_str_equals(
const char* arg,
const char* arg1) {
159 if (arg == NULL || arg1 == NULL) {
163 if (arg[i] ==
'\0' && arg1[i] ==
'\0') {
166 if (arg[i] != arg1[i]) {
174 static Annotation
inline metaref_get_field_annotation(Field field,
const char *name) {
175 for(
int _iter_index = 0; field.annotations[_iter_index].line_num != 0; ++_iter_index) {
176 if (metaref_str_equals(field.annotations[_iter_index].name, name)) {
177 return field.annotations[_iter_index];
180 Annotation METAREF_sub_annotation__ = {0, METAREF_ANNOTATION_TERMINATOR, NULL, NULL, -1, -1, NULL};
181 return METAREF_sub_annotation__ ;
184 static Field metaref_struct_get_field(Struct *the_struct,
const char *name) {
185 for(
size_t i = 0; the_struct->fields_array[i].type != NULL; ++i) {
186 if (metaref_str_equals(the_struct->fields_array[i].name, name)) {
187 return the_struct->fields_array[i];
190 Field METAREF_sub_fields1__ = {0, NULL, NULL, NULL, {}};
191 return METAREF_sub_fields1__;
220 #define STRUCT(struct_name, ...) \ 221 typedef struct METAREF_##struct_name { \ 223 Struct *metaref_obj; \ 229 #define FIELD(annotations, type_v, identifier) \ 250 #define _S(annotation_name, annotation_value) 271 #define _I(annotation_name, annotation_value) 292 #define _L(annotation_name, annotation_value) 319 #define _F(annotation_name, annotation_value) 321 #define _FS(annotation_name, annotation_value) 322 #define _FI(annotation_name, annotation_value) 323 #define _FL(annotation_name, annotation_value) 324 #define _FF(annotation_name, annotation_value) 326 #include __STRUCT_FILE__ 346 #define STRUCT(struct_name, ...) 348 #define FIELD(annotations, type_v, identifier) 350 #define _S(annotation_name, annotation_value)\ 351 {__LINE__, METAREF_ANNOTATION_STRING, #annotation_name, annotation_value, -1, -1, NULL}, 353 #define _I(annotation_name, annotation_value)\ 354 {__LINE__, METAREF_ANNOTATION_INT, #annotation_name, NULL, annotation_value, -1, NULL}, 356 #define _L(annotation_name, annotation_value)\ 357 {__LINE__, METAREF_ANNOTATION_LONG, #annotation_name, NULL, -1, annotation_value, NULL}, 359 #define _F(annotation_name, annotation_value)\ 360 {__LINE__, METAREF_ANNOTATION_FUNCTION, #annotation_name, NULL, -1, -1, annotation_value}, 362 #define _FS(annotation_name, annotation_value) 364 #define _FI(annotation_name, annotation_value) 366 #define _FL(annotation_name, annotation_value) 368 #define _FF(annotation_name, annotation_value) 373 const static Annotation METAREF_CONCAT(METAREF_, METAREF_CONCAT(__STRUCT_NAME__, _annotations))[] = {
374 #include __STRUCT_FILE__ 375 {0, METAREF_ANNOTATION_TERMINATOR, NULL, NULL, -1, -1, NULL}
399 #define STRUCT(struct_name, ...) \ 400 static Field METAREF_##struct_name##_fields[] = { \ 402 {0, NULL, NULL, NULL, {}}, \ 405 #define FIELD(annotations, type_v, identifier) \ 406 {__LINE__, #type_v, #identifier, NULL, annotations}, 408 #define _S(annotation_name, annotation_value) 410 #define _I(annotation_name, annotation_value) 412 #define _L(annotation_name, annotation_value) 414 #define _F(annotation_name, annotation_value) 416 #define _FS(annotation_name, annotation_value)\ 417 {__LINE__, METAREF_ANNOTATION_STRING, #annotation_name, annotation_value, -1, -1, NULL}, 419 #define _FI(annotation_name, annotation_value)\ 420 {__LINE__, METAREF_ANNOTATION_INT, #annotation_name, NULL, annotation_value, -1, NULL}, 422 #define _FL(annotation_name, annotation_value)\ 423 {__LINE__, METAREF_ANNOTATION_LONG, #annotation_name, NULL, -1, annotation_value, NULL}, 425 #define _FF(annotation_name, annotation_value)\ 426 {__LINE__, METAREF_ANNOTATION_FUNCTION, #annotation_name, NULL, -1, -1, annotation_value}, 428 #include __STRUCT_FILE__ 447 #define STRUCT(struct_name, ...) \ 448 Annotation METAREF_##struct_name##_get_annotation(const char *name) {\ 449 for(size_t i = 0; METAREF_##struct_name##_annotations[i].type != METAREF_ANNOTATION_TERMINATOR; ++i) {\ 450 if (metaref_str_equals(METAREF_##struct_name##_annotations[i].name, name)) {\ 451 return METAREF_##struct_name##_annotations[i];\ 454 Annotation METAREF_sub_fields__ = {0, METAREF_ANNOTATION_TERMINATOR, NULL, NULL, -1, -1, NULL};\ 455 return METAREF_sub_fields__;\ 457 Field METAREF_##struct_name##_get_field_name(const char *name) {\ 458 for(size_t i = 0; METAREF_##struct_name##_fields[i].type != NULL; ++i) {\ 459 if (metaref_str_equals(METAREF_##struct_name##_fields[i].name, name)) {\ 460 return METAREF_##struct_name##_fields[i];\ 463 Field METAREF_sub_fields1__ = {0, NULL, NULL, NULL, {}};\ 464 return METAREF_sub_fields1__;\ 467 #define FIELD(annotations, type_v, identifier) 469 #define _S(annotation_name, annotation_value) 471 #define _I(annotation_name, annotation_value) 473 #define _L(annotation_name, annotation_value) 475 #define _F(annotation_name, annotation_value) 477 #define _FS(annotation_name, annotation_value) 479 #define _FI(annotation_name, annotation_value) 481 #define _FL(annotation_name, annotation_value) 483 #define _FF(annotation_name, annotation_value) 485 #include __STRUCT_FILE__ 504 #define STRUCT(struct_name, ...) \ 505 Struct *METAREF_##struct_name##_Struct; \ 506 Struct *METAREF_##struct_name##_Struct_init(const struct_name *the_meta_struct) { \ 507 if (METAREF_##struct_name##_Struct == NULL) {\ 508 for(size_t i = 0; METAREF_##struct_name##_fields[i].type != NULL && the_meta_struct != NULL; ++i) {\ 509 Field metaref_field___ = METAREF_##struct_name##_fields[i];\ 511 METAREF_##struct_name##_fields[i].ptr_address = metaref_field___.ptr_address;\ 513 METAREF_##struct_name##_Struct = (Struct *) malloc(sizeof(Struct));\ 514 METAREF_##struct_name##_Struct->name = #struct_name;\ 515 METAREF_##struct_name##_Struct->file_name = __FILE__;\ 516 METAREF_##struct_name##_Struct->line_num = __LINE__;\ 517 METAREF_##struct_name##_Struct->fields_array = METAREF_##struct_name##_fields;\ 518 METAREF_##struct_name##_Struct->annotations_array = METAREF_##struct_name##_annotations;\ 520 return METAREF_##struct_name##_Struct;\ 523 #define FIELD(annotations, type_v, identifier) \ 524 if (metaref_str_equals(metaref_field___.name, #identifier) == 1) {\ 525 metaref_field___.ptr_address = (METAREF_FIELD_PTR_ADDRESS_TYPE)&the_meta_struct->identifier;\ 528 #define _S(annotation_name, annotation_value) 530 #define _I(annotation_name, annotation_value) 532 #define _L(annotation_name, annotation_value) 534 #define _F(annotation_name, annotation_value) 536 #define _FS(annotation_name, annotation_value) 538 #define _FI(annotation_name, annotation_value) 540 #define _FL(annotation_name, annotation_value) 542 #define _FF(annotation_name, annotation_value) 544 #include __STRUCT_FILE__ 562 #define STRUCT(struct_name, ...) 564 #define FIELD(annotations, type_v, identifier) 566 #define _S(annotation_name, annotation_value) 568 #define _I(annotation_name, annotation_value) 570 #define _L(annotation_name, annotation_value) 572 #define _F(annotation_name, annotation_value) 574 #define _FS(annotation_name, annotation_value) 576 #define _FI(annotation_name, annotation_value) 578 #define _FL(annotation_name, annotation_value) 580 #define _FF(annotation_name, annotation_value) 582 #ifdef __STRUCT_FILE__ 583 #include __STRUCT_FILE__ 584 #undef __STRUCT_FILE__ 585 #undef __STRUCT_NAME__ 588 #ifdef METAREF_FIELD_PTR_ADDRESS_TYPE 589 #undef METAREF_FIELD_PTR_ADDRESS_TYPE 592 #ifndef METAREF_HELPER_MACROS 593 #define METAREF_HELPER_MACROS 601 #define METAREF_GET_NAME(struct_name) METAREF_##struct_name 628 #define METAREF_GET_STRUCT(struct_name, struct_object)\ 629 METAREF_##struct_name##_Struct_init(struct_object); 639 #define METAREF_FREE_STRUCT(struct_name)\ 640 if (METAREF_##struct_name##_Struct != NULL) {\ 641 free(METAREF_##struct_name##_Struct);\ 642 METAREF_##struct_name##_Struct = NULL;\ 651 #define METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name)\ 652 METAREF_##struct_name##_get_annotation(annotation_name) 660 #define METAREF_STRUCT_GET_ANNOTATION2(struct_name, annotation_name)\ 661 METAREF_STRUCT_GET_ANNOTATION(struct_name, #annotation_name) 669 #define METAREF_STRUCT_HAS_ANNOTATION(struct_name, annotation_name)\ 670 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type != METAREF_ANNOTATION_TERMINATOR) 680 #define METAREF_STRUCT_ANNOTATION_IS_STRING(struct_name, annotation_name)\ 681 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_STRING) 690 #define METAREF_STRUCT_ANNOTATION_STR_VALUE(struct_name, annotation_name)\ 691 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_STRING ? \ 692 METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).str_value\ 703 #define METAREF_STRUCT_ANNOTATION_IS_INT(struct_name, annotation_name)\ 704 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_INT) 713 #define METAREF_STRUCT_ANNOTATION_INT_VALUE(struct_name, annotation_name)\ 714 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_INT ? \ 715 METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).int_value\ 726 #define METAREF_STRUCT_ANNOTATION_IS_LONG(struct_name, annotation_name)\ 727 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_LONG) 736 #define METAREF_STRUCT_ANNOTATION_LONG_VALUE(struct_name, annotation_name)\ 737 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_LONG ? \ 738 METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).long_value\ 749 #define METAREF_STRUCT_ANNOTATION_IS_FUNCTION(struct_name, annotation_name)\ 750 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_FUNCTION) 759 #define METAREF_STRUCT_ANNOTATION_FUNC_VALUE(struct_name, annotation_name)\ 760 (METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).type == METAREF_ANNOTATION_FUNCTION ? \ 761 METAREF_STRUCT_GET_ANNOTATION(struct_name, annotation_name).func_ptr\ 771 #define FOREACH_STRUCT_ANNOTATION(struct_name, annotation, body)\ 772 for(size_t i = 0; METAREF_##struct_name##_annotations[i].type != METAREF_ANNOTATION_TERMINATOR; ++i) {\ 773 Annotation annotation = METAREF_##struct_name##_annotations[i]; \ 784 #define FOREACH_ANNOTATION(the_struct, annotation, body)\ 785 for(size_t i = 0; the_struct->annotations_array[i].type != METAREF_ANNOTATION_TERMINATOR; ++i) {\ 786 Annotation annotation = the_struct->annotations_array[i]; \ 798 #define FOREACH_STRUCT_ANNOTATION_INDEX(struct_name, index, annotation, body)\ 799 for(size_t i = 0; METAREF_##struct_name##_annotations[i].type != METAREF_ANNOTATION_TERMINATOR; ++i) {\ 801 Annotation annotation = METAREF_##struct_name##_annotations[index]; \ 813 #define FOREACH_ANNOTATION_INDEX(the_struct, index, annotation, body)\ 814 for(size_t i = 0; the_struct->annotations_array[i].type != METAREF_ANNOTATION_TERMINATOR; ++i) {\ 816 Annotation annotation = the_struct->annotations_array[index]; \ 825 #define METAREF_STRUCT_FIELD_COUNT(struct_name)\ 826 ((sizeof(METAREF_##struct_name##_fields) / sizeof(METAREF_##struct_name##_fields[0])) - 1) 834 #define METAREF_GET_STRUCT_FIELD(struct_name, field_name)\ 835 METAREF_##struct_name##_get_field_name(field_name) 843 #define METAREF_HAS_FIELD(struct_name, field_name)\ 844 (METAREF_GET_STRUCT_FIELD(struct_name, field_name).type != NULL) 853 #define FOREACH_STRUCT_FIELD(struct_name, field, body)\ 854 for(size_t i = 0; METAREF_##struct_name##_fields[i].type != NULL; ++i) {\ 855 Field field = METAREF_##struct_name##_fields[i]; \ 867 #define FOREACH_STRUCT_FIELD_INDEX(struct_name, index, field, body)\ 868 for(size_t i = 0; METAREF_##struct_name##_fields[i].type != NULL; ++i) {\ 870 Field field = METAREF_##struct_name##_fields[index]; \ 897 #define METAREF_FIELD_IS_CHAR_ARRAY(field)\ 898 (metaref_str_equals(field.type, "char *") == 1 || \ 899 metaref_str_equals(field.type, "char*") == 1) 901 #define METAREF_STRUCT_FIELD_IS_CHAR_ARRAY(struct_name, field_name)\ 902 (METAREF_FIELD_IS_CHAR_ARRAY(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 927 #define METAREF_FIELD_IS_CHAR(field)\ 928 (metaref_str_equals(field.type, "char") == 1 || \ 929 metaref_str_equals(field.type, "signed char") == 1) 931 #define METAREF_STRUCT_FIELD_IS_CHAR(struct_name, field_name)\ 932 (METAREF_FIELD_IS_CHAR(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 956 #define METAREF_FIELD_IS_UCHAR(field)\ 957 (metaref_str_equals(field.type, "unsigned char") == 1) 959 #define METAREF_STRUCT_FIELD_IS_UCHAR(struct_name, field_name)\ 960 (METAREF_FIELD_IS_UCHAR(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 986 #define METAREF_FIELD_IS_INT(field)\ 987 (metaref_str_equals(field.type, "int") == 1 || \ 988 metaref_str_equals(field.type, "signed") == 1 || \ 989 metaref_str_equals(field.type, "signed int") == 1) 991 #define METAREF_STRUCT_FIELD_IS_INT(struct_name, field_name)\ 992 (METAREF_FIELD_IS_INT(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1017 #define METAREF_FIELD_IS_UINT(field)\ 1018 (metaref_str_equals(field.type, "unsigned") == 1 || \ 1019 metaref_str_equals(field.type, "unsigned int") == 1) 1021 #define METAREF_STRUCT_FIELD_IS_UINT(struct_name, field_name)\ 1022 (METAREF_FIELD_IS_UINT(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1049 #define METAREF_FIELD_IS_SHORT(field)\ 1050 (metaref_str_equals(field.type, "short") == 1 || \ 1051 metaref_str_equals(field.type, "short int") == 1 || \ 1052 metaref_str_equals(field.type, "signed short") == 1 || \ 1053 metaref_str_equals(field.type, "signed short int") == 1) 1055 #define METAREF_STRUCT_FIELD_IS_SHORT(struct_name, field_name)\ 1056 (METAREF_FIELD_IS_SHORT(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1081 #define METAREF_FIELD_IS_USHORT(field)\ 1082 (metaref_str_equals(field.type, "unsigned short") == 1 || \ 1083 metaref_str_equals(field.type, "unsigned short int") == 1) 1085 #define METAREF_STRUCT_FIELD_IS_USHORT(struct_name, field_name)\ 1086 (METAREF_FIELD_IS_USHORT(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1113 #define METAREF_FIELD_IS_LONG(field)\ 1114 (metaref_str_equals(field.type,"long") == 1 || \ 1115 metaref_str_equals(field.type,"long int") == 1 || \ 1116 metaref_str_equals(field.type,"signed long") == 1 || \ 1117 metaref_str_equals(field.type,"signed long int") == 1) 1119 #define METAREF_STRUCT_FIELD_IS_LONG(struct_name, field_name)\ 1120 (METAREF_FIELD_IS_LONG(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1145 #define METAREF_FIELD_IS_ULONG(field)\ 1146 (metaref_str_equals(field.type, "unsigned long") == 1 || \ 1147 metaref_str_equals(field.type, "unsigned long int") == 1) 1149 #define METAREF_STRUCT_FIELD_IS_ULONG(struct_name, field_name)\ 1150 (METAREF_FIELD_IS_ULONG(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1174 #define METAREF_FIELD_IS_FLOAT(field)\ 1175 (metaref_str_equals(field.type,"float") == 1) 1177 #define METAREF_STRUCT_FIELD_IS_FLOAT(struct_name, field_name)\ 1178 (METAREF_FIELD_IS_FLOAT(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1202 #define METAREF_FIELD_IS_DOUBLE(field)\ 1203 (metaref_str_equals(field.type,"double") == 1) 1205 #define METAREF_STRUCT_FIELD_IS_DOUBLE(struct_name, field_name)\ 1206 (METAREF_FIELD_IS_DOUBLE(METAREF_GET_STRUCT_FIELD(struct_name, field_name)) == 1) 1230 #define METAREF_FIELD_IS_LONG_DOUBLE(field)\ 1231 (metaref_str_equals(field.type,"long double") == 1) 1233 #define METAREF_STRUCT_FIELD_IS_LONG_DOUBLE(struct_name, field_name)\ 1234 (METAREF_FIELD_IS_LONG_DOUBLE(METAREF_GET_STRUCT_FIELD(struct_name, field_name))) 1241 #define METAREF_GET_FIELD_ANNOTATIONS(field) field.annotations 1251 #define FOREACH_FIELD_ANNOTATION(field, annotation, body)\ 1252 for(size_t mr_i_ = 0; field.annotations[mr_i_].line_num != 0; ++mr_i_) {\ 1253 Annotation annotation = field.annotations[mr_i_]; \ 1263 #define METAREF_FIELD_GET_ANNOTATION(field, annotation_name)\ 1264 metaref_get_field_annotation(field, annotation_name) 1272 #define METAREF_FIELD_GET_ANNOTATION2(field, annotation_name)\ 1273 METAREF_FIELD_GET_ANNOTATION(field, #annotation_name) 1281 #define METAREF_FIELD_HAS_ANNOTATION(field, annotation_name)\ 1282 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type != METAREF_ANNOTATION_TERMINATOR) 1292 #define METAREF_FIELD_ANNOTATION_IS_STRING(field, annotation_name)\ 1293 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_STRING) 1302 #define METAREF_FIELD_ANNOTATION_STR_VALUE(field, annotation_name)\ 1303 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_STRING ? \ 1304 METAREF_FIELD_GET_ANNOTATION(field, annotation_name).str_value\ 1315 #define METAREF_FIELD_ANNOTATION_IS_INT(field, annotation_name)\ 1316 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_INT) 1325 #define METAREF_FIELD_ANNOTATION_INT_VALUE(field, annotation_name)\ 1326 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_INT ? \ 1327 METAREF_FIELD_GET_ANNOTATION(field, annotation_name).int_value\ 1338 #define METAREF_FIELD_ANNOTATION_IS_LONG(field, annotation_name)\ 1339 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_LONG) 1348 #define METAREF_FIELD_ANNOTATION_LONG_VALUE(field, annotation_name)\ 1349 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_LONG ? \ 1350 METAREF_FIELD_GET_ANNOTATION(field, annotation_name).long_value\ 1361 #define METAREF_FIELD_ANNOTATION_IS_FUNCTION(field, annotation_name)\ 1362 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_FUNCTION) 1371 #define METAREF_FIELD_ANNOTATION_FUNC_VALUE(field, annotation_name)\ 1372 (METAREF_FIELD_GET_ANNOTATION(field, annotation_name).type == METAREF_ANNOTATION_FUNCTION ? \ 1373 METAREF_FIELD_GET_ANNOTATION(field, annotation_name).func_ptr\ 1390 #define METAREF_GET_FIELD(the_meta_struct, field_name)\ 1391 metaref_struct_get_field(the_meta_struct, field_name) 1404 #define FOREACH_FIELD(struct_name, obj, field, body)\ 1405 for(size_t i = 0; the_struct->fields_array[i].type != NULL; ++i) {\ 1406 Field field = the_struct->fields_array[i]; \ 1422 #define FOREACH_FIELD_INDEX(the_struct, index, field, body)\ 1423 for(size_t i = 0; the_struct->fields_array[i].type != NULL; ++i) {\ 1425 Field field = the_struct->fields_array[index]; \ 1438 #define METAREF_FIELD_VALUE_IS_NULL(field)\ 1439 (field.ptr_address == NULL || *field.ptr_address == NULL) 1450 #define METAREF_FIELD_VALUE_PTR(field)\ 1451 (*field.ptr_address) 1463 #define METAREF_FIELD_VALUE_PTR_AS(type, field)\ 1464 ((type*)field.ptr_address) 1471 #define METAREF_SET_FIELD_VALUE(field, value)\ 1472 *field.ptr_address = (void*)value 1476 #define METAREF_PREPROCESSING_DONE 1477 #undef EXOTIC_METAREF_STRUCT