Skip to content

Commit

Permalink
update code to match refactoring of rosidl definitions (#49)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
  • Loading branch information
dirk-thomas authored Apr 19, 2019
1 parent d95bc24 commit 78870f9
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 88 deletions.
42 changes: 21 additions & 21 deletions rosidl_typesupport_c/resource/msg__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if len(type_supports) != 1:
@[end for]@
@
@[if len(type_supports) != 1]@
@[ for ns in message.structure.type.namespaces]@
@[ for ns in message.structure.namespaced_type.namespaces]@

namespace @(ns)
{
Expand All @@ -41,12 +41,12 @@ namespace @(ns)
namespace rosidl_typesupport_c
{

typedef struct _@(message.structure.type.name)_type_support_ids_t
typedef struct _@(message.structure.namespaced_type.name)_type_support_ids_t
{
const char * typesupport_identifier[@(len(type_supports))];
} _@(message.structure.type.name)_type_support_ids_t;
} _@(message.structure.namespaced_type.name)_type_support_ids_t;

static const _@(message.structure.type.name)_type_support_ids_t _@(message.structure.type.name)_message_typesupport_ids = {
static const _@(message.structure.namespaced_type.name)_type_support_ids_t _@(message.structure.namespaced_type.name)_message_typesupport_ids = {
{
@# TODO(dirk-thomas) use identifier symbol again
@[ for type_support in sorted(type_supports)]@
Expand All @@ -55,51 +55,51 @@ static const _@(message.structure.type.name)_type_support_ids_t _@(message.struc
}
};

typedef struct _@(message.structure.type.name)_type_support_symbol_names_t
typedef struct _@(message.structure.namespaced_type.name)_type_support_symbol_names_t
{
const char * symbol_name[@(len(type_supports))];
} _@(message.structure.type.name)_type_support_symbol_names_t;
} _@(message.structure.namespaced_type.name)_type_support_symbol_names_t;

#define STRINGIFY_(s) #s
#define STRINGIFY(s) STRINGIFY_(s)

static const _@(message.structure.type.name)_type_support_symbol_names_t _@(message.structure.type.name)_message_typesupport_symbol_names = {
static const _@(message.structure.namespaced_type.name)_type_support_symbol_names_t _@(message.structure.namespaced_type.name)_message_typesupport_symbol_names = {
{
@[ for type_support in sorted(type_supports)]@
STRINGIFY(ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(type_support), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.type.name))),
STRINGIFY(ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(type_support), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))),
@[ end for]@
}
};

typedef struct _@(message.structure.type.name)_type_support_data_t
typedef struct _@(message.structure.namespaced_type.name)_type_support_data_t
{
void * data[@(len(type_supports))];
} _@(message.structure.type.name)_type_support_data_t;
} _@(message.structure.namespaced_type.name)_type_support_data_t;

static _@(message.structure.type.name)_type_support_data_t _@(message.structure.type.name)_message_typesupport_data = {
static _@(message.structure.namespaced_type.name)_type_support_data_t _@(message.structure.namespaced_type.name)_message_typesupport_data = {
{
@[for type_support in sorted(type_supports)]@
0, // will store the shared library later
@[end for]@
}
};

static const type_support_map_t _@(message.structure.type.name)_message_typesupport_map = {
static const type_support_map_t _@(message.structure.namespaced_type.name)_message_typesupport_map = {
@(len(type_supports)),
"@(package_name)",
&_@(message.structure.type.name)_message_typesupport_ids.typesupport_identifier[0],
&_@(message.structure.type.name)_message_typesupport_symbol_names.symbol_name[0],
&_@(message.structure.type.name)_message_typesupport_data.data[0],
&_@(message.structure.namespaced_type.name)_message_typesupport_ids.typesupport_identifier[0],
&_@(message.structure.namespaced_type.name)_message_typesupport_symbol_names.symbol_name[0],
&_@(message.structure.namespaced_type.name)_message_typesupport_data.data[0],
};

static const rosidl_message_type_support_t @(message.structure.type.name)_message_type_support_handle = {
static const rosidl_message_type_support_t @(message.structure.namespaced_type.name)_message_type_support_handle = {
rosidl_typesupport_c__typesupport_identifier,
reinterpret_cast<const type_support_map_t *>(&_@(message.structure.type.name)_message_typesupport_map),
reinterpret_cast<const type_support_map_t *>(&_@(message.structure.namespaced_type.name)_message_typesupport_map),
rosidl_typesupport_c__get_message_typesupport_handle_function,
};

} // namespace rosidl_typesupport_c
@[ for ns in reversed(message.structure.type.namespaces)]@
@[ for ns in reversed(message.structure.namespaced_type.namespaces)]@

} // namespace @(ns)
@[ end for]@
Expand Down Expand Up @@ -127,11 +127,11 @@ extern "C"

ROSIDL_TYPESUPPORT_C_EXPORT_@(package_name)
const rosidl_message_type_support_t *
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.type.name))() {
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))() {
@[if len(type_supports) != 1]@
return &::@('::'.join([package_name] + list(interface_path.parents[0].parts)))::rosidl_typesupport_c::@(message.structure.type.name)_message_type_support_handle;
return &::@('::'.join([package_name] + list(interface_path.parents[0].parts)))::rosidl_typesupport_c::@(message.structure.namespaced_type.name)_message_type_support_handle;
@[else]@
return ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(list(type_supports)[0]), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.type.name))();
return ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(list(type_supports)[0]), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))();
@[end if]@
}

