Commit fc7476a5 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

bugfix

refs 804
parent cb33b6a3
......@@ -38,13 +38,13 @@ import org.fortiss.af3.generator.common.model.c.Variable;
import org.fortiss.af3.generator.common.model.source.DeclarationBase;
/**
* The generator for {@link DataDictionary}. It produces two files:
* <code>data_dictionary.h</code> and <code>data_dictionary.c</code>;
* The generator for {@link DataDictionary}. It produces two files: <code>data_dictionary.h</code>
* and <code>data_dictionary.c</code>;
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 103E1E2E1054371B886D6FE6883EF5C8
* @ConQAT.Rating YELLOW Hash: A62BC363D99149F7CC7426662E519D01
*/
public class DataDictionaryGenerator {
......@@ -64,20 +64,22 @@ public class DataDictionaryGenerator {
/** Constructor. */
@SuppressWarnings("unchecked")
public DataDictionaryGenerator(DataDictionary dictionary) {
for (Enumeration e : dictionary.getEnumerationsList()) {
EnumGenerator en = new EnumGenerator(e);
enums.add(en);
functions.addAll(en.getConstructorFunctions());
}
for (FunctionDefinition fdef : dictionary.getFunctionsList()) {
List<Variable> params = new ArrayList<Variable>();
for (FunctionParameter param : fdef.getParametersList()) {
params.add(new Variable(NONE, param.getType(), param.getVar()
.getIdentifier(), TYPE_STRING_GENERATOR));
if(dictionary != null) {
for(Enumeration e : dictionary.getEnumerationsList()) {
EnumGenerator en = new EnumGenerator(e);
enums.add(en);
functions.addAll(en.getConstructorFunctions());
}
for(FunctionDefinition fdef : dictionary.getFunctionsList()) {
List<Variable> params = new ArrayList<Variable>();
for(FunctionParameter param : fdef.getParametersList()) {
params.add(new Variable(NONE, param.getType(), param.getVar().getIdentifier(),
TYPE_STRING_GENERATOR));
}
functions.add(new Function(EXTERN, fdef.getReturnType(), fdef.getFunction()
.getName(), params, Collections.EMPTY_LIST, fdef.getDefinition(),
TYPE_STRING_GENERATOR));
}
functions.add(new Function(EXTERN, fdef.getReturnType(), fdef
.getFunction().getName(), params, Collections.EMPTY_LIST,
fdef.getDefinition(), TYPE_STRING_GENERATOR));
}
}
......@@ -85,10 +87,10 @@ public class DataDictionaryGenerator {
public HeaderFile createHeaderFile() {
HeaderFile hfile = new HeaderFile(DATA_DICTIONARY_FILE_NAME);
hfile.addDeclaration(defaultTypes);
for (EnumGenerator e : enums) {
for(EnumGenerator e : enums) {
hfile.addDeclaration(e.getTypeDefDeclaration());
}
for (Function f : functions) {
for(Function f : functions) {
hfile.addDeclaration(f.getDeclaration());
}
return hfile;
......@@ -96,10 +98,9 @@ public class DataDictionaryGenerator {
/** Produces the implementation file. */
public ImplementationFile createImplementationFile() {
ImplementationFile ifile = new ImplementationFile(
DATA_DICTIONARY_FILE_NAME);
ImplementationFile ifile = new ImplementationFile(DATA_DICTIONARY_FILE_NAME);
ifile.addImport(new Include(DATA_DICTIONARY_HEADER));
for (Function f : functions) {
for(Function f : functions) {
ifile.addDefinition(f.getDefinition());
}
return ifile;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment