Skip to content

Commit

Permalink
Add names to variables in function signatures
Browse files Browse the repository at this point in the history
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
  • Loading branch information
emersonknapp committed Apr 4, 2023
1 parent 3405deb commit a6b610b
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 47 deletions.
23 changes: 20 additions & 3 deletions rosidl_generator_c/resource/empty__description.c.em
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ def typename_to_c(typename):
}@

/// Define exported TypeDescriptions and TypeSources
@[for msg in [toplevel_type_description] + implicit_type_descriptions]@
@[for msg, interface_type in [toplevel_type_description] + implicit_type_descriptions]@
@{
td_typename = msg['type_description']['type_name']
td_c_typename = typename_to_c(td_typename)
}@
const rosidl_runtime_c__type_description__TypeDescription *
@(td_c_typename)__@(GET_DESCRIPTION_FUNC)()
@(td_c_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static const rosidl_runtime_c__type_description__TypeDescription description = {
{
{NULL, 0, 0},
Expand All @@ -28,8 +30,23 @@ const rosidl_runtime_c__type_description__TypeDescription *
}
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(td_c_typename)__@(GET_SOURCES_FUNC)()
@(td_c_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static const rosidl_runtime_c__type_description__TypeSource source = {
{NULL, 0, 0},
{NULL, 0, 0},
{NULL, 0, 0}
};
return &source;
}
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(td_c_typename)__@(GET_SOURCES_FUNC)(
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static const rosidl_runtime_c__type_description__TypeSource__Sequence sources = {NULL, 0, 0};
return &sources;
}
Expand Down
28 changes: 17 additions & 11 deletions rosidl_generator_c/resource/full__description.c.em
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ static rosidl_runtime_c__type_description__IndividualTypeDescription @(td_c_type
@[ end if]@

const rosidl_runtime_c__type_description__TypeDescription *
@(td_c_typename)__@(GET_DESCRIPTION_FUNC)(const rosidl_@(interface_type)_type_support_t *)
@(td_c_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static bool constructed = false;
static const rosidl_runtime_c__type_description__TypeDescription description = {
{
Expand Down Expand Up @@ -157,18 +159,19 @@ c_typename = typename_to_c(ref_td['type_name'])
@#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@# Define Raw Sources
@[if raw_source_content]@
static char toplevel_type_raw_source[] = ""@
@[ for line in raw_source_content.splitlines()]
"@(escape_string(line))\n"@
@[ end for]@
;
static char toplevel_type_raw_source[] =@
@[ for line in raw_source_content.splitlines()[:-1]]
"@(escape_string(line))\n"@
@[ end for]
"@(escape_string(raw_source_content.splitlines()[-1]))";
@[end if]@
@

static char @(toplevel_encoding)_encoding[] = "@(toplevel_encoding)";
@[if implicit_type_descriptions]@
static char implicit_encoding[] = "implicit";
@[end if]@
@

// Define all individual source functions
@[for type_description_msg, interface_type in full_type_descriptions]@
@{
itype_description = type_description_msg['type_description']
Expand All @@ -180,8 +183,9 @@ contents = None if td_typename in implicit_type_names else raw_source_content

const rosidl_runtime_c__type_description__TypeSource *
@(td_c_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_@(interface_type)_type_support_t *)
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static const rosidl_runtime_c__type_description__TypeSource source = {
@(static_seq(f'{td_c_typename}__TYPE_NAME', td_typename)),
@(static_seq(f'{encoding}_encoding', encoding)),
Expand All @@ -190,7 +194,8 @@ const rosidl_runtime_c__type_description__TypeSource *
return &source;
}
@[end for]@
@

// Define all full source sequence functions
@[for type_description_msg, interface_type in full_type_descriptions]@
@{
ref_tds = type_description_msg['referenced_type_descriptions']
Expand All @@ -200,8 +205,9 @@ td_c_typename = typename_to_c(type_description_msg['type_description']['type_nam

const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(td_c_typename)__@(GET_SOURCES_FUNC)(
const rosidl_@(interface_type)_type_support_t *)
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static rosidl_runtime_c__type_description__TypeSource sources[@(num_sources)];
static const rosidl_runtime_c__type_description__TypeSource__Sequence source_sequence = @(static_seq_n('sources', num_sources));
static bool constructed = false;
Expand Down
4 changes: 3 additions & 1 deletion rosidl_generator_c/resource/idl__description.c.em
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ c_typename = typename.replace('/', '__')
}@
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_type_hash_t *
@(c_typename)__@(GET_HASH_FUNC)(const rosidl_@(interface_type)_type_support_t *)
@(c_typename)__@(GET_HASH_FUNC)(
const rosidl_@(interface_type)_type_support_t * type_support)
{
(void)type_support;
static rosidl_type_hash_t hash = @(type_hash_to_c_definition(hash_lookup[typename], indent=4));
return &hash;
}
Expand Down
73 changes: 49 additions & 24 deletions rosidl_generator_c/resource/idl__functions.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from rosidl_generator_c import idl_structure_type_to_c_typename
from rosidl_generator_type_description import GET_DESCRIPTION_FUNC
from rosidl_generator_type_description import GET_HASH_FUNC
from rosidl_generator_type_description import GET_INDIVIDUAL_SOURCE_FUNC
from rosidl_generator_type_description import GET_SOURCES_FUNC
from rosidl_pycommon import convert_camel_case_to_lower_case_underscore
include_parts = [package_name] + list(interface_path.parents[0].parts) + [
Expand Down Expand Up @@ -71,23 +72,29 @@ from rosidl_parser.definition import Service
@{
service_typename = idl_structure_type_to_c_typename(service.namespaced_type)
}@
/// Retrieve pointer to the hash of the description of the service type.
/// Retrieve pointer to the hash of the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_type_hash_t *
@(service_typename)__@(GET_HASH_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);
/// Retrieve pointer to the description of the service type.
/// Retrieve pointer to the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeDescription *
@(service_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);

/// Retrieve pointer to the raw source texts that defined the description of the service type.
/// Retrieve pointer to the single raw source text that defined this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource *
@(service_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_service_type_support_t * type_support);
/// Retrieve pointer to the recursive raw sources that defined the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(service_typename)__@(GET_SOURCES_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);

@{
TEMPLATE(
Expand Down Expand Up @@ -123,23 +130,29 @@ action_typename = idl_structure_type_to_c_typename(action.namespaced_type)
send_goal_srv_typename = idl_structure_type_to_c_typename(action.send_goal_service.namespaced_type)
get_result_srv_typename = idl_structure_type_to_c_typename(action.get_result_service.namespaced_type)
}@
/// Retrieve pointer to the hash of the description of the service type.
/// Retrieve pointer to the hash of the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_type_hash_t *
@(action_typename)__@(GET_HASH_FUNC)(
const rosidl_action_type_support_t *);
const rosidl_action_type_support_t * type_support);
/// Retrieve pointer to the description of the action type.
/// Retrieve pointer to the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeDescription *
@(action_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_action_type_support_t *);
const rosidl_action_type_support_t * type_support);

/// Retrieve pointer to the single raw source text that defined this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource *
@(action_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_action_type_support_t * type_support);
/// Retrieve pointer to the raw source texts that defined the description of the action type.
/// Retrieve pointer to the recursive raw sources that defined the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(action_typename)__@(GET_SOURCES_FUNC)(
const rosidl_action_type_support_t *);
const rosidl_action_type_support_t * type_support);

@{
TEMPLATE(
Expand All @@ -162,23 +175,29 @@ TEMPLATE(
message=action.feedback)
}@

/// Retrieve pointer to the hash of the description of the service type.
/// Retrieve pointer to the hash of the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_type_hash_t *
@(send_goal_srv_typename)__@(GET_HASH_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);
/// Retrieve pointer to the description of the service type.
/// Retrieve pointer to the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeDescription *
@(send_goal_srv_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);

/// Retrieve pointer to the raw source texts that defined the description of the service type.
/// Retrieve pointer to the single raw source text that defined this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource *
@(send_goal_srv_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_service_type_support_t * type_support);
/// Retrieve pointer to the recursive raw sources that defined the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(send_goal_srv_typename)__@(GET_SOURCES_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);

@{
TEMPLATE(
Expand All @@ -201,23 +220,29 @@ TEMPLATE(
message=action.send_goal_service.event_message)
}@

/// Retrieve pointer to the hash of the description of the service type.
/// Retrieve pointer to the hash of the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_type_hash_t *
@(get_result_srv_typename)__@(GET_HASH_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);
/// Retrieve pointer to the description of the service type.
/// Retrieve pointer to the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeDescription *
@(get_result_srv_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);

/// Retrieve pointer to the single raw source text that defined this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource *
@(get_result_srv_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_service_type_support_t * type_support);
/// Retrieve pointer to the raw source texts that defined the description of the service type.
/// Retrieve pointer to the recursive raw sources that defined the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(get_result_srv_typename)__@(GET_SOURCES_FUNC)(
const rosidl_service_type_support_t *);
const rosidl_service_type_support_t * type_support);

@{
TEMPLATE(
Expand Down
15 changes: 8 additions & 7 deletions rosidl_generator_c/resource/msg__functions.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,29 @@ bool
const @(message_typename) * input,
@(message_typename) * output);

/// Retrieve pointer to the hash of the description of the message type.
/// Retrieve pointer to the hash of the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_type_hash_t *
@(message_typename)__@(GET_HASH_FUNC)(
const rosidl_message_type_support_t *);
const rosidl_message_type_support_t * type_support);
/// Retrieve pointer to the description of the message type.
/// Retrieve pointer to the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeDescription *
@(message_typename)__@(GET_DESCRIPTION_FUNC)(
const rosidl_message_type_support_t *);
const rosidl_message_type_support_t * type_support);

/// Retrieve pointer to the single raw source text that defined this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource *
@(message_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)(
const rosidl_message_type_support_t *);
const rosidl_message_type_support_t * type_support);
/// Retrieve pointer to the raw source texts that defined the description of the message type.
/// Retrieve pointer to the recursive raw sources that defined the description of this type.
ROSIDL_GENERATOR_C_PUBLIC_@(package_name)
const rosidl_runtime_c__type_description__TypeSource__Sequence *
@(message_typename)__@(GET_SOURCES_FUNC)(
const rosidl_message_type_support_t *);
const rosidl_message_type_support_t * type_support);

@#######################################################################
@# array functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ int test_source_defined()
return 1;
}
// Implicit message of implicit service of an action
if (!rosidl_generator_tests__action__Fibonacci_SendGoal_Response__get_type_description_sources(NULL)) {
if (!rosidl_generator_tests__action__Fibonacci_SendGoal_Response__get_type_description_sources(
NULL))
{
return 1;
}
return 0;
Expand Down

0 comments on commit a6b610b

Please sign in to comment.