Skip to content

Commit d6425fe

Browse files
committed
Refs #23232. Avoid generating detail namespace for interfaces without output arguments.
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
1 parent e22eb8e commit d6425fe

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,12 @@ private:
190190

191191
interface(ctx, parent, interface, export_list) ::= <<
192192

193+
$if(interface.withOutputParameters)$
193194
namespace detail {
194195

195196
$interface.operations : { op | $if(op.outputparam)$$operation_out_struct_fwd_decl(interface, op)$$endif$}$
196-
}
197+
} // namespace detail
198+
$endif$
197199

198200
/*!
199201
* @brief This class represents the interface $interface.name$ defined by the user in the IDL file.
@@ -207,10 +209,12 @@ public:
207209
$export_list$
208210
};
209211

212+
$if(interface.withOutputParameters)$
210213
namespace detail {
211214

212215
$interface.operations : { op | $if(op.outputparam)$$operation_out_struct(interface, op)$$"\n"$$endif$}$
213-
}
216+
} // namespace detail
217+
$endif$
214218
>>
215219

216220
operation(ctx, parent, operation, param_list, operation_type) ::= <<

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public void add(com.eprosima.idl.parser.tree.Export exp)
4343
m_hasOutputFeeds = true;
4444
}
4545

46+
if (op.getOutputparam().size() > 0)
47+
{
48+
m_has_operations_with_output_arguments = true;
49+
}
50+
4651
m_context.operationAdded(op);
4752
}
4853
}
@@ -57,6 +62,18 @@ public boolean isWithOutputFeeds()
5762
return m_hasOutputFeeds;
5863
}
5964

65+
/*!
66+
* @ingroup api_for_stg
67+
*
68+
* @brief This function is used to check if the interface has operations output arguments.
69+
*
70+
* @return True if the interface has operations with output arguments, false otherwise.
71+
*/
72+
public boolean isWithOutputParameters()
73+
{
74+
return m_has_operations_with_output_arguments;
75+
}
76+
6077
/*!
6178
* @brief This function is used in stringtemplates to generate the typesupport code for the interface.
6279
*
@@ -161,6 +178,7 @@ private EnumTypeCode get_remoteExceptionCode_t_type()
161178

162179
private Context m_context = null;
163180
private boolean m_hasOutputFeeds = false;
181+
private boolean m_has_operations_with_output_arguments = false;
164182
private StructTypeCode m_request_type = null;
165183
private StructTypeCode m_reply_type = null;
166184
static private EnumTypeCode m_remoteExceptionCode_t_type = null;

0 commit comments

Comments
 (0)