Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User types header-only [19965] #263

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
748 changes: 512 additions & 236 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg

Large diffs are not rendered by default.

1,348 changes: 0 additions & 1,348 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $fast_macro_declarations()$
$ctx.directIncludeDependencies : {include | %include "$include$.i"}; separator="\n"$

%{
#include "$ctx.filename$.h"
#include "$ctx.filename$.hpp"

#include <fastdds/dds/core/LoanableSequence.hpp>
%}
Expand Down Expand Up @@ -66,7 +66,7 @@ namespace swig {
$definitions; separator="\n"$

// Include the class interfaces
%include "$ctx.filename$.h"
%include "$ctx.filename$.hpp"

// Include the corresponding TopicDataType
%include "$ctx.filename$PubSubTypes.i"
Expand Down
214 changes: 112 additions & 102 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ $solution.projects : { project | $pub_sub_execs(project=project, libraries=solut
pub_sub_execs(project, libraries, test) ::= <<

message(STATUS "Configuring $project.name$...")
$if(!project.commonSrcFiles.empty)$
add_library($project.name$_lib $project.commonSrcFiles : { file | $file$}; separator=" "$)
target_link_libraries($project.name$_lib $solution.libraries : { library | $library$}; separator=" "$)
$endif$

$if(!project.projectSrcFiles.empty)$
add_executable($project.name$ $project.projectSrcFiles : { file | $file$}; separator=" "$)
target_link_libraries($project.name$ $solution.libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$
)
$endif$

$if(test)$
Expand All @@ -75,7 +78,8 @@ add_executable($project.name$SerializationTest
target_link_libraries($project.name$SerializationTest
GTest::gtest_main
$solution.libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$
)
gtest_discover_tests($project.name$SerializationTest)

$endif$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "PubSubTypes.h"], description=["This h
#include <fastdds/rtps/common/SerializedPayload.h>
#include <fastrtps/utils/md5.h>

#include "$ctx.filename$.h"
#include "$ctx.filename$.hpp"

$ctx.directIncludeDependencies : {include | #include "$include$PubSubTypes.h"}; separator="\n"$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t;

$definitions; separator="\n"$

$if(ctx.thereIsStructOrUnion)$
// Include auxiliary functions like for serializing/deserializing.
#include "$ctx.filename$CdrAux.ipp"
$endif$

Comment on lines +34 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this included here. TypesCdrAuxHeader has not been removed in this PR, so this code is included twice as far as I understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the inclusion of the implementation was located in TypesSource.stg. This file was removed and now the inclusion is done here (temporally)

>>

module(ctx, parent, module, definition_list) ::= <<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "eprosima.stg"
main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, "JNII.cxx"], description=[""])$

#include "$ctx.filename$.h"
#include "$ctx.filename$.hpp"
#include <jni.h>

#if defined(_WIN32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "Serialization.h"], description=["This
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_SERIALIZATION_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_SERIALIZATION_H_

#include "$ctx.filename$.h"
#include "$ctx.filename$.hpp"

$definitions; separator="\n"$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "TypeObject.cpp"], description=["This s
namespace { char dummy; }
#endif

#include "$ctx.filename$.h"
#include "$ctx.filename$.hpp"
#include "$ctx.filename$TypeObject.h"
#include <mutex>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "CdrAux.hpp"], description=["This sourc
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$CDRAUX_HPP_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$CDRAUX_HPP_

#include "$ctx.filename$.h"
#include "$ctx.filename$.hpp"

$if(ctx.anyCdr)$
$ctx.types:{ type | $if(type.inScope)$$if(type.typeCode.isStructType)$
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/eprosima/fastdds/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import org.stringtemplate.v4.ST;

import com.eprosima.idl.generator.manager.TemplateST;

import java.io.*;

public class Utils
Expand Down Expand Up @@ -74,6 +76,11 @@ public static String addFileSeparator(String directory)
return returnedValue;
}

public static boolean writeFile(String file, TemplateST template, boolean replace)
{
return writeFile(file, template.get_st(), replace);
}

public static boolean writeFile(String file, ST template, boolean replace)
{
boolean returnedValue = false;
Expand Down