Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-12-10 17:45:50 +0000
committerHenrik Rentz-Reichert2012-12-10 17:45:50 +0000
commit35222929e316b6dab71f531f0d225fa44b4795c4 (patch)
tree39f6dc62bd52da6cc89247a57bb4e84dc33db0ba
parent9e3a84af9a9d87acae9c08322c76489e9bc8a49b (diff)
downloadorg.eclipse.etrice-35222929e316b6dab71f531f0d225fa44b4795c4.tar.gz
org.eclipse.etrice-35222929e316b6dab71f531f0d225fa44b4795c4.tar.xz
org.eclipse.etrice-35222929e316b6dab71f531f0d225fa44b4795c4.zip
[generator.cpp] added flag to generate etUnit includes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend12
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend7
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend7
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend18
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java9
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java13
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java16
10 files changed, 102 insertions, 20 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java
new file mode 100644
index 000000000..9bbfb89ca
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class GeneratorOptions {
+
+ static private boolean useEtUnit = false;
+
+ public static boolean isUseEtUnit() {
+ return useEtUnit;
+ }
+
+ public static void setUseEtUnit(boolean useEtUnit) {
+ GeneratorOptions.useEtUnit = useEtUnit;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java
index 2e9ee7b46..377ef86b9 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java
@@ -37,6 +37,7 @@ public class Main extends AbstractGenerator {
public static final String OPTION_DOCUMENTATION = "-genDocu";
public static final String OPTION_SAVE_GEN_MODEL = "-saveGenModel";
public static final String OPTION_DEBUG = "-debug";
+ public static final String OPTION_ETUNIT = "-etunit";
/**
* print usage message to stderr
@@ -104,6 +105,9 @@ public class Main extends AbstractGenerator {
else if (args[i].equals(OPTION_DEBUG)) {
debug = true;
}
+ else if (args[i].equals(OPTION_ETUNIT)) {
+ GeneratorOptions.setUseEtUnit(true);
+ }
else {
uriList.add(args[i]);
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
index d87388e0a..a742a7db4 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -14,7 +14,7 @@ import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-
+import org.eclipse.etrice.generator.cpp.GeneratorOptions
import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
import org.eclipse.etrice.core.room.ActorCommunicationType
@@ -66,6 +66,11 @@ class ActorClassGen extends GenericActorClassGenerator {
#include "common/messaging/Address.h"
#include "common/messaging/IMessageReceiver.h"
#include "common/debugging/DebuggingService.h"
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
#include <string>
#include <vector>
@@ -190,6 +195,11 @@ class ActorClassGen extends GenericActorClassGenerator {
#include "«ac.getCppHeaderFileName»"
#include "common/debugging/DebuggingService.h"
#include <iostream>
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
using namespace etRuntime;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index 2dc3d42cf..11b69b548 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -57,7 +57,12 @@ class CppExtensions implements ILanguageExtension {
override String selfPointer(String classname, boolean hasArgs) {""}
override String selfPointer(boolean hasArgs) { "" }
- override String operationScope(String classname, boolean isDeclaration) {""}
+ override String operationScope(String classname, boolean isDeclaration) {
+ if (isDeclaration)
+ ""
+ else
+ classname+"::"
+ }
override String memberInDeclaration(String namespace, String member) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index df44859bd..ed88dc3be 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -15,6 +15,7 @@ import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
import org.eclipse.etrice.generator.cpp.gen.Initialization
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.cpp.GeneratorOptions
import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@@ -115,6 +116,11 @@ class DataClassGen {
*/
#include "«dc.getCppHeaderFileName»"
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
«helpers.userCode(dc.userCode3)»
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index 38601e088..e32101d4f 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -22,6 +22,8 @@ import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.core.room.PortClass
+import org.eclipse.etrice.generator.cpp.GeneratorOptions
+
@Singleton
class ProtocolClassGen extends GenericProtocolClassGenerator {
@@ -173,6 +175,11 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
#include "«pc.getCppHeaderFileName»"
#include "common/debugging/DebuggingService.h"
#include <iostream>
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
using namespace etRuntime;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
index 4e182a220..5c998149f 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -28,7 +28,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
@Inject ProtocolClassGen cppProtGen
override genExtraDecl(ExpandedActorClass xpac) {
- val ac = xpac.actorClass
+// val ac = xpac.actorClass
'''
protected:
static std::string s_stateStrings[];
@@ -79,22 +79,6 @@ class StateMachineGen extends GenericStateMachineGenerator {
return langExt.genEnumeration("triggers", list)
}
- override constRef(String classname) {
- return "const " + classname + "&"
- }
-
- override pointer(String classname) {
- return classname + "*"
- }
-
- override scopePrefix(String classname) {
- return classname + "::"
- }
-
- override addressOp(String classname) {
- return "&" + classname
- }
-
override constPointer(String classname) {
return "const " + classname + "*"
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
index 4fffb7d1c..fff0cfc07 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -89,7 +89,14 @@ public class CppExtensions implements ILanguageExtension {
}
public String operationScope(final String classname, final boolean isDeclaration) {
- return "";
+ String _xifexpression = null;
+ if (isDeclaration) {
+ _xifexpression = "";
+ } else {
+ String _plus = (classname + "::");
+ _xifexpression = _plus;
+ }
+ return _xifexpression;
}
public String memberInDeclaration(final String namespace, final String member) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
index 6010749c6..8aff81f59 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
@@ -17,6 +17,7 @@ import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.cpp.GeneratorOptions;
import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
import org.eclipse.etrice.generator.cpp.gen.Initialization;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
@@ -334,6 +335,18 @@ public class DataClassGen {
_builder.append(_cppHeaderFileName, "");
_builder.append("\"");
_builder.newLineIfNotEmpty();
+ {
+ boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
+ if (_isUseEtUnit) {
+ _builder.append("extern \"C\" {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"etUnit.h\"");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
_builder.newLine();
DetailCode _userCode3 = dc.getUserCode3();
CharSequence _userCode = this.helpers.userCode(_userCode3);
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
index 06c8a4345..f08d2faa3 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
@@ -27,6 +27,7 @@ import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.SAPRef;
import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.cpp.GeneratorOptions;
import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
import org.eclipse.etrice.generator.cpp.gen.Initialization;
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
@@ -473,6 +474,21 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
_builder.append("#include <iostream>");
_builder.newLine();
+ {
+ boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
+ if (_isUseEtUnit) {
+ _builder.append("\t");
+ _builder.append("extern \"C\" {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("#include \"etUnit.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
_builder.newLine();
_builder.append("\t");
_builder.append("using namespace etRuntime;");

Back to the top