Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement create_sample and create_dynamic_sample #4373

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion MPC/config/optional_jni_check.mpb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

feature(jni_check) {

postbuild += $(DDS_ROOT)<%slash%>java<%slash%>build_scripts<%slash%>jni_check.pl <%libout%><%slash%><%sharedname%>
postbuild += perl $(DDS_ROOT)<%slash%>java<%slash%>build_scripts<%slash%>jni_check.pl <%libout%><%slash%><%sharedname%>

}
6 changes: 5 additions & 1 deletion MPC/modules/IDLBase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ sub do_cached_parse {
$self->{'default_nested'} = 1;

## Set up the macros and include paths supplied in the command flags
my %macros = ('__OPENDDS_IDL' => 1, '__OPENDDS_MPC' => 1);
my %macros = (
__OPENDDS_IDL => 1,
__OPENDDS_MPC => 1,
OPENDDS_HIDE_DYNAMIC_DATA => 1,
);
my %mparams;
my @include;
if (defined $flags) {
Expand Down
68 changes: 67 additions & 1 deletion dds/DCPS/TypeSupportImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@
};

template <typename NativeType>
class TypeSupportImpl_T : public TypeSupportImpl {
class TypeSupportImpl_T
: public virtual LocalObject<typename DDSTraits<NativeType>::TypeSupportType>
, public TypeSupportImpl
{
public:
typedef DDSTraits<NativeType> TraitsType;
typedef MarshalTraits<NativeType> MarshalTraitsType;
Expand Down Expand Up @@ -218,6 +221,69 @@
get_type_from_type_lookup_service();
return TypeSupportImpl::get_type();
}

/// The IDL is `NativeType create_sample(DDS::DynamicData src)`, but in the
/// C++ mapping this can return NativeType* or just NativeType depending on if
/// 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)
{
OpenDDS::DCPS::set_default(dst);
# if OPENDDS_HAS_DYNAMIC_DATA_ADAPTOR
DDS::DynamicType_var type = get_type();
DDS::DynamicData_var dst_dd = get_dynamic_data_adapter<NativeType>(type, dst);
const DDS::ReturnCode_t rc = XTypes::copy(dst_dd, src);
if (rc != DDS::RETCODE_OK && log_level >= LogLevel::Notice) {
ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: TypeSupportImpl_T::create_sample_rc: "
"failed to copy from DynamicData: %C\n", retcode_to_string(rc)));
}
return rc;
# else
ACE_UNUSED_ARG(dst);
ACE_UNUSED_ARG(src);
if (log_level >= LogLevel::Notice) {

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_clang12_i0w1_sec

use of undeclared identifier 'log_level'

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_clang12_i0w1_sec

use of undeclared identifier 'LogLevel'

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_d0i0v1_sec_js0_FM-08

‘log_level’ was not declared in this scope

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_d0i0v1_sec_js0_FM-08

‘LogLevel’ has not been declared

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_gcc11_i0_xer0

‘log_level’ was not declared in this scope

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_gcc11_i0_xer0

‘LogLevel’ has not been declared

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_i0_xer0_js0_j17

‘log_level’ was not declared in this scope

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_i0_xer0_js0_j17

‘LogLevel’ has not been declared

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_gcc8_i0_js0_j

‘log_level’ was not declared in this scope

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_gcc8_i0_js0_j

‘LogLevel’ has not been declared

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_m12_i0_j_FM-1f

use of undeclared identifier 'log_level'

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_m12_i0_j_FM-1f

use of undeclared identifier 'LogLevel'

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'log_level': identifier not found [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'LogLevel': identifier not found [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'log_level': undeclared identifier [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'LogLevel': undeclared identifier [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'log_level': identifier not found [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 245 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'LogLevel': identifier not found [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]
ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: TypeSupportImpl_T::create_sample_rc: "
"OpenDDS built without DynamicDataAdaptor support\n"));
}
return DDS::RETCODE_UNSUPPORTED;
# endif
}

DDS::ReturnCode_t create_dynamic_sample_rc(const NativeType& src, DDS::DynamicData_ptr& dst)
{
CORBA::release(dst);
dst = 0;
# if OPENDDS_HAS_DYNAMIC_DATA_ADAPTOR
DDS::DynamicType_var type = get_type();
DDS::DynamicData_var dest_dd = DDS::DynamicDataFactory::get_instance()->create_data(type);
DDS::DynamicData_var src_dd = get_dynamic_data_adapter<NativeType>(type, &src);
const DDS::ReturnCode_t rc = XTypes::copy(dest_dd, src_dd);
if (rc == DDS::RETCODE_OK) {
dst = DDS::DynamicData::_duplicate(dest_dd);
return rc;
}
if (log_level >= LogLevel::Notice) {
ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: TypeSupportImpl_T::create_dynamic_sample_rc: "
"failed to copy to DynamicData: %C\n", retcode_to_string(rc)));
}
# else
ACE_UNUSED_ARG(dst);
ACE_UNUSED_ARG(src);
if (log_level >= LogLevel::Notice) {

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_clang12_i0w1_sec

use of undeclared identifier 'log_level'

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_clang12_i0w1_sec

use of undeclared identifier 'LogLevel'

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_d0i0v1_sec_js0_FM-08

‘log_level’ was not declared in this scope

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_d0i0v1_sec_js0_FM-08

‘LogLevel’ has not been declared

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_gcc11_i0_xer0

‘log_level’ was not declared in this scope

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u22_gcc11_i0_xer0

‘LogLevel’ has not been declared

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_i0_xer0_js0_j17

‘log_level’ was not declared in this scope

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_i0_xer0_js0_j17

‘LogLevel’ has not been declared

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_gcc8_i0_js0_j

‘log_level’ was not declared in this scope

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_u20_gcc8_i0_js0_j

‘LogLevel’ has not been declared

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_m12_i0_j_FM-1f

use of undeclared identifier 'log_level'

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_m12_i0_j_FM-1f

use of undeclared identifier 'LogLevel'

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'log_level': identifier not found [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'LogLevel': identifier not found [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'log_level': undeclared identifier [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]

Check failure on line 273 in dds/DCPS/TypeSupportImpl.h

View workflow job for this annotation

GitHub Actions / build_w22_p1

'LogLevel': undeclared identifier [D:\a\OpenDDS\OpenDDS\OpenDDS\dds\OpenDDS_Dcps.vcxproj]
ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: TypeSupportImpl_T::create_dynamic_sample_rc: "
"OpenDDS built without DynamicDataAdaptor support\n"));
}
return DDS::RETCODE_UNSUPPORTED;
# endif
}

DDS::DynamicData_ptr create_dynamic_sample(const NativeType& src)
{
DDS::DynamicData_var dst;
create_dynamic_sample_rc(src, dst);
return dst;
}
#endif
};

