mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 12:16:17 +08:00
IDL generation: add constants fields for IDL's
This commit is contained in:
@@ -83,6 +83,15 @@ def add_msg_fields():
|
|||||||
key=sizeof_field_type, reverse=True)
|
key=sizeof_field_type, reverse=True)
|
||||||
for field in sorted_fields:
|
for field in sorted_fields:
|
||||||
add_msg_field(field)
|
add_msg_field(field)
|
||||||
|
|
||||||
|
|
||||||
|
def add_msg_constants():
|
||||||
|
sorted_constants = sorted(spec.constants,
|
||||||
|
key=sizeof_field_type, reverse=True)
|
||||||
|
for constant in sorted_constants:
|
||||||
|
constant_value = '%d' % constant.val
|
||||||
|
print("const " + get_idl_type_name(constant.type) + " " + constant.name + " = " + constant_value + ";")
|
||||||
|
|
||||||
}@
|
}@
|
||||||
#ifndef __@(spec.short_name)__idl__
|
#ifndef __@(spec.short_name)__idl__
|
||||||
#define __@(spec.short_name)__idl__
|
#define __@(spec.short_name)__idl__
|
||||||
@@ -94,6 +103,9 @@ def add_msg_fields():
|
|||||||
@(line)
|
@(line)
|
||||||
@[end for]@
|
@[end for]@
|
||||||
|
|
||||||
|
@# Constants
|
||||||
|
@add_msg_constants()
|
||||||
|
|
||||||
@[for type in builtin_types]@
|
@[for type in builtin_types]@
|
||||||
typedef @(type + '_') @(type);
|
typedef @(type + '_') @(type);
|
||||||
@[end for]@
|
@[end for]@
|
||||||
|
|||||||
@@ -221,11 +221,11 @@ else:
|
|||||||
|
|
||||||
if args.fastrtpsgen is None or args.fastrtpsgen == "":
|
if args.fastrtpsgen is None or args.fastrtpsgen == "":
|
||||||
# Assume fastrtpsgen is in PATH
|
# Assume fastrtpsgen is in PATH
|
||||||
fastrtpsgen_path = "fastrtpsgen"
|
fastrtpsgen_path = 'fastrtpsgen'
|
||||||
else:
|
else:
|
||||||
# Path to fastrtpsgen is explicitly specified
|
# Path to fastrtpsgen is explicitly specified
|
||||||
fastrtpsgen_path = os.path.join(
|
fastrtpsgen_path = os.path.join(
|
||||||
get_absolute_path(args.fastrtpsgen), "/fastrtpsgen")
|
get_absolute_path(args.fastrtpsgen), 'fastrtpsgen')
|
||||||
fastrtpsgen_include = args.fastrtpsgen_include
|
fastrtpsgen_include = args.fastrtpsgen_include
|
||||||
if fastrtpsgen_include is not None and fastrtpsgen_include != '':
|
if fastrtpsgen_include is not None and fastrtpsgen_include != '':
|
||||||
fastrtpsgen_include = "-I " + \
|
fastrtpsgen_include = "-I " + \
|
||||||
|
|||||||
Reference in New Issue
Block a user