Expand Down
42 changes: 21 additions & 21 deletions rosidl_typesupport_c/resource/srv__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ header_files.append('rosidl_typesupport_interface/macros.h')
@[end for]@
@
@[if len(type_supports) != 1]@
@[ for ns in service.structure_type.namespaces]@
@[ for ns in service.namespaced_type.namespaces]@

namespace @(ns)
{
Expand All @@ -54,12 +54,12 @@ namespace @(ns)
namespace rosidl_typesupport_c
{

typedef struct _@(service.structure_type.name)_type_support_ids_t
typedef struct _@(service.namespaced_type.name)_type_support_ids_t
{
const char * typesupport_identifier[@(len(type_supports))];
} _@(service.structure_type.name)_type_support_ids_t;
} _@(service.namespaced_type.name)_type_support_ids_t;

static const _@(service.structure_type.name)_type_support_ids_t _@(service.structure_type.name)_service_typesupport_ids = {
static const _@(service.namespaced_type.name)_type_support_ids_t _@(service.namespaced_type.name)_service_typesupport_ids = {
{
@# TODO(dirk-thomas) use identifier symbol again
@[for type_support in sorted(type_supports)]@
Expand All @@ -68,51 +68,51 @@ static const _@(service.structure_type.name)_type_support_ids_t _@(service.struc
}
};

typedef struct _@(service.structure_type.name)_type_support_symbol_names_t
typedef struct _@(service.namespaced_type.name)_type_support_symbol_names_t
{
const char * symbol_name[@(len(type_supports))];
} _@(service.structure_type.name)_type_support_symbol_names_t;
} _@(service.namespaced_type.name)_type_support_symbol_names_t;

#define STRINGIFY_(s) #s
#define STRINGIFY(s) STRINGIFY_(s)

static const _@(service.structure_type.name)_type_support_symbol_names_t _@(service.structure_type.name)_service_typesupport_symbol_names = {
static const _@(service.namespaced_type.name)_type_support_symbol_names_t _@(service.namespaced_type.name)_service_typesupport_symbol_names = {
{
@[for type_support in sorted(type_supports)]@
STRINGIFY(ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(@(type_support), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.structure_type.name))),
STRINGIFY(ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(@(type_support), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))),
@[end for]@
}
};

typedef struct _@(service.structure_type.name)_type_support_data_t
typedef struct _@(service.namespaced_type.name)_type_support_data_t
{
void * data[@(len(type_supports))];
} _@(service.structure_type.name)_type_support_data_t;
} _@(service.namespaced_type.name)_type_support_data_t;

