lib/accessor.h
changeset 377 60b012b7793f
parent 252 0bda13ec66b3
child 392 9b88b8b6bccd
equal deleted inserted replaced
376:7dcbd8418771 377:60b012b7793f
     1 #ifndef __ACCESSOR_H
     1 #ifndef __ACCESSOR_H
     2 #define __ACCESSOR_H
     2 #define __ACCESSOR_H
     3 
     3 
       
     4 #define __INITIAL_VALUE(...) __VA_ARGS__
     4 
     5 
     5 // variable declaration macros
     6 // variable declaration macros
     6 #define __DECLARE_VAR(type, name)\
     7 #define __DECLARE_VAR(type, name)\
     7 	__IEC_##type##_t name;
     8 	__IEC_##type##_t name;
     8 #define __DECLARE_GLOBAL(type, resource, name)\
     9 #define __DECLARE_GLOBAL(type, resource, name)\
    43 #define __INIT_RETAIN(name, retained)\
    44 #define __INIT_RETAIN(name, retained)\
    44     name.flags |= retained?__IEC_RETAIN_FLAG:0;
    45     name.flags |= retained?__IEC_RETAIN_FLAG:0;
    45 #define __INIT_VAR(name, initial, retained)\
    46 #define __INIT_VAR(name, initial, retained)\
    46 	name.value = initial;\
    47 	name.value = initial;\
    47 	__INIT_RETAIN(name, retained)
    48 	__INIT_RETAIN(name, retained)
    48 #define __INIT_GLOBAL(name, initial, retained)\
    49 #define __INIT_GLOBAL(type, name, initial, retained)\
    49 	__INIT_GLOBAL_##name(initial);\
    50     {\
    50 	__INIT_RETAIN((*GLOBAL__##name), retained)
    51 	    static const type temp = initial;\
       
    52 	    __INIT_GLOBAL_##name(temp);\
       
    53 	    __INIT_RETAIN((*GLOBAL__##name), retained)\
       
    54     }
    51 #define __INIT_GLOBAL_LOCATED(resource, name, location, retained)\
    55 #define __INIT_GLOBAL_LOCATED(resource, name, location, retained)\
    52 	resource##__##name.value = location;\
    56 	resource##__##name.value = location;\
    53 	__INIT_RETAIN(resource##__##name, retained)
    57 	__INIT_RETAIN(resource##__##name, retained)
    54 #define __INIT_EXTERNAL(type, global, name, retained)\
    58 #define __INIT_EXTERNAL(type, global, name, retained)\
    55 	name.value = __GET_GLOBAL_##global();\
    59 	name.value = __GET_GLOBAL_##global();\