Expand Down
5 changes: 0 additions & 5 deletions dds/DCPS/XTypes/DynamicDataAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ DDS::MemberId DynamicDataAdapter::get_member_id_at_index(DDS::UInt32 index)
}
}

DDS::ReturnCode_t DynamicDataAdapter::clear_all_values()
{
return unsupported_method("DynamicDataAdapater::clear_all_values");
}

DDS::ReturnCode_t DynamicDataAdapter::clear_nonkey_values()
{
return unsupported_method("DynamicDataAdapater::clear_nonkey_values");
Expand Down
4 changes: 1 addition & 3 deletions dds/DCPS/XTypes/DynamicDataAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DynamicDataAdapterImpl;
* TODO:
* - Support direct array methods, like get_int32_values
* - Part of this is accessing all types as complex value.
* - Implement equals, clear_value, clear_all_values, and clear_nonkey_values
* - Implement equals, clear_value, and clear_nonkey_values
* - Respect bounds of strings and sequences.
* - Add a way to check if using get_complex_value on a complex member of a
* union that isn't selected. Doing this will cause a segfault. It should
Expand All @@ -75,10 +75,8 @@ class OpenDDS_Dcps_Export DynamicDataAdapter : public DynamicDataBase {
virtual DDS::MemberId get_member_id_at_index_impl(DDS::UInt32);
DDS::MemberId get_member_id_at_index(DDS::UInt32 index);

DDS::ReturnCode_t clear_all_values();
DDS::ReturnCode_t clear_nonkey_values();
DDS::ReturnCode_t clear_value(DDS::MemberId);
DDS::DynamicData_ptr clone() = 0;

DDS::ReturnCode_t get_int8_value(CORBA::Int8& value,
DDS::MemberId id)
Expand Down
6 changes: 2 additions & 4 deletions dds/DdsDcpsTopic.idl
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ module DDS {
in string type_name);
string get_type_name();
#ifndef OPENDDS_SAFETY_PROFILE
// valuetype isn't supported in Java. This will exclude this operation
// from the generated Java code and return null in get_type method of
// the TAOPeer generated C++ class so it isn't a pure virtual function.
@OpenDDS::hidden_op_in_java("return 0;")
// TODO: valuetype isn't supported in Java
@OpenDDS::internal::hidden_op_in_java(0)
DynamicType get_type();
#endif
};
Expand Down
15 changes: 9 additions & 6 deletions dds/DdsDynamicData.idl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
Expand All @@ -9,13 +7,15 @@
#define OPENDDS_DDS_DYNAMIC_DATA_IDL

#ifndef OPENDDS_SAFETY_PROFILE

#include <dds/DdsDcpsInfrastructure.idl>
#include <dds/DdsDcpsDomain.idl>
#include <dds/DdsDynamicDataSeq.idl>
# ifndef OPENDDS_HIDE_DYNAMIC_DATA
# include <dds/DdsDcpsInfrastructure.idl>
# include <dds/DdsDcpsDomain.idl>
# include <dds/DdsDynamicDataSeq.idl>
# endif

module DDS {
local interface DynamicType;
# ifndef OPENDDS_HIDE_DYNAMIC_DATA
valuetype TypeDescriptor;

typedef sequence<string> IncludePathSeq;
Expand Down Expand Up @@ -158,9 +158,11 @@ module DDS {

void clear();
};
# endif // OPENDDS_HIDE_DYNAMIC_DATA

local interface DynamicData;

# ifndef OPENDDS_HIDE_DYNAMIC_DATA
local interface DynamicDataFactoryInterf {
// Implemented in C++
// static DynamicDataFactory get_instance();
Expand Down Expand Up @@ -401,6 +403,7 @@ module DDS {
in MemberId id,
in WstringSeq value);
}; // local interface DynamicData
# endif // OPENDDS_HIDE_DYNAMIC_DATA
};

#endif // OPENDDS_SAFETY_PROFILE
Expand Down
11 changes: 11 additions & 0 deletions dds/idl/IDLTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ typedef sequence<<%SCOPED%>> <%TYPE%><%SEQ%>;
* this interface.
*/
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);
@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);
@OpenDDS::internal::hidden_op_in_java(0)
::DDS::DynamicData create_dynamic_sample(in <%SCOPED%> src);
#endif

