in code/4diac-integration/src/main/kotlin/org/fbme/ide/integration/fordiac/translator/cpp/AbstractTranslator.kt [353:446]
protected open fun constructFBInterfaceSpecDefinition(): String {
val sb = StringBuilder()
sb.append("const SFBInterfaceSpec ")
.append(this.constructFBClassName())
.appendLine("::scm_stFBInterfaceSpec = {")
.append(" ")
.append(this.type().inputEvents.size)
.append(", ")
val noInputEvents = this.type().inputEvents.isEmpty()
if (noInputEvents) {
sb.append("nullptr, nullptr, nullptr")
} else {
sb.append("scm_anEventInputNames, ")
.append(
if (this.hasInputWith()) {
"scm_anEIWith"
} else {
"nullptr"
}
)
.append(", scm_anEIWithIndexes")
}
sb.appendLine(",")
.append(" ")
.append(this.type().outputEvents.size)
.append(", ")
val noOutputEvents = this.type().outputEvents.isEmpty()
if (noOutputEvents) {
sb.append("nullptr, nullptr, nullptr")
} else {
sb.append("scm_anEventOutputNames, ")
.append(
if (this.hasOutputWith()) {
"scm_anEOWith"
} else {
"nullptr"
}
)
.append(", scm_anEOWithIndexes")
}
sb.appendLine(",")
.append(" ")
.append(this.type().inputParameters.size)
.append(", ")
val noInputParameters = this.type().inputParameters.isEmpty()
sb.append(
if (noInputParameters) {
"nullptr, nullptr"
} else {
"scm_anDataInputNames, scm_anDataInputTypeIds"
}
)
.appendLine(",")
.append(" ")
.append(this.type().outputParameters.size)
.append(", ")
val noOutputParameters = this.type().outputParameters.isEmpty()
sb.append(
if (noOutputParameters) {
"nullptr, nullptr"
} else {
"scm_anDataOutputNames, scm_anDataOutputTypeIds"
}
)
.appendLine(",")
val adapterPortsAmount = this.type().templateTypeDescriptor.socketPorts.size +
this.type().templateTypeDescriptor.plugPorts.size
sb.append(" ")
.append(adapterPortsAmount)
.append(", ")
.appendLine(
if (adapterPortsAmount > 0) {
"scm_astAdapterInstances"
} else {
"nullptr"
}
)
.appendLine("};")
return sb.toString()
}