From 9ed558ba5f9b12942f5f66d866f91a9720c69651 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 30 Apr 2025 11:12:56 +0200 Subject: [PATCH 01/17] Refs #23079. Add interfaces code to TypesSwigInterface.stg Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 49fd4092..4f5fde75 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -47,6 +47,11 @@ $ctx.directIncludeDependencies : {include | %include "$include$.i"}; separator=" %{ #include "$ctx.filename$.hpp" +$if(ctx.thereIsInterface)$ +#include "$ctx.filename$Client.hpp" +#include "$ctx.filename$Server.hpp" +#include "$ctx.filename$ServerImpl.hpp" +$endif$ #include %} @@ -62,6 +67,12 @@ $endif$ %import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" %import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" +$if(ctx.thereIsInterface)$ +%import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcException.hpp" +%import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" +%include +$endif$ + %define %traits_penumn(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits") { @@ -78,6 +89,11 @@ $definitions; separator="\n"$ // Include the class interfaces %include "$ctx.filename$.hpp" +$if(ctx.thereIsInterface)$ +%include "$ctx.filename$Client.hpp" +%include "$ctx.filename$Server.hpp" +%include "$ctx.filename$ServerImpl.hpp" +$endif$ // Include the corresponding TopicDataType %include "$ctx.filename$PubSubTypes.i" @@ -241,3 +257,13 @@ bitset_type(ctx, parent, bitset, extensions) ::= << enum_type(ctx, parent, enum) ::= << %traits_penumn(enum $enum.cppTypename$); >> + +interface(ctx, parent, interface, export_list) ::= << + +$export_list$ + +%shared_ptr($interface.scopedname$); +%shared_ptr($interface.scopedname$Server); +%shared_ptr($interface.scopedname$Server_IServerImplementation); +%shared_ptr($interface.scopedname$ServerImplementation); +>> From 5571482884cf172dc4777d2c14baa886b747136e Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 30 Apr 2025 15:09:37 +0200 Subject: [PATCH 02/17] Refs #23079. Swig code for operation return types. Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 4f5fde75..88246868 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -15,6 +15,7 @@ group TypesSwigInterface; import "com/eprosima/fastdds/idl/templates/eprosima.stg" +import "FastCdrCommon.stg" main(ctx, definitions) ::= << $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file contains the SWIG interface of the described types in the IDL file."])$ @@ -37,6 +38,38 @@ $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file c %include "std_vector.i" %include "typemaps.i" +$if(ctx.thereIsNonFeedOperation)$ +// Code for std::future taken from https://github.com/swig/swig/issues/1828#issuecomment-648449092 +namespace eprosima::fastdds::dds::rpc +{ +template +class RpcFuture { + public: + RpcFuture() noexcept; + RpcFuture(RpcFuture &&) noexcept; + RpcFuture(const RpcFuture& rhs) = delete; + ~RpcFuture(); + RpcFuture& operator=(const RpcFuture& rhs) = delete; + RpcFuture& operator=(RpcFuture&&) noexcept; + + // retrieving the value + R get(); + + // functions to check state + bool valid() const noexcept; + void wait() const; + +/* + template + future_status wait_for(const chrono::duration& rel_time) const; + template + future_status wait_until(const chrono::time_point& abs_time) const; +*/ +}; + +} +$endif$ + // Assignemt operators are ignored, as there is no such thing in Python. // Trying to export them issues a warning %ignore *::operator=; @@ -70,6 +103,7 @@ $endif$ $if(ctx.thereIsInterface)$ %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcException.hpp" %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" +%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientReader.hpp" %include $endif$ @@ -267,3 +301,24 @@ $export_list$ %shared_ptr($interface.scopedname$Server_IServerImplementation); %shared_ptr($interface.scopedname$ServerImplementation); >> + +operation(ctx, parent, operation, param_list, operation_type) ::= << +$if(operation.annotationFeed)$ +%shared_ptr(eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$>); +%template($parent.name$_$operation.name$_result) eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$>; +$else$ +%shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$>); +%template($parent.name$_$operation.name$_result) eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$>; + +$! +// Combine the typemap from shared_ptr +// https://github.com/swig/swig/blob/b96b955ca15a01f0425fb26c234528530923202a/Lib/python/boost_shared_ptr.i#L41-L44 +// with the use of the 'optimal' attribute to avoid the need for a copy constructor, inspired by +// https://github.com/swig/swig/issues/1828#issuecomment-648449092 +!$ +%typemap(out, optimal="1") eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$> { + std::shared_ptr<\$1_ltype> *smartresult = new std::shared_ptr<\$1_ltype>(new \$1_ltype(\$1)); + \$result = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), \$descriptor(std::shared_ptr< eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$\>> *), SWIG_POINTER_OWN); +} +$endif$ +>> From 1102f78e9bf6b73923f74e7291b5816783a82d81 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 19 May 2025 09:46:21 +0200 Subject: [PATCH 03/17] Refs #23079. Improvements on RpcClientReader. Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 88246868..fd8a2bb7 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -101,10 +101,28 @@ $endif$ %import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" $if(ctx.thereIsInterface)$ +%include +%include %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcException.hpp" %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" %import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientReader.hpp" -%include + +%extend eprosima::fastdds::dds::rpc::RpcClientReader { + std::pair read( + const eprosima::fastdds::dds::Duration_t& timeout = eprosima::fastdds::dds::c_TimeInfinite) + { + std::pair ret_val{}; + if (eprosima::fastdds::dds::c_TimeInfinite == timeout) + { + ret_val.first = self->read(ret_val.second); + } + else + { + ret_val.first = self->read(ret_val.second, timeout); + } + return ret_val; + } +} $endif$ %define %traits_penumn(Type...) @@ -305,6 +323,7 @@ $export_list$ operation(ctx, parent, operation, param_list, operation_type) ::= << $if(operation.annotationFeed)$ %shared_ptr(eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$>); +%template($parent.name$_$operation.name$_result_pair) std::pair; %template($parent.name$_$operation.name$_result) eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$>; $else$ %shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$>); From f29b791eda84866cd0b5c19bd530793578a43849 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 19 May 2025 14:06:41 +0200 Subject: [PATCH 04/17] Refs #23079. Avoid duplicates of code generated for template classes. Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 95 ++++++++++--------- .../eprosima/fastdds/idl/grammar/Context.java | 68 ++++++++++--- .../fastdds/idl/grammar/Interface.java | 7 +- 3 files changed, 108 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index fd8a2bb7..35f5470d 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -38,38 +38,6 @@ $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file c %include "std_vector.i" %include "typemaps.i" -$if(ctx.thereIsNonFeedOperation)$ -// Code for std::future taken from https://github.com/swig/swig/issues/1828#issuecomment-648449092 -namespace eprosima::fastdds::dds::rpc -{ -template -class RpcFuture { - public: - RpcFuture() noexcept; - RpcFuture(RpcFuture &&) noexcept; - RpcFuture(const RpcFuture& rhs) = delete; - ~RpcFuture(); - RpcFuture& operator=(const RpcFuture& rhs) = delete; - RpcFuture& operator=(RpcFuture&&) noexcept; - - // retrieving the value - R get(); - - // functions to check state - bool valid() const noexcept; - void wait() const; - -/* - template - future_status wait_for(const chrono::duration& rel_time) const; - template - future_status wait_until(const chrono::time_point& abs_time) const; -*/ -}; - -} -$endif$ - // Assignemt operators are ignored, as there is no such thing in Python. // Trying to export them issues a warning %ignore *::operator=; @@ -105,8 +73,11 @@ $if(ctx.thereIsInterface)$ %include %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcException.hpp" %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" -%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientReader.hpp" +$if(ctx.thereIsOutputFeed)$ +%ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&); +%ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&,eprosima::fastdds::dds::Duration_t&); +%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientReader.hpp" %extend eprosima::fastdds::dds::rpc::RpcClientReader { std::pair read( const eprosima::fastdds::dds::Duration_t& timeout = eprosima::fastdds::dds::c_TimeInfinite) @@ -123,6 +94,42 @@ $if(ctx.thereIsInterface)$ return ret_val; } } + +$ctx.outputFeedTypes : {feed_type | $output_feed(feed_type)$}; separator="\n\n"$ +$endif$ +$if(ctx.thereIsNonFeedOperation)$ +// Code for std::future taken from https://github.com/swig/swig/issues/1828#issuecomment-648449092 +namespace eprosima::fastdds::dds::rpc +{ +template +class RpcFuture { + public: + RpcFuture() noexcept; + RpcFuture(RpcFuture &&) noexcept; + RpcFuture(const RpcFuture& rhs) = delete; + ~RpcFuture(); + RpcFuture& operator=(const RpcFuture& rhs) = delete; + RpcFuture& operator=(RpcFuture&&) noexcept; + + // retrieving the value + R get(); + + // functions to check state + bool valid() const noexcept; + void wait() const; + +/* + template + future_status wait_for(const chrono::duration& rel_time) const; + template + future_status wait_until(const chrono::time_point& abs_time) const; +*/ +}; + +} + +$ctx.outputNonFeedTypes : {non_feed_type | $output_non_feed(non_feed_type)$}; separator="\n\n"$ +$endif$ $endif$ %define %traits_penumn(Type...) @@ -320,14 +327,9 @@ $export_list$ %shared_ptr($interface.scopedname$ServerImplementation); >> -operation(ctx, parent, operation, param_list, operation_type) ::= << -$if(operation.annotationFeed)$ -%shared_ptr(eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$>); -%template($parent.name$_$operation.name$_result_pair) std::pair; -%template($parent.name$_$operation.name$_result) eprosima::fastdds::dds::rpc::RpcClientReader<$paramRetType(operation.rettype)$>; -$else$ -%shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$>); -%template($parent.name$_$operation.name$_result) eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$>; +output_non_feed(type) ::= << +%shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<$type.cppTypename$>); +%template($type.formatedCppTypename$_rpc_future) eprosima::fastdds::dds::rpc::RpcFuture<$type.cppTypename$>; $! // Combine the typemap from shared_ptr @@ -335,9 +337,14 @@ $! // with the use of the 'optimal' attribute to avoid the need for a copy constructor, inspired by // https://github.com/swig/swig/issues/1828#issuecomment-648449092 !$ -%typemap(out, optimal="1") eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$> { +%typemap(out, optimal="1") eprosima::fastdds::dds::rpc::RpcFuture<$type.cppTypename$> { std::shared_ptr<\$1_ltype> *smartresult = new std::shared_ptr<\$1_ltype>(new \$1_ltype(\$1)); - \$result = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), \$descriptor(std::shared_ptr< eprosima::fastdds::dds::rpc::RpcFuture<$paramRetType(operation.rettype)$\>> *), SWIG_POINTER_OWN); + \$result = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), \$descriptor(std::shared_ptr< eprosima::fastdds::dds::rpc::RpcFuture<$type.cppTypename$\>> *), SWIG_POINTER_OWN); } -$endif$ +>> + +output_feed(type) ::= << +%shared_ptr(eprosima::fastdds::dds::rpc::RpcClientReader<$type.cppTypename$>); +%template($type.formatedCppTypename$_client_reader_result) std::pair; +%template($type.formatedCppTypename$_client_reader) eprosima::fastdds::dds::rpc::RpcClientReader<$type.cppTypename$>; >> diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java index 53337fa7..84084b48 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java @@ -14,6 +14,7 @@ package com.eprosima.fastdds.idl.grammar; +import com.eprosima.fastdds.idl.grammar.Operation; import com.eprosima.fastdds.idl.parser.typecode.AliasTypeCode; import com.eprosima.fastdds.idl.parser.typecode.ArrayTypeCode; import com.eprosima.fastdds.idl.parser.typecode.BitmaskTypeCode; @@ -47,14 +48,35 @@ import java.util.Map.Entry; import java.util.AbstractMap; import java.util.AbstractMap.SimpleEntry; +import java.util.HashMap; import java.util.Stack; import java.util.stream.Collectors; import java.util.stream.Stream; import org.antlr.v4.runtime.Token; - public class Context extends com.eprosima.idl.context.Context implements com.eprosima.fastcdr.idl.context.Context { + + public class TypeNamePair + { + public TypeNamePair(TypeCode type) + { + if (null != type) + { + this.cppTypename = type.getCppTypename(); + this.formatedCppTypename = type.getFormatedCppTypename(); + } + else + { + this.cppTypename = "void"; + this.formatedCppTypename = "void"; + } + } + + public String cppTypename; + public String formatedCppTypename; + } + // TODO Remove middleware parameter. It is temporal while cdr and rest don't have async functions. public Context( TemplateManager tmanager, @@ -500,26 +522,46 @@ public boolean isThereIsInputFeed() return there_is_at_least_one_input_feed; } - public boolean setThereIsOutputFeed( - boolean value) + public boolean isThereIsOutputFeed() { - return there_is_at_least_one_output_feed = value; + return !m_output_feed_types.isEmpty(); } - public boolean isThereIsOutputFeed() + public boolean isThereIsNonFeedOperation() { - return there_is_at_least_one_output_feed; + return !m_output_non_feed_types.isEmpty(); } - public boolean setThereIsNonFeedOperation( - boolean value) + public void operationAdded( + Operation op) { - return there_is_at_least_one_non_feed_operation = value; + TypeNamePair type_pair = new TypeNamePair(op.getRettype()); + if (op.isAnnotationFeed()) + { + m_output_feed_types.putIfAbsent(type_pair.cppTypename, type_pair); + } + else + { + m_output_non_feed_types.putIfAbsent(type_pair.cppTypename, type_pair); + } } - public boolean isThereIsNonFeedOperation() + /*! + * @ingroup api_for_stg + * @brief This function returns the list of types used in output feeds. + */ + public ArrayList getOutputFeedTypes() + { + return new ArrayList(m_output_feed_types.values()); + } + + /*! + * @ingroup api_for_stg + * @brief This function returns the list of types used as operation return types. + */ + public ArrayList getOutputNonFeedTypes() { - return there_is_at_least_one_non_feed_operation; + return new ArrayList(m_output_non_feed_types.values()); } /*** Functions inherited from FastCDR Context ***/ @@ -856,9 +898,9 @@ public Param createParam( private boolean there_is_at_least_one_input_feed = false; - private boolean there_is_at_least_one_output_feed = false; + private Map m_output_feed_types = new HashMap(); - private boolean there_is_at_least_one_non_feed_operation = false; + private Map m_output_non_feed_types = new HashMap(); private boolean there_is_at_least_one_interface = false; } diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java index 3bacaa39..dae09781 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java @@ -39,12 +39,9 @@ public void add(com.eprosima.idl.parser.tree.Export exp) if (op.isAnnotationFeed()) { m_hasOutputFeeds = true; - m_context.setThereIsOutputFeed(true); - } - else - { - m_context.setThereIsNonFeedOperation(true); } + + m_context.operationAdded(op); } super.add(exp); From 35b4e77e66a29e193ab3d1bc52bc070b0bbd31bd Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 20 May 2025 09:42:11 +0200 Subject: [PATCH 05/17] Refs #23079. Generate code for input feeds. Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 18 ++++++++++++++++ .../eprosima/fastdds/idl/grammar/Context.java | 21 ++++++++++++++----- .../fastdds/idl/grammar/Operation.java | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 35f5470d..f7926274 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -130,6 +130,12 @@ class RpcFuture { $ctx.outputNonFeedTypes : {non_feed_type | $output_non_feed(non_feed_type)$}; separator="\n\n"$ $endif$ +$if(ctx.thereIsInputFeed)$ +%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientWriter.hpp" +%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcStatusCode.hpp" + +$ctx.inputFeedTypes : {feed_type | $input_feed(feed_type)$}; separator="\n\n"$ +$endif$ $endif$ %define %traits_penumn(Type...) @@ -348,3 +354,15 @@ output_feed(type) ::= << %template($type.formatedCppTypename$_client_reader_result) std::pair; %template($type.formatedCppTypename$_client_reader) eprosima::fastdds::dds::rpc::RpcClientReader<$type.cppTypename$>; >> + +input_feed(type) ::= << +%shared_ptr(eprosima::fastdds::dds::rpc::RpcClientWriter<$type.cppTypename$>); +%template($type.formatedCppTypename$_rpc_client_writer) eprosima::fastdds::dds::rpc::RpcClientWriter<$type.cppTypename$>; +%typemap(in,numinputs=0) std::shared_ptr>& %{ + \$1 = new std::shared_ptr>(); +%} +%typemap(argout) std::shared_ptr>& (PyObject* tmp) %{ + tmp = SWIG_NewPointerObj(\$1, \$1_descriptor, SWIG_POINTER_OWN); + \$result = SWIG_Python_AppendOutput(\$result, tmp); +%} +>> diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java index 84084b48..1f2e6557 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java @@ -15,6 +15,7 @@ package com.eprosima.fastdds.idl.grammar; import com.eprosima.fastdds.idl.grammar.Operation; +import com.eprosima.fastdds.idl.grammar.Param; import com.eprosima.fastdds.idl.parser.typecode.AliasTypeCode; import com.eprosima.fastdds.idl.parser.typecode.ArrayTypeCode; import com.eprosima.fastdds.idl.parser.typecode.BitmaskTypeCode; @@ -511,15 +512,25 @@ public boolean isThereIsInterface() return there_is_at_least_one_interface; } - public void setThereIsInputFeed( - boolean value) + public void inputFeedAdded( + Param p) + { + TypeNamePair type_pair = new TypeNamePair(p.getTypecode()); + m_input_feed_types.putIfAbsent(type_pair.cppTypename, type_pair); + } + + /*! + * @ingroup api_for_stg + * @brief This function returns the list of types used in input feeds. + */ + public ArrayList getInputFeedTypes() { - there_is_at_least_one_input_feed = value; + return new ArrayList(m_input_feed_types.values()); } public boolean isThereIsInputFeed() { - return there_is_at_least_one_input_feed; + return !m_input_feed_types.isEmpty(); } public boolean isThereIsOutputFeed() @@ -896,7 +907,7 @@ public Param createParam( private boolean there_is_at_least_one_exception = false; - private boolean there_is_at_least_one_input_feed = false; + private Map m_input_feed_types = new HashMap(); private Map m_output_feed_types = new HashMap(); diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Operation.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Operation.java index ffd031ea..ccc7a882 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Operation.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Operation.java @@ -85,7 +85,7 @@ public void add(com.eprosima.idl.parser.tree.Param param) else { // Take note that there is at least one input feed - m_context.setThereIsInputFeed(true); + m_context.inputFeedAdded(p); m_hasInputFeeds = true; } } From 35026922e36fcd24f2fee231ff2bf7edc1e509bb Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 20 May 2025 10:32:20 +0200 Subject: [PATCH 06/17] Refs #23079. Generate code to catch exceptions. Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index f7926274..c11a0bb5 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -69,11 +69,32 @@ $endif$ %import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" $if(ctx.thereIsInterface)$ +%include %include %include + %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcException.hpp" %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" +%exception { + try + { + \$action + } + catch (const eprosima::fastdds::dds::rpc::RpcException& ex) + { + SWIG_exception(SWIG_RuntimeError, ex.what()); + } + catch (const std::exception& ex) + { + SWIG_exception(SWIG_RuntimeError, ex.what()); + } + catch (...) + { + SWIG_exception(SWIG_RuntimeError,"Unknown exception"); + } +} + $if(ctx.thereIsOutputFeed)$ %ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&); %ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&,eprosima::fastdds::dds::Duration_t&); @@ -97,6 +118,7 @@ $if(ctx.thereIsOutputFeed)$ $ctx.outputFeedTypes : {feed_type | $output_feed(feed_type)$}; separator="\n\n"$ $endif$ + $if(ctx.thereIsNonFeedOperation)$ // Code for std::future taken from https://github.com/swig/swig/issues/1828#issuecomment-648449092 namespace eprosima::fastdds::dds::rpc @@ -130,12 +152,15 @@ class RpcFuture { $ctx.outputNonFeedTypes : {non_feed_type | $output_non_feed(non_feed_type)$}; separator="\n\n"$ $endif$ + $if(ctx.thereIsInputFeed)$ %import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientWriter.hpp" %import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcStatusCode.hpp" $ctx.inputFeedTypes : {feed_type | $input_feed(feed_type)$}; separator="\n\n"$ $endif$ + +%exception; $endif$ %define %traits_penumn(Type...) From b9fae4aa6f05932ee56d4b9b8a38c123602d9d1b Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 20 May 2025 15:45:46 +0200 Subject: [PATCH 07/17] Refs #23079. Director feature for ServerImplementation classes. Signed-off-by: Miguel Company --- .../com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index c11a0bb5..6603afc0 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -20,7 +20,7 @@ import "FastCdrCommon.stg" main(ctx, definitions) ::= << $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file contains the SWIG interface of the described types in the IDL file."])$ -%module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ +%module(directors="1",moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ // If using windows in debug, it would try to use python_d, which would not be found. %begin %{ @@ -356,6 +356,7 @@ $export_list$ %shared_ptr($interface.scopedname$Server); %shared_ptr($interface.scopedname$Server_IServerImplementation); %shared_ptr($interface.scopedname$ServerImplementation); +%feature("director") $interface.scopedname$ServerImplementation; >> output_non_feed(type) ::= << From 81e2ae5dda6d115c3f6b7661592341772be2017c Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 20 May 2025 16:50:51 +0200 Subject: [PATCH 08/17] Refs #23079. Avoid Server code for nested interfaces. Signed-off-by: Miguel Company --- .../com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 6603afc0..dce7974e 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -353,10 +353,12 @@ interface(ctx, parent, interface, export_list) ::= << $export_list$ %shared_ptr($interface.scopedname$); +$if(!interface.annotatedAsNested)$ %shared_ptr($interface.scopedname$Server); %shared_ptr($interface.scopedname$Server_IServerImplementation); %shared_ptr($interface.scopedname$ServerImplementation); %feature("director") $interface.scopedname$ServerImplementation; +$endif$ >> output_non_feed(type) ::= << From 4e74c0f714ad0bc743c065f91400c30fd140c6c9 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 21 May 2025 10:45:46 +0200 Subject: [PATCH 09/17] Refs #23079. Server code for feeds. Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index dce7974e..5678a481 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -96,6 +96,7 @@ $if(ctx.thereIsInterface)$ } $if(ctx.thereIsOutputFeed)$ +%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcServerWriter.hpp" %ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&); %ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&,eprosima::fastdds::dds::Duration_t&); %import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientReader.hpp" @@ -157,6 +158,26 @@ $if(ctx.thereIsInputFeed)$ %import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientWriter.hpp" %import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcStatusCode.hpp" +%ignore eprosima::fastdds::dds::rpc::RpcServerReader::read(T&); +%ignore eprosima::fastdds::dds::rpc::RpcServerReader::read(T&,eprosima::fastdds::dds::Duration_t&); +%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcServerReader.hpp" +%extend eprosima::fastdds::dds::rpc::RpcServerReader { + std::pair read( + const eprosima::fastdds::dds::Duration_t& timeout = eprosima::fastdds::dds::c_TimeInfinite) + { + std::pair ret_val{}; + if (eprosima::fastdds::dds::c_TimeInfinite == timeout) + { + ret_val.first = self->read(ret_val.second); + } + else + { + ret_val.first = self->read(ret_val.second, timeout); + } + return ret_val; + } +} + $ctx.inputFeedTypes : {feed_type | $input_feed(feed_type)$}; separator="\n\n"$ $endif$ @@ -381,9 +402,14 @@ output_feed(type) ::= << %shared_ptr(eprosima::fastdds::dds::rpc::RpcClientReader<$type.cppTypename$>); %template($type.formatedCppTypename$_client_reader_result) std::pair; %template($type.formatedCppTypename$_client_reader) eprosima::fastdds::dds::rpc::RpcClientReader<$type.cppTypename$>; + +%template($type.formatedCppTypename$_server_writer) eprosima::fastdds::dds::rpc::RpcServerWriter<$type.cppTypename$>; >> input_feed(type) ::= << +%template($type.formatedCppTypename$_server_reader_result) std::pair; +%template($type.formatedCppTypename$_server_reader) eprosima::fastdds::dds::rpc::RpcServerReader<$type.cppTypename$>; + %shared_ptr(eprosima::fastdds::dds::rpc::RpcClientWriter<$type.cppTypename$>); %template($type.formatedCppTypename$_rpc_client_writer) eprosima::fastdds::dds::rpc::RpcClientWriter<$type.cppTypename$>; %typemap(in,numinputs=0) std::shared_ptr>& %{ From f309e9c63c397f8bdc62600fc36f21be7067d1bb Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 26 May 2025 16:36:36 +0200 Subject: [PATCH 10/17] Refs #23079. Refactor output arguments. Signed-off-by: Miguel Company --- .../com/eprosima/fastdds/idl/grammar/Context.java | 11 ++++++++++- .../com/eprosima/fastdds/idl/grammar/Interface.java | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java index 1f2e6557..d158b5c4 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java @@ -546,7 +546,16 @@ public boolean isThereIsNonFeedOperation() public void operationAdded( Operation op) { - TypeNamePair type_pair = new TypeNamePair(op.getRettype()); + TypeNamePair type_pair; + if (op.getOutputparam().size() > 0) + { + type_pair = new TypeNamePair(op.getOutTypeCode()); + } + else + { + type_pair = new TypeNamePair(op.getRettype()); + } + if (op.isAnnotationFeed()) { m_output_feed_types.putIfAbsent(type_pair.cppTypename, type_pair); diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java index dae09781..3c1b5d18 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java @@ -33,6 +33,8 @@ public Interface(Context ctx, String scopeFile, boolean isInScope, String scope, @Override public void add(com.eprosima.idl.parser.tree.Export exp) { + super.add(exp); + if (exp instanceof Operation) { Operation op = (Operation)exp; @@ -43,8 +45,6 @@ public void add(com.eprosima.idl.parser.tree.Export exp) m_context.operationAdded(op); } - - super.add(exp); } /*! From cd6ef5185e23ed4496ba4ba57b6e66ab13f9dbe2 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 27 May 2025 08:09:55 +0200 Subject: [PATCH 11/17] Refs #23079. Enable thread support for directors and release lock in server run(). Signed-off-by: Miguel Company --- .../idl/templates/TypesSwigInterface.stg | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 5678a481..0e763aad 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -20,7 +20,15 @@ import "FastCdrCommon.stg" main(ctx, definitions) ::= << $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file contains the SWIG interface of the described types in the IDL file."])$ -%module(directors="1",moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ +%module($if(ctx.thereIsInterface)$threads="1",$endif$directors="1",moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ + +$if(ctx.thereIsInterface)$ +// We have enabled threads because the RPC server directors will call the target language environment +// from the C++ server threads, but we don't want the calls from the target language to release their +// locks (e.g. Python GIL) when calling the C++ methods. +// See a very nice explanation at https://github.com/swig/swig/issues/927#issuecomment-289279243 +%feature("nothreadallow"); +$endif$ // If using windows in debug, it would try to use python_d, which would not be found. %begin %{ @@ -376,6 +384,16 @@ $export_list$ %shared_ptr($interface.scopedname$); $if(!interface.annotatedAsNested)$ %shared_ptr($interface.scopedname$Server); +%extend $interface.scopedname$Server +{ + void run() + { + Py_BEGIN_ALLOW_THREADS + self->run(); + Py_END_ALLOW_THREADS + } +} + %shared_ptr($interface.scopedname$Server_IServerImplementation); %shared_ptr($interface.scopedname$ServerImplementation); %feature("director") $interface.scopedname$ServerImplementation; From 4a345c12d6c3a7acd564fdaf466911a45f8b7931 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 27 May 2025 11:40:55 +0200 Subject: [PATCH 12/17] Refs #23232. Avoid generating detail namespace for interfaces without output arguments. Signed-off-by: Miguel Company --- .../fastcdr/idl/templates/TypesHeader.stg | 8 ++++++-- .../fastdds/idl/grammar/Interface.java | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg index 572862c3..ddac0b03 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -190,10 +190,12 @@ private: interface(ctx, parent, interface, export_list) ::= << +$if(interface.withOutputParameters)$ namespace detail { $interface.operations : { op | $if(op.outputparam)$$operation_out_struct_fwd_decl(interface, op)$$endif$}$ -} +} // namespace detail +$endif$ /*! * @brief This class represents the interface $interface.name$ defined by the user in the IDL file. @@ -207,10 +209,12 @@ public: $export_list$ }; +$if(interface.withOutputParameters)$ namespace detail { $interface.operations : { op | $if(op.outputparam)$$operation_out_struct(interface, op)$$"\n"$$endif$}$ -} +} // namespace detail +$endif$ >> operation(ctx, parent, operation, param_list, operation_type) ::= << diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java index 3c1b5d18..f11bf96f 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java @@ -43,6 +43,11 @@ public void add(com.eprosima.idl.parser.tree.Export exp) m_hasOutputFeeds = true; } + if (op.getOutputparam().size() > 0) + { + m_has_operations_with_output_arguments = true; + } + m_context.operationAdded(op); } } @@ -57,6 +62,18 @@ public boolean isWithOutputFeeds() return m_hasOutputFeeds; } + /*! + * @ingroup api_for_stg + * + * @brief This function is used to check if the interface has operations output arguments. + * + * @return True if the interface has operations with output arguments, false otherwise. + */ + public boolean isWithOutputParameters() + { + return m_has_operations_with_output_arguments; + } + /*! * @brief This function is used in stringtemplates to generate the typesupport code for the interface. * @@ -161,6 +178,7 @@ private EnumTypeCode get_remoteExceptionCode_t_type() private Context m_context = null; private boolean m_hasOutputFeeds = false; + private boolean m_has_operations_with_output_arguments = false; private StructTypeCode m_request_type = null; private StructTypeCode m_reply_type = null; static private EnumTypeCode m_remoteExceptionCode_t_type = null; From 939342b84e34801e204140feeb15f2d57140ebce Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 27 May 2025 18:57:41 +0200 Subject: [PATCH 13/17] Windows compilation Fix Signed-off-by: Mario Dominguez --- .../java/com/eprosima/fastdds/idl/templates/ServerSource.stg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/ServerSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/ServerSource.stg index db9cf0f7..ab51748c 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/ServerSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/ServerSource.stg @@ -194,7 +194,7 @@ public: private: //{ Output feed helpers - + struct IOutputFeedCancellator { virtual ~IOutputFeedCancellator() = default; @@ -770,7 +770,7 @@ $endif$ $endif$ } $if(op.annotationFeed)$ - catch (const frpc::RpcFeedCancelledException& ex) + catch (const frpc::RpcFeedCancelledException& /*ex*/) { ReplyType reply{}; reply.$op.name$ = $op.resultTypeCode.scopedname${}; From d4b6219285834ab48eb955b0b5f63683667dd1ab Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 27 May 2025 21:25:54 +0200 Subject: [PATCH 14/17] MacOs warning Fix Signed-off-by: Mario Dominguez --- .../java/com/eprosima/fastdds/idl/templates/ClientSource.stg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/ClientSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/ClientSource.stg index e4f0d134..871e4167 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/ClientSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/ClientSource.stg @@ -477,7 +477,7 @@ $if(operation.annotationFeed)$ } void set_exception( - std::exception_ptr exception) + std::exception_ptr exception) override { std::lock_guard _(mtx_); if (!finished_) From 4a1ca476dd23af92200fc27017accb1507d93260 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 28 May 2025 11:46:28 +0200 Subject: [PATCH 15/17] Refs #23079. Add copyright header to SwigCMake template. Signed-off-by: Miguel Company --- .../eprosima/fastdds/idl/templates/SwigCMake.stg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg b/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg index ccb62e84..8c621982 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg @@ -16,6 +16,20 @@ group SwigCMake; swig_cmake(solution) ::= << +# 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. + cmake_minimum_required(VERSION 3.20) # SWIG: use standard target name. From 889734601aaf44020e21e11b7cbaff25cac9ed55 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 28 May 2025 11:46:44 +0200 Subject: [PATCH 16/17] Refs #23079. Apply review. Signed-off-by: Miguel Company --- .../fastcdr/idl/templates/TypesSwigInterface.stg | 11 +++++++---- .../com/eprosima/fastdds/idl/grammar/Interface.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 0e763aad..88c6e38b 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -39,9 +39,16 @@ $endif$ %} // SWIG helper modules +$if(ctx.thereIsInterface)$ +%include "exception.i" +$endif$ %include "stdint.i" %include "std_array.i" %include "std_map.i" +$if(ctx.thereIsInterface)$ +%include "std_pair.i" +%include "std_shared_ptr.i" +$endif$ %include "std_string.i" %include "std_vector.i" %include "typemaps.i" @@ -77,10 +84,6 @@ $endif$ %import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" $if(ctx.thereIsInterface)$ -%include -%include -%include - %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcException.hpp" %import(module="fastdds") "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java index f11bf96f..75a6faa8 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Interface.java @@ -65,7 +65,7 @@ public boolean isWithOutputFeeds() /*! * @ingroup api_for_stg * - * @brief This function is used to check if the interface has operations output arguments. + * @brief This function is used to check if the interface has operations with output arguments. * * @return True if the interface has operations with output arguments, false otherwise. */ From 92af4cd15b6e5f4d8010cdbfb749ee2bace2c2bb Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 28 May 2025 12:28:11 +0200 Subject: [PATCH 17/17] Refs #23079. Directors only necessary when there are interfaces. Signed-off-by: Miguel Company --- .../com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 88c6e38b..4714f46a 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -20,7 +20,7 @@ import "FastCdrCommon.stg" main(ctx, definitions) ::= << $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file contains the SWIG interface of the described types in the IDL file."])$ -%module($if(ctx.thereIsInterface)$threads="1",$endif$directors="1",moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ +%module($if(ctx.thereIsInterface)$threads="1",directors="1",$endif$moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ $if(ctx.thereIsInterface)$ // We have enabled threads because the RPC server directors will call the target language environment