Skip to content

Commit

Permalink
TypeObject generation (#280)
Browse files Browse the repository at this point in the history
* Typeobjects with tests (#255)

* Fix tests for common struct name in different modules (#268)

* Refs #20052: fix tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20052: update submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

---------

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Added TypeObject tests with templates for primitives and strings structures.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Added TypeObject tests for most cases.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Added TypeObject tests for unions enums and annotations.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Added missing checks

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* API changes. Additional checks.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Changes if TypeIdentifiers checks.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* API changes. Fixed errors.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Tests use gtest now.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Format changes.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Fixed namespaces, inheritance check and type functions.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Typo

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Refs #19595: -typeobject argument is deprecated. TypeObject files will always be generated

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix copyright and include header order. Remove unused headers

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix TypeObjectRegistry::get_type_identifiers call

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix TypeObjectRegistry::get_type_objects call

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: remove const tests: constants do not have TypeObject

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix templates. Remove non-required parameter

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: simplify test templates and include collection and string tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: refactor struct TypeObject test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: refactor bitset TypeObject test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: refactor bitset TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix enum type TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix enum literals TypeObject test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix bitmask TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix type detail annotations checks

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix alias tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix union type TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix union member tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: reorder templates. Fixes for string/wstring

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: check Collection TypeIdentifier EquivalenceKind

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix discriminator API according to review suggestion

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: array type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix map type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: map type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix build errors

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: check TypeIdentifier and TypeObject consistency

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: remove non-necessary template attribute

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: member applied annotations check

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: remove non necessary templates. Check already done within consistency methods

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: check dimension/union label

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: add annotation type test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: w/string type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: REMOVE: comment TypeObject code in order to build

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update submodules

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fixes in TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update dds types test submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update idl parser submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix Fast DDS include

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

---------

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: adriancampo <adriancampo@eprosima.com>
Co-authored-by: José Luis Bueno López <69244257+JLBuenoLopez-eProsima@users.noreply.github.com>
Co-authored-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: introduce new templates to generate TypeObject code

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: TypeObject header implementation

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: minor fixes

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: move anonymous collection name generator to common code

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: skeleton

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: improve verbatim annotation test. Alias custom annotations should be included only once

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: fix typo

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: alias type implementation

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: struct_type implementation

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: fix sequential member id

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: struct members

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: refactor TypeObjectSupport infrastructure

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: refactor TypeObjectSupport

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: do not execute code in main function

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: assign proper member id with inheritance

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: refactor register struct type

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: fix calling templates with proper parameters

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: annotation impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: enum impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: w/string impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: several fixes in tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: alias impl. Annotation refactor

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: fix get TypeObject template

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: union impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: union member impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: bitset impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: bitmask impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: sequences impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: small refactor to adapt to new throwing API

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: update unbounded collections name

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: arrays impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19906: map impl

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: support for not applied annotations

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: generate TypeObject tests only for main dependency

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix expected flags

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: option to avoid generating type object support files

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: delete legacy TypeObject template

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: integration, fix use of external and other minor bugs/typos

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: test integration: fix unbounded collections, correctly test collections, correctly check TypeIdentifiers, correctly use fixed_string API

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: use variables

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix conflicts after rebase

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: no type support option disables also TypeObject support generation

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix Fast DDS include

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: avoid warning

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: use genapi module conversion in TypeObject templates

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: apply review suggestions

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: create register_type_object_representation method in TypeSupport

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix map keys

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: add sequence order check and fixes in map keys and minimal annotation parameters

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: update IDL Parser submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix Windows warnings C4456: declararion hides previous local declaration

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix collection name in case of enum types

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: update IDL Parser submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: fix Windows warning

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: update IDL Parser submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20129: apply review suggestions

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

---------

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: adriancampo <adriancampo@eprosima.com>
Co-authored-by: Adrian del Campo <107918259+adriancampo@users.noreply.github.com>
  • Loading branch information
2 people authored and richiware committed Mar 13, 2024
1 parent c44ac1e commit d221f8b
Show file tree
Hide file tree
Showing 14 changed files with 2,869 additions and 2,135 deletions.
2 changes: 1 addition & 1 deletion resources/Custom.stg
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ string_type(ctx, string) ::= <<>>

wide_string_type(ctx, wstring) ::= <<>>

array_declarator(ctx, array, array_type) ::= <<>>
array_declarator(ctx, array) ::= <<>>

interface(ctx, parent, interface, export_list) ::= <<>>

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/eprosima/fastcdr/idl/context/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public interface Context

public String getHeaderGuardName ();

public boolean isGenerateTypeObject();

public boolean isGenerateTypesROS2();

public boolean isGenerateTypeObjectSupport();

public boolean isCdr();

public boolean isFastcdr();
Expand Down
16 changes: 2 additions & 14 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ $endif$

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

$if(ctx.generateTypeObject)$
#include "$ctx.filename$TypeObject.h"
$endif$

#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
Expand Down Expand Up @@ -104,9 +100,9 @@ $if(annotation.enums || annotation.typeDefs || annotation.constDecls)$
namespace $annotation.name$ {
$annotation.enums : { enum | $enum_type(ctx=ctx, parent=annotation, enum=enum)$}; separator="\n"$

$annotation.typeDefs : { typedef | $typedef_decl(ctx=ctx, parent=annotation, typedefs=typedef)$}; separator="\n"$
$annotation.typeDefs : { typedef | $typedef_decl(ctx=ctx, parent=annotation, typedefs=typedef, typedefs_type="", declarator_type="")$}; separator="\n"$

$annotation.constDecls : { const | $const_decl(ctx=ctx, parent=annotation, const=const)$}; separator="\n"$
$annotation.constDecls : { const | $const_decl(ctx=ctx, parent=annotation, const=const, const_type="")$}; separator="\n"$

} // namespace $annotation.name$
$endif$
Expand Down Expand Up @@ -157,10 +153,6 @@ public:
: $struct_inherit_default_init(struct.inheritance)$
$endif$
{
$if(ctx.generateTypeObject)$
// Just to register all known types
register$ctx.filename$Types();
$endif$
}

/*!
Expand Down Expand Up @@ -491,10 +483,6 @@ public:
: $struct_inherit_default_init(bitset.inheritance)$
$endif$
{
$if(ctx.generateTypeObject)$
// Just to register all known types
register$ctx.filename$Types();
$endif$
}

/*!
Expand Down
104 changes: 60 additions & 44 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ public class fastddsgen
// Generates type naming compatible with ROS 2
private boolean m_type_ros2 = false;

// Generate TypeObject files?
private boolean m_type_object_files = false;

// Generate string and sequence types compatible with C?
private boolean m_typesc = false;

Expand Down Expand Up @@ -144,6 +141,9 @@ public enum LANGUAGE
// Specifies whether the dependent IDL files should be processed.
private boolean generate_dependencies_ = true;

// Specifies whether the TypeObject Support files should be generated.
private boolean generate_typeobjectsupport_ = true;

/*
* ----------------------------------------------------------------------------------------
*
Expand Down Expand Up @@ -307,11 +307,16 @@ else if (languageOption.equalsIgnoreCase("java"))
else if (arg.equals(no_typesupport_arg))
{
generate_typesupport_ = false;
generate_typeobjectsupport_ = false;
}
else if (arg.equals(no_dependencies_arg))
{
generate_dependencies_ = false;
}
else if (arg.equals(no_typeobjectsupport_arg))
{
generate_typeobjectsupport_ = false;
}
else if (arg.equals(package_arg))
{
if (count < args.length)
Expand Down Expand Up @@ -361,10 +366,6 @@ else if (arg.equals(execute_test_arg))
{
m_test = true;
}
else if (arg.equals(typeobject_arg))
{
m_type_object_files = true;
}
else if (arg.equals(ros2_names_arg))
{
m_type_ros2 = true;
Expand Down Expand Up @@ -579,6 +580,7 @@ private void showVersion()
private static final String include_path_arg = "-I";
private static final String language_arg = "-language";
private static final String no_typesupport_arg = "-no-typesupport";
private static final String no_typeobjectsupport_arg = "-no-typeobjectsupport";
private static final String no_dependencies_arg = "-no-dependencies";
private static final String package_arg = "-package";
private static final String disable_preprocessor_arg = "-ppDisable";
Expand Down Expand Up @@ -628,15 +630,15 @@ public static void printHelp()
System.out.println("\t\t" + include_path_arg + " <path>: add directory to preprocessor include paths.");
System.out.println("\t\t" + language_arg + " <lang>: chooses between <c++> or <java> languages.");
System.out.println("\t\t" + no_typesupport_arg + ": avoid generating the type support files.");
System.out.println("\t\t" + no_typeobjectsupport_arg + ": avoid generating the TypeObject support specific files.");
System.out.println("\t\t\tEnabled automatically if " + no_typesupport_arg + " argument is used.");
System.out.println("\t\t" + no_dependencies_arg + ": avoid processing the dependent IDL files.");
System.out.println("\t\t" + package_arg + ": default package used in Java files.");
System.out.println("\t\t" + disable_preprocessor_arg + ": disables the preprocessor.");
System.out.println("\t\t" + preprocessor_path_arg + ": specifies the preprocessor path.");
System.out.println("\t\t" + python_bindings_arg + ": generates python bindings for the generated types.");
System.out.println("\t\t" + replace_arg + ": replaces existing generated files.");
System.out.println("\t\t" + temp_dir_arg + " <temp dir>: sets a specific directory as a temporary directory.");
System.out.print("\t\t" + typeobject_arg + ": generates TypeObject files to automatically register the ");
System.out.println("types as dynamic.");
System.out.println("\t\t" + cnames_arg + ": generates string and sequence types compatible with C.");
System.out.println("\t\t" + ros2_names_arg + ": generates type naming compatible with ROS2.");
System.out.println("\t\t" + version_arg + ": shows the current version of eProsima Fast DDS gen.");
Expand Down Expand Up @@ -730,7 +732,7 @@ private Project parseIDL(
TemplateManager tmanager = new TemplateManager();

Context ctx = new Context(tmanager, idlFilename, m_includePaths, m_subscribercode, m_publishercode,
m_localAppProduct, m_type_object_files, m_typesc, m_type_ros2, gen_api_);
m_localAppProduct, m_typesc, m_type_ros2, gen_api_, generate_typeobjectsupport_);

String relative_dir = ctx.getRelativeDir(dependant_idl_dir);
String output_dir;
Expand Down Expand Up @@ -769,11 +771,6 @@ private Project parseIDL(
// Load common types template
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesHeader.stg").enable_custom_property(
Context.using_explicitly_modules_custom_property);
if (m_type_object_files)
{
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg");
}

// Load Types common templates
if (generate_typesupport_)
Expand All @@ -782,6 +779,12 @@ private Project parseIDL(
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg");

if (generate_typeobjectsupport_)
{
tmanager.addGroup("com/eprosima/fastdds/idl/templates/XTypesTypeObjectHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg");
}
}

if (m_exampleOption != null)
Expand All @@ -804,6 +807,12 @@ private Project parseIDL(
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationTestSource.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationSource.stg");

if (generate_typeobjectsupport_)
{
// Load TypeObjectSupport test template
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg");
}
}

// Add JNI sources.
Expand Down Expand Up @@ -852,8 +861,7 @@ private Project parseIDL(
lexer.setContext(ctx);
CommonTokenStream tokens = new CommonTokenStream(lexer);
IDLParser parser = new IDLParser(tokens);
// Pass the finelame without the extension

// Pass the filename without the extension
Specification specification = parser.specification(ctx, tmanager, maintemplates).spec;
returnedValue = specification != null && !tmanager.get_st_error();;

Expand Down Expand Up @@ -909,32 +917,17 @@ private Project parseIDL(
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesHeader.stg"),
m_replace)))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + ".hpp");

if (m_type_object_files)
{
System.out.println("Generating TypeObject files...");
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.h",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg"), m_replace))
{
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg"), m_replace))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "TypeObject.h");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "TypeObject.cxx");
}
}
}
if (m_python)
{
System.out.println("Generating Swig interface files...");
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + ".i",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg"), m_replace))
{

}
}
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + ".hpp");

if (m_python)
{
System.out.println("Generating Swig interface files...");
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + ".i",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg"), m_replace))
{
}
}
}

if (m_test)
Expand All @@ -961,11 +954,34 @@ private Project parseIDL(
String trimmedElement = element.substring(0, element.length() - 4);// Remove .idl
project.addCommonTestingFile(trimmedElement + "Serialization.cpp");
}

if (generate_typeobjectsupport_)
{
System.out.println("Generating TypeObjects Test file...");
String fileNameTO = output_dir + ctx.getFilename() + "TypeObjectTestingTest.cpp";
returnedValue = Utils.writeFile(fileNameTO, maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg"), m_replace);
project.addTypeObjectTestingFile(relative_dir + ctx.getFilename() + "TypeObjectTestingTest.cpp");
}
}

System.out.println("Generating Type Support files...");
if (generate_typesupport_)
{
if (generate_typeobjectsupport_)
{
System.out.println("Generating TypeObjectSupport files...");
if (returnedValue &= Utils.writeFile(output_dir + ctx.getFilename() + "TypeObjectSupport.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/XTypesTypeObjectHeader.stg"), m_replace))
{
if (returnedValue &= Utils.writeFile(output_dir + ctx.getFilename() + "TypeObjectSupport.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg"), m_replace))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "TypeObjectSupport.hpp");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "TypeObjectSupport.cxx");
}
}
}

if (ctx.isThereIsStructOrUnion())
{
if (returnedValue &=
Expand Down Expand Up @@ -1669,7 +1685,7 @@ public void run()
}
else
{
// Sustituir los "\\" que pone cl.exe por "\"
// Substitute "\\" added by cl.exe for "\"
if (line.startsWith(clLine))
{
line = "#" + line.substring(clLine.length());
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/eprosima/fastdds/idl/grammar/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public Context(
boolean subscribercode,
boolean publishercode,
String appProduct,
boolean generate_type_object,
boolean generate_typesc,
boolean generate_type_ros2,
boolean is_generating_api
boolean is_generating_api,
boolean generate_typeobjectsupport
)
{
super(tmanager, file, includePaths, generate_typesc);
Expand All @@ -78,13 +78,13 @@ public Context(
//m_protocol = protocol;
//m_ddstypes = ddstypes;

m_type_object = generate_type_object;
m_type_ros2 = generate_type_ros2;
is_generating_api_ = is_generating_api;
generate_typeobject_support_ = generate_typeobjectsupport;

// Create default @Key annotation.
AnnotationDeclaration keyann = this.createAnnotationDeclaration("Key", null);
keyann.addMember(new AnnotationMember("value", new PrimitiveTypeCode(Kind.KIND_BOOLEAN), "true"));
AnnotationDeclaration keyann = this.createAnnotationDeclaration(Annotation.eprosima_key_str, null);
keyann.addMember(new AnnotationMember(Annotation.value_str, new PrimitiveTypeCode(Kind.KIND_BOOLEAN), Annotation.true_str));

}

Expand Down Expand Up @@ -565,20 +565,20 @@ public String getPackageUnder()

private TypeDeclaration m_lastStructure = null;

private boolean m_type_object = false;

private boolean m_type_ros2 = false;

private boolean generate_typeobject_support_ = true;

@Override
public boolean isGenerateTypeObject()
public boolean isGenerateTypesROS2()
{
return m_type_object;
return m_type_ros2;
}

@Override
public boolean isGenerateTypesROS2()
public boolean isGenerateTypeObjectSupport()
{
return m_type_ros2;
return generate_typeobject_support_;
}

public String getHeaderGuardName ()
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,23 @@ find_package(fastrtps 2.12 REQUIRED)

$solution.projects : { project | $pub_sub_execs(project=project, libraries=solution.libraries, test=test)$}; separator="\n"$

$if (test)$
$type_object_tests(project=solution.mainProject, libraries=solution.libraries)$
$endif$

>>

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=" "$)
target_link_libraries($project.name$_lib $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=" "$
target_link_libraries($project.name$ $libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$
)
$endif$
Expand All @@ -77,11 +81,26 @@ add_executable($project.name$SerializationTest
)
target_link_libraries($project.name$SerializationTest
GTest::gtest_main
$solution.libraries : { library | $library$}; separator=" "$
$libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$
)
gtest_discover_tests($project.name$SerializationTest)

$endif$


>>

type_object_tests(project, libraries) ::= <<
$if(project.typeObjectTestingFiles)$
# $project.name$ TypeObject Test
add_executable($project.name$TypeObjectTestingTest
$project.typeObjectTestingFiles : { file | $file$}; separator="\n"$
)
target_link_libraries($project.name$TypeObjectTestingTest
GTest::gtest_main
$libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)
gtest_discover_tests($project.name$TypeObjectTestingTest)
$endif$
>>
Loading

0 comments on commit d221f8b

Please sign in to comment.