Skip to content

Commit 165cbad

Browse files
TypeObject generation (#280)
* Typeobjects with tests (#255) * Fix tests for common struct name in different modules (#268) * Refs #20052: fix tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20052: update submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> --------- Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Added TypeObject tests with templates for primitives and strings structures. Signed-off-by: adriancampo <[email protected]> * Added TypeObject tests for most cases. Signed-off-by: adriancampo <[email protected]> * Added TypeObject tests for unions enums and annotations. Signed-off-by: adriancampo <[email protected]> * Added missing checks Signed-off-by: adriancampo <[email protected]> * API changes. Additional checks. Signed-off-by: adriancampo <[email protected]> * Changes if TypeIdentifiers checks. Signed-off-by: adriancampo <[email protected]> * API changes. Fixed errors. Signed-off-by: adriancampo <[email protected]> * Tests use gtest now. Signed-off-by: adriancampo <[email protected]> * Format changes. Signed-off-by: adriancampo <[email protected]> * Fixed namespaces, inheritance check and type functions. Signed-off-by: adriancampo <[email protected]> * Typo Signed-off-by: adriancampo <[email protected]> * Refs #19595: -typeobject argument is deprecated. TypeObject files will always be generated Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix copyright and include header order. Remove unused headers Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix TypeObjectRegistry::get_type_identifiers call Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix TypeObjectRegistry::get_type_objects call Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: remove const tests: constants do not have TypeObject Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix templates. Remove non-required parameter Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: simplify test templates and include collection and string tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: refactor struct TypeObject test Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: refactor bitset TypeObject test Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: refactor bitset TypeObject tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix enum type TypeObject tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix enum literals TypeObject test Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix bitmask TypeObject tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix type detail annotations checks Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix alias tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix union type TypeObject tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix union member tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: reorder templates. Fixes for string/wstring Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: check Collection TypeIdentifier EquivalenceKind Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix discriminator API according to review suggestion Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: array type tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix map type tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: map type tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix build errors Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: check TypeIdentifier and TypeObject consistency Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: remove non-necessary template attribute Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: member applied annotations check Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: remove non necessary templates. Check already done within consistency methods Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: check dimension/union label Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: add annotation type test Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: w/string type tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: REMOVE: comment TypeObject code in order to build Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: update submodules Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fixes in TypeObject tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: update dds types test submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: update idl parser submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: fix Fast DDS include Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19595: update submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> --------- Signed-off-by: JLBuenoLopez-eProsima <[email protected]> Signed-off-by: adriancampo <[email protected]> Co-authored-by: José Luis Bueno López <[email protected]> Co-authored-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: introduce new templates to generate TypeObject code Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: TypeObject header implementation Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: minor fixes Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: move anonymous collection name generator to common code Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: skeleton Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: improve verbatim annotation test. Alias custom annotations should be included only once Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: fix typo Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: alias type implementation Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: struct_type implementation Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: fix sequential member id Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: struct members Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: refactor TypeObjectSupport infrastructure Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: refactor TypeObjectSupport Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: do not execute code in main function Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: assign proper member id with inheritance Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: refactor register struct type Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: fix calling templates with proper parameters Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: annotation impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: enum impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: w/string impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: several fixes in tests Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: alias impl. Annotation refactor Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: fix get TypeObject template Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: union impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: union member impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: bitset impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: bitmask impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: sequences impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: small refactor to adapt to new throwing API Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: update unbounded collections name Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: arrays impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #19906: map impl Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: support for not applied annotations Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: generate TypeObject tests only for main dependency Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix expected flags Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: option to avoid generating type object support files Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: delete legacy TypeObject template Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: integration, fix use of external and other minor bugs/typos Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: test integration: fix unbounded collections, correctly test collections, correctly check TypeIdentifiers, correctly use fixed_string API Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: use variables Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix conflicts after rebase Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: no type support option disables also TypeObject support generation Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix Fast DDS include Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: avoid warning Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: use genapi module conversion in TypeObject templates Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: create register_type_object_representation method in TypeSupport Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix map keys Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: add sequence order check and fixes in map keys and minimal annotation parameters Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: update IDL Parser submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix Windows warnings C4456: declararion hides previous local declaration Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix collection name in case of enum types Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: update IDL Parser submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: fix Windows warning Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: update IDL Parser submodule Signed-off-by: JLBuenoLopez-eProsima <[email protected]> * Refs #20129: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima <[email protected]> --------- Signed-off-by: JLBuenoLopez-eProsima <[email protected]> Signed-off-by: adriancampo <[email protected]> Co-authored-by: Adrian del Campo <[email protected]>
1 parent d9b23a3 commit 165cbad

File tree

15 files changed

+2870
-2136
lines changed

15 files changed

+2870
-2136
lines changed

resources/Custom.stg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ string_type(ctx, string) ::= <<>>
8484

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

87-
array_declarator(ctx, array, array_type) ::= <<>>
87+
array_declarator(ctx, array) ::= <<>>
8888

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

src/main/java/com/eprosima/fastcdr/idl/context/Context.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public interface Context
3939

4040
public String getHeaderGuardName ();
4141

42-
public boolean isGenerateTypeObject();
43-
4442
public boolean isGenerateTypesROS2();
4543

44+
public boolean isGenerateTypeObjectSupport();
45+
4646
public boolean isCdr();
4747

4848
public boolean isFastcdr();

src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ $endif$
5656

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

59-
$if(ctx.generateTypeObject)$
60-
#include "$ctx.filename$TypeObject.h"
61-
$endif$
62-
6359
#if defined(_WIN32)
6460
#if defined(EPROSIMA_USER_DLL_EXPORT)
6561
#define eProsima_user_DllExport __declspec( dllexport )
@@ -104,9 +100,9 @@ $if(annotation.enums || annotation.typeDefs || annotation.constDecls)$
104100
namespace $annotation.name$ {
105101
$annotation.enums : { enum | $enum_type(ctx=ctx, parent=annotation, enum=enum)$}; separator="\n"$
106102

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

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

111107
} // namespace $annotation.name$
112108
$endif$
@@ -157,10 +153,6 @@ public:
157153
: $struct_inherit_default_init(struct.inheritance)$
158154
$endif$
159155
{
160-
$if(ctx.generateTypeObject)$
161-
// Just to register all known types
162-
register$ctx.filename$Types();
163-
$endif$
164156
}
165157

166158
/*!
@@ -491,10 +483,6 @@ public:
491483
: $struct_inherit_default_init(bitset.inheritance)$
492484
$endif$
493485
{
494-
$if(ctx.generateTypeObject)$
495-
// Just to register all known types
496-
register$ctx.filename$Types();
497-
$endif$
498486
}
499487

500488
/*!

src/main/java/com/eprosima/fastdds/fastddsgen.java

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ public class fastddsgen
107107
// Generates type naming compatible with ROS 2
108108
private boolean m_type_ros2 = false;
109109

110-
// Generate TypeObject files?
111-
private boolean m_type_object_files = false;
112-
113110
// Generate string and sequence types compatible with C?
114111
private boolean m_typesc = false;
115112

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

144+
// Specifies whether the TypeObject Support files should be generated.
145+
private boolean generate_typeobjectsupport_ = true;
146+
147147
/*
148148
* ----------------------------------------------------------------------------------------
149149
*
@@ -307,11 +307,16 @@ else if (languageOption.equalsIgnoreCase("java"))
307307
else if (arg.equals(no_typesupport_arg))
308308
{
309309
generate_typesupport_ = false;
310+
generate_typeobjectsupport_ = false;
310311
}
311312
else if (arg.equals(no_dependencies_arg))
312313
{
313314
generate_dependencies_ = false;
314315
}
316+
else if (arg.equals(no_typeobjectsupport_arg))
317+
{
318+
generate_typeobjectsupport_ = false;
319+
}
315320
else if (arg.equals(package_arg))
316321
{
317322
if (count < args.length)
@@ -361,10 +366,6 @@ else if (arg.equals(execute_test_arg))
361366
{
362367
m_test = true;
363368
}
364-
else if (arg.equals(typeobject_arg))
365-
{
366-
m_type_object_files = true;
367-
}
368369
else if (arg.equals(ros2_names_arg))
369370
{
370371
m_type_ros2 = true;
@@ -579,6 +580,7 @@ private void showVersion()
579580
private static final String include_path_arg = "-I";
580581
private static final String language_arg = "-language";
581582
private static final String no_typesupport_arg = "-no-typesupport";
583+
private static final String no_typeobjectsupport_arg = "-no-typeobjectsupport";
582584
private static final String no_dependencies_arg = "-no-dependencies";
583585
private static final String package_arg = "-package";
584586
private static final String disable_preprocessor_arg = "-ppDisable";
@@ -628,15 +630,15 @@ public static void printHelp()
628630
System.out.println("\t\t" + include_path_arg + " <path>: add directory to preprocessor include paths.");
629631
System.out.println("\t\t" + language_arg + " <lang>: chooses between <c++> or <java> languages.");
630632
System.out.println("\t\t" + no_typesupport_arg + ": avoid generating the type support files.");
633+
System.out.println("\t\t" + no_typeobjectsupport_arg + ": avoid generating the TypeObject support specific files.");
634+
System.out.println("\t\t\tEnabled automatically if " + no_typesupport_arg + " argument is used.");
631635
System.out.println("\t\t" + no_dependencies_arg + ": avoid processing the dependent IDL files.");
632636
System.out.println("\t\t" + package_arg + ": default package used in Java files.");
633637
System.out.println("\t\t" + disable_preprocessor_arg + ": disables the preprocessor.");
634638
System.out.println("\t\t" + preprocessor_path_arg + ": specifies the preprocessor path.");
635639
System.out.println("\t\t" + python_bindings_arg + ": generates python bindings for the generated types.");
636640
System.out.println("\t\t" + replace_arg + ": replaces existing generated files.");
637641
System.out.println("\t\t" + temp_dir_arg + " <temp dir>: sets a specific directory as a temporary directory.");
638-
System.out.print("\t\t" + typeobject_arg + ": generates TypeObject files to automatically register the ");
639-
System.out.println("types as dynamic.");
640642
System.out.println("\t\t" + cnames_arg + ": generates string and sequence types compatible with C.");
641643
System.out.println("\t\t" + ros2_names_arg + ": generates type naming compatible with ROS2.");
642644
System.out.println("\t\t" + version_arg + ": shows the current version of eProsima Fast DDS gen.");
@@ -730,7 +732,7 @@ private Project parseIDL(
730732
TemplateManager tmanager = new TemplateManager();
731733

732734
Context ctx = new Context(tmanager, idlFilename, m_includePaths, m_subscribercode, m_publishercode,
733-
m_localAppProduct, m_type_object_files, m_typesc, m_type_ros2, gen_api_);
735+
m_localAppProduct, m_typesc, m_type_ros2, gen_api_, generate_typeobjectsupport_);
734736

735737
String relative_dir = ctx.getRelativeDir(dependant_idl_dir);
736738
String output_dir;
@@ -769,11 +771,6 @@ private Project parseIDL(
769771
// Load common types template
770772
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesHeader.stg").enable_custom_property(
771773
Context.using_explicitly_modules_custom_property);
772-
if (m_type_object_files)
773-
{
774-
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg");
775-
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg");
776-
}
777774

778775
// Load Types common templates
779776
if (generate_typesupport_)
@@ -782,6 +779,12 @@ private Project parseIDL(
782779
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg");
783780
tmanager.addGroup("com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg");
784781
tmanager.addGroup("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg");
782+
783+
if (generate_typeobjectsupport_)
784+
{
785+
tmanager.addGroup("com/eprosima/fastdds/idl/templates/XTypesTypeObjectHeader.stg");
786+
tmanager.addGroup("com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg");
787+
}
785788
}
786789

787790
if (m_exampleOption != null)
@@ -804,6 +807,12 @@ private Project parseIDL(
804807
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationTestSource.stg");
805808
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationHeader.stg");
806809
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationSource.stg");
810+
811+
if (generate_typeobjectsupport_)
812+
{
813+
// Load TypeObjectSupport test template
814+
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg");
815+
}
807816
}
808817

809818
// Add JNI sources.
@@ -852,8 +861,7 @@ private Project parseIDL(
852861
lexer.setContext(ctx);
853862
CommonTokenStream tokens = new CommonTokenStream(lexer);
854863
IDLParser parser = new IDLParser(tokens);
855-
// Pass the finelame without the extension
856-
864+
// Pass the filename without the extension
857865
Specification specification = parser.specification(ctx, tmanager, maintemplates).spec;
858866
returnedValue = specification != null && !tmanager.get_st_error();;
859867

@@ -909,32 +917,17 @@ private Project parseIDL(
909917
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesHeader.stg"),
910918
m_replace)))
911919
{
912-
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + ".hpp");
913-
914-
if (m_type_object_files)
915-
{
916-
System.out.println("Generating TypeObject files...");
917-
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.h",
918-
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg"), m_replace))
919-
{
920-
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.cxx",
921-
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg"), m_replace))
922-
{
923-
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "TypeObject.h");
924-
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "TypeObject.cxx");
925-
}
926-
}
927-
}
928-
if (m_python)
929-
{
930-
System.out.println("Generating Swig interface files...");
931-
if (returnedValue =
932-
Utils.writeFile(output_dir + ctx.getFilename() + ".i",
933-
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg"), m_replace))
934-
{
935-
936-
}
937-
}
920+
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + ".hpp");
921+
922+
if (m_python)
923+
{
924+
System.out.println("Generating Swig interface files...");
925+
if (returnedValue =
926+
Utils.writeFile(output_dir + ctx.getFilename() + ".i",
927+
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg"), m_replace))
928+
{
929+
}
930+
}
938931
}
939932

940933
if (m_test)
@@ -961,11 +954,34 @@ private Project parseIDL(
961954
String trimmedElement = element.substring(0, element.length() - 4);// Remove .idl
962955
project.addCommonTestingFile(trimmedElement + "Serialization.cpp");
963956
}
957+
958+
if (generate_typeobjectsupport_)
959+
{
960+
System.out.println("Generating TypeObjects Test file...");
961+
String fileNameTO = output_dir + ctx.getFilename() + "TypeObjectTestingTest.cpp";
962+
returnedValue = Utils.writeFile(fileNameTO, maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg"), m_replace);
963+
project.addTypeObjectTestingFile(relative_dir + ctx.getFilename() + "TypeObjectTestingTest.cpp");
964+
}
964965
}
965966

966967
System.out.println("Generating Type Support files...");
967968
if (generate_typesupport_)
968969
{
970+
if (generate_typeobjectsupport_)
971+
{
972+
System.out.println("Generating TypeObjectSupport files...");
973+
if (returnedValue &= Utils.writeFile(output_dir + ctx.getFilename() + "TypeObjectSupport.hpp",
974+
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/XTypesTypeObjectHeader.stg"), m_replace))
975+
{
976+
if (returnedValue &= Utils.writeFile(output_dir + ctx.getFilename() + "TypeObjectSupport.cxx",
977+
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg"), m_replace))
978+
{
979+
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "TypeObjectSupport.hpp");
980+
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "TypeObjectSupport.cxx");
981+
}
982+
}
983+
}
984+
969985
if (ctx.isThereIsStructOrUnion())
970986
{
971987
if (returnedValue &=
@@ -1669,7 +1685,7 @@ public void run()
16691685
}
16701686
else
16711687
{
1672-
// Sustituir los "\\" que pone cl.exe por "\"
1688+
// Substitute "\\" added by cl.exe for "\"
16731689
if (line.startsWith(clLine))
16741690
{
16751691
line = "#" + line.substring(clLine.length());

src/main/java/com/eprosima/fastdds/idl/grammar/Context.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ public Context(
6161
boolean subscribercode,
6262
boolean publishercode,
6363
String appProduct,
64-
boolean generate_type_object,
6564
boolean generate_typesc,
6665
boolean generate_type_ros2,
67-
boolean is_generating_api
66+
boolean is_generating_api,
67+
boolean generate_typeobjectsupport
6868
)
6969
{
7070
super(tmanager, file, includePaths, generate_typesc);
@@ -78,13 +78,13 @@ public Context(
7878
//m_protocol = protocol;
7979
//m_ddstypes = ddstypes;
8080

81-
m_type_object = generate_type_object;
8281
m_type_ros2 = generate_type_ros2;
8382
is_generating_api_ = is_generating_api;
83+
generate_typeobject_support_ = generate_typeobjectsupport;
8484

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

8989
}
9090

@@ -565,20 +565,20 @@ public String getPackageUnder()
565565

566566
private TypeDeclaration m_lastStructure = null;
567567

568-
private boolean m_type_object = false;
569-
570568
private boolean m_type_ros2 = false;
571569

570+
private boolean generate_typeobject_support_ = true;
571+
572572
@Override
573-
public boolean isGenerateTypeObject()
573+
public boolean isGenerateTypesROS2()
574574
{
575-
return m_type_object;
575+
return m_type_ros2;
576576
}
577577

578578
@Override
579-
public boolean isGenerateTypesROS2()
579+
public boolean isGenerateTypeObjectSupport()
580580
{
581-
return m_type_ros2;
581+
return generate_typeobject_support_;
582582
}
583583

584584
public String getHeaderGuardName ()

src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,23 @@ find_package(fastrtps 2.12 REQUIRED)
4343

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

46+
$if (test)$
47+
$type_object_tests(project=solution.mainProject, libraries=solution.libraries)$
48+
$endif$
49+
4650
>>
4751

4852
pub_sub_execs(project, libraries, test) ::= <<
4953

5054
message(STATUS "Configuring $project.name$...")
5155
$if(!project.commonSrcFiles.empty)$
5256
add_library($project.name$_lib $project.commonSrcFiles : { file | $file$}; separator=" "$)
53-
target_link_libraries($project.name$_lib $solution.libraries : { library | $library$}; separator=" "$)
57+
target_link_libraries($project.name$_lib $libraries : { library | $library$}; separator=" "$)
5458
$endif$
5559

5660
$if(!project.projectSrcFiles.empty)$
5761
add_executable($project.name$ $project.projectSrcFiles : { file | $file$}; separator=" "$)
58-
target_link_libraries($project.name$ $solution.libraries : { library | $library$}; separator=" "$
62+
target_link_libraries($project.name$ $libraries : { library | $library$}; separator=" "$
5963
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$
6064
)
6165
$endif$
@@ -77,11 +81,26 @@ add_executable($project.name$SerializationTest
7781
)
7882
target_link_libraries($project.name$SerializationTest
7983
GTest::gtest_main
80-
$solution.libraries : { library | $library$}; separator=" "$
84+
$libraries : { library | $library$}; separator=" "$
8185
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$
8286
)
8387
gtest_discover_tests($project.name$SerializationTest)
8488

8589
$endif$
8690

91+
92+
>>
93+
94+
type_object_tests(project, libraries) ::= <<
95+
$if(project.typeObjectTestingFiles)$
96+
# $project.name$ TypeObject Test
97+
add_executable($project.name$TypeObjectTestingTest
98+
$project.typeObjectTestingFiles : { file | $file$}; separator="\n"$
99+
)
100+
target_link_libraries($project.name$TypeObjectTestingTest
101+
GTest::gtest_main
102+
$libraries : { library | $library$}; separator=" "$
103+
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)
104+
gtest_discover_tests($project.name$TypeObjectTestingTest)
105+
$endif$
87106
>>

0 commit comments

Comments
 (0)