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

Fix get type support handle #9

Merged
merged 5 commits into from Mar 26, 2015
Merged
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
3 changes: 3 additions & 0 deletions rosidl_typesupport_introspection_cpp/CMakeLists.txt
Expand Up @@ -6,6 +6,9 @@ find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)

ament_export_dependencies(rosidl_cmake)
# The reason the impl folder is exported is that it contains the
# implementation for the get_*_type_support_handle functions and defines the
# rosidl_typesupport_introspection_cpp specific version of these functions.
ament_export_include_directories(include include/${PROJECT_NAME}/impl)

ament_python_install_package(${PROJECT_NAME})
Expand Down
Expand Up @@ -61,7 +61,7 @@ set(_target_suffix "__typesupport_introspection_cpp")
add_library(${rosidl_generate_interfaces_TARGET}${_target_suffix} SHARED ${_generated_files})
if(WIN32)
target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix}
PRIVATE "ROSIDL_TSI_CPP_BUILDING_DLL")
PRIVATE "ROSIDL_BUILDING_DLL")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the CMake docs it looks like that you can specify both definitions in a single invocation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I actually meant to remove the flag above, along with the whole visibility header in the rosidl_typesupport_introspection_cpp package. I'll update it one way or another.

endif()
target_include_directories(${rosidl_generate_interfaces_TARGET}${_target_suffix}
PUBLIC
Expand Down

This file was deleted.

This file was deleted.

@@ -1,8 +1,7 @@
#ifndef __rosidl_typesupport_introspection_cpp__field_types__hpp__
#define __rosidl_typesupport_introspection_cpp__field_types__hpp__

#ifndef __rosidl_typesupport_introspection_cpp__FieldTypes__h__
#define __rosidl_typesupport_introspection_cpp__FieldTypes__h__

#include <stdint.h>
#include <cstdint>

namespace rosidl_typesupport_introspection_cpp
{
Expand All @@ -26,4 +25,4 @@ const uint8_t ROS_TYPE_MESSAGE = 15;

} // namespace rosidl_typesupport_introspection_cpp

#endif // __rosidl_typesupport_introspection_cpp__FieldTypes__h__
#endif // __rosidl_typesupport_introspection_cpp__field_types__hpp__
@@ -0,0 +1,11 @@
#ifndef ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_IDENTIFIER_HPP_
#define ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_IDENTIFIER_HPP_

namespace rosidl_typesupport_introspection_cpp
{

static const char * typesupport_introspection_identifier = "introspection";

} // namespace rosidl_typesupport_introspection_cpp

#endif // ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_IDENTIFIER_HPP_
@@ -0,0 +1,58 @@
/* Copyright 2015 Open Source Robotics Foundation, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// This header contains the type support introspection specific implementation
// of the <rosidl_generator_cpp/message_type_support_decl.hpp> header.

#ifndef __rosidl_generator_cpp__message_type_support__hpp__
#define __rosidl_generator_cpp__message_type_support__hpp__

// Provides the definition of the rosidl_message_type_support_t struct.
#include <rosidl_generator_c/message_type_support.h>
// Provides visibility macros like ROSIDL_PUBLIC.
#include <rosidl_generator_c/visibility_control.h>
// Provides the declaration of the function
// rosidl_generator_cpp::get_message_type_support_handle.
#include <rosidl_generator_cpp/message_type_support_decl.hpp>

namespace rosidl_typesupport_introspection_cpp
{

// This is implemented in the shared library provided by this package.
template<typename T>
ROSIDL_PUBLIC
const rosidl_message_type_support_t * get_message_type_support_handle_introspection();

} // namespace rosidl_typesupport_introspection_cpp

namespace rosidl_generator_cpp
{

template<typename T>
const rosidl_message_type_support_t * get_message_type_support_handle()
{
// Hand off to implementation specific handle getter.
// By using this implementation specific getter in this header, it makes
// the user executable or library have a reference to an implementation
// specific symbol, which is implemented in the implementation specific
// message library. This is intentional to allow the linker to pick the
// correct implementation specific message library when being over linked
// with multiple implementation options.
return rosidl_typesupport_introspection_cpp::get_message_type_support_handle_introspection<T>();
}

} // namespace rosidl_generator_cpp

#endif // __rosidl_generator_cpp__message_type_support__hpp__
@@ -0,0 +1,58 @@
/* Copyright 2015 Open Source Robotics Foundation, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// This header contains the type support introspection specific implementation
// of the <rosidl_generator_cpp/service_type_support_decl.hpp> header.

#ifndef __rosidl_generator_cpp__service_type_support__hpp__
#define __rosidl_generator_cpp__service_type_support__hpp__

// Provides the definition of the rosidl_service_type_support_t struct.
#include <rosidl_generator_c/service_type_support.h>
// Provides visibility macros like ROSIDL_PUBLIC.
#include <rosidl_generator_c/visibility_control.h>
// Provides the declaration of the function
// rosidl_generator_cpp::get_service_type_support_handle.
#include <rosidl_generator_cpp/service_type_support_decl.hpp>

namespace rosidl_typesupport_introspection_cpp
{

// This is implemented in the shared library provided by this package.
template<typename T>
ROSIDL_PUBLIC
const rosidl_service_type_support_t * get_service_type_support_handle_introspection();

} // namespace rosidl_typesupport_introspection_cpp

namespace rosidl_generator_cpp
{

template<typename T>
const rosidl_service_type_support_t * get_service_type_support_handle()
{
// Hand off to implementation specific handle getter.
// By using this implementation specific getter in this header, it makes
// the user executable or library have a reference to an implementation
// specific symbol, which is implemented in the implementation specific
// service library. This is intentional to allow the linker to pick the
// correct implementation specific service library when being over linked
// with multiple implementation options.
return rosidl_typesupport_introspection_cpp::get_service_type_support_handle_introspection<T>();
}

} // namespace rosidl_generator_cpp

#endif // __rosidl_generator_cpp__service_type_support__hpp__

This file was deleted.

Expand Up @@ -2,18 +2,17 @@
#define __rosidl_typesupport_introspection_cpp__MessageIntrospection__h__

#include <cstddef>
#include <stdint.h>
#include <cstdint>

#include <rosidl_generator_c/message_type_support.h>

#include "impl/visibility_control.h"
#include <rosidl_generator_c/visibility_control.h>

namespace rosidl_typesupport_introspection_cpp
{

struct ROSIDL_TSI_CPP_PUBLIC MessageMembers;
struct ROSIDL_PUBLIC MessageMembers;

typedef struct ROSIDL_TSI_CPP_PUBLIC MessageMember
typedef struct ROSIDL_PUBLIC MessageMember
{
const char * name_;
uint8_t type_id_;
Expand All @@ -26,18 +25,14 @@ typedef struct ROSIDL_TSI_CPP_PUBLIC MessageMember
const void * default_value_;
} MessageMember;

typedef struct ROSIDL_TSI_CPP_PUBLIC MessageMembers
typedef struct ROSIDL_PUBLIC MessageMembers
{
const char * package_name_;
const char * message_name_;
unsigned long member_count_;
const MessageMember * members_;
} MessageMembers;

template<typename T>
ROSIDL_TSI_CPP_PUBLIC
const rosidl_message_type_support_t * get_type_support_handle();

} // namespace rosidl_typesupport_introspection_cpp

#endif // __rosidl_typesupport_introspection_cpp__MessageIntrospection__h__
9 changes: 8 additions & 1 deletion rosidl_typesupport_introspection_cpp/package.xml
Expand Up @@ -2,16 +2,23 @@
<package format="2">
<name>rosidl_typesupport_introspection_cpp</name>
<version>0.0.0</version>
<description>Generate the message type support for dynamic message construction in C++.</description>
<description>
Generate the message type support for dynamic message construction in C++.
</description>
<maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_cmake</buildtool_depend>

<!-- This is required for the rosidl_message_type_support_t struct and visibility macros -->
<build_depend>rosidl_generator_c</build_depend>

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<build_export_depend>rosidl_generator_c</build_export_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
</package>
Expand Up @@ -18,12 +18,15 @@
// Include cstddef for offsetof().
#include <cstddef>

#include <rosidl_generator_c/message_type_support.h>
// This is defined in the rosidl_typesupport_introspection_cpp package and
// is in the include/rosidl_typesupport_introspection_cpp/impl folder.
#include <rosidl_generator_cpp/message_type_support.hpp>

#include "@(spec.base_type.pkg_name)/@(spec.base_type.type)_Struct.h"
#include "rosidl_generator_cpp/MessageTypeSupport.h"
#include "rosidl_typesupport_introspection_cpp/FieldTypes.h"
#include "rosidl_typesupport_introspection_cpp/Identifier.h"
#include "rosidl_typesupport_introspection_cpp/MessageIntrospection.h"
#include "rosidl_typesupport_introspection_cpp/impl/visibility_control.h"
#include "rosidl_typesupport_introspection_cpp/field_types.hpp"
#include "rosidl_typesupport_introspection_cpp/identifier.hpp"
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"

namespace @(spec.base_type.pkg_name)
{
Expand Down Expand Up @@ -52,7 +55,7 @@ for index, field in enumerate(spec.fields):
# size_t string_upper_bound
print(' 0,')
# const rosidl_message_type_support_t * members_
print(' ::rosidl_typesupport_introspection_cpp::get_type_support_handle<%s::%s>(),' % (field.type.pkg_name, field.type.type))
print(' ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle_introspection<%s::%s>(),' % (field.type.pkg_name, field.type.type))
# bool is_array_
print(' %s,' % ('true' if field.type.is_array else 'false'))
# size_t array_size_
Expand Down Expand Up @@ -95,12 +98,13 @@ namespace rosidl_typesupport_introspection_cpp
{

template<>
ROSIDL_TSI_CPP_PUBLIC
const rosidl_message_type_support_t * get_type_support_handle<@(spec.base_type.pkg_name)::@(spec.base_type.type)>()
ROSIDL_PUBLIC
const rosidl_message_type_support_t *
get_message_type_support_handle_introspection<@(spec.base_type.pkg_name)::@(spec.base_type.type)>()
{
return &::@(spec.base_type.pkg_name)::rosidl_typesupport_introspection_cpp::@(spec.base_type.type)_message_type_support_handle;
}

} // namespace rosidl_generator_cpp
} // namespace rosidl_typesupport_introspection_cpp

#endif // __@(spec.base_type.pkg_name)__@(spec.base_type.type)_TypeSupport__h__
Expand Up @@ -15,9 +15,12 @@
// rosidl_typesupport_introspection_cpp/resource/srv_ServiceTypeSupport_Introspection.cpp.template
#include <iostream>

#include <rosidl_generator_c/service_type_support.h>
// This is defined in the rosidl_typesupport_introspection_cpp package and
// is in the include/rosidl_typesupport_introspection_cpp/impl folder.
#include <rosidl_generator_cpp/service_type_support.hpp>

#include "@(spec.pkg_name)/@(spec.srv_name)_Service.h"
#include "rosidl_generator_cpp/ServiceTypeSupport.h"
#include "rosidl_typesupport_introspection_cpp/ServiceIntrospection.h"

namespace rosidl_typesupport_introspection_cpp
{
Expand All @@ -28,8 +31,9 @@ static rosidl_service_type_support_t handle;
}

template <>
ROSIDL_PUBLIC
const rosidl_service_type_support_t *
get_service_type_support_handle<@(spec.pkg_name)::@(spec.srv_name)>()
get_service_type_support_handle_introspection<@(spec.pkg_name)::@(spec.srv_name)>()
{
return &impl::handle;
}
Expand Down