This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor C and C++ typesupport (#18)
* Switch C++ type support generation pipeline. * Adds outer C++ IDL templates. * Adapts C++ msg & srv header templates. * Adapts C++ msg & srv source templates. * Switch C type support generation pipeline. * Adds outer C IDL templates. * Adapts C msg & srv header templates. * Adapts C msg source template. * Adapts C msg & srv source templates. * Adds missing Python imports in templates. * Converts IDL files to RTI Connext IDL files. * Fixing typesupport generation issues. * Uses rosidl_dds again for IDL2IDL conversion. * Applies many fixes to C & C++ typesupport. * Fixes for C++ srv templates. * Many fixes to C & C++ type support. * Yet more fixes to C & C++ type support. * Fixes copyright dates. * Adds back attribute to generated code constants. * Adds missing type support for action messages.
- Loading branch information
Showing
20 changed files
with
1,301 additions
and
1,041 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
76 changes: 76 additions & 0 deletions
76
rosidl_typesupport_connext_c/resource/idl__dds_connext__type_support_c.cpp.em
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,76 @@ | ||
// generated from rosidl_typesupport_connext_c/resource/idl__dds_connext__type_support_c.cpp.em | ||
// with input from @(package_name):@(interface_path) | ||
// generated code does not contain a copyright notice | ||
|
||
@{ | ||
####################################################################### | ||
# EmPy template for generating <idl>__type_support_c.cpp files | ||
# | ||
# Context: | ||
# - package_name (string) | ||
# - content (rosidl_parser.definition.IdlContent result of parsing IDL file) | ||
# - interface_path (Path relative to the directory named after the package) | ||
####################################################################### | ||
include_directives = set() | ||
####################################################################### | ||
# Handle message | ||
####################################################################### | ||
from rosidl_parser.definition import Message | ||
for message in content.get_elements_of_type(Message): | ||
TEMPLATE( | ||
'msg__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
message=message, include_directives=include_directives | ||
) | ||
####################################################################### | ||
# Handle service | ||
####################################################################### | ||
from rosidl_parser.definition import Service | ||
for service in content.get_elements_of_type(Service): | ||
TEMPLATE( | ||
'srv__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
service=service, include_directives=include_directives | ||
) | ||
####################################################################### | ||
# Handle action | ||
####################################################################### | ||
from rosidl_parser.definition import Action | ||
for action in content.get_elements_of_type(Action): | ||
TEMPLATE( | ||
'msg__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
service=action.goal_request, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'srv__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
service=action.goal_service, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'msg__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
service=action.result_response, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'srv__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
service=action.result_service, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'msg__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
message=action.feedback, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'msg__type_support_c.cpp.em', | ||
package_name=package_name, interface_path=interface_path, | ||
message=action.feedback_message, | ||
include_directives=include_directives | ||
) | ||
}@ |
68 changes: 68 additions & 0 deletions
68
rosidl_typesupport_connext_c/resource/idl__rosidl_typesupport_connext_c.h.em
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,68 @@ | ||
// generated from rosidl_typesupport_connext_c/resource/idl__rosidl_typesupport_connext_c.h.em | ||
// with input from @(package_name):@(interface_path) | ||
// generated code does not contain a copyright notice | ||
|
||
@{ | ||
####################################################################### | ||
# EmPy template for generating <idl>__rosidl_typesupport_connext_c.h files | ||
# | ||
# Context: | ||
# - package_name (string) | ||
# - content (rosidl_parser.definition.IdlContent result of parsing IDL file) | ||
# - interface_path (Path relative to the directory named after the package) | ||
####################################################################### | ||
from rosidl_cmake import convert_camel_case_to_lower_case_underscore | ||
include_parts = [package_name] + list(interface_path.parents[0].parts) + \ | ||
[convert_camel_case_to_lower_case_underscore(interface_path.stem)] | ||
header_guard_variable = '__'.join([x.upper() for x in include_parts]) + \ | ||
'__ROSIDL_TYPESUPPORT_CONNEXT_C_H_' | ||
include_directives = set() | ||
}@ | ||
|
||
#ifndef @(header_guard_variable) | ||
#define @(header_guard_variable) | ||
|
||
@{ | ||
####################################################################### | ||
# Handle message | ||
####################################################################### | ||
from rosidl_parser.definition import Message | ||
for message in content.get_elements_of_type(Message): | ||
TEMPLATE( | ||
'msg__rosidl_typesupport_connext_c.h.em', | ||
package_name=package_name, interface_path=interface_path, message=message, | ||
include_directives=include_directives | ||
) | ||
####################################################################### | ||
# Handle service | ||
####################################################################### | ||
from rosidl_parser.definition import Service | ||
for service in content.get_elements_of_type(Service): | ||
TEMPLATE( | ||
'srv__rosidl_typesupport_connext_c.h.em', | ||
package_name=package_name, interface_path=interface_path, service=service, | ||
include_directives=include_directives | ||
) | ||
####################################################################### | ||
# Handle action | ||
####################################################################### | ||
from rosidl_parser.definition import Action | ||
for action in content.get_elements_of_type(Action): | ||
TEMPLATE( | ||
'srv__rosidl_typesupport_connext_c.h.em', | ||
package_name=package_name, interface_path=interface_path, service=action.goal_service, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'srv__rosidl_typesupport_connext_c.h.em', | ||
package_name=package_name, interface_path=interface_path, service=action.result_service, | ||
include_directives=include_directives | ||
) | ||
TEMPLATE( | ||
'msg__rosidl_typesupport_connext_c.h.em', | ||
package_name=package_name, interface_path=interface_path, message=action.feedback_message, | ||
include_directives=include_directives | ||
) | ||
}@ | ||
|
||
#endif // @(header_guard_variable) |
51 changes: 21 additions & 30 deletions
51
rosidl_typesupport_connext_c/resource/msg__rosidl_typesupport_connext_c.h.em
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 |
---|---|---|
@@ -1,45 +1,36 @@ | ||
// generated from | ||
// rosidl_typesupport_connext_c/resource/msg__rosidl_typesupport_connext_c.h.em | ||
// generated code does not contain a copyright notice | ||
@# Included from rosidl_typesupport_connext_c/resource/idl__rosidl_typesupport_connext_c.h.em | ||
|
||
@####################################################################### | ||
@# EmPy template for generating | ||
@# <msg>__rosidl_typesupport_connext_c.h files | ||
@# | ||
@# Context: | ||
@# - spec (rosidl_parser.MessageSpecification) | ||
@# Parsed specification of the .msg file | ||
@# - subfolder (string) | ||
@# The subfolder / subnamespace of the message | ||
@# Could be 'msg', 'srv' or 'action' | ||
@# - get_header_filename_from_msg_name (function) | ||
@####################################################################### | ||
@ | ||
@{ | ||
header_guard_parts = [ | ||
spec.base_type.pkg_name, subfolder, | ||
get_header_filename_from_msg_name(spec.base_type.type) + '__rosidl_typesupport_connext_c_h'] | ||
header_guard_variable = '__'.join([x.upper() for x in header_guard_parts]) + '_' | ||
header_files = [ | ||
'rosidl_generator_c/message_type_support_struct.h', | ||
'rosidl_typesupport_interface/macros.h', | ||
package_name + '/msg/rosidl_typesupport_connext_c__visibility_control.h' | ||
] | ||
}@ | ||
#ifndef @(header_guard_variable) | ||
#define @(header_guard_variable) | ||
|
||
#include "rosidl_generator_c/message_type_support_struct.h" | ||
#include "rosidl_typesupport_interface/macros.h" | ||
|
||
#include "@(spec.base_type.pkg_name)/msg/rosidl_typesupport_connext_c__visibility_control.h" | ||
@[for header_file in header_files]@ | ||
@[ if header_file in include_directives]@ | ||
// already included above | ||
// @ | ||
@[ else]@ | ||
@{include_directives.add(header_file)}@ | ||
@[ end if]@ | ||
#include "@(header_file)" | ||
@[end for]@ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
ROSIDL_TYPESUPPORT_CONNEXT_C_PUBLIC_@(spec.base_type.pkg_name) | ||
ROSIDL_TYPESUPPORT_CONNEXT_C_PUBLIC_@(package_name) | ||
const rosidl_message_type_support_t * | ||
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_connext_c, @(spec.base_type.pkg_name), @(subfolder), @(spec.base_type.type))(); | ||
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( | ||
rosidl_typesupport_connext_c, | ||
@(', '.join([package_name] + list(interface_path.parents[0].parts))), | ||
@(message.structure.type.name))(); | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // @(header_guard_variable) |
Oops, something went wrong.