Browse Source

Added easy C++ API access to c code statemachine API YAKHMI-454

jos.itemis@gmail.com 13 years ago
parent
commit
770d9363c1

+ 9 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomEventH.xpt

@@ -22,8 +22,13 @@ Templates for the main statechart cpp file.
 #ifndef «EVNAME()»_H_
 #define «EVNAME()»_H_
 
+ 
 #include "Event.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
 «REM» lost things:
   ev_«((EventDefinition)ev).name.toLowerCase()»,
   ev_«((TimeEvent)ev).name.toLowerCase()»,
@@ -55,6 +60,10 @@ typedef struct {
  
 extern uint32_t «scName()»_getSizeofEvent(uint32_t evid);
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* «name.toUpperCase()»_H_ */
 
 «ENDFILE»

+ 9 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineH.xpt

@@ -21,7 +21,7 @@ Templates for the main statechart cpp file.
 
 #ifndef «STNAME()»_H_
 #define «STNAME()»_H_
-
+ 
 «FOREACH this.scopes.getUsableScopes() AS interface -»
 #include "«interface.interfaceClassName()».h"
 «ENDFOREACH»
@@ -29,6 +29,10 @@ Templates for the main statechart cpp file.
 #include "«EvName()».h"
 #include "EventPool.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
 #define MAX_PARALLEL_STATES «this.stateVector.size»
 
 typedef void(*raiseEventFPtr)(_Event* evPtr);
@@ -82,6 +86,10 @@ extern void statemachine_cy__runCycle(Statemachine_cy* handle);
 
 #endif /* «STNAME()»_FRIENDS */
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* «STNAME()»_H_ */
 
 «ENDFILE»

+ 8 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/DummyTimer.xpt

@@ -21,6 +21,10 @@ Templates for the main statechart c file.
 
 #include "Timer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+ 
 extern void setTimer(const uint32_t evid, const uint32_t time_ms,
 		boolean periodic);
 
@@ -28,6 +32,10 @@ extern void unsetTimer(const uint32_t evid);
 
 extern void dummyTimer_init(Timer* handle);
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* DUMMYTIMER_H_ */
 «ENDFILE»
 

+ 8 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/EventH.xpt

@@ -22,6 +22,10 @@ Templates for the main statechart c file.
 
 #include "definition.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
 typedef struct {
   uint32_t id;
 } _Event;
@@ -31,6 +35,10 @@ extern void _event_init(_Event* handle, uint32_t id);
 /* event handler callback signature definition */ 
 typedef void(*handleEvent)(_Event ev);
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* EVENT_H_ */
 «ENDFILE»
 

+ 8 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/EventPoolH.xpt

@@ -22,6 +22,10 @@ Templates for the main statechart c file.
 #include "Event.h"
 #include "definition.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+ 
 typedef uint32_t(*getSizeOfEventFP)(uint32_t evid);
 
 typedef struct {
@@ -51,6 +55,10 @@ extern void eventPool_init_static(EventPool* handle, TypePool* eventPool,
 
 extern void eventPool_exit(EventPool* handle);
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* EVENTPOOL_H_ */
 «ENDFILE»
 

+ 8 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/EventSetH.xpt

@@ -21,6 +21,10 @@ Templates for the main statechart c file.
 
 #include "definition.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+ 
 typedef enum {
 	ev_type_input,
 	ev_type_output,
@@ -49,6 +53,10 @@ extern boolean eventSet_isAny_input(EventSet* handle);
 extern boolean eventSet_isAny_output(EventSet* handle);
 extern void eventSet_clean_single(EventSet* handle, const uint32_t evid);
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* EVENTSET_H_ */
 «ENDFILE»
 

+ 8 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Interfaces.xpt

@@ -30,6 +30,10 @@ Templates for the main statechart cpp file.
 #include "Statemachine_cy.h"
 #include "«EvName()».h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+ 
 typedef struct {
 	EventSet* eventSet;
 	Statemachine_cy* statemachine;
@@ -92,7 +96,10 @@ IF !event.type.isVoid() -
 
 #endif // INTERFACE_LISTENER
 
-
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* INTERFACEBASE_H_ */
 
 

+ 9 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/StatemachineBaseH.xpt

@@ -18,10 +18,14 @@ Templates for the main statechart c file.
 «getLicenseHeader(genEntry)»
 #ifndef STATEMACHINEBASE_H_
 #define STATEMACHINEBASE_H_
-
+ 
 #include "definition.h"
 #include "Timer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
 typedef struct {
 
 	uint32_t* state;
@@ -42,6 +46,10 @@ extern void statemachineBase_destruct(StatemachineBase* handle);
 extern uint32_t statemachineBase_getState(StatemachineBase* handle, uint16_t pos);
 
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* STATEMACHINEBASE_H_ */
 «ENDFILE»
 

+ 8 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyH.xpt

@@ -24,6 +24,10 @@ Templates for the main statechart c file.
 #include "Timer.h"
 #include "EventPool.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+ 
 typedef struct {
   StatemachineBase base;
   EventSet   eventSet;
@@ -49,6 +53,10 @@ extern boolean statemachine_cy_eventWaiting(Statemachine_cy* handle);
 /* implement me in derived codegeneration */
 extern void statemachine_cy__runCycle(Statemachine_cy* handle);
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* STATEMACHINE_CY_H_ */
 «ENDFILE»
 

+ 9 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/TimerH.xpt

@@ -21,6 +21,10 @@ Templates for the main statechart c file.
 
 #include "definition.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
 typedef void(*setTimerFPtr)(uint32_t evid, const uint32_t time_ms, boolean periodic);
 typedef void(*unsetTimerFPtr)(const uint32_t evid);
 
@@ -34,6 +38,11 @@ typedef struct {
 
 extern void timer_setFPtr(Timer* handle, setTimerFPtr stfptr, unsetTimerFPtr utfptr);
 extern void timer_exit(Timer* handle);
+
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* TIMER_H_ */
 «ENDFILE»
 

+ 8 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/definitionH.xpt

@@ -19,6 +19,10 @@ Templates for the main statechart cpp file.
 #ifndef DEFINITION_H_
 #define DEFINITION_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+ 
 /* platform/compiler specific additions (#includes) */
 /* temporarly set to fix values */ 
 
@@ -33,6 +37,10 @@ typedef enum { bool_false = 0, bool_true = 1 } boolean;
 typedef double real;
 «REM»typedef string char*;«ENDREM»
 
+#ifdef __cplusplus
+}
+#endif 
+ 
 #endif /* DEFINITION_H_ */
 «ENDFILE»