blob: 7d3a7c056ad7885c806ed54cb6fbd9393234a02a [file] [log] [blame]
/**
* Copyright (c) 2020-2021 Robert Bosch GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
*/
package org.eclipse.app4mc.slg.linux.generators;
import org.eclipse.app4mc.amalthea.model.Label;
import org.eclipse.app4mc.transformation.util.OutputBuffer;
public class LinuxLabelTranslationUnit extends LinuxSyntheticTranslationUnit {
public static String getModulePathStatic() {
return getBasePathStatic() + "/" + getModuleNameStatic();
}
public static String getMakeFilePathStatic() {
return getModulePathStatic() + "/" + getMakeFileName();
}
public static String getModuleNameStatic() {
return "labels";
}
public static String getLibName() {
return "LABELS_LIB";
}
@Override
public String getModuleName() {
return LinuxLabelTranslationUnit.getModuleNameStatic();
}
private String getName() {
return this.label.getName();
}
@Override
public String getIncFile() {
return this.getModuleName() + ".h";
}
// ---------- names of generated 'C' functions ----------
public String initCall() { return "initialize_" + getName(); }
public String readCall(String param) { return "read_" + getName() + "(" + param + ")"; }
public String writeCall(String param) { return "write_" + getName() + "(" + param + ")"; }
// ----------
private final Label label;
public LinuxLabelTranslationUnit(final OutputBuffer outputBuffer, final Label label) {
super(outputBuffer);
this.label = label;
this.genFiles();
}
public void genFiles() {
if (this.isSrcFileEmpty()) {
this.srcAppend("#include \"" + this.getIncFile() + "\"\n");
this.srcAppend("#include <stdbool.h>\n\n");
}
this.incAppend(LinuxLabelGenerator.toH(label));
this.srcAppend(LinuxLabelGenerator.toCpp(label));
}
}