diff --git a/org.lflang/src/org/lflang/federated/extensions/CExtension.java b/org.lflang/src/org/lflang/federated/extensions/CExtension.java index 8a69e979c6..a86d6fd1f0 100644 --- a/org.lflang/src/org/lflang/federated/extensions/CExtension.java +++ b/org.lflang/src/org/lflang/federated/extensions/CExtension.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.LinkedHashMap; import java.util.List; import org.lflang.ASTUtils; @@ -49,7 +48,6 @@ import org.lflang.federated.launcher.RtiConfig; import org.lflang.federated.serialization.FedROS2CPPSerialization; import org.lflang.generator.CodeBuilder; -import org.lflang.generator.GeneratorUtils; import org.lflang.generator.LFGeneratorContext; import org.lflang.generator.ReactionInstance; import org.lflang.generator.ReactorInstance; @@ -505,6 +503,7 @@ public String generatePreamble( includes.pr("#ifdef __cplusplus\n" + "}\n" + "#endif"); + includes.pr(generateSerializationIncludes(federate, fileConfig)); } return includes.toString(); @@ -537,8 +536,6 @@ protected String makePreamble( size_t _lf_action_table_size = %1$s; """.formatted(numOfNetworkActions)); - code.pr(generateSerializationPreamble(federate, fileConfig)); - code.pr(generateExecutablePreamble(federate, rtiConfig, errorReporter)); code.pr(generateInitializeTriggers(federate, errorReporter)); @@ -551,8 +548,8 @@ protected String makePreamble( /** * Generate preamble code needed for enabled serializers of the federate. */ - protected String generateSerializationPreamble(FederateInstance federate, FedFileConfig fileConfig) { - return CExtensionUtils.generateSerializationPreamble(federate, fileConfig); + protected String generateSerializationIncludes(FederateInstance federate, FedFileConfig fileConfig) { + return CExtensionUtils.generateSerializationIncludes(federate, fileConfig); } /** diff --git a/org.lflang/src/org/lflang/federated/extensions/CExtensionUtils.java b/org.lflang/src/org/lflang/federated/extensions/CExtensionUtils.java index 55a489ce51..7a03655923 100644 --- a/org.lflang/src/org/lflang/federated/extensions/CExtensionUtils.java +++ b/org.lflang/src/org/lflang/federated/extensions/CExtensionUtils.java @@ -20,7 +20,6 @@ import org.lflang.federated.serialization.FedROS2CPPSerialization; import org.lflang.federated.serialization.SupportedSerializers; import org.lflang.generator.CodeBuilder; -import org.lflang.generator.GeneratorBase; import org.lflang.generator.ReactorInstance; import org.lflang.generator.c.CTypes; import org.lflang.generator.c.CUtil; @@ -547,7 +546,7 @@ public static String surroundWithIfFederatedDecentralized(String code) { /** * Generate preamble code needed for enabled serializers of the federate. */ - public static String generateSerializationPreamble( + public static String generateSerializationIncludes( FederateInstance federate, FedFileConfig fileConfig ) { diff --git a/org.lflang/src/org/lflang/federated/extensions/PythonExtension.java b/org.lflang/src/org/lflang/federated/extensions/PythonExtension.java index 73bed06f7b..c533a1f765 100644 --- a/org.lflang/src/org/lflang/federated/extensions/PythonExtension.java +++ b/org.lflang/src/org/lflang/federated/extensions/PythonExtension.java @@ -57,7 +57,7 @@ public class PythonExtension extends CExtension { protected void generateCMakeInclude(FederateInstance federate, FedFileConfig fileConfig) throws IOException {} @Override - protected String generateSerializationPreamble(FederateInstance federate, FedFileConfig fileConfig) { + protected String generateSerializationIncludes(FederateInstance federate, FedFileConfig fileConfig) { CodeBuilder code = new CodeBuilder(); for (SupportedSerializers serialization : federate.enabledSerializers) { switch (serialization) {