# HG changeset patch # User edouard # Date 1259935988 -3600 # Node ID 270ba3d91e59c8f47ac917d0fe8b7689c578e240 # Parent a09ed6620a7da1b8ab9d70ba665963642d8c0b02 type definition to match accessor and new debug diff -r a09ed6620a7d -r 270ba3d91e59 lib/accessor.h --- a/lib/accessor.h Fri Dec 04 15:11:16 2009 +0100 +++ b/lib/accessor.h Fri Dec 04 15:13:08 2009 +0100 @@ -22,7 +22,7 @@ // variable initialization macros #define __INIT_STRUCT(name, initial, retained)\ name.value = initial;\ - name.flags |= retained?RETAIN_FLAG:0; + name.flags |= retained?__IEC_RETAIN_FLAG:0; #define __INIT_VAR(name, initial, retained)\ __INIT_STRUCT(name, initial, retained) #define __INIT_GLOBAL(name, initial, retained)\ @@ -43,9 +43,9 @@ #define __GET_VAR(name, ...)\ name.value __VA_ARGS__ #define __GET_EXTERNAL(name)\ - name.flags & FORCE_FLAG ? name.fvalue : *(name.value) + name.flags & __IEC_FORCE_FLAG ? name.fvalue : *(name.value) #define __GET_LOCATED(name)\ - name.flags & FORCE_FLAG ? name.fvalue : *(name.value) + name.flags & __IEC_FORCE_FLAG ? name.fvalue : *(name.value) #define __GET_VAR_BY_REF(name)\ &(name) #define __GET_EXTERNAL_BY_REF(name)\ @@ -55,10 +55,10 @@ // variable setting macros #define __SET_VAR(name, new_value, ...)\ - if (!(name.flags & FORCE_FLAG)) name.value __VA_ARGS__ = new_value + if (!(name.flags & __IEC_FORCE_FLAG)) name.value __VA_ARGS__ = new_value #define __SET_EXTERNAL(name, new_value)\ - if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value + if (!(name.flags & __IEC_FORCE_FLAG)) *(name.value) = new_value #define __SET_LOCATED(name, new_value)\ - if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value + if (!(name.flags & __IEC_FORCE_FLAG)) *(name.value) = new_value #endif //__ACCESSOR_H diff -r a09ed6620a7d -r 270ba3d91e59 lib/iec_types_all.h --- a/lib/iec_types_all.h Fri Dec 04 15:11:16 2009 +0100 +++ b/lib/iec_types_all.h Fri Dec 04 15:13:08 2009 +0100 @@ -13,9 +13,9 @@ #define TRUE 1 #define FALSE 0 -#define DEBUG_FLAG 1 -#define FORCE_FLAG 2 -#define RETAIN_FLAG 4 +#define __IEC_DEBUG_FLAG 0x01 +#define __IEC_FORCE_FLAG 0x02 +#define __IEC_RETAIN_FLAG 0x04 #define __DECLARE_IEC_TYPE(type)\ typedef IEC_##type type;\ @@ -58,36 +58,6 @@ /* i.e. this file cannot be included aside windows.h */ ANY(__DECLARE_IEC_TYPE) - -/* -typedef IEC_BOOL BOOL; - -typedef IEC_SINT SINT; -typedef IEC_INT INT; -typedef IEC_DINT DINT; -typedef IEC_LINT LINT; - -typedef IEC_USINT USINT; -typedef IEC_UINT UINT; -typedef IEC_UDINT UDINT; -typedef IEC_ULINT ULINT; - -typedef IEC_BYTE BYTE; -typedef IEC_WORD WORD; -typedef IEC_DWORD DWORD; -typedef IEC_LWORD LWORD; - -typedef IEC_REAL REAL; -typedef IEC_LREAL LREAL; - -typedef IEC_TIME TIME; -typedef IEC_DATE DATE; -typedef IEC_DT DT; -typedef IEC_TOD TOD; - -typedef IEC_STRING STRING; -*/ - typedef struct { __IEC_BOOL_t state; // current step state. 0 : inative, 1: active BOOL prev_state; // previous step state. 0 : inative, 1: active @@ -108,38 +78,28 @@ /* Enumerate native types */ #define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, +#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, typedef enum{ ANY(__decl_enum_type) - ANY_SFC(__decl_enum_type) - /*TODO handle custom types*/ + ANY(__decl_enum_pointer) + /* SFC specific types are never external or global */ + UNKNOWN_ENUM } __IEC_types_enum; /* Get size of type from its number */ -#define __decl_size_case(TYPENAME) case TYPENAME##_ENUM: return sizeof(TYPENAME); -#define __decl_size_case_force_BOOL(TYPENAME) case TYPENAME##_ENUM: return sizeof(BOOL); +#define __decl_size_case(TYPENAME) \ + case TYPENAME##_ENUM:\ + case TYPENAME##_P_ENUM:\ + return sizeof(TYPENAME); static inline USINT __get_type_enum_size(__IEC_types_enum t){ switch(t){ ANY(__decl_size_case) /* size do not correspond to real struct. * only a bool is used to represent state*/ - ANY_SFC(__decl_size_case_force_BOOL) - /*TODO handle custom types*/ + default: + return 0; } return 0; } -/* Get name of type from its number */ -#define __decl_typename_case(TYPENAME) case TYPENAME##_ENUM: return #TYPENAME ; -static inline const char* __get_type_enum_name(__IEC_types_enum t){ - switch(t){ - ANY(__decl_typename_case) - /* size do not correspond to real struct. - * only a bool is used to represent state*/ - ANY_SFC(__decl_typename_case) - /*TODO handle custom types*/ - } - return 0; -} - - #endif /*IEC_TYPES_ALL_H*/