-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate typesupport getter declarations for actions, messages and se…
…rvices. (#778) Signed-off-by: Stefan Fabian <[email protected]>
- Loading branch information
1 parent
cf3b637
commit 6a18bbf
Showing
8 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@# Included from rosidl_generator_cpp/resource/action__type_support.hpp.em | ||
@{header_file = 'rosidl_typesupport_cpp/action_type_support.hpp'}@ | ||
@[if header_file in include_directives]@ | ||
// already included above | ||
// @ | ||
@[else]@ | ||
@{include_directives.add(header_file)}@ | ||
@[end if]@ | ||
#include "@(header_file)" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
// Forward declare the get type support functions for this type. | ||
ROSIDL_GENERATOR_CPP_PUBLIC_@(package_name) | ||
const rosidl_action_type_support_t * | ||
ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( | ||
rosidl_typesupport_cpp, | ||
@(',\n '.join(action.namespaced_type.namespaced_name())) | ||
)(); | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=action.goal, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=action.result, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=action.feedback, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@{ | ||
TEMPLATE( | ||
'srv__type_support.hpp.em', | ||
package_name=package_name, service=action.send_goal_service, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@{ | ||
TEMPLATE( | ||
'srv__type_support.hpp.em', | ||
package_name=package_name, service=action.get_result_service, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=action.feedback_message, | ||
include_directives=include_directives) | ||
}@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// generated from rosidl_generator_cpp/resource/idl__type_support.hpp.em | ||
// with input from @(package_name):@(interface_path) | ||
// generated code does not contain a copyright notice | ||
@ | ||
@####################################################################### | ||
@# EmPy template for generating <idl>__struct.h files | ||
@# | ||
@# Context: | ||
@# - package_name (string) | ||
@# - interface_path (Path relative to the directory named after the package) | ||
@# - content (IdlContent, list of elements, e.g. Messages or Services) | ||
@####################################################################### | ||
@{ | ||
from rosidl_cmake import convert_camel_case_to_lower_case_underscore | ||
include_parts = [package_name] + list(interface_path.parents[0].parts) + [ | ||
'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] | ||
header_guard_variable = '__'.join([x.upper() for x in include_parts]) + \ | ||
'__TYPE_SUPPORT_HPP_' | ||
|
||
include_directives = set() | ||
}@ | ||
|
||
#ifndef @(header_guard_variable) | ||
#define @(header_guard_variable) | ||
|
||
#include "rosidl_typesupport_interface/macros.h" | ||
|
||
#include "@(package_name)/msg/rosidl_generator_cpp__visibility_control.hpp" | ||
|
||
@####################################################################### | ||
@# Handle message | ||
@####################################################################### | ||
@{ | ||
from rosidl_parser.definition import Message | ||
}@ | ||
@[for message in content.get_elements_of_type(Message)]@ | ||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=message, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@[end for]@ | ||
@ | ||
@####################################################################### | ||
@# Handle service | ||
@####################################################################### | ||
@{ | ||
from rosidl_parser.definition import Service | ||
}@ | ||
@[for service in content.get_elements_of_type(Service)]@ | ||
@{ | ||
TEMPLATE( | ||
'srv__type_support.hpp.em', | ||
package_name=package_name, service=service, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@[end for]@ | ||
@ | ||
@####################################################################### | ||
@# Handle action | ||
@####################################################################### | ||
@{ | ||
from rosidl_parser.definition import Action | ||
}@ | ||
@[for action in content.get_elements_of_type(Action)]@ | ||
@{ | ||
TEMPLATE( | ||
'action__type_support.hpp.em', | ||
package_name=package_name, action=action, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@[end for]@ | ||
#endif // @(header_guard_variable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@# Included from rosidl_generator_cpp/resource/msg__type_support.hpp.em | ||
@{header_file = 'rosidl_typesupport_cpp/message_type_support.hpp'}@ | ||
@[if header_file in include_directives]@ | ||
// already included above | ||
// @ | ||
@[else]@ | ||
@{include_directives.add(header_file)}@ | ||
@[end if]@ | ||
#include "@(header_file)" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
// Forward declare the get type support functions for this type. | ||
ROSIDL_GENERATOR_CPP_PUBLIC_@(package_name) | ||
const rosidl_message_type_support_t * | ||
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( | ||
rosidl_typesupport_cpp, | ||
@(',\n '.join(message.structure.namespaced_type.namespaced_name())) | ||
)(); | ||
#ifdef __cplusplus | ||
} | ||
#endif |
42 changes: 42 additions & 0 deletions
42
rosidl_generator_cpp/resource/rosidl_generator_cpp__visibility_control.hpp.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// generated from rosidl_generator_cpp/resource/rosidl_generator_cpp__visibility_control.hpp.in | ||
// generated code does not contain a copyright notice | ||
|
||
#ifndef @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_CPP__VISIBILITY_CONTROL_HPP_ | ||
#define @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_CPP__VISIBILITY_CONTROL_HPP_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
// This logic was borrowed (then namespaced) from the examples on the gcc wiki: | ||
// https://gcc.gnu.org/wiki/Visibility | ||
|
||
#if defined _WIN32 || defined __CYGWIN__ | ||
#ifdef __GNUC__ | ||
#define ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ __attribute__ ((dllexport)) | ||
#define ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ __attribute__ ((dllimport)) | ||
#else | ||
#define ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ __declspec(dllexport) | ||
#define ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ __declspec(dllimport) | ||
#endif | ||
#ifdef ROSIDL_GENERATOR_CPP_BUILDING_DLL_@PROJECT_NAME@ | ||
#define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ | ||
#else | ||
#define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ | ||
#endif | ||
#else | ||
#define ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default"))) | ||
#define ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ | ||
#if __GNUC__ >= 4 | ||
#define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ __attribute__ ((visibility("default"))) | ||
#else | ||
#define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ | ||
#endif | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_CPP__VISIBILITY_CONTROL_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@# Included from rosidl_generator_cpp/resource/srv__type_support.hpp.em | ||
@{header_file = 'rosidl_typesupport_cpp/service_type_support.hpp'}@ | ||
@[if header_file in include_directives]@ | ||
// already included above | ||
// @ | ||
@[else]@ | ||
@{include_directives.add(header_file)}@ | ||
@[end if]@ | ||
#include "@(header_file)" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
// Forward declare the get type support functions for this type. | ||
ROSIDL_GENERATOR_CPP_PUBLIC_@(package_name) | ||
const rosidl_service_type_support_t * | ||
ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME( | ||
rosidl_typesupport_cpp, | ||
@(',\n '.join(service.namespaced_type.namespaced_name())) | ||
)(); | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=service.request_message, | ||
include_directives=include_directives) | ||
}@ | ||
|
||
@{ | ||
TEMPLATE( | ||
'msg__type_support.hpp.em', | ||
package_name=package_name, message=service.response_message, | ||
include_directives=include_directives) | ||
}@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters