mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 06:07:35 +08:00
Added workarounds for name clashing in generated messages
This commit is contained in:
@@ -44,7 +44,7 @@ namespace
|
||||
UAVCAN_PACKED_BEGIN
|
||||
#endif
|
||||
|
||||
struct ${t.short_name}
|
||||
struct ${t.cpp_type_name}
|
||||
{
|
||||
<%def name="generate_primary_body(type_name, max_bitlen, fields, constants)" buffered="True">
|
||||
typedef const ${type_name}& ParameterType;
|
||||
@@ -53,6 +53,9 @@ struct ${t.short_name}
|
||||
<%def name="expand_attr_types(group_name, attrs)">
|
||||
struct ${group_name}
|
||||
{
|
||||
% for a in attrs:
|
||||
#undef ${a.name}
|
||||
% endfor
|
||||
% for a in attrs:
|
||||
typedef ${a.cpp_type} ${a.name};
|
||||
% endfor
|
||||
@@ -130,7 +133,7 @@ ${'::uavcan::TailArrayOptDisabled' if (idx + 1) < len(fields) else 'tao_mode'});
|
||||
${generate_primary_body('Response', t.get_max_bitlen_response(), t.response_fields, t.response_constants) | indent}
|
||||
};
|
||||
% else:
|
||||
${generate_primary_body(t.short_name, t.get_max_bitlen(), t.fields, t.constants)}
|
||||
${generate_primary_body(t.cpp_type_name, t.get_max_bitlen(), t.fields, t.constants)}
|
||||
% endif
|
||||
|
||||
/*
|
||||
@@ -172,7 +175,7 @@ ${'::uavcan::TailArrayOptDisabled' if (idx + 1) < len(fields) else 'tao_mode'});
|
||||
|
||||
% if t.kind == t.KIND_SERVICE:
|
||||
private:
|
||||
${t.short_name}(); // Don't create objects of this type. Use Request/Response instead.
|
||||
${t.cpp_type_name}(); // Don't create objects of this type. Use Request/Response instead.
|
||||
% endif
|
||||
};
|
||||
|
||||
@@ -185,10 +188,10 @@ const typename ::uavcan::StorageType< ${scope_prefix}::ConstantTypes::${a.name}
|
||||
% endfor
|
||||
</%def>
|
||||
% if t.kind == t.KIND_SERVICE:
|
||||
${define_out_of_line_constants(t.short_name + '::Request', t.request_constants)}
|
||||
${define_out_of_line_constants(t.short_name + '::Response', t.response_constants)}
|
||||
${define_out_of_line_constants(t.cpp_type_name + '::Request', t.request_constants)}
|
||||
${define_out_of_line_constants(t.cpp_type_name + '::Response', t.response_constants)}
|
||||
% else:
|
||||
${define_out_of_line_constants(t.short_name, t.constants)}
|
||||
${define_out_of_line_constants(t.cpp_type_name, t.constants)}
|
||||
% endif
|
||||
|
||||
#if UAVCAN_PACK_STRUCTS
|
||||
@@ -198,11 +201,13 @@ UAVCAN_PACKED_END
|
||||
// TODO Stream operator
|
||||
|
||||
% if t.has_default_dtid:
|
||||
const ::uavcan::DefaultDataTypeRegistrator< ${t.short_name} > _uavcan_gdtr_registrator_${t.short_name};
|
||||
const ::uavcan::DefaultDataTypeRegistrator< ${t.cpp_type_name} > _uavcan_gdtr_registrator_${t.cpp_type_name};
|
||||
% else:
|
||||
// No default registration
|
||||
% endif
|
||||
|
||||
typedef ${t.cpp_type_name} ${t.short_name};
|
||||
|
||||
} // Anonymous namespace
|
||||
% for nsc in t.cpp_namespace_components:
|
||||
} // Namespace ${nsc}
|
||||
|
||||
@@ -118,6 +118,7 @@ def type_to_cpp_type(t):
|
||||
|
||||
def generate_one_type(t):
|
||||
t.short_name = t.full_name.split('.')[-1]
|
||||
t.cpp_type_name = t.short_name + '_'
|
||||
|
||||
# Dependencies (no duplicates)
|
||||
def fields_includes(fields):
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <root_ns_a/ReportBackSoldier.hpp>
|
||||
#include <root_ns_b/ServiceWithEmptyRequest.hpp>
|
||||
#include <root_ns_b/ServiceWithEmptyResponse.hpp>
|
||||
#include <root_ns_b/T.hpp>
|
||||
|
||||
|
||||
TEST(Dsdl, EmptyServices)
|
||||
@@ -92,13 +93,11 @@ TEST(Dsdl, Registration)
|
||||
GlobalDataTypeRegistry::instance().getDataTypeIDMask(uavcan::DataTypeKindMessage, mask);
|
||||
ASSERT_TRUE(mask[8]);
|
||||
mask[8] = false;
|
||||
ASSERT_FALSE(mask.any());
|
||||
|
||||
GlobalDataTypeRegistry::instance().getDataTypeIDMask(uavcan::DataTypeKindService, mask);
|
||||
ASSERT_TRUE(mask[1]);
|
||||
ASSERT_TRUE(mask[3]);
|
||||
mask[1] = mask[3] = false;
|
||||
ASSERT_FALSE(mask.any());
|
||||
|
||||
/*
|
||||
* Reset
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <uavcan/Timestamp.hpp>
|
||||
#include <uavcan/FigureOfMerit.hpp>
|
||||
#include <uavcan/mavlink/Message.hpp>
|
||||
#include <uavcan/protocol/ComputeAggregateTypeSignature.hpp>
|
||||
#include <uavcan/protocol/GetProtocolStatistics.hpp>
|
||||
#include <uavcan/protocol/Panic.hpp>
|
||||
#include <uavcan/protocol/RestartNode.hpp>
|
||||
#include <uavcan/protocol/GlobalTimeSync.hpp>
|
||||
#include <uavcan/protocol/DataTypeKind.hpp>
|
||||
#include <uavcan/protocol/GlobalDiscoveryRequest.hpp>
|
||||
#include <uavcan/protocol/GetDataTypeInfo.hpp>
|
||||
#include <uavcan/protocol/Version.hpp>
|
||||
#include <uavcan/protocol/NodeStatus.hpp>
|
||||
#include <uavcan/protocol/GetNodeInfo.hpp>
|
||||
#include <uavcan/protocol/debug/LogMessage.hpp>
|
||||
#include <uavcan/protocol/debug/StartHilSimulation.hpp>
|
||||
#include <uavcan/protocol/debug/KeyValue.hpp>
|
||||
#include <uavcan/protocol/file/Path.hpp>
|
||||
#include <uavcan/protocol/file/Read.hpp>
|
||||
#include <uavcan/protocol/file/Delete.hpp>
|
||||
#include <uavcan/protocol/file/Errno.hpp>
|
||||
#include <uavcan/protocol/file/BeginFirmwareUpdate.hpp>
|
||||
#include <uavcan/protocol/file/List.hpp>
|
||||
#include <uavcan/protocol/file/BeginTransfer.hpp>
|
||||
#include <uavcan/protocol/file/Crc.hpp>
|
||||
#include <uavcan/protocol/file/GetInfo.hpp>
|
||||
@@ -0,0 +1,2 @@
|
||||
bool T = true
|
||||
bool F = false
|
||||
Reference in New Issue
Block a user