::DDS::ReturnCode_t encode_to_string(in <%SCOPED%> sample, out string encoded, in OpenDDS::DCPS::RepresentationFormat format);
::DDS::ReturnCode_t encode_to_bytes(in <%SCOPED%> sample, out ::DDS::OctetSeq encoded, in OpenDDS::DCPS::RepresentationFormat format);
Expand Down
3 changes: 2 additions & 1 deletion dds/idl/be_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ BE_post_init(char*[], long)
be_global->builtin_annotations_.register_all();
// This annotation isn't used, but must match the one in idl2jni to avoid
// warnings or errors.
idl_global->eval("module OpenDDS {@annotation hidden_op_in_java {string impl;};};\n");
idl_global->eval(
"module OpenDDS {module internal {@annotation hidden_op_in_java {int8 dummy;};};};\n");
}
18 changes: 10 additions & 8 deletions dds/idl/dynamic_data_adapter_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ namespace {
" : DynamicDataAdapter_T<" << cpp_name << ">(type, value)\n"
" {\n"
" }\n"
"\n"
" DDS::ReturnCode_t clear_all_values()\n"
" {\n"
" const DDS::ReturnCode_t rc = assert_mutable(\"DynamicDataAdapter::clear_all_values\");\n"
" if (rc == DDS::RETCODE_OK) {\n"
" OpenDDS::DCPS::set_default(value_);\n"
" }\n"
" return rc;\n"
" }\n"
"\n";
if (struct_node || seq_node || array_node) {
be_global->impl_ <<
Expand Down Expand Up @@ -460,11 +469,6 @@ namespace {
const bool forany = needs_forany(node_as_type);
const bool distinct_type = needs_distinct_type(node_as_type);
be_global->impl_ <<
" DDS::DynamicData_ptr clone()\n"
" {\n"
" return new DynamicDataAdapterImpl(type_, value_);\n"
" }\n"
"\n"
" bool serialized_size(const OpenDDS::DCPS::Encoding& enc, size_t& size, OpenDDS::DCPS::Sample::Extent ext) const\n"
" {\n";
if (struct_node || union_node) {
Expand Down Expand Up @@ -552,9 +556,7 @@ namespace {
}
be_global->impl_ <<
" }\n"
"\n";

be_global->impl_ <<
"\n"
"protected:\n";

if (!generate_dynamic_data_adapter_access(node, wrapper, false)) {
Expand Down