Changes merged
authorlaurent
Sat, 05 Dec 2009 18:53:01 +0100
changeset 227 560c1231ad1f
parent 226 29f8ffc203c1 (current diff)
parent 224 270ba3d91e59 (diff)
child 228 43831b683764
Changes merged
lib/accessor.h
lib/iec_types_all.h
--- a/Makefile.CYGWIN_NT-5.1	Sat Dec 05 18:38:53 2009 +0100
+++ b/Makefile.CYGWIN_NT-5.1	Sat Dec 05 18:53:01 2009 +0100
@@ -2,7 +2,7 @@
 CXX = g++ -mno-cygwin
 
 #get warnings, debugging information and optimization
-CFLAGS  = -Wall -pedantic -Wpointer-arith -Wwrite-strings
+CFLAGS  = -Wall -Wpointer-arith -Wwrite-strings
 # CFLAGS += -Werror
 CFLAGS += -ggdb
 #CFLAGS += -O3 -funroll-loops
@@ -14,4 +14,4 @@
 #CXXFLAGS += -O3 -funroll-loops
 CXXFLAGS  = $(CFLAGS)
 
-IECLIBDIR=lib
\ No newline at end of file
+IECLIBDIR=lib
--- a/lib/accessor.h	Sat Dec 05 18:38:53 2009 +0100
+++ b/lib/accessor.h	Sat Dec 05 18:53:01 2009 +0100
@@ -21,7 +21,7 @@
 
 // variable initialization macros
 #define __INIT_RETAIN(name, retained)\
-    name.flags |= retained?__RETAIN_FLAG:0;
+    name.flags |= retained?__IEC_RETAIN_FLAG:0;
 #define __INIT_VAR(name, initial, retained)\
 	name.value = initial;\
 	__INIT_RETAIN(name, retained)
@@ -47,9 +47,9 @@
 #define __GET_VAR(name, ...)\
 	name.value __VA_ARGS__
 #define __GET_EXTERNAL(name, ...)\
-	(name.flags & __FORCE_FLAG) ? name.fvalue __VA_ARGS__ : *(name.value) __VA_ARGS__
+	(name.flags & __IEC_FORCE_FLAG) ? name.fvalue __VA_ARGS__ : *(name.value) __VA_ARGS__
 #define __GET_LOCATED(name, ...)\
-	(name.flags & __FORCE_FLAG) ? name.fvalue __VA_ARGS__ : *(name.value) __VA_ARGS__
+	(name.flags & __IEC_FORCE_FLAG) ? name.fvalue __VA_ARGS__ : *(name.value) __VA_ARGS__
 #define __GET_VAR_BY_REF(name)\
 	&(name)
 #define __GET_EXTERNAL_BY_REF(name)\
@@ -59,10 +59,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) __VA_ARGS__ = new_value
+	if (!(name.flags & __IEC_FORCE_FLAG)) *(name.value) __VA_ARGS__ = new_value
 #define __SET_LOCATED(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
 
 #endif //__ACCESSOR_H
--- a/lib/iec_types_all.h	Sat Dec 05 18:38:53 2009 +0100
+++ b/lib/iec_types_all.h	Sat Dec 05 18:53:01 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*/