Browse Source

Merge pull request #932 from Yakindu/pro_issue_353

Pro issue 353
Thomas Kutz 9 years ago
parent
commit
36f8f7fdbf

+ 6 - 5
plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/AbstractTypeSystem.java

@@ -17,7 +17,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.resource.Resource;
@@ -28,6 +27,9 @@ import org.yakindu.base.types.PrimitiveType;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.TypesFactory;
 
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
+
 /**
  * Abstract base implementation if {@link ITypeSystem}. Provides convenience
  * methods to determine type compatibility.
@@ -38,7 +40,7 @@ import org.yakindu.base.types.TypesFactory;
 public abstract class AbstractTypeSystem implements ITypeSystem {
 
 	protected Map<String, Type> typeRegistry = new HashMap<String, Type>();
-	protected Map<Type, Type> extendsRegistry = new HashMap<Type, Type>();
+	protected ListMultimap<Type, Type> extendsRegistry = ArrayListMultimap.create();
 	protected Map<Type, Type> conversionRegistry = new HashMap<Type, Type>();
 
 	protected abstract void initBuiltInTypes();
@@ -66,8 +68,7 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 
 	public List<Type> getSuperTypes(Type type) {
 		List<Type> superTypes = new ArrayList<Type>();
-		Set<Entry<Type, Type>> entrySet = extendsRegistry.entrySet();
-		for (Entry<Type, Type> entry : entrySet) {
+		for (Entry<Type, Type> entry : extendsRegistry.entries()) {
 			if (isSame(type, entry.getKey())) {
 				superTypes.add(entry.getValue());
 			}
@@ -130,7 +131,7 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 	public void removeType(String name) {
 		Type type = typeRegistry.get(name);
 		if (type != null) {
-			extendsRegistry.remove(type);
+			extendsRegistry.removeAll(type);
 			resource.getContents().remove(type);
 			typeRegistry.remove(type);
 		}

+ 9 - 0
plugins/org.yakindu.sct.doc.user/src/user-guide/c-domain.textile

@@ -438,6 +438,15 @@ bq.. *Please note:*
 State machines calling C functions as operations are debarred from simulation and debugging. The simulator is not yet capable to call C functions.
 
 
+h2(#cdom_defines). Macro Definitions
+
+Macro definitions declared in a C header file via the @#define@ keyword are also accessible in the statechart. There are two kinds of macro definitions leading to different interpretations in the context of state machines:
+
+* Constant definitions, e.g. @#define PI 3.14@, are translated into _const_ properties. They can be used within a statechart just like normal variables, but are not changeable during a simulation. The value of such a constant is derived from the value part of the macro definition. However, there are cases where this derivation is not successful, e.g. when other macros are referenced.
+
+* Parameterized macros, like @#define MIN(x,y) ((x<y) ? x : y)@, are translated into operations. They can be used within a statechart just like normal operations, but are not interpreted during a simulation.
+
+
 h2(#cdom_generating_c_source_code). Generating C source code
 
 Code generation, i.&#8239;e. turning a statechart model into source code of a programming language, is explained in the section _Generating state machine code_. Therefore we won't go into the details here, but instead only put some emphasis on code generation specialties of the _Deep C Integration_.