Skip to content

Commit 4a15132

Browse files
MiguelCompanymergify[bot]
authored andcommitted
Fix python code generation for bounded strings (#440)
* Refs #22835. SWIG extend to set fixed_string from std::string. Signed-off-by: Miguel Company <[email protected]> * Refs #22835. SWIG export template for fixed_string members. Signed-off-by: Miguel Company <[email protected]> * Refs #22835. Fix access to typecode. Signed-off-by: Miguel Company <[email protected]> * Refs #22835. Fix max size typo. Signed-off-by: Miguel Company <[email protected]> * Refs #22835. Fix exported template name. Signed-off-by: Miguel Company <[email protected]> * Refs #22835. Fix extend code. Signed-off-by: Miguel Company <[email protected]> * Refs #22850. Apply suggestions from review. Signed-off-by: Miguel Company <[email protected]> --------- Signed-off-by: Miguel Company <[email protected]> (cherry picked from commit 8eaca9a) # Conflicts: # src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg
1 parent bb44c0f commit 4a15132

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ $ctx.directIncludeDependencies : {include | %include "$include$.i"}; separator="
4444
%}
4545

4646
%include <fastcdr/config.h>
47+
<<<<<<< HEAD
4748
#if FASTCDR_VERSION_MAJOR > 1
4849
%import(module="fastdds") "fastcdr/xcdr/optional.hpp"
4950
#endif
51+
=======
52+
$if(ctx.thereIsOptionalAnnotation)$
53+
%import(module="fastdds") "fastcdr/xcdr/optional.hpp"
54+
$endif$
55+
$if(ctx.thereIsString)$
56+
%import(module="fastdds") "fastcdr/cdr/fixed_size_string.hpp"
57+
$endif$
58+
>>>>>>> 8eaca9a (Fix python code generation for bounded strings (#440))
5059
%import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp"
5160
%import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp"
5261
%import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp"
@@ -205,6 +214,18 @@ $else$
205214
%ignore $struct_name$::$member.name$();
206215
%rename("%s") $struct_name$::$member.name$() const;
207216

217+
$if(member.typecode.isStringType && member.typecode.isBounded)$
218+
%template(fixed_string_$member.typecode.maxsize$) eprosima::fastcdr::fixed_string<$member.typecode.maxsize$>;
219+
%extend $struct_name$
220+
{
221+
void $member.name$(const std::string& value)
222+
{
223+
eprosima::fastcdr::fixed_string<$member.typecode.maxsize$> tmp(value);
224+
\$self->$member.name$(tmp);
225+
}
226+
}
227+
$endif$
228+
208229
$endif$
209230

210231
>>

0 commit comments

Comments
 (0)