tyagikunal

ros_idl_typesupport_diff

Dec 3rd, 2017
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 59.49 KB | None | 0 0
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 887bbb3..fb8d51b 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -1,6 +1,6 @@
  6.  cmake_minimum_required(VERSION 3.5)
  7.  
  8. -project(rosidl_typesupport_c)
  9. +project(rosidl_typesupport_common)
  10.  
  11.  # Default to C11
  12.  if(NOT CMAKE_C_STANDARD)
  13. @@ -29,40 +29,59 @@ ament_export_include_directories(include)
  14.  
  15.  ament_python_install_package(${PROJECT_NAME})
  16.  
  17. -add_library(${PROJECT_NAME} SHARED
  18. -  src/identifier.c
  19. -  src/message_type_support_dispatch.cpp
  20. -  src/service_type_support_dispatch.cpp
  21. -  src/type_support_dispatch.cpp)
  22. -if(Poco_FOUND)
  23. -  target_compile_definitions(${PROJECT_NAME}
  24. -    PRIVATE "ROSIDL_TYPESUPPORT_C_USE_POCO")
  25. -endif()
  26. -if(WIN32)
  27. -  target_compile_definitions(${PROJECT_NAME}
  28. -    PRIVATE "ROSIDL_TYPESUPPORT_C_BUILDING_DLL")
  29. -endif()
  30. -target_include_directories(${PROJECT_NAME}
  31. -  PUBLIC
  32. -  include ${Poco_INCLUDE_DIRS}
  33. -)
  34. -target_link_libraries(${PROJECT_NAME} ${Poco_LIBRARIES})
  35. -ament_target_dependencies(${PROJECT_NAME} "rosidl_generator_c")
  36. -ament_export_libraries(${PROJECT_NAME})
  37. +set(common_name "rosidl_typesupport")
  38. +string(TOUPPER ${PROJECT_NAME} project_name_upper)
  39. +
  40. +#ament_export_libraries(${PROJECT_NAME}_c ${PROJECT_NAME}_cpp)
  41.  
  42. +set(lib_list ${PROJECT_NAME}_c ${PROJECT_NAME}_cpp)
  43. +
  44. +ament_export_libraries(${lib_list})
  45.  if(BUILD_TESTING)
  46.    find_package(ament_lint_auto REQUIRED)
  47.    ament_lint_auto_find_test_dependencies()
  48.  endif()
  49. -
  50.  ament_package(
  51. -  CONFIG_EXTRAS "rosidl_typesupport_c-extras.cmake.in"
  52. +    CONFIG_EXTRAS "${PROJECT_NAME}_c-extras.cmake.in"
  53. +                  "${PROJECT_NAME}_cpp-extras.cmake.in"
  54.  )
  55.  
  56. -install(
  57. -  PROGRAMS bin/rosidl_typesupport_c
  58. -  DESTINATION lib/rosidl_typesupport_c
  59. -)
  60. +foreach(lib_name ${lib_list})
  61. +  string(TOUPPER ${lib_name} lib_name_upper)
  62. +  add_library(${lib_name} SHARED
  63. +    src/identifier.cpp
  64. +    src/message_type_support_dispatch.cpp
  65. +    src/service_type_support_dispatch.cpp
  66. +    src/type_support_dispatch.cpp)
  67. +  if(Poco_FOUND)
  68. +    target_compile_definitions(${lib_name}
  69. +      PRIVATE "${project_name_upper}_USE_POCO")
  70. +  endif()
  71. +  if(WIN32)
  72. +    target_compile_definitions(${lib_name}
  73. +      PRIVATE "${project_name_upper}_BUILDING_DLL")
  74. +  endif()
  75. +  target_include_directories(${lib_name}
  76. +    PUBLIC
  77. +    include ${Poco_INCLUDE_DIRS}
  78. +  )
  79. +  target_link_libraries(${lib_name} ${Poco_LIBRARIES})
  80. +  target_compile_definitions(${lib_name} PRIVATE "${lib_name_upper}")
  81. +
  82. +  ament_target_dependencies(${lib_name} "rosidl_generator_c")
  83. +
  84. +  install(
  85. +    PROGRAMS bin/${PROJECT_NAME}
  86. +    DESTINATION lib/${lib_name}
  87. +  )
  88. +  install(
  89. +    TARGETS ${lib_name}
  90. +    ARCHIVE DESTINATION lib
  91. +    LIBRARY DESTINATION lib
  92. +    RUNTIME DESTINATION bin
  93. +  )
  94. +endforeach()
  95. +
  96.  install(
  97.    DIRECTORY cmake resource
  98.    DESTINATION share/${PROJECT_NAME}
  99. @@ -71,9 +90,3 @@ install(
  100.    DIRECTORY include/
  101.    DESTINATION include
  102.  )
  103. -install(
  104. -  TARGETS ${PROJECT_NAME}
  105. -  ARCHIVE DESTINATION lib
  106. -  LIBRARY DESTINATION lib
  107. -  RUNTIME DESTINATION bin
  108. -)
  109. diff --git a/README.md b/README.md
  110. new file mode 100644
  111. index 0000000..a8c7a34
  112. --- /dev/null
  113. +++ b/README.md
  114. @@ -0,0 +1,3 @@
  115. +# WARNING
  116. +
  117. +Here be Dragons
  118. diff --git a/bin/rosidl_typesupport_common b/bin/rosidl_typesupport_common
  119. new file mode 100644
  120. index 0000000..b30cb97
  121. --- /dev/null
  122. +++ b/bin/rosidl_typesupport_common
  123. @@ -0,0 +1,36 @@
  124. +#!/usr/bin/env python3
  125. +
  126. +import argparse
  127. +import sys
  128. +
  129. +from rosidl_parser import UnknownMessageType
  130. +from rosidl_typesupport_common import generate_common
  131. +
  132. +
  133. +def main(argv=sys.argv[1:]):
  134. +    parser = argparse.ArgumentParser(
  135. +        description='Generate the C and C++ type support to handle ROS messages.',
  136. +        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  137. +    parser.add_argument(
  138. +        '--generator-arguments-file',
  139. +        required=True,
  140. +        help='The location of the file containing the generator arguments')
  141. +    parser.add_argument(
  142. +        '--typesupports',
  143. +        required=True,
  144. +        nargs='+',
  145. +        help='The typesupports to be used')
  146. +    args = parser.parse_args(argv)
  147. +
  148. +    try:
  149. +        return generate_common(
  150. +            args.generator_arguments_file,
  151. +            args.typesupports,
  152. +        )
  153. +    except UnknownMessageType as e:
  154. +        print(str(e), file=sys.stderr)
  155. +        return 1
  156. +
  157. +
  158. +if __name__ == '__main__':
  159. +    sys.exit(main())
  160. diff --git a/cmake/rosidl_typesupport_c_generate_interfaces.cmake b/cmake/rosidl_typesupport_c_generate_interfaces.cmake
  161. index de9194b..625d65c 100644
  162. --- a/cmake/rosidl_typesupport_c_generate_interfaces.cmake
  163. +++ b/cmake/rosidl_typesupport_c_generate_interfaces.cmake
  164. @@ -99,7 +99,7 @@ if(WIN32)
  165.    target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  166.      PRIVATE "ROSIDL_GENERATOR_C_BUILDING_DLL_${PROJECT_NAME}")
  167.    target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  168. -    PRIVATE "ROSIDL_TYPESUPPORT_C_BUILDING_DLL_${PROJECT_NAME}")
  169. +    PRIVATE "ROSIDL_TYPESUPPORT_COMMON_C_BUILDING_DLL_${PROJECT_NAME}")
  170.  endif()
  171.  
  172.  set_target_properties(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  173. diff --git a/cmake/rosidl_typesupport_cpp_generate_interfaces.cmake b/cmake/rosidl_typesupport_cpp_generate_interfaces.cmake
  174. new file mode 100644
  175. index 0000000..0942fc6
  176. --- /dev/null
  177. +++ b/cmake/rosidl_typesupport_cpp_generate_interfaces.cmake
  178. @@ -0,0 +1,170 @@
  179. +# Copyright 2016 Open Source Robotics Foundation, Inc.
  180. +#
  181. +# Licensed under the Apache License, Version 2.0 (the "License");
  182. +# you may not use this file except in compliance with the License.
  183. +# You may obtain a copy of the License at
  184. +#
  185. +#     http://www.apache.org/licenses/LICENSE-2.0
  186. +#
  187. +# Unless required by applicable law or agreed to in writing, software
  188. +# distributed under the License is distributed on an "AS IS" BASIS,
  189. +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  190. +# See the License for the specific language governing permissions and
  191. +# limitations under the License.
  192. +
  193. +set(_output_path
  194. +  "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_cpp/${PROJECT_NAME}")
  195. +set(_generated_files "")
  196. +foreach(_idl_file ${rosidl_generate_interfaces_IDL_FILES})
  197. +  get_filename_component(_parent_folder "${_idl_file}" DIRECTORY)
  198. +  get_filename_component(_parent_folder "${_parent_folder}" NAME)
  199. +  if(_parent_folder STREQUAL "msg" OR _parent_folder STREQUAL "srv")
  200. +    get_filename_component(_msg_name "${_idl_file}" NAME_WE)
  201. +    string_camel_case_to_lower_case_underscore("${_msg_name}" _header_name)
  202. +    list(APPEND _generated_files
  203. +      "${_output_path}/${_parent_folder}/${_header_name}__type_support.cpp"
  204. +    )
  205. +  else()
  206. +    message(FATAL_ERROR "Interface file with unknown parent folder: ${_idl_file}")
  207. +  endif()
  208. +endforeach()
  209. +
  210. +set(_dependency_files "")
  211. +set(_dependencies "")
  212. +foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
  213. +  foreach(_idl_file ${${_pkg_name}_INTERFACE_FILES})
  214. +  get_filename_component(_extension "${_idl_file}" EXT)
  215. +  if(_extension STREQUAL ".msg")
  216. +    set(_abs_idl_file "${${_pkg_name}_DIR}/../${_idl_file}")
  217. +    normalize_path(_abs_idl_file "${_abs_idl_file}")
  218. +    list(APPEND _dependency_files "${_abs_idl_file}")
  219. +    list(APPEND _dependencies "${_pkg_name}:${_abs_idl_file}")
  220. +  endif()
  221. +  endforeach()
  222. +endforeach()
  223. +
  224. +set(target_dependencies
  225. +  "${rosidl_typesupport_cpp_BIN}"
  226. +  ${rosidl_typesupport_cpp_GENERATOR_FILES}
  227. +  "${rosidl_typesupport_cpp_TEMPLATE_DIR}/msg__type_support.cpp.em"
  228. +  "${rosidl_typesupport_cpp_TEMPLATE_DIR}/srv__type_support.cpp.em"
  229. +  ${rosidl_generate_interfaces_IDL_FILES}
  230. +  ${_dependency_files})
  231. +foreach(dep ${target_dependencies})
  232. +  if(NOT EXISTS "${dep}")
  233. +    message(FATAL_ERROR "Target dependency '${dep}' does not exist")
  234. +  endif()
  235. +endforeach()
  236. +
  237. +set(generator_arguments_file "${CMAKE_BINARY_DIR}/rosidl_typesupport_cpp__arguments.json")
  238. +rosidl_write_generator_arguments(
  239. +  "${generator_arguments_file}"
  240. +  PACKAGE_NAME "${PROJECT_NAME}"
  241. +  ROS_INTERFACE_FILES "${rosidl_generate_interfaces_IDL_FILES}"
  242. +  ROS_INTERFACE_DEPENDENCIES "${_dependencies}"
  243. +  OUTPUT_DIR "${_output_path}"
  244. +  TEMPLATE_DIR "${rosidl_typesupport_cpp_TEMPLATE_DIR}"
  245. +  TARGET_DEPENDENCIES ${target_dependencies}
  246. +)
  247. +
  248. +get_used_typesupports(typesupports "rosidl_typesupport_cpp")
  249. +add_custom_command(
  250. +  OUTPUT ${_generated_files}
  251. +  COMMAND ${PYTHON_EXECUTABLE} ${rosidl_typesupport_cpp_BIN}
  252. +  --generator-arguments-file "${generator_arguments_file}"
  253. +  --typesupports ${typesupports}
  254. +  DEPENDS ${target_dependencies}
  255. +  COMMENT "Generating C++ type support dispatch for ROS interfaces"
  256. +  VERBATIM
  257. +)
  258. +
  259. +set(_target_suffix "__rosidl_typesupport_cpp")
  260. +
  261. +add_library(${rosidl_generate_interfaces_TARGET}${_target_suffix} SHARED ${_generated_files})
  262. +if(rosidl_generate_interfaces_LIBRARY_NAME)
  263. +  set_target_properties(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  264. +    PROPERTIES OUTPUT_NAME "${rosidl_generate_interfaces_LIBRARY_NAME}${_target_suffix}")
  265. +endif()
  266. +if(WIN32)
  267. +  target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  268. +      PRIVATE "ROSIDL_TYPESUPPORT_COMMON_CPP_BUILDING_DLL")
  269. +endif()
  270. +set_target_properties(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  271. +  PROPERTIES CXX_STANDARD 14)
  272. +
  273. +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  274. +  set_target_properties(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  275. +    PROPERTIES COMPILE_OPTIONS -Wall -Wextra -Wpedantic)
  276. +endif()
  277. +target_include_directories(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  278. +  PUBLIC
  279. +  ${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_cpp
  280. +)
  281. +
  282. +# if only a single typesupport is used this package will directly reference it
  283. +# therefore it needs to link against the selected typesupport
  284. +if(NOT typesupports MATCHES ";")
  285. +  target_include_directories(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  286. +    PUBLIC
  287. +    "${CMAKE_CURRENT_BINARY_DIR}/${typesupports}")
  288. +  target_link_libraries(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  289. +    ${rosidl_generate_interfaces_TARGET}__${typesupports})
  290. +elseif(NOT rosidl_typesupport_cpp_SUPPORTS_POCO)
  291. +  message(FATAL_ERROR "Multiple typesupports but Poco was not available when "
  292. +    "rosidl_typesupport_cpp was built")
  293. +endif()
  294. +
  295. +ament_target_dependencies(${rosidl_generate_interfaces_TARGET}${_target_suffix}
  296. +  "rosidl_generator_c"
  297. +  "rosidl_generator_cpp"
  298. +  "rosidl_typesupport_cpp"
  299. +  "rosidl_typesupport_interface")
  300. +foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
  301. +  ament_target_dependencies(
  302. +    ${rosidl_generate_interfaces_TARGET}${_target_suffix}
  303. +    ${_pkg_name})
  304. +endforeach()
  305. +
  306. +add_dependencies(
  307. +  ${rosidl_generate_interfaces_TARGET}
  308. +  ${rosidl_generate_interfaces_TARGET}${_target_suffix}
  309. +)
  310. +add_dependencies(
  311. +  ${rosidl_generate_interfaces_TARGET}${_target_suffix}
  312. +  ${rosidl_generate_interfaces_TARGET}__cpp
  313. +)
  314. +
  315. +if(NOT rosidl_generate_interfaces_SKIP_INSTALL)
  316. +  install(
  317. +    TARGETS ${rosidl_generate_interfaces_TARGET}${_target_suffix}
  318. +    ARCHIVE DESTINATION lib
  319. +    LIBRARY DESTINATION lib
  320. +    RUNTIME DESTINATION bin
  321. +  )
  322. +  ament_export_libraries(${rosidl_generate_interfaces_TARGET}${_target_suffix})
  323. +endif()
  324. +
  325. +if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
  326. +  if(NOT _generated_files STREQUAL "")
  327. +    find_package(ament_cmake_cppcheck REQUIRED)
  328. +    ament_cppcheck(
  329. +      TESTNAME "cppcheck_rosidl_typesupport_cpp"
  330. +      "${_output_path}")
  331. +
  332. +    find_package(ament_cmake_cpplint REQUIRED)
  333. +    get_filename_component(_cpplint_root "${_output_path}" DIRECTORY)
  334. +    ament_cpplint(
  335. +      TESTNAME "cpplint_rosidl_typesupport_cpp"
  336. +      # the generated code might contain longer lines for templated types
  337. +      MAX_LINE_LENGTH 999
  338. +      ROOT "${_cpplint_root}"
  339. +      "${_output_path}")
  340. +
  341. +    find_package(ament_cmake_uncrustify REQUIRED)
  342. +    ament_uncrustify(
  343. +      TESTNAME "uncrustify_rosidl_typesupport_cpp"
  344. +      # the generated code might contain longer lines for templated types
  345. +      MAX_LINE_LENGTH 999
  346. +      "${_output_path}")
  347. +  endif()
  348. +endif()
  349. diff --git a/include/rosidl_typesupport_c/identifier.h b/include/rosidl_typesupport_c/identifier.h
  350. deleted file mode 100644
  351. index e5aece9..0000000
  352. --- a/include/rosidl_typesupport_c/identifier.h
  353. +++ /dev/null
  354. @@ -1,32 +0,0 @@
  355. -// Copyright 2016 Open Source Robotics Foundation, Inc.
  356. -//
  357. -// Licensed under the Apache License, Version 2.0 (the "License");
  358. -// you may not use this file except in compliance with the License.
  359. -// You may obtain a copy of the License at
  360. -//
  361. -//     http://www.apache.org/licenses/LICENSE-2.0
  362. -//
  363. -// Unless required by applicable law or agreed to in writing, software
  364. -// distributed under the License is distributed on an "AS IS" BASIS,
  365. -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  366. -// See the License for the specific language governing permissions and
  367. -// limitations under the License.
  368. -
  369. -#ifndef ROSIDL_TYPESUPPORT_C__IDENTIFIER_H_
  370. -#define ROSIDL_TYPESUPPORT_C__IDENTIFIER_H_
  371. -
  372. -#include "rosidl_typesupport_c/visibility_control.h"
  373. -
  374. -#if __cplusplus
  375. -extern "C"
  376. -{
  377. -#endif
  378. -
  379. -ROSIDL_TYPESUPPORT_C_PUBLIC
  380. -extern const char * rosidl_typesupport_c__typesupport_identifier;
  381. -
  382. -#if __cplusplus
  383. -}
  384. -#endif
  385. -
  386. -#endif  // ROSIDL_TYPESUPPORT_C__IDENTIFIER_H_
  387. diff --git a/include/rosidl_typesupport_c/message_type_support_dispatch.h b/include/rosidl_typesupport_c/message_type_support_dispatch.h
  388. deleted file mode 100644
  389. index c2c0a8a..0000000
  390. --- a/include/rosidl_typesupport_c/message_type_support_dispatch.h
  391. +++ /dev/null
  392. @@ -1,36 +0,0 @@
  393. -// Copyright 2016 Open Source Robotics Foundation, Inc.
  394. -//
  395. -// Licensed under the Apache License, Version 2.0 (the "License");
  396. -// you may not use this file except in compliance with the License.
  397. -// You may obtain a copy of the License at
  398. -//
  399. -//     http://www.apache.org/licenses/LICENSE-2.0
  400. -//
  401. -// Unless required by applicable law or agreed to in writing, software
  402. -// distributed under the License is distributed on an "AS IS" BASIS,
  403. -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  404. -// See the License for the specific language governing permissions and
  405. -// limitations under the License.
  406. -
  407. -#ifndef ROSIDL_TYPESUPPORT_C__MESSAGE_TYPE_SUPPORT_DISPATCH_H_
  408. -#define ROSIDL_TYPESUPPORT_C__MESSAGE_TYPE_SUPPORT_DISPATCH_H_
  409. -
  410. -#include "rosidl_generator_c/message_type_support_struct.h"
  411. -
  412. -#include "rosidl_typesupport_c/visibility_control.h"
  413. -
  414. -#if __cplusplus
  415. -extern "C"
  416. -{
  417. -#endif
  418. -
  419. -ROSIDL_TYPESUPPORT_C_PUBLIC
  420. -const rosidl_message_type_support_t *
  421. -rosidl_typesupport_c__get_message_typesupport_handle_function(
  422. -  const rosidl_message_type_support_t * handle, const char * identifier);
  423. -
  424. -#if __cplusplus
  425. -}
  426. -#endif
  427. -
  428. -#endif  // ROSIDL_TYPESUPPORT_C__MESSAGE_TYPE_SUPPORT_DISPATCH_H_
  429. diff --git a/include/rosidl_typesupport_c/service_type_support_dispatch.h b/include/rosidl_typesupport_c/service_type_support_dispatch.h
  430. deleted file mode 100644
  431. index c109089..0000000
  432. --- a/include/rosidl_typesupport_c/service_type_support_dispatch.h
  433. +++ /dev/null
  434. @@ -1,36 +0,0 @@
  435. -// Copyright 2016 Open Source Robotics Foundation, Inc.
  436. -//
  437. -// Licensed under the Apache License, Version 2.0 (the "License");
  438. -// you may not use this file except in compliance with the License.
  439. -// You may obtain a copy of the License at
  440. -//
  441. -//     http://www.apache.org/licenses/LICENSE-2.0
  442. -//
  443. -// Unless required by applicable law or agreed to in writing, software
  444. -// distributed under the License is distributed on an "AS IS" BASIS,
  445. -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  446. -// See the License for the specific language governing permissions and
  447. -// limitations under the License.
  448. -
  449. -#ifndef ROSIDL_TYPESUPPORT_C__SERVICE_TYPE_SUPPORT_DISPATCH_H_
  450. -#define ROSIDL_TYPESUPPORT_C__SERVICE_TYPE_SUPPORT_DISPATCH_H_
  451. -
  452. -#include "rosidl_generator_c/service_type_support.h"
  453. -
  454. -#include "rosidl_typesupport_c/visibility_control.h"
  455. -
  456. -#if __cplusplus
  457. -extern "C"
  458. -{
  459. -#endif
  460. -
  461. -ROSIDL_TYPESUPPORT_C_PUBLIC
  462. -const rosidl_service_type_support_t *
  463. -rosidl_typesupport_c__get_service_typesupport_handle_function(
  464. -  const rosidl_service_type_support_t * handle, const char * identifier);
  465. -
  466. -#if __cplusplus
  467. -}
  468. -#endif
  469. -
  470. -#endif  // ROSIDL_TYPESUPPORT_C__SERVICE_TYPE_SUPPORT_DISPATCH_H_
  471. diff --git a/include/rosidl_typesupport_c/type_support_map.h b/include/rosidl_typesupport_c/type_support_map.h
  472. deleted file mode 100644
  473. index df48abb..0000000
  474. --- a/include/rosidl_typesupport_c/type_support_map.h
  475. +++ /dev/null
  476. @@ -1,41 +0,0 @@
  477. -// Copyright 2016 Open Source Robotics Foundation, Inc.
  478. -//
  479. -// Licensed under the Apache License, Version 2.0 (the "License");
  480. -// you may not use this file except in compliance with the License.
  481. -// You may obtain a copy of the License at
  482. -//
  483. -//     http://www.apache.org/licenses/LICENSE-2.0
  484. -//
  485. -// Unless required by applicable law or agreed to in writing, software
  486. -// distributed under the License is distributed on an "AS IS" BASIS,
  487. -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  488. -// See the License for the specific language governing permissions and
  489. -// limitations under the License.
  490. -
  491. -#ifndef ROSIDL_TYPESUPPORT_C__TYPE_SUPPORT_MAP_H_
  492. -#define ROSIDL_TYPESUPPORT_C__TYPE_SUPPORT_MAP_H_
  493. -
  494. -#include <cstddef>
  495. -
  496. -#ifdef __cplusplus
  497. -extern "C"
  498. -{
  499. -#endif
  500. -
  501. -typedef struct type_support_map_t
  502. -{
  503. -  // TODO(dirk-thomas) const should not be defined for the fields
  504. -  // but should be set for the struct when it is being used
  505. -  // same for rosidl_message_type_support_t et al
  506. -  const size_t size;
  507. -  const char * package_name;
  508. -  const char * const * typesupport_identifier;
  509. -  const char * const * symbol_name;
  510. -  void ** data;
  511. -} type_support_map_t;
  512. -
  513. -#ifdef __cplusplus
  514. -}
  515. -#endif
  516. -
  517. -#endif  // ROSIDL_TYPESUPPORT_C__TYPE_SUPPORT_MAP_H_
  518. diff --git a/include/rosidl_typesupport_c/visibility_control.h b/include/rosidl_typesupport_c/visibility_control.h
  519. deleted file mode 100644
  520. index b891953..0000000
  521. --- a/include/rosidl_typesupport_c/visibility_control.h
  522. +++ /dev/null
  523. @@ -1,56 +0,0 @@
  524. -// Copyright 2016 Open Source Robotics Foundation, Inc.
  525. -//
  526. -// Licensed under the Apache License, Version 2.0 (the "License");
  527. -// you may not use this file except in compliance with the License.
  528. -// You may obtain a copy of the License at
  529. -//
  530. -//     http://www.apache.org/licenses/LICENSE-2.0
  531. -//
  532. -// Unless required by applicable law or agreed to in writing, software
  533. -// distributed under the License is distributed on an "AS IS" BASIS,
  534. -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  535. -// See the License for the specific language governing permissions and
  536. -// limitations under the License.
  537. -
  538. -#ifndef ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  539. -#define ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  540. -
  541. -#if __cplusplus
  542. -extern "C"
  543. -{
  544. -#endif
  545. -
  546. -// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
  547. -//     https://gcc.gnu.org/wiki/Visibility
  548. -
  549. -#if defined _WIN32 || defined __CYGWIN__
  550. -  #ifdef __GNUC__
  551. -    #define ROSIDL_TYPESUPPORT_C_EXPORT __attribute__ ((dllexport))
  552. -    #define ROSIDL_TYPESUPPORT_C_IMPORT __attribute__ ((dllimport))
  553. -  #else
  554. -    #define ROSIDL_TYPESUPPORT_C_EXPORT __declspec(dllexport)
  555. -    #define ROSIDL_TYPESUPPORT_C_IMPORT __declspec(dllimport)
  556. -  #endif
  557. -  #ifdef ROSIDL_TYPESUPPORT_C_BUILDING_DLL
  558. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC ROSIDL_TYPESUPPORT_C_EXPORT
  559. -  #else
  560. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC ROSIDL_TYPESUPPORT_C_IMPORT
  561. -  #endif
  562. -  #define ROSIDL_TYPESUPPORT_C_LOCAL
  563. -#else
  564. -  #define ROSIDL_TYPESUPPORT_C_EXPORT __attribute__ ((visibility("default")))
  565. -  #define ROSIDL_TYPESUPPORT_C_IMPORT
  566. -  #if __GNUC__ >= 4
  567. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC __attribute__ ((visibility("default")))
  568. -    #define ROSIDL_TYPESUPPORT_C_LOCAL  __attribute__ ((visibility("hidden")))
  569. -  #else
  570. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC
  571. -    #define ROSIDL_TYPESUPPORT_C_LOCAL
  572. -  #endif
  573. -#endif
  574. -
  575. -#if __cplusplus
  576. -}
  577. -#endif
  578. -
  579. -#endif  // ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  580. diff --git a/include/rosidl_typesupport_common/identifier.h b/include/rosidl_typesupport_common/identifier.h
  581. new file mode 100644
  582. index 0000000..fb7e2a8
  583. --- /dev/null
  584. +++ b/include/rosidl_typesupport_common/identifier.h
  585. @@ -0,0 +1,41 @@
  586. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  587. +//
  588. +// Licensed under the Apache License, Version 2.0 (the "License");
  589. +// you may not use this file except in compliance with the License.
  590. +// You may obtain a copy of the License at
  591. +//
  592. +//     http://www.apache.org/licenses/LICENSE-2.0
  593. +//
  594. +// Unless required by applicable law or agreed to in writing, software
  595. +// distributed under the License is distributed on an "AS IS" BASIS,
  596. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  597. +// See the License for the specific language governing permissions and
  598. +// limitations under the License.
  599. +
  600. +#ifndef ROSIDL_TYPESUPPORT_COMMON__IDENTIFIER_H_
  601. +#define ROSIDL_TYPESUPPORT_COMMON__IDENTIFIER_H_
  602. +
  603. +#include <rosidl_typesupport_common/namespace.h>
  604. +#include <rosidl_typesupport_common/visibility_control.h>
  605. +
  606. +#ifdef ROSIDL_TYPESUPPORT_COMMON_C
  607. +
  608. +NS_BEGIN
  609. +
  610. +ROSIDL_TYPESUPPORT_COMMON_PUBLIC
  611. +extern const char * NS_ROSIDL_TYPESUPPORT(typesupport_identifier);
  612. +
  613. +NS_END
  614. +
  615. +#else
  616. +
  617. +NS_BEGIN
  618. +
  619. +ROSIDL_TYPESUPPORT_COMMON_IMPORT
  620. +extern const char * typesupport_identifier;
  621. +
  622. +NS_END
  623. +
  624. +#endif  // ROSIDL_TYPESUPPORT_COMMON_C
  625. +
  626. +#endif  // ROSIDL_TYPESUPPORT_COMMON__IDENTIFIER_H_
  627. diff --git a/include/rosidl_typesupport_common/message_type_support_dispatch.h b/include/rosidl_typesupport_common/message_type_support_dispatch.h
  628. new file mode 100644
  629. index 0000000..93b8026
  630. --- /dev/null
  631. +++ b/include/rosidl_typesupport_common/message_type_support_dispatch.h
  632. @@ -0,0 +1,36 @@
  633. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  634. +//
  635. +// Licensed under the Apache License, Version 2.0 (the "License");
  636. +// you may not use this file except in compliance with the License.
  637. +// You may obtain a copy of the License at
  638. +//
  639. +//     http://www.apache.org/licenses/LICENSE-2.0
  640. +//
  641. +// Unless required by applicable law or agreed to in writing, software
  642. +// distributed under the License is distributed on an "AS IS" BASIS,
  643. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  644. +// See the License for the specific language governing permissions and
  645. +// limitations under the License.
  646. +
  647. +#ifndef ROSIDL_TYPESUPPORT_COMMON__MESSAGE_TYPE_SUPPORT_DISPATCH_H_
  648. +#define ROSIDL_TYPESUPPORT_COMMON__MESSAGE_TYPE_SUPPORT_DISPATCH_H_
  649. +
  650. +#include "rosidl_generator_c/message_type_support_struct.h"
  651. +
  652. +#include <rosidl_typesupport_common/namespace.h>
  653. +#include <rosidl_typesupport_common/visibility_control.h>
  654. +
  655. +NS_BEGIN
  656. +
  657. +ROSIDL_TYPESUPPORT_COMMON_PUBLIC
  658. +const rosidl_message_type_support_t *
  659. +#if ROSIDL_TYPESUPPORT_COMMON_C
  660. +NS_ROSIDL_TYPESUPPORT(get_message_typesupport_handle_function)(
  661. +#else
  662. +                      get_message_typesupport_handle_function (
  663. +#endif
  664. +  const rosidl_message_type_support_t * handle, const char * identifier);
  665. +
  666. +NS_END
  667. +
  668. +#endif  // ROSIDL_TYPESUPPORT_COMMON__MESSAGE_TYPE_SUPPORT_DISPATCH_H_
  669. diff --git a/include/rosidl_typesupport_common/namespace.h b/include/rosidl_typesupport_common/namespace.h
  670. new file mode 100644
  671. index 0000000..ae6dad1
  672. --- /dev/null
  673. +++ b/include/rosidl_typesupport_common/namespace.h
  674. @@ -0,0 +1,45 @@
  675. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  676. +//
  677. +// Licensed under the Apache License, Version 2.0 (the "License");
  678. +// you may not use this file except in compliance with the License.
  679. +// You may obtain a copy of the License at
  680. +//
  681. +//     http://www.apache.org/licenses/LICENSE-2.0
  682. +//
  683. +// Unless required by applicable law or agreed to in writing, software
  684. +// distributed under the License is distributed on an "AS IS" BASIS,
  685. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  686. +// See the License for the specific language governing permissions and
  687. +// limitations under the License.
  688. +
  689. +#ifndef ROSIDL_TYPESUPPORT_COMMON__NAMESPACE_H_
  690. +#define ROSIDL_TYPESUPPORT_COMMON__NAMESPACE_H_
  691. +
  692. +#if __cplusplus
  693. +namespace rosidl_typesupport_common {}
  694. +#endif
  695. +
  696. +#define _ADD_C_NAMESPACE_(namespace, name)   namespace ## __ ## name
  697. +#define _ADD_CPP_NAMESPACE_(namespace, name) namespace :: name
  698. +
  699. +#define NS_ROSIDL_TYPESUPPORT_C(name)   _ADD_C_NAMESPACE_  (rosidl_typesupport_common, name)
  700. +#define NS_ROSIDL_TYPESUPPORT_CPP(name) _ADD_CPP_NAMESPACE_(rosidl_typesupport_common, name)
  701. +
  702. +#if defined (ROSIDL_TYPESUPPORT_COMMON_CPP)
  703. +  #define NS_ROSIDL_TYPESUPPORT(name) NS_ROSIDL_TYPESUPPORT_CPP(name)
  704. +  #define ROSIDL_TYPESUPPORT_STRING "rosidl_typesupport_cpp"
  705. +  #define NS_BEGIN namespace rosidl_typesupport_common {
  706. +  #define NS_END } // namespace rosidl_typesupport_common
  707. +#elif defined (ROSIDL_TYPESUPPORT_COMMON_C)
  708. +  #define NS_ROSIDL_TYPESUPPORT(name) NS_ROSIDL_TYPESUPPORT_C(name)
  709. +  #define ROSIDL_TYPESUPPORT_STRING "rosidl_typesupport_c"
  710. +  #if __cplusplus
  711. +    #define NS_BEGIN extern "C" {
  712. +    #define NS_END }  // extern "C"
  713. +  #else
  714. +    #define NS_BEGIN
  715. +    #define NS_END
  716. +  #endif
  717. +#endif
  718. +
  719. +#endif  // ROSIDL_TYPESUPPORT_COMMON__NAMESPACE_H_
  720. diff --git a/include/rosidl_typesupport_common/service_type_support_dispatch.h b/include/rosidl_typesupport_common/service_type_support_dispatch.h
  721. new file mode 100644
  722. index 0000000..396746c
  723. --- /dev/null
  724. +++ b/include/rosidl_typesupport_common/service_type_support_dispatch.h
  725. @@ -0,0 +1,36 @@
  726. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  727. +//
  728. +// Licensed under the Apache License, Version 2.0 (the "License");
  729. +// you may not use this file except in compliance with the License.
  730. +// You may obtain a copy of the License at
  731. +//
  732. +//     http://www.apache.org/licenses/LICENSE-2.0
  733. +//
  734. +// Unless required by applicable law or agreed to in writing, software
  735. +// distributed under the License is distributed on an "AS IS" BASIS,
  736. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  737. +// See the License for the specific language governing permissions and
  738. +// limitations under the License.
  739. +
  740. +#ifndef ROSIDL_TYPESUPPORT_COMMON__SERVICE_TYPE_SUPPORT_DISPATCH_H_
  741. +#define ROSIDL_TYPESUPPORT_COMMON__SERVICE_TYPE_SUPPORT_DISPATCH_H_
  742. +
  743. +#include "rosidl_generator_c/service_type_support.h"
  744. +
  745. +#include <rosidl_typesupport_common/namespace.h>
  746. +#include <rosidl_typesupport_common/visibility_control.h>
  747. +
  748. +NS_BEGIN
  749. +
  750. +ROSIDL_TYPESUPPORT_COMMON_PUBLIC
  751. +const rosidl_service_type_support_t *
  752. +#if ROSIDL_TYPESUPPORT_COMMON_C
  753. +NS_ROSIDL_TYPESUPPORT(get_service_typesupport_handle_function)(
  754. +#else
  755. +                      get_service_typesupport_handle_function (
  756. +#endif
  757. +  const rosidl_service_type_support_t * handle, const char * identifier);
  758. +
  759. +NS_END
  760. +
  761. +#endif  // ROSIDL_TYPESUPPORT_COMMON__SERVICE_TYPE_SUPPORT_DISPATCH_H_
  762. diff --git a/include/rosidl_typesupport_common/type_support_map.h b/include/rosidl_typesupport_common/type_support_map.h
  763. new file mode 100644
  764. index 0000000..e1d4d16
  765. --- /dev/null
  766. +++ b/include/rosidl_typesupport_common/type_support_map.h
  767. @@ -0,0 +1,41 @@
  768. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  769. +//
  770. +// Licensed under the Apache License, Version 2.0 (the "License");
  771. +// you may not use this file except in compliance with the License.
  772. +// You may obtain a copy of the License at
  773. +//
  774. +//     http://www.apache.org/licenses/LICENSE-2.0
  775. +//
  776. +// Unless required by applicable law or agreed to in writing, software
  777. +// distributed under the License is distributed on an "AS IS" BASIS,
  778. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  779. +// See the License for the specific language governing permissions and
  780. +// limitations under the License.
  781. +
  782. +#ifndef ROSIDL_TYPESUPPORT_COMMON__TYPE_SUPPORT_MAP_H_
  783. +#define ROSIDL_TYPESUPPORT_COMMON__TYPE_SUPPORT_MAP_H_
  784. +
  785. +#include <cstddef>
  786. +
  787. +#ifdef __cplusplus
  788. +extern "C"
  789. +{
  790. +#endif
  791. +
  792. +typedef struct type_support_map_t
  793. +{
  794. +  // TODO(dirk-thomas) const should not be defined for the fields
  795. +  // but should be set for the struct when it is being used
  796. +  // same for rosidl_message_type_support_t et al
  797. +  const size_t size;
  798. +  const char * package_name;
  799. +  const char * const * typesupport_identifier;
  800. +  const char * const * symbol_name;
  801. +  void ** data;
  802. +} type_support_map_t;
  803. +
  804. +#ifdef __cplusplus
  805. +}
  806. +#endif
  807. +
  808. +#endif  // ROSIDL_TYPESUPPORT_COMMON__TYPE_SUPPORT_MAP_H_
  809. diff --git a/include/rosidl_typesupport_common/visibility_control.h b/include/rosidl_typesupport_common/visibility_control.h
  810. new file mode 100644
  811. index 0000000..b253f93
  812. --- /dev/null
  813. +++ b/include/rosidl_typesupport_common/visibility_control.h
  814. @@ -0,0 +1,56 @@
  815. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  816. +//
  817. +// Licensed under the Apache License, Version 2.0 (the "License");
  818. +// you may not use this file except in compliance with the License.
  819. +// You may obtain a copy of the License at
  820. +//
  821. +//     http://www.apache.org/licenses/LICENSE-2.0
  822. +//
  823. +// Unless required by applicable law or agreed to in writing, software
  824. +// distributed under the License is distributed on an "AS IS" BASIS,
  825. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  826. +// See the License for the specific language governing permissions and
  827. +// limitations under the License.
  828. +
  829. +#ifndef ROSIDL_TYPESUPPORT_COMMON__VISIBILITY_CONTROL_H_
  830. +#define ROSIDL_TYPESUPPORT_COMMON__VISIBILITY_CONTROL_H_
  831. +
  832. +#if __cplusplus
  833. +extern "C"
  834. +{
  835. +#endif
  836. +
  837. +// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
  838. +//     https://gcc.gnu.org/wiki/Visibility
  839. +
  840. +#if defined _WIN32 || defined __CYGWIN__
  841. +  #ifdef __GNUC__
  842. +    #define ROSIDL_TYPESUPPORT_COMMON_EXPORT __attribute__ ((dllexport))
  843. +    #define ROSIDL_TYPESUPPORT_COMMON_IMPORT __attribute__ ((dllimport))
  844. +  #else
  845. +    #define ROSIDL_TYPESUPPORT_COMMON_EXPORT __declspec(dllexport)
  846. +    #define ROSIDL_TYPESUPPORT_COMMON_IMPORT __declspec(dllimport)
  847. +  #endif
  848. +  #ifdef ROSIDL_TYPESUPPORT_COMMON_BUILDING_DLL
  849. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC ROSIDL_TYPESUPPORT_COMMON_EXPORT
  850. +  #else
  851. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC ROSIDL_TYPESUPPORT_COMMON_IMPORT
  852. +  #endif
  853. +  #define ROSIDL_TYPESUPPORT_COMMON_LOCAL
  854. +#else
  855. +  #define ROSIDL_TYPESUPPORT_COMMON_EXPORT __attribute__ ((visibility("default")))
  856. +  #define ROSIDL_TYPESUPPORT_COMMON_IMPORT
  857. +  #if __GNUC__ >= 4
  858. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC __attribute__ ((visibility("default")))
  859. +    #define ROSIDL_TYPESUPPORT_COMMON_LOCAL  __attribute__ ((visibility("hidden")))
  860. +  #else
  861. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC
  862. +    #define ROSIDL_TYPESUPPORT_COMMON_LOCAL
  863. +  #endif
  864. +#endif
  865. +
  866. +#if __cplusplus
  867. +}
  868. +#endif
  869. +
  870. +#endif  // ROSIDL_TYPESUPPORT_COMMON__VISIBILITY_CONTROL_H_
  871. diff --git a/package.xml b/package.xml
  872. index c361c8c..8e36457 100644
  873. --- a/package.xml
  874. +++ b/package.xml
  875. @@ -1,9 +1,9 @@
  876.  <?xml version="1.0"?>
  877.  <?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
  878.  <package format="2">
  879. -  <name>rosidl_typesupport_c</name>
  880. +  <name>rosidl_typesupport_common</name>
  881.    <version>0.0.3</version>
  882. -  <description>Generate the type support for C messages.</description>
  883. +  <description>Generate the type support for C and C++ messages.</description>
  884.    <maintainer email="[email protected]">Dirk Thomas</maintainer>
  885.    <license>Apache License 2.0</license>
  886.  
  887. diff --git a/resource/msg__type_support.cpp.em b/resource/msg__type_support.cpp.em
  888. index 41e5316..0a93857 100644
  889. --- a/resource/msg__type_support.cpp.em
  890. +++ b/resource/msg__type_support.cpp.em
  891. @@ -1,4 +1,4 @@
  892. -// generated from rosidl_typesupport_c/resource/msg__type_support.cpp.em
  893. +// generated from rosidl_typesupport_common/resource/msg__type_support.cpp.em
  894.  // generated code does not contain a copyright notice
  895.  
  896.  @#######################################################################
  897. @@ -19,15 +19,15 @@
  898.  
  899.  #include "rosidl_generator_c/message_type_support_struct.h"
  900.  
  901. -#include "@(spec.base_type.pkg_name)/msg/rosidl_typesupport_c__visibility_control.h"
  902. +#include "@(spec.base_type.pkg_name)/msg/rosidl_typesupport_common__visibility_control.h"
  903.  #include "@(spec.base_type.pkg_name)/@(subfolder)/@(get_header_filename_from_msg_name(spec.base_type.type))__struct.h"
  904.  
  905.  @[if len(type_supports) != 1]@
  906. -#include "rosidl_typesupport_c/identifier.h"
  907. -#include "rosidl_typesupport_c/message_type_support_dispatch.h"
  908. -#include "rosidl_typesupport_c/type_support_map.h"
  909. +#include "rosidl_typesupport_common/identifier.h"
  910. +#include "rosidl_typesupport_common/message_type_support_dispatch.h"
  911. +#include "rosidl_typesupport_common/type_support_map.h"
  912.  @[end if]@
  913. -#include "rosidl_typesupport_c/visibility_control.h"
  914. +#include "rosidl_typesupport_common/visibility_control.h"
  915.  @[if len(type_supports) != 1]@
  916.  #include "rosidl_typesupport_interface/macros.h"
  917.  @[end if]@
  918. @@ -39,7 +39,7 @@ namespace @(spec.base_type.pkg_name)
  919.  namespace @(subfolder)
  920.  {
  921.  
  922. -namespace rosidl_typesupport_c
  923. +namespace rosidl_typesupport_common
  924.  {
  925.  
  926.  typedef struct _type_support_ids_t
  927. @@ -99,7 +99,7 @@ static const rosidl_message_type_support_t @(spec.base_type.type)_message_type_s
  928.    rosidl_typesupport_c__get_message_typesupport_handle_function,
  929.  };
  930.  
  931. -}  // namespace rosidl_typesupport_c
  932. +}  // namespace rosidl_typesupport_common
  933.  
  934.  }  // namespace @(subfolder)
  935.  
  936. @@ -114,11 +114,11 @@ extern "C"
  937.  {
  938.  #endif
  939.  
  940. -ROSIDL_TYPESUPPORT_C_EXPORT_@(spec.base_type.pkg_name)
  941. +ROSIDL_TYPESUPPORT_COMMON_EXPORT_@(spec.base_type.pkg_name)
  942.  const rosidl_message_type_support_t *
  943. -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_c, @(spec.base_type.pkg_name), @(subfolder), @(spec.base_type.type))() {
  944. +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_common, @(spec.base_type.pkg_name), @(subfolder), @(spec.base_type.type))() {
  945.  @[if len(type_supports) != 1]@
  946. -  return &::@(spec.base_type.pkg_name)::@(subfolder)::rosidl_typesupport_c::@(spec.base_type.type)_message_type_support_handle;
  947. +  return &::@(spec.base_type.pkg_name)::@(subfolder)::rosidl_typesupport_common::@(spec.base_type.type)_message_type_support_handle;
  948.  @[else]@
  949.    return ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(list(type_supports)[0]), @(spec.base_type.pkg_name), @(subfolder), @(spec.base_type.type))();
  950.  @[end if]@
  951. diff --git a/resource/rosidl_typesupport_c__visibility_control.h.in b/resource/rosidl_typesupport_c__visibility_control.h.in
  952. deleted file mode 100644
  953. index 3da5ac5..0000000
  954. --- a/resource/rosidl_typesupport_c__visibility_control.h.in
  955. +++ /dev/null
  956. @@ -1,43 +0,0 @@
  957. -// generated from
  958. -// rosidl_typesupport_c/resource/rosidl_typesupport_c__visibility_control.h.in
  959. -// generated code does not contain a copyright notice
  960. -
  961. -#ifndef @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  962. -#define @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  963. -
  964. -#if __cplusplus
  965. -extern "C"
  966. -{
  967. -#endif
  968. -
  969. -// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
  970. -//     https://gcc.gnu.org/wiki/Visibility
  971. -
  972. -#if defined _WIN32 || defined __CYGWIN__
  973. -  #ifdef __GNUC__
  974. -    #define ROSIDL_TYPESUPPORT_C_EXPORT_@PROJECT_NAME@ __attribute__ ((dllexport))
  975. -    #define ROSIDL_TYPESUPPORT_C_IMPORT_@PROJECT_NAME@ __attribute__ ((dllimport))
  976. -  #else
  977. -    #define ROSIDL_TYPESUPPORT_C_EXPORT_@PROJECT_NAME@ __declspec(dllexport)
  978. -    #define ROSIDL_TYPESUPPORT_C_IMPORT_@PROJECT_NAME@ __declspec(dllimport)
  979. -  #endif
  980. -  #ifdef ROSIDL_TYPESUPPORT_C_BUILDING_DLL_@PROJECT_NAME@
  981. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_C_EXPORT_@PROJECT_NAME@
  982. -  #else
  983. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_C_IMPORT_@PROJECT_NAME@
  984. -  #endif
  985. -#else
  986. -  #define ROSIDL_TYPESUPPORT_C_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default")))
  987. -  #define ROSIDL_TYPESUPPORT_C_IMPORT_@PROJECT_NAME@
  988. -  #if __GNUC__ >= 4
  989. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC_@PROJECT_NAME@ __attribute__ ((visibility("default")))
  990. -  #else
  991. -    #define ROSIDL_TYPESUPPORT_C_PUBLIC_@PROJECT_NAME@
  992. -  #endif
  993. -#endif
  994. -
  995. -#if __cplusplus
  996. -}
  997. -#endif
  998. -
  999. -#endif  // @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  1000. diff --git a/resource/rosidl_typesupport_common__visibility_control.h.in b/resource/rosidl_typesupport_common__visibility_control.h.in
  1001. new file mode 100644
  1002. index 0000000..e577b2f
  1003. --- /dev/null
  1004. +++ b/resource/rosidl_typesupport_common__visibility_control.h.in
  1005. @@ -0,0 +1,45 @@
  1006. +// generated from
  1007. +// rosidl_typesupport_c/resource/rosidl_typesupport_common__visibility_control.h.in
  1008. +// generated code does not contain a copyright notice
  1009. +
  1010. +#ifndef @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_COMMON__VISIBILITY_CONTROL_H_
  1011. +#define @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_COMMON__VISIBILITY_CONTROL_H_
  1012. +
  1013. +#if __cplusplus
  1014. +extern "C"
  1015. +{
  1016. +#endif
  1017. +
  1018. +// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
  1019. +//     https://gcc.gnu.org/wiki/Visibility
  1020. +
  1021. +#if defined _WIN32 || defined __CYGWIN__
  1022. +  #ifdef __GNUC__
  1023. +    #define ROSIDL_TYPESUPPORT_COMMON_EXPORT_@PROJECT_NAME@ __attribute__ ((dllexport))
  1024. +    #define ROSIDL_TYPESUPPORT_COMMON_IMPORT_@PROJECT_NAME@ __attribute__ ((dllimport))
  1025. +  #else
  1026. +    #define ROSIDL_TYPESUPPORT_COMMON_EXPORT_@PROJECT_NAME@ __declspec(dllexport)
  1027. +    #define ROSIDL_TYPESUPPORT_COMMON_IMPORT_@PROJECT_NAME@ __declspec(dllimport)
  1028. +  #endif
  1029. +
  1030. +  #ifdef ROSIDL_TYPESUPPORT_COMMON_BUILDING_DLL_@PROJECT_NAME@
  1031. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_C_EXPORT_@PROJECT_NAME@
  1032. +  #else
  1033. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_C_IMPORT_@PROJECT_NAME@
  1034. +  #endif
  1035. +
  1036. +#else
  1037. +  #define ROSIDL_TYPESUPPORT_COMMON_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default")))
  1038. +  #define ROSIDL_TYPESUPPORT_COMMON_IMPORT_@PROJECT_NAME@
  1039. +  #if __GNUC__ >= 4
  1040. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC_@PROJECT_NAME@ __attribute__ ((visibility("default")))
  1041. +  #else
  1042. +    #define ROSIDL_TYPESUPPORT_COMMON_PUBLIC_@PROJECT_NAME@
  1043. +  #endif
  1044. +#endif
  1045. +
  1046. +#if __cplusplus
  1047. +}
  1048. +#endif
  1049. +
  1050. +#endif  // @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_C__VISIBILITY_CONTROL_H_
  1051. diff --git a/resource/srv__type_support.cpp.em b/resource/srv__type_support.cpp.em
  1052. index c35ec42..05c2349 100644
  1053. --- a/resource/srv__type_support.cpp.em
  1054. +++ b/resource/srv__type_support.cpp.em
  1055. @@ -1,4 +1,4 @@
  1056. -// generated from rosidl_typesupport_c/resource/srv__type_support.cpp.em
  1057. +// generated from rosidl_typesupport_common/resource/srv__type_support.cpp.em
  1058.  // generated code does not contain a copyright notice
  1059.  
  1060.  @#######################################################################
  1061. @@ -16,12 +16,12 @@
  1062.  
  1063.  #include "rosidl_generator_c/service_type_support.h"
  1064.  
  1065. -#include "@(spec.pkg_name)/msg/rosidl_typesupport_c__visibility_control.h"
  1066. +#include "@(spec.pkg_name)/msg/rosidl_typesupport_common__visibility_control.h"
  1067.  
  1068.  @[if len(type_supports) != 1]@
  1069. -#include "rosidl_typesupport_c/identifier.h"
  1070. -#include "rosidl_typesupport_c/service_type_support_dispatch.h"
  1071. -#include "rosidl_typesupport_c/type_support_map.h"
  1072. +#include "rosidl_typesupport_common/identifier.h"
  1073. +#include "rosidl_typesupport_common/service_type_support_dispatch.h"
  1074. +#include "rosidl_typesupport_common/type_support_map.h"
  1075.  @[end if]@
  1076.  #include "rosidl_typesupport_interface/macros.h"
  1077.  
  1078. @@ -32,7 +32,7 @@ namespace @(spec.pkg_name)
  1079.  namespace srv
  1080.  {
  1081.  
  1082. -namespace rosidl_typesupport_c
  1083. +namespace rosidl_typesupport_common
  1084.  {
  1085.  
  1086.  typedef struct _type_support_ids_t
  1087. @@ -87,12 +87,12 @@ static const type_support_map_t _@(spec.srv_name)_service_typesupport_map = {
  1088.  };
  1089.  
  1090.  static const rosidl_service_type_support_t @(spec.srv_name)_service_type_support_handle = {
  1091. -  rosidl_typesupport_c__typesupport_identifier,
  1092. +  rosidl_typesupport_common__typesupport_identifier,
  1093.    reinterpret_cast<const type_support_map_t *>(&_@(spec.srv_name)_service_typesupport_map),
  1094. -  rosidl_typesupport_c__get_service_typesupport_handle_function,
  1095. +  rosidl_typesupport_common__get_service_typesupport_handle_function,
  1096.  };
  1097.  
  1098. -}  // namespace rosidl_typesupport_c
  1099. +}  // namespace rosidl_typesupport_common
  1100.  
  1101.  }  // namespace srv
  1102.  
  1103. @@ -107,11 +107,11 @@ extern "C"
  1104.  {
  1105.  #endif
  1106.  
  1107. -ROSIDL_TYPESUPPORT_C_EXPORT_@(spec.pkg_name)
  1108. +ROSIDL_TYPESUPPORT_COMMON_EXPORT_@(spec.pkg_name)
  1109.  const rosidl_service_type_support_t *
  1110. -ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_c, @(spec.pkg_name), @(spec.srv_name))() {
  1111. +ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_common, @(spec.pkg_name), @(spec.srv_name))() {
  1112.  @[if len(type_supports) != 1]@
  1113. -  return &::@(spec.pkg_name)::srv::rosidl_typesupport_c::@(spec.srv_name)_service_type_support_handle;
  1114. +  return &::@(spec.pkg_name)::srv::rosidl_typesupport_common::@(spec.srv_name)_service_type_support_handle;
  1115.  @[else]@
  1116.    return ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(@(list(type_supports)[0]), @(spec.pkg_name), @(spec.srv_name))();
  1117.  @[end if]@
  1118. diff --git a/rosidl_typesupport_c-extras.cmake.in b/rosidl_typesupport_c-extras.cmake.in
  1119. deleted file mode 100644
  1120. index 45422bb..0000000
  1121. --- a/rosidl_typesupport_c-extras.cmake.in
  1122. +++ /dev/null
  1123. @@ -1,28 +0,0 @@
  1124. -# generated from
  1125. -# rosidl_typesupport_c/rosidl_typesupport_c-extras.cmake.in
  1126. -
  1127. -find_package(ament_cmake_core QUIET REQUIRED)
  1128. -
  1129. -include("${rosidl_typesupport_c_DIR}/get_used_typesupports.cmake")
  1130. -
  1131. -ament_register_extension(
  1132. -  "rosidl_generate_interfaces"
  1133. -  "rosidl_typesupport_c"
  1134. -  "rosidl_typesupport_c_generate_interfaces.cmake")
  1135. -
  1136. -set(rosidl_typesupport_c_SUPPORTS_POCO @Poco_FOUND@)
  1137. -
  1138. -set(rosidl_typesupport_c_BIN
  1139. -  "${rosidl_typesupport_c_DIR}/../../../lib/rosidl_typesupport_c/rosidl_typesupport_c")
  1140. -normalize_path(rosidl_typesupport_c_BIN
  1141. -  "${rosidl_typesupport_c_BIN}")
  1142. -
  1143. -set(rosidl_typesupport_c_GENERATOR_FILES
  1144. -  "${rosidl_typesupport_c_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_c/__init__.py")
  1145. -normalize_path(rosidl_typesupport_c_GENERATOR_FILES
  1146. -  "${rosidl_typesupport_c_GENERATOR_FILES}")
  1147. -
  1148. -set(rosidl_typesupport_c_TEMPLATE_DIR
  1149. -  "${rosidl_typesupport_c_DIR}/../resource")
  1150. -normalize_path(rosidl_typesupport_c_TEMPLATE_DIR
  1151. -  "${rosidl_typesupport_c_TEMPLATE_DIR}")
  1152. diff --git a/rosidl_typesupport_c/__init__.py b/rosidl_typesupport_c/__init__.py
  1153. deleted file mode 100644
  1154. index 63f9333..0000000
  1155. --- a/rosidl_typesupport_c/__init__.py
  1156. +++ /dev/null
  1157. @@ -1,86 +0,0 @@
  1158. -# Copyright 2016 Open Source Robotics Foundation, Inc.
  1159. -#
  1160. -# Licensed under the Apache License, Version 2.0 (the "License");
  1161. -# you may not use this file except in compliance with the License.
  1162. -# You may obtain a copy of the License at
  1163. -#
  1164. -#     http://www.apache.org/licenses/LICENSE-2.0
  1165. -#
  1166. -# Unless required by applicable law or agreed to in writing, software
  1167. -# distributed under the License is distributed on an "AS IS" BASIS,
  1168. -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1169. -# See the License for the specific language governing permissions and
  1170. -# limitations under the License.
  1171. -
  1172. -import os
  1173. -
  1174. -from rosidl_cmake import convert_camel_case_to_lower_case_underscore
  1175. -from rosidl_cmake import expand_template
  1176. -from rosidl_cmake import extract_message_types
  1177. -from rosidl_cmake import get_newest_modification_time
  1178. -from rosidl_cmake import read_generator_arguments
  1179. -from rosidl_parser import parse_message_file
  1180. -from rosidl_parser import parse_service_file
  1181. -from rosidl_parser import validate_field_types
  1182. -
  1183. -
  1184. -def generate_c(generator_arguments_file, type_supports):
  1185. -    args = read_generator_arguments(generator_arguments_file)
  1186. -
  1187. -    template_dir = args['template_dir']
  1188. -    mapping_msgs = {
  1189. -        os.path.join(template_dir, 'msg__type_support.cpp.em'):
  1190. -        '%s__type_support.cpp',
  1191. -    }
  1192. -    mapping_srvs = {
  1193. -        os.path.join(template_dir, 'srv__type_support.cpp.em'):
  1194. -        '%s__type_support.cpp',
  1195. -    }
  1196. -
  1197. -    for template_file in mapping_msgs.keys():
  1198. -        assert os.path.exists(template_file), 'Could not find template: ' + template_file
  1199. -
  1200. -    for template_file in mapping_srvs.keys():
  1201. -        assert os.path.exists(template_file), 'Could not find template: ' + template_file
  1202. -
  1203. -    pkg_name = args['package_name']
  1204. -    known_msg_types = extract_message_types(
  1205. -        pkg_name, args['ros_interface_files'], args.get('ros_interface_dependencies', []))
  1206. -
  1207. -    functions = {
  1208. -        'get_header_filename_from_msg_name': convert_camel_case_to_lower_case_underscore,
  1209. -    }
  1210. -    latest_target_timestamp = get_newest_modification_time(args['target_dependencies'])
  1211. -
  1212. -    for ros_interface_file in args['ros_interface_files']:
  1213. -        extension = os.path.splitext(ros_interface_file)[1]
  1214. -        subfolder = os.path.basename(os.path.dirname(ros_interface_file))
  1215. -        if extension == '.msg':
  1216. -            spec = parse_message_file(pkg_name, ros_interface_file)
  1217. -            validate_field_types(spec, known_msg_types)
  1218. -            for template_file, generated_filename in mapping_msgs.items():
  1219. -                generated_file = os.path.join(
  1220. -                    args['output_dir'], subfolder, generated_filename %
  1221. -                    convert_camel_case_to_lower_case_underscore(spec.base_type.type))
  1222. -
  1223. -                data = {'spec': spec, 'subfolder': subfolder, 'type_supports': type_supports}
  1224. -                data.update(functions)
  1225. -                expand_template(
  1226. -                    template_file, data, generated_file,
  1227. -                    minimum_timestamp=latest_target_timestamp)
  1228. -
  1229. -        elif extension == '.srv':
  1230. -            spec = parse_service_file(pkg_name, ros_interface_file)
  1231. -            validate_field_types(spec, known_msg_types)
  1232. -            for template_file, generated_filename in mapping_srvs.items():
  1233. -                generated_file = os.path.join(
  1234. -                    args['output_dir'], subfolder, generated_filename %
  1235. -                    convert_camel_case_to_lower_case_underscore(spec.srv_name))
  1236. -
  1237. -                data = {'spec': spec, 'type_supports': type_supports}
  1238. -                data.update(functions)
  1239. -                expand_template(
  1240. -                    template_file, data, generated_file,
  1241. -                    minimum_timestamp=latest_target_timestamp)
  1242. -
  1243. -    return 0
  1244. diff --git a/rosidl_typesupport_common/__init__.py b/rosidl_typesupport_common/__init__.py
  1245. new file mode 100644
  1246. index 0000000..24cb5e8
  1247. --- /dev/null
  1248. +++ b/rosidl_typesupport_common/__init__.py
  1249. @@ -0,0 +1,86 @@
  1250. +# Copyright 2016 Open Source Robotics Foundation, Inc.
  1251. +#
  1252. +# Licensed under the Apache License, Version 2.0 (the "License");
  1253. +# you may not use this file except in compliance with the License.
  1254. +# You may obtain a copy of the License at
  1255. +#
  1256. +#     http://www.apache.org/licenses/LICENSE-2.0
  1257. +#
  1258. +# Unless required by applicable law or agreed to in writing, software
  1259. +# distributed under the License is distributed on an "AS IS" BASIS,
  1260. +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1261. +# See the License for the specific language governing permissions and
  1262. +# limitations under the License.
  1263. +
  1264. +import os
  1265. +
  1266. +from rosidl_cmake import convert_camel_case_to_lower_case_underscore
  1267. +from rosidl_cmake import expand_template
  1268. +from rosidl_cmake import extract_message_types
  1269. +from rosidl_cmake import get_newest_modification_time
  1270. +from rosidl_cmake import read_generator_arguments
  1271. +from rosidl_parser import parse_message_file
  1272. +from rosidl_parser import parse_service_file
  1273. +from rosidl_parser import validate_field_types
  1274. +
  1275. +
  1276. +def generate_common(generator_arguments_file, type_supports):
  1277. +    args = read_generator_arguments(generator_arguments_file)
  1278. +
  1279. +    template_dir = args['template_dir']
  1280. +    mapping_msgs = {
  1281. +        os.path.join(template_dir, 'msg__type_support.cpp.em'):
  1282. +        '%s__type_support.cpp',
  1283. +    }
  1284. +    mapping_srvs = {
  1285. +        os.path.join(template_dir, 'srv__type_support.cpp.em'):
  1286. +        '%s__type_support.cpp',
  1287. +    }
  1288. +
  1289. +    for template_file in mapping_msgs.keys():
  1290. +        assert os.path.exists(template_file), 'Could not find template: ' + template_file
  1291. +
  1292. +    for template_file in mapping_srvs.keys():
  1293. +        assert os.path.exists(template_file), 'Could not find template: ' + template_file
  1294. +
  1295. +    pkg_name = args['package_name']
  1296. +    known_msg_types = extract_message_types(
  1297. +        pkg_name, args['ros_interface_files'], args.get('ros_interface_dependencies', []))
  1298. +
  1299. +    functions = {
  1300. +        'get_header_filename_from_msg_name': convert_camel_case_to_lower_case_underscore,
  1301. +    }
  1302. +    latest_target_timestamp = get_newest_modification_time(args['target_dependencies'])
  1303. +
  1304. +    for ros_interface_file in args['ros_interface_files']:
  1305. +        extension = os.path.splitext(ros_interface_file)[1]
  1306. +        subfolder = os.path.basename(os.path.dirname(ros_interface_file))
  1307. +        if extension == '.msg':
  1308. +            spec = parse_message_file(pkg_name, ros_interface_file)
  1309. +            validate_field_types(spec, known_msg_types)
  1310. +            for template_file, generated_filename in mapping_msgs.items():
  1311. +                generated_file = os.path.join(
  1312. +                    args['output_dir'], subfolder, generated_filename %
  1313. +                    convert_camel_case_to_lower_case_underscore(spec.base_type.type))
  1314. +
  1315. +                data = {'spec': spec, 'subfolder': subfolder, 'type_supports': type_supports}
  1316. +                data.update(functions)
  1317. +                expand_template(
  1318. +                    template_file, data, generated_file,
  1319. +                    minimum_timestamp=latest_target_timestamp)
  1320. +
  1321. +        elif extension == '.srv':
  1322. +            spec = parse_service_file(pkg_name, ros_interface_file)
  1323. +            validate_field_types(spec, known_msg_types)
  1324. +            for template_file, generated_filename in mapping_srvs.items():
  1325. +                generated_file = os.path.join(
  1326. +                    args['output_dir'], subfolder, generated_filename %
  1327. +                    convert_camel_case_to_lower_case_underscore(spec.srv_name))
  1328. +
  1329. +                data = {'spec': spec, 'type_supports': type_supports}
  1330. +                data.update(functions)
  1331. +                expand_template(
  1332. +                    template_file, data, generated_file,
  1333. +                    minimum_timestamp=latest_target_timestamp)
  1334. +
  1335. +    return 0
  1336. diff --git a/rosidl_typesupport_common_c-extras.cmake.in b/rosidl_typesupport_common_c-extras.cmake.in
  1337. new file mode 100644
  1338. index 0000000..f17429d
  1339. --- /dev/null
  1340. +++ b/rosidl_typesupport_common_c-extras.cmake.in
  1341. @@ -0,0 +1,28 @@
  1342. +# generated from
  1343. +# rosidl_typesupport_c/rosidl_typesupport_c-extras.cmake.in
  1344. +
  1345. +find_package(ament_cmake_core QUIET REQUIRED)
  1346. +
  1347. +include("${rosidl_typesupport_common_DIR}/get_used_typesupports.cmake")
  1348. +
  1349. +ament_register_extension(
  1350. +  "rosidl_generate_interfaces"
  1351. +  "rosidl_typesupport_c"
  1352. +  "rosidl_typesupport_c_generate_interfaces.cmake")
  1353. +
  1354. +set(rosidl_typesupport_c_SUPPORTS_POCO @Poco_FOUND@)
  1355. +
  1356. +set(rosidl_typesupport_c_BIN
  1357. +  "${rosidl_typesupport_c_DIR}/../../../lib/rosidl_typesupport_c/rosidl_typesupport_c")
  1358. +normalize_path(rosidl_typesupport_c_BIN
  1359. +  "${rosidl_typesupport_c_BIN}")
  1360. +
  1361. +set(rosidl_typesupport_c_GENERATOR_FILES
  1362. +  "${rosidl_typesupport_c_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_c/__init__.py")
  1363. +normalize_path(rosidl_typesupport_c_GENERATOR_FILES
  1364. +  "${rosidl_typesupport_c_GENERATOR_FILES}")
  1365. +
  1366. +set(rosidl_typesupport_c_TEMPLATE_DIR
  1367. +  "${rosidl_typesupport_c_DIR}/../resource")
  1368. +normalize_path(rosidl_typesupport_c_TEMPLATE_DIR
  1369. +  "${rosidl_typesupport_c_TEMPLATE_DIR}")
  1370. diff --git a/rosidl_typesupport_common_cpp-extras.cmake.in b/rosidl_typesupport_common_cpp-extras.cmake.in
  1371. new file mode 100644
  1372. index 0000000..790810e
  1373. --- /dev/null
  1374. +++ b/rosidl_typesupport_common_cpp-extras.cmake.in
  1375. @@ -0,0 +1,26 @@
  1376. +# generated from
  1377. +# rosidl_typesupport_cpp/rosidl_typesupport_cpp-extras.cmake.in
  1378. +
  1379. +find_package(ament_cmake_core QUIET REQUIRED)
  1380. +
  1381. +ament_register_extension(
  1382. +  "rosidl_generate_interfaces"
  1383. +  "rosidl_typesupport_cpp"
  1384. +  "rosidl_typesupport_cpp_generate_interfaces.cmake")
  1385. +
  1386. +set(rosidl_typesupport_cpp_SUPPORTS_POCO @Poco_FOUND@)
  1387. +
  1388. +set(rosidl_typesupport_cpp_BIN
  1389. +  "${rosidl_typesupport_cpp_DIR}/../../../lib/rosidl_typesupport_cpp/rosidl_typesupport_cpp")
  1390. +normalize_path(rosidl_typesupport_cpp_BIN
  1391. +  "${rosidl_typesupport_cpp_BIN}")
  1392. +
  1393. +set(rosidl_typesupport_cpp_GENERATOR_FILES
  1394. +  "${rosidl_typesupport_cpp_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_cpp/__init__.py")
  1395. +normalize_path(rosidl_typesupport_cpp_GENERATOR_FILES
  1396. +  "${rosidl_typesupport_cpp_GENERATOR_FILES}")
  1397. +
  1398. +set(rosidl_typesupport_cpp_TEMPLATE_DIR
  1399. +  "${rosidl_typesupport_cpp_DIR}/../resource")
  1400. +normalize_path(rosidl_typesupport_cpp_TEMPLATE_DIR
  1401. +  "${rosidl_typesupport_cpp_TEMPLATE_DIR}")
  1402. diff --git a/src/identifier.c b/src/identifier.c
  1403. deleted file mode 100644
  1404. index d982445..0000000
  1405. --- a/src/identifier.c
  1406. +++ /dev/null
  1407. @@ -1,18 +0,0 @@
  1408. -// Copyright 2016 Open Source Robotics Foundation, Inc.
  1409. -//
  1410. -// Licensed under the Apache License, Version 2.0 (the "License");
  1411. -// you may not use this file except in compliance with the License.
  1412. -// You may obtain a copy of the License at
  1413. -//
  1414. -//     http://www.apache.org/licenses/LICENSE-2.0
  1415. -//
  1416. -// Unless required by applicable law or agreed to in writing, software
  1417. -// distributed under the License is distributed on an "AS IS" BASIS,
  1418. -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1419. -// See the License for the specific language governing permissions and
  1420. -// limitations under the License.
  1421. -
  1422. -#include <rosidl_typesupport_c/visibility_control.h>
  1423. -
  1424. -ROSIDL_TYPESUPPORT_C_EXPORT
  1425. -const char * rosidl_typesupport_c__typesupport_identifier = "rosidl_typesupport_c";
  1426. diff --git a/src/identifier.cpp b/src/identifier.cpp
  1427. new file mode 100644
  1428. index 0000000..123f0eb
  1429. --- /dev/null
  1430. +++ b/src/identifier.cpp
  1431. @@ -0,0 +1,20 @@
  1432. +// Copyright 2016 Open Source Robotics Foundation, Inc.
  1433. +//
  1434. +// Licensed under the Apache License, Version 2.0 (the "License");
  1435. +// you may not use this file except in compliance with the License.
  1436. +// You may obtain a copy of the License at
  1437. +//
  1438. +//     http://www.apache.org/licenses/LICENSE-2.0
  1439. +//
  1440. +// Unless required by applicable law or agreed to in writing, software
  1441. +// distributed under the License is distributed on an "AS IS" BASIS,
  1442. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1443. +// See the License for the specific language governing permissions and
  1444. +// limitations under the License.
  1445. +
  1446. +#include <rosidl_typesupport_common/namespace.h>
  1447. +#include <rosidl_typesupport_common/visibility_control.h>
  1448. +#include <rosidl_typesupport_common/identifier.h>
  1449. +
  1450. +ROSIDL_TYPESUPPORT_COMMON_EXPORT
  1451. +const char * NS_ROSIDL_TYPESUPPORT(typesupport_identifier) = ROSIDL_TYPESUPPORT_STRING;
  1452. diff --git a/src/message_type_support_dispatch.cpp b/src/message_type_support_dispatch.cpp
  1453. index 4130c8f..2ee8e99 100644
  1454. --- a/src/message_type_support_dispatch.cpp
  1455. +++ b/src/message_type_support_dispatch.cpp
  1456. @@ -12,23 +12,24 @@
  1457.  // See the License for the specific language governing permissions and
  1458.  // limitations under the License.
  1459.  
  1460. -#include "rosidl_typesupport_c/message_type_support_dispatch.h"
  1461. +#include <rosidl_typesupport_common/namespace.h>
  1462. +#include <rosidl_typesupport_common/message_type_support_dispatch.h>
  1463.  
  1464.  #include "type_support_dispatch.hpp"
  1465.  
  1466. -#if __cplusplus
  1467. -extern "C"
  1468. -{
  1469. -#endif
  1470. +NS_BEGIN
  1471.  
  1472. +#if defined (ROSIDL_TYPESUPPORT_COMMON_C)
  1473.  const rosidl_message_type_support_t *
  1474. -rosidl_typesupport_c__get_message_typesupport_handle_function(
  1475. +NS_ROSIDL_TYPESUPPORT(get_message_typesupport_handle_function)(
  1476. +  const rosidl_message_type_support_t * handle, const char * identifier)
  1477. +#elif defined (ROSIDL_TYPESUPPORT_COMMON_CPP)
  1478. +const rosidl_message_type_support_t * get_message_typesupport_handle_function(
  1479.    const rosidl_message_type_support_t * handle, const char * identifier)
  1480. +#endif
  1481.  {
  1482. -  return rosidl_typesupport_c::get_typesupport_handle_function<
  1483. +  return rosidl_typesupport_common::get_typesupport_handle_function<
  1484.      rosidl_message_type_support_t>(handle, identifier);
  1485.  }
  1486.  
  1487. -#if __cplusplus
  1488. -}
  1489. -#endif
  1490. +NS_END
  1491. diff --git a/src/service_type_support_dispatch.cpp b/src/service_type_support_dispatch.cpp
  1492. index 8188425..c585074 100644
  1493. --- a/src/service_type_support_dispatch.cpp
  1494. +++ b/src/service_type_support_dispatch.cpp
  1495. @@ -12,23 +12,24 @@
  1496.  // See the License for the specific language governing permissions and
  1497.  // limitations under the License.
  1498.  
  1499. -#include "rosidl_typesupport_c/service_type_support_dispatch.h"
  1500. +#include <rosidl_typesupport_common/namespace.h>
  1501. +#include <rosidl_typesupport_common/service_type_support_dispatch.h>
  1502.  
  1503.  #include "type_support_dispatch.hpp"
  1504.  
  1505. -#if __cplusplus
  1506. -extern "C"
  1507. -{
  1508. -#endif
  1509. +NS_BEGIN
  1510.  
  1511. +#if defined (ROSIDL_TYPESUPPORT_COMMON_C)
  1512.  const rosidl_service_type_support_t *
  1513. -rosidl_typesupport_c__get_service_typesupport_handle_function(
  1514. +NS_ROSIDL_TYPESUPPORT(get_service_typesupport_handle_function)(
  1515. +  const rosidl_service_type_support_t * handle, const char * identifier)
  1516. +#elif defined (ROSIDL_TYPESUPPORT_COMMON_CPP)
  1517. +const rosidl_service_type_support_t * get_service_typesupport_handle_function(
  1518.    const rosidl_service_type_support_t * handle, const char * identifier)
  1519. +#endif
  1520.  {
  1521. -  return rosidl_typesupport_c::get_typesupport_handle_function<
  1522. +  return rosidl_typesupport_common::get_typesupport_handle_function<
  1523.      rosidl_service_type_support_t>(handle, identifier);
  1524.  }
  1525.  
  1526. -#if __cplusplus
  1527. -}
  1528. -#endif
  1529. +NS_END
  1530. diff --git a/src/type_support_dispatch.cpp b/src/type_support_dispatch.cpp
  1531. index 055aba0..d9d0b26 100644
  1532. --- a/src/type_support_dispatch.cpp
  1533. +++ b/src/type_support_dispatch.cpp
  1534. @@ -20,7 +20,7 @@
  1535.  #include <fstream>
  1536.  #include <sstream>
  1537.  
  1538. -namespace rosidl_typesupport_c
  1539. +namespace rosidl_typesupport_common
  1540.  {
  1541.  
  1542.  std::string find_library_path(const std::string & library_name)
  1543. @@ -99,4 +99,4 @@ bool is_file_exist(const char * filename)
  1544.    return h.good();
  1545.  }
  1546.  
  1547. -}  // namespace rosidl_typesupport_c
  1548. +}  // namespace rosidl_typesupport_common
  1549. diff --git a/src/type_support_dispatch.hpp b/src/type_support_dispatch.hpp
  1550. index f1f168e..07c7e1d 100644
  1551. --- a/src/type_support_dispatch.hpp
  1552. +++ b/src/type_support_dispatch.hpp
  1553. @@ -22,14 +22,14 @@
  1554.  #include <list>
  1555.  #include <string>
  1556.  
  1557. -#ifdef ROSIDL_TYPESUPPORT_C_USE_POCO
  1558. +#ifdef ROSIDL_TYPESUPPORT_COMMON_USE_POCO
  1559.  #include "Poco/SharedLibrary.h"
  1560.  #endif
  1561.  
  1562. -#include "rosidl_typesupport_c/identifier.h"
  1563. -#include "rosidl_typesupport_c/type_support_map.h"
  1564. +#include <rosidl_typesupport_common/identifier.h>
  1565. +#include <rosidl_typesupport_common/type_support_map.h>
  1566.  
  1567. -namespace rosidl_typesupport_c
  1568. +namespace rosidl_typesupport_common
  1569.  {
  1570.  
  1571.  std::string find_library_path(const std::string & library_name);
  1572. @@ -51,8 +51,8 @@ get_typesupport_handle_function(
  1573.      return handle;
  1574.    }
  1575.  
  1576. -#ifdef ROSIDL_TYPESUPPORT_C_USE_POCO
  1577. -  if (handle->typesupport_identifier == rosidl_typesupport_c__typesupport_identifier) {
  1578. +#ifdef ROSIDL_TYPESUPPORT_COMMON_USE_POCO
  1579. +  if (handle->typesupport_identifier == NS_ROSIDL_TYPESUPPORT(typesupport_identifier)) {
  1580.      const type_support_map_t * map = \
  1581.        static_cast<const type_support_map_t *>(handle->data);
  1582.      for (size_t i = 0; i < map->size; ++i) {
  1583. @@ -92,6 +92,6 @@ get_typesupport_handle_function(
  1584.    return nullptr;
  1585.  }
  1586.  
  1587. -}  // namespace rosidl_typesupport_c
  1588. +}  // namespace rosidl_typesupport_common
  1589.  
  1590.  #endif  // TYPE_SUPPORT_DISPATCH_HPP_
Advertisement
Add Comment
Please, Sign In to add comment