static _@(service.structure_type.name)_type_support_data_t _@(service.structure_type.name)_service_typesupport_data = {
static _@(service.namespaced_type.name)_type_support_data_t _@(service.namespaced_type.name)_service_typesupport_data = {
{
@[for type_support in sorted(type_supports)]@
0, // will store the shared library later
@[end for]@
}
};

static const type_support_map_t _@(service.structure_type.name)_service_typesupport_map = {
static const type_support_map_t _@(service.namespaced_type.name)_service_typesupport_map = {
@(len(type_supports)),
"@(package_name)",
&_@(service.structure_type.name)_service_typesupport_ids.typesupport_identifier[0],
&_@(service.structure_type.name)_service_typesupport_symbol_names.symbol_name[0],
&_@(service.structure_type.name)_service_typesupport_data.data[0],
&_@(service.namespaced_type.name)_service_typesupport_ids.typesupport_identifier[0],
&_@(service.namespaced_type.name)_service_typesupport_symbol_names.symbol_name[0],
&_@(service.namespaced_type.name)_service_typesupport_data.data[0],
};

static const rosidl_service_type_support_t @(service.structure_type.name)_service_type_support_handle = {
static const rosidl_service_type_support_t @(service.namespaced_type.name)_service_type_support_handle = {
rosidl_typesupport_c__typesupport_identifier,
reinterpret_cast<const type_support_map_t *>(&_@(service.structure_type.name)_service_typesupport_map),
reinterpret_cast<const type_support_map_t *>(&_@(service.namespaced_type.name)_service_typesupport_map),
rosidl_typesupport_c__get_service_typesupport_handle_function,
};

} // namespace rosidl_typesupport_c
@[ for ns in reversed(service.structure_type.namespaces)]@
@[ for ns in reversed(service.namespaced_type.namespaces)]@

} // namespace @(ns)
@[ end for]@
Expand Down Expand Up @@ -140,11 +140,11 @@ extern "C"

ROSIDL_TYPESUPPORT_C_EXPORT_@(package_name)
const rosidl_service_type_support_t *
ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.structure_type.name))() {
ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))() {
@[if len(type_supports) != 1]@
return &::@('::'.join([package_name] + list(interface_path.parents[0].parts)))::rosidl_typesupport_c::@(service.structure_type.name)_service_type_support_handle;
return &::@('::'.join([package_name] + list(interface_path.parents[0].parts)))::rosidl_typesupport_c::@(service.namespaced_type.name)_service_type_support_handle;
@[else]@
return ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(@(list(type_supports)[0]), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.structure_type.name))();
return ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(@(list(type_supports)[0]), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))();
@[end if]@
}

Expand Down
4 changes: 2 additions & 2 deletions rosidl_typesupport_cpp/resource/action__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ header_files = (
#include "@(header_file)"
@[end for]@
@
@[ for ns in action.structure_type.namespaces]@
@[ for ns in action.namespaced_type.namespaces]@

namespace @(ns)
{
Expand All @@ -39,7 +39,7 @@ static rosidl_action_type_support_t @(interface_path.stem)_action_type_support_h
NULL, NULL, NULL, NULL, NULL};

} // namespace rosidl_typesupport_cpp
@[ for ns in reversed(action.structure_type.namespaces)]@
@[ for ns in reversed(action.namespaced_type.namespaces)]@

} // namespace @(ns)
@[ end for]@
Expand Down
46 changes: 23 additions & 23 deletions rosidl_typesupport_cpp/resource/msg__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if len(type_supports) != 1:
@[end for]@
@
@[if len(type_supports) != 1]@
@[ for ns in message.structure.type.namespaces]@
@[ for ns in message.structure.namespaced_type.namespaces]@

namespace @(ns)
{
Expand All @@ -42,12 +42,12 @@ namespace @(ns)
namespace rosidl_typesupport_cpp
{

typedef struct _@(message.structure.type.name)_type_support_ids_t
typedef struct _@(message.structure.namespaced_type.name)_type_support_ids_t
{
const char * typesupport_identifier[@(len(type_supports))];
} _@(message.structure.type.name)_type_support_ids_t;
} _@(message.structure.namespaced_type.name)_type_support_ids_t;

static const _@(message.structure.type.name)_type_support_ids_t _@(message.structure.type.name)_message_typesupport_ids = {
static const _@(message.structure.namespaced_type.name)_type_support_ids_t _@(message.structure.namespaced_type.name)_message_typesupport_ids = {
{
@# TODO(dirk-thomas) use identifier symbol again
@[for type_support in sorted(type_supports)]@
Expand All @@ -56,51 +56,51 @@ static const _@(message.structure.type.name)_type_support_ids_t _@(message.struc
}
};

typedef struct _@(message.structure.type.name)_type_support_symbol_names_t
typedef struct _@(message.structure.namespaced_type.name)_type_support_symbol_names_t
{
const char * symbol_name[@(len(type_supports))];
} _@(message.structure.type.name)_type_support_symbol_names_t;
} _@(message.structure.namespaced_type.name)_type_support_symbol_names_t;

#define STRINGIFY_(s) #s
#define STRINGIFY(s) STRINGIFY_(s)

static const _@(message.structure.type.name)_type_support_symbol_names_t _@(message.structure.type.name)_message_typesupport_symbol_names = {
static const _@(message.structure.namespaced_type.name)_type_support_symbol_names_t _@(message.structure.namespaced_type.name)_message_typesupport_symbol_names = {
{
@[for type_support in sorted(type_supports)]@
STRINGIFY(ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(type_support), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.type.name))),
STRINGIFY(ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(type_support), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))),
@[end for]@
}
};

