Adding Flags bit symbols
authorlaurent
Wed, 02 Dec 2009 19:55:23 +0100
changeset 222 8b1757417a54
parent 221 c6aed7e5f070
child 223 a09ed6620a7d
child 225 36d05588f91b
Adding Flags bit symbols
lib/accessor.h
lib/iec_types_all.h
--- a/lib/accessor.h	Wed Dec 02 16:11:01 2009 +0100
+++ b/lib/accessor.h	Wed Dec 02 19:55:23 2009 +0100
@@ -22,7 +22,7 @@
 // variable initialization macros
 #define __INIT_STRUCT(name, initial, retained)\
     name.value = initial;\
-	name.flags |= retained?4:0;
+	name.flags |= retained?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 & 2 ? name.fvalue : *(name.value)
+	name.flags & FORCE_FLAG ? name.fvalue : *(name.value)
 #define __GET_LOCATED(name)\
-	name.flags & 2 ? name.fvalue : *(name.value)
+	name.flags & 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 & 2)) name.value __VA_ARGS__ = new_value
+	if (!(name.flags & FORCE_FLAG)) name.value __VA_ARGS__ = new_value
 #define __SET_EXTERNAL(name, new_value)\
-	if (!(name.flags & 2)) *(name.value) = new_value
+	if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value
 #define __SET_LOCATED(name, new_value)\
-	if (!(name.flags & 2)) *(name.value) = new_value
+	if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value
 
 #endif //__ACCESSOR_H
--- a/lib/iec_types_all.h	Wed Dec 02 16:11:01 2009 +0100
+++ b/lib/iec_types_all.h	Wed Dec 02 19:55:23 2009 +0100
@@ -13,6 +13,10 @@
 #define TRUE 1
 #define FALSE 0
 
+#define DEBUG_FLAG 1
+#define FORCE_FLAG 2
+#define RETAIN_FLAG 4
+
 #define __DECLARE_IEC_TYPE(type)\
 typedef IEC_##type type;\
 \