laurent@219: #ifndef __ACCESSOR_H laurent@219: #define __ACCESSOR_H laurent@219: laurent@221: laurent@219: // variable declaration macros laurent@219: #define __DECLARE_VAR(type, name)\ laurent@221: __IEC_##type##_t name; laurent@219: #define __DECLARE_GLOBAL(type, resource, name)\ laurent@221: __IEC_##type##_t resource##__##name;\ laurent@221: static __IEC_##type##_t *GLOBAL__##name = &resource##__##name; laurent@219: #define __DECLARE_GLOBAL_LOCATION(type, location)\ laurent@219: extern type *location; laurent@219: #define __DECLARE_GLOBAL_LOCATED(type, resource, name)\ laurent@221: __IEC_##type##_p resource##__##name;\ laurent@221: static __IEC_##type##_p *GLOBAL__##name; laurent@219: #define __DECLARE_EXTERNAL(type, name)\ laurent@221: __IEC_##type##_p name; laurent@219: #define __DECLARE_LOCATED(type, name)\ laurent@221: __IEC_##type##_p name; laurent@219: laurent@219: laurent@219: // variable initialization macros laurent@221: #define __INIT_STRUCT(name, initial, retained)\ laurent@221: name.value = initial;\ laurent@222: name.flags |= retained?RETAIN_FLAG:0; laurent@221: #define __INIT_VAR(name, initial, retained)\ laurent@221: __INIT_STRUCT(name, initial, retained) laurent@221: #define __INIT_GLOBAL(name, initial, retained)\ laurent@221: __INIT_STRUCT((*GLOBAL__##name), initial, retained) laurent@221: #define __INIT_GLOBAL_LOCATED(resource, name, location, retained)\ laurent@221: __INIT_STRUCT(resource##__##name, location, retained) laurent@221: #define __INIT_EXTERNAL(type, global, name, retained)\ laurent@221: {extern __IEC_##type##_t *GLOBAL__##global;\ laurent@221: __INIT_STRUCT(name, &((*GLOBAL__##global).value), retained)} laurent@221: #define __INIT_LOCATED(type, location, name, retained)\ laurent@219: {extern type *location;\ laurent@221: __INIT_STRUCT(name, location, retained)} laurent@219: #define __INIT_LOCATED_VALUE(name, initial)\ laurent@221: *(name.value) = initial; laurent@219: laurent@219: laurent@219: // variable getting macros laurent@221: #define __GET_VAR(name, ...)\ laurent@221: name.value __VA_ARGS__ laurent@219: #define __GET_EXTERNAL(name)\ laurent@222: name.flags & FORCE_FLAG ? name.fvalue : *(name.value) laurent@219: #define __GET_LOCATED(name)\ laurent@222: name.flags & FORCE_FLAG ? name.fvalue : *(name.value) laurent@219: #define __GET_VAR_BY_REF(name)\ laurent@219: &(name) laurent@219: #define __GET_EXTERNAL_BY_REF(name)\ laurent@221: name.value laurent@219: #define __GET_LOCATED_BY_REF(name)\ laurent@221: name.value laurent@219: laurent@219: // variable setting macros laurent@221: #define __SET_VAR(name, new_value, ...)\ laurent@222: if (!(name.flags & FORCE_FLAG)) name.value __VA_ARGS__ = new_value laurent@219: #define __SET_EXTERNAL(name, new_value)\ laurent@222: if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value laurent@219: #define __SET_LOCATED(name, new_value)\ laurent@222: if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value laurent@219: laurent@219: #endif //__ACCESSOR_H