Skip to content

Commit

Permalink
Fix ROS serialization.
Browse files Browse the repository at this point in the history
The problem was that the relevant #includes were behind an extern "C".
  • Loading branch information
petervdonovan committed May 20, 2023
1 parent 03310fa commit 34c8bcb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -505,6 +503,7 @@ public String generatePreamble(
includes.pr("#ifdef __cplusplus\n"
+ "}\n"
+ "#endif");
includes.pr(generateSerializationIncludes(federate, fileConfig));
}

return includes.toString();
Expand Down Expand Up @@ -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));
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 34c8bcb

Please sign in to comment.