Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5c332a2
Add builtin `@feed` annotation (#435)
MiguelCompany Feb 11, 2025
c043c3c
Generate type definitions for exceptions (#436)
MiguelCompany Feb 20, 2025
7e18f1c
Generate code for interfaces in header files (#447)
MiguelCompany Mar 7, 2025
4597ede
Generate request / reply data structures (#451)
MiguelCompany Apr 1, 2025
1caee11
Generate ServiceTypeSupport for interfaces (#459)
MiguelCompany Apr 7, 2025
f609455
Generate code for interface clients (#464)
MiguelCompany Apr 21, 2025
b24f52a
Generate code for interface servers (#465)
MiguelCompany May 8, 2025
c19fcd8
Refs #23153. Fix build after rebase.
MiguelCompany May 8, 2025
de836a5
Refs #23153. Update dds-types-test submodule.
MiguelCompany May 8, 2025
6323f2f
Refs #23153. Add created interfaces to context.
MiguelCompany May 8, 2025
9fa832d
Refs #23153. Fix generation of interfaces with inheritance.
MiguelCompany May 8, 2025
1bb59cb
Refs #23153. Avoid generation of code for nested interfaces.
MiguelCompany May 9, 2025
4526046
Refs #23153. Fix build with non-namespaced interfaces.
MiguelCompany May 12, 2025
c8e2b73
Refs #23153. Do not generate type support for nested.
MiguelCompany May 12, 2025
0ee2c98
Refs #23153. Add IDL from review.
MiguelCompany May 12, 2025
dc16a4b
Refs #23153. Filter replies from different writers.
MiguelCompany May 12, 2025
86cfe76
Refs #23153. Always generate PubSubTypes.
MiguelCompany May 12, 2025
b1e5da7
Refs #23153. Fix generation of `using namespace ...`
MiguelCompany May 13, 2025
aac53be
Refs #23153. Fix generation of test code.
MiguelCompany May 13, 2025
b23ae99
Refs #23153. Update submodules.
MiguelCompany May 14, 2025
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
32 changes: 32 additions & 0 deletions src/main/java/com/eprosima/fastcdr/idl/templates/FastCdrCommon.stg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,38 @@

group FastCdrCommon;

paramRetType(typecode) ::= <%
$if(typecode)$
$typecode.cppTypename$
$else$
void
$endif$
%>

paramTypeByRef(typecode) ::= <%
$typecode.cppTypename$&
%>

paramTypeByValue(typecode, feed, is_server) ::= <%
$if(feed)$
$if(is_server)$
eprosima::fastdds::dds::rpc::RpcServerReader<$typecode.cppTypename$>&
$else$
std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<$typecode.cppTypename$>>&
$endif$
$else$
$if(typecode.primitive)$
$typecode.cppTypename$
$else$
const $typecode.cppTypename$&
$endif$
$endif$
%>

paramDeclarations(params, initialSeparator="") ::= <<
$if(params)$$initialSeparator$$endif$$params : {param | /*$param.comment$*/ $if(param.output)$$paramTypeByRef(typecode=param.typecode)$$else$$paramTypeByValue(typecode=param.typecode, feed=param.annotationFeed, is_server=false)$$endif$ $param.name$}; anchor, separator=",\n"$
>>

object_serialization(ctx, object) ::= <<
scdr << eprosima::fastcdr::MemberId($object.id$) << $object.name$();
>>
Expand Down
97 changes: 96 additions & 1 deletion src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ $endif$
$if(ctx.thereIsMap)$
#include <map>
$endif$
$if(ctx.thereIsInputFeed || ctx.thereIsOutputFeed)$
#include <memory>
$endif$
$if(ctx.thereIsString)$
#include <string>
$endif$
Expand All @@ -54,6 +57,19 @@ $if(ctx.thereIsUnion)$
#include <fastcdr/exceptions/BadParamException.h>
$endif$

$if(ctx.thereIsException)$
#include <fastdds/dds/rpc/exceptions/RpcOperationError.hpp>
$endif$
$if(ctx.thereIsOutputFeed)$
#include <fastdds/dds/rpc/interfaces/RpcClientReader.hpp>
$endif$
$if(ctx.thereIsInputFeed)$
#include <fastdds/dds/rpc/interfaces/RpcClientWriter.hpp>
$endif$
$if(ctx.thereIsNonFeedOperation)$
#include <fastdds/dds/rpc/interfaces/RpcFuture.hpp>
$endif$

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

#if defined(_WIN32)
Expand Down Expand Up @@ -108,19 +124,90 @@ namespace $annotation.name$ {
$endif$
>>

exception(ctx, parent, exception, extensions) ::= <<
/*!
* @brief This class implements the user exception $exception.scopedname$
* @ingroup $ctx.trimfilename$
*/
class eProsima_user_DllExport $exception.name$ : public eprosima::fastdds::dds::rpc::RpcOperationError
{
public:

/**
* Default constructor.
*/
$exception.name$()
: $exception.name$("$exception.name$")
{
}

/**
* Constructor.
*/
$exception.name$(
const std::string& message)
: eprosima::fastdds::dds::rpc::RpcOperationError(message)
{
}

/**
* Constructor.
*/
$exception.name$(
const char* message)
: eprosima::fastdds::dds::rpc::RpcOperationError(message)
{
}

/**
* Copy constructor.
*/
$exception.name$(
const $exception.name$& other) noexcept = default;

/**
* Copy assignment.
*/
$exception.name$& operator =(
const $exception.name$& other) noexcept = default;

/**
* Destructor.
*/
virtual ~$exception.name$() noexcept = default;

$exception.members:{ member | $public_member_declaration(member)$}; separator="\n"$

$extensions : { extension | $extension$}; separator="\n"$

private:

$exception.members:{ member | $private_member_declaration(member=member)$}; separator="\n"$

};

>>

interface(ctx, parent, interface, export_list) ::= <<
/*!
* @brief This class represents the interface $interface.name$ defined by the user in the IDL file.
* @ingroup $ctx.trimfilename$
*/
class $ctx.fileNameUpper$_DllAPI $interface.name$ $if(interface.bases)$: $interface.bases : {base |public $base.scopedname$}; separator=", "$$endif$
class eProsima_user_DllExport $interface.name$ $if(interface.bases)$: $interface.bases : {base |public $base.scopedname$}; separator=", "$$endif$
{
public:
virtual ~$interface.name$() = default;

$export_list$
};
>>

operation(ctx, parent, operation, param_list, operation_type) ::= <<
virtual $operationRetType(operation)$ $operation.name$(
$paramDeclarations(params=operation.parameters)$) = 0;

>>

const_decl(ctx, parent, const, const_type) ::= <<
$const_type$
const $const.typeCode.cppTypename$ $const.name$ = $const.value$$const_value_prefix(const)$;
Expand Down Expand Up @@ -849,6 +936,14 @@ new(&m_$member.name$) $member_type_declaration(member)$();
$endif$
>>

operationRetType(operation) ::= <%
$if(operation.annotationFeed)$
std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$> >
$else$
eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$>
$endif$
%>

//{ Fast DDS-Gen extensions
module_conversion(ctx, parent, modules, definition_list) ::= <<
$modules : { module |
Expand Down
67 changes: 58 additions & 9 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,16 @@ private Project parseIDL(
// Load Types common templates
if (generate_typesupport_)
{
tmanager.addGroup("com/eprosima/fastdds/idl/templates/InterfaceDetails.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeader.stg");
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");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/ClientHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/ClientSource.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/ServerHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/ServerSource.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/ServerImplementation.stg");

if (generate_typeobjectsupport_)
{
Expand Down Expand Up @@ -1014,7 +1020,15 @@ private Project parseIDL(
}
}

if (ctx.isThereIsStructOrUnion())
if (ctx.isThereIsInterface())
{
// Generate Interface details
returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "_details.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/InterfaceDetails.stg"), m_replace);
}

if (ctx.isThereIsStructOrUnion() || ctx.isThereIsException())
{
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.hpp",
Expand All @@ -1030,16 +1044,13 @@ private Project parseIDL(
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg"), m_replace);
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "PubSubTypes.hpp");
if (ctx.existsLastStructure())
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg"), m_replace))
{
m_atLeastOneStructure = true;
project.setHasStruct(true);

if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg"), m_replace))
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "PubSubTypes.cxx");
if (ctx.existsLastStructure() || ctx.isThereIsInterface())
{
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "PubSubTypes.cxx");
if (m_python)
{
System.out.println("Generating Swig interface files...");
Expand All @@ -1048,6 +1059,44 @@ private Project parseIDL(
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSwigInterface.stg"), m_replace);
}
}
}

// Generate client code for interfaces
if (ctx.isThereIsInterface())
{
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "Client.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/ClientHeader.stg"), m_replace))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "Client.hpp");
}
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "Client.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/ClientSource.stg"), m_replace))
{
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "Client.cxx");
}
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "Server.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/ServerHeader.stg"), m_replace))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "Server.hpp");
}
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "Server.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/ServerSource.stg"), m_replace))
{
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "Server.cxx");
}
returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "ServerImpl.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/ServerImplementation.stg"), m_replace);
}

if (ctx.existsLastStructure())
{
m_atLeastOneStructure = true;
project.setHasStruct(true);

if (m_exampleOption != null)
{
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/eprosima/fastdds/idl/grammar/Annotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.eprosima.fastdds.idl.grammar;

import com.eprosima.idl.parser.tree.AnnotationDeclaration;

public class Annotation extends com.eprosima.idl.parser.tree.Annotation
{
public static final String rpc_feed_str = "feed";

public Annotation(AnnotationDeclaration declaration)
{
super(declaration);
}
}
Loading