Skip to content

Commit

Permalink
Switch create*_sample args, Fix XTypes Unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Jun 10, 2024
1 parent f2581f4 commit 1dc8757
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions dds/DCPS/TypeSupportImpl_T.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class TypeSupportImpl_T
/// the type is "variable length". If it has something like a sequence then
/// it's variable length and returns a pointer else it's fixed and returns on
/// the stack. opendds_idl will wrap this in the correct form.
DDS::ReturnCode_t create_sample_rc(DDS::DynamicData_ptr src, NativeType& dst)
DDS::ReturnCode_t create_sample_rc(NativeType& dst, DDS::DynamicData_ptr src)
{
OpenDDS::DCPS::set_default(dst);
# if OPENDDS_HAS_DYNAMIC_DATA_ADAPTER
Expand All @@ -109,7 +109,7 @@ class TypeSupportImpl_T
# endif
}

DDS::ReturnCode_t create_dynamic_sample_rc(const NativeType& src, DDS::DynamicData_ptr& dst)
DDS::ReturnCode_t create_dynamic_sample_rc(DDS::DynamicData_ptr& dst, const NativeType& src)
{
CORBA::release(dst);
DDS::DynamicType_var type = get_type();
Expand All @@ -136,7 +136,7 @@ class TypeSupportImpl_T
DDS::DynamicData_ptr create_dynamic_sample(const NativeType& src)
{
DDS::DynamicData_var dst;
create_dynamic_sample_rc(src, dst);
create_dynamic_sample_rc(dst, src);
return dst;
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions dds/idl/IDLTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ local interface <%TYPE%>TypeSupport : OpenDDS::DCPS::TypeSupport {
#ifndef OPENDDS_SAFETY_PROFILE
// TODO: valuetype isn't supported in Java.
@OpenDDS::internal::hidden_op_in_java(0)
::DDS::ReturnCode_t create_sample_rc(in ::DDS::DynamicData src, inout <%SCOPED%> dst);
::DDS::ReturnCode_t create_sample_rc(in ::DDS::DynamicData dst, inout <%SCOPED%> src);
@OpenDDS::internal::hidden_op_in_java(0)
<%SCOPED%> create_sample(in ::DDS::DynamicData src);
@OpenDDS::internal::hidden_op_in_java(0)
::DDS::ReturnCode_t create_dynamic_sample_rc(in <%SCOPED%> src, inout ::DDS::DynamicData dst);
::DDS::ReturnCode_t create_dynamic_sample_rc(in <%SCOPED%> dst, inout ::DDS::DynamicData src);
@OpenDDS::internal::hidden_op_in_java(0)
::DDS::DynamicData create_dynamic_sample(in <%SCOPED%> src);
#endif
Expand Down
4 changes: 2 additions & 2 deletions dds/idl/ts_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ bool ts_generator::generate_ts(AST_Type* node, UTL_ScopedName* name)
if (op_ret_is_ptr) {
be_global->impl_ <<
" " << short_cxx_name << "* value = new " << short_cxx_name << ";\n"
" const ::DDS::ReturnCode_t rc = " << ts_base << "::create_sample_rc(src, *value);\n";
" const ::DDS::ReturnCode_t rc = " << ts_base << "::create_sample_rc(*value, src);\n";
} else {
be_global->impl_ <<
" " << short_cxx_name << " value;\n"
" const ::DDS::ReturnCode_t rc = " << ts_base << "::create_sample_rc(src, value);\n";
" const ::DDS::ReturnCode_t rc = " << ts_base << "::create_sample_rc(value, src);\n";
}
be_global->impl_ <<
" if (rc != ::DDS::RETCODE_OK && OpenDDS::DCPS::log_level >= OpenDDS::DCPS::LogLevel::Warning) {\n"
Expand Down
10 changes: 6 additions & 4 deletions docs/devguide/xtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1385,15 +1385,15 @@ If the type contains a ``vector`` or ``string`` anywhere, then then it returns a
Foo foo = type_support->create_sample(data);
``create_sample_rc`` is the same regardless and returns a ``ReturnCode_t`` to indicate failure:
Using ``create_sample_rc`` is the same regardless of the type and returns a ``ReturnCode_t`` to indicate failure:

.. code-block:: cpp
FooTypeSupport_var type_support = new FooTypeSupportImpl();
DynamicData_var data = /* ... */;
Foo foo;
DDS::ReturnCode_t rc = type_support->create_sample_rc(data, foo);
const DDS::ReturnCode_t rc = type_support->create_sample_rc(foo, data);
if (rc != DDS::RETCODE_OK) /* (handle error) */;
``create_dynamic_sample`` and ``create_dynamic_sample_rc``
Expand All @@ -1416,7 +1416,7 @@ If the type contains a ``vector`` or ``string`` anywhere, then then it returns a
Foo foo = /* ... */;
DynamicData_var data;
DDS::ReturnCode_t rc = type_support->create_dynamic_sample_rc(foo, data);
const DDS::ReturnCode_t rc = type_support->create_dynamic_sample_rc(data, foo);
if (rc != DDS::RETCODE_OK) /* (handle error) */;
.. _xtypes-dynamic-data-adapter:
Expand Down Expand Up @@ -1509,7 +1509,9 @@ Type System

* IDL ``bitmask`` type

* Struct and union inheritance
* IDL ``bitset`` type

* Struct inheritance

.. _xtypes--annotations:

Expand Down
4 changes: 2 additions & 2 deletions tests/DCPS/Compiler/xcdr/xcdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void amalgam_serializer_test_base(
#if OPENDDS_HAS_DYNAMIC_DATA_ADAPTER
typename DDSTraits<RealTypeA>::TypeSupportImplType tsi;
DDS::DynamicData_var dd;
ASSERT_RC_OK(tsi.create_dynamic_sample_rc(value, dd));
ASSERT_RC_OK(tsi.create_dynamic_sample_rc(dd, value));

DDS::DynamicData_ptr dd_ptr = dd.in();
if (key_only) {
Expand Down Expand Up @@ -252,7 +252,7 @@ void amalgam_serializer_test_base(
DDS::DynamicData_var ddi = new DynamicDataXcdrReadImpl(serializer, type,
key_only ? Sample::KeyOnly: Sample::Full);
typename DDSTraits<RealTypeB>::TypeSupportImplType tsi;
ASSERT_RC_OK(tsi.create_sample_rc(ddi, result));
ASSERT_RC_OK(tsi.create_sample_rc(result, ddi));
#else
ASSERT_TRUE(false);
#endif
Expand Down

0 comments on commit 1dc8757

Please sign in to comment.