typedef struct _@(message.structure.type.name)_type_support_data_t
typedef struct _@(message.structure.namespaced_type.name)_type_support_data_t
{
void * data[@(len(type_supports))];
} _@(message.structure.type.name)_type_support_data_t;
} _@(message.structure.namespaced_type.name)_type_support_data_t;

static _@(message.structure.type.name)_type_support_data_t _@(message.structure.type.name)_message_typesupport_data = {
static _@(message.structure.namespaced_type.name)_type_support_data_t _@(message.structure.namespaced_type.name)_message_typesupport_data = {
{
@[for type_support in sorted(type_supports)]@
0, // will store the shared library later
@[end for]@
}
};

static const type_support_map_t _@(message.structure.type.name)_message_typesupport_map = {
static const type_support_map_t _@(message.structure.namespaced_type.name)_message_typesupport_map = {
@(len(type_supports)),
"@(package_name)",
&_@(message.structure.type.name)_message_typesupport_ids.typesupport_identifier[0],
&_@(message.structure.type.name)_message_typesupport_symbol_names.symbol_name[0],
&_@(message.structure.type.name)_message_typesupport_data.data[0],
&_@(message.structure.namespaced_type.name)_message_typesupport_ids.typesupport_identifier[0],
&_@(message.structure.namespaced_type.name)_message_typesupport_symbol_names.symbol_name[0],
&_@(message.structure.namespaced_type.name)_message_typesupport_data.data[0],
};

static const rosidl_message_type_support_t @(message.structure.type.name)_message_type_support_handle = {
static const rosidl_message_type_support_t @(message.structure.namespaced_type.name)_message_type_support_handle = {
::rosidl_typesupport_cpp::typesupport_identifier,
reinterpret_cast<const type_support_map_t *>(&_@(message.structure.type.name)_message_typesupport_map),
reinterpret_cast<const type_support_map_t *>(&_@(message.structure.namespaced_type.name)_message_typesupport_map),
::rosidl_typesupport_cpp::get_message_typesupport_handle_function,
};

} // namespace rosidl_typesupport_cpp
@[ for ns in reversed(message.structure.type.namespaces)]@
@[ for ns in reversed(message.structure.namespaced_type.namespaces)]@

} // namespace @(ns)
@[ end for]@
Expand All @@ -127,12 +127,12 @@ namespace rosidl_typesupport_cpp
template<>
ROSIDL_TYPESUPPORT_CPP_PUBLIC
const rosidl_message_type_support_t *
get_message_type_support_handle<@('::'.join([package_name] + list(interface_path.parents[0].parts)))::@(message.structure.type.name)>()
get_message_type_support_handle<@('::'.join([package_name] + list(interface_path.parents[0].parts)))::@(message.structure.namespaced_type.name)>()
{
@[if len(type_supports) != 1]@
return &::@('::'.join([package_name] + list(interface_path.parents[0].parts)))::rosidl_typesupport_cpp::@(message.structure.type.name)_message_type_support_handle;
return &::@('::'.join([package_name] + list(interface_path.parents[0].parts)))::rosidl_typesupport_cpp::@(message.structure.namespaced_type.name)_message_type_support_handle;
@[else]@
return ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(list(type_supports)[0]), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.type.name))();
return ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(@(list(type_supports)[0]), @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))();
@[end if]@
}

Expand All @@ -143,8 +143,8 @@ extern "C"

ROSIDL_TYPESUPPORT_CPP_PUBLIC
const rosidl_message_type_support_t *
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.type.name))() {
return get_message_type_support_handle<@('::'.join([package_name] + list(interface_path.parents[0].parts)))::@(message.structure.type.name)>();
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))() {
return get_message_type_support_handle<@('::'.join([package_name] + list(interface_path.parents[0].parts)))::@(message.structure.namespaced_type.name)>();
}

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 78870f9

Please sign in to comment.