File tree 3 files changed +19
-7
lines changed
rosidl_adapter/rosidl_adapter/resource
rosidl_parser/rosidl_parser
3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 40
40
@ [if msg .constants ]@
41
41
module @ (msg .msg_name )_Constants {
42
42
@ [ for constant in msg .constants ]@
43
+ @ [ if constant .annotations .get (' comment' , [])]@
44
+ @@verbatim (language = " comment" , text =
45
+ @ [ for i, line in enumerate (constant .annotations [' comment' ])]@
46
+ @ (string_to_idl_string_literal (line))@
47
+ @ [ if i < len (constant .annotations .get (' comment' )) - 1 ]@
48
+ " \n " @
49
+ @ [ end if ]@
50
+ @ [ end for ]@
51
+ )
52
+ @ [ end if ]@
43
53
const @ (get_idl_type (constant .type )) @ (constant .name ) = @ (to_idl_literal (get_idl_type (constant .type ), constant .value ));
44
54
@ [ end for ]@
45
55
};
Original file line number Diff line number Diff line change @@ -113,8 +113,8 @@ scoped_name.1: IDENTIFIER
113
113
// separate rule to identify the separator
114
114
scoped_name_separator : " ::"
115
115
116
- // (5)
117
- const_dcl : " const" const_type IDENTIFIER " =" const_expr
116
+ // (5), 7.4.15.2
117
+ const_dcl : annotation_appl * " const" const_type IDENTIFIER " =" const_expr
118
118
119
119
// (6)
120
120
const_type : integer_type
Original file line number Diff line number Diff line change @@ -103,16 +103,18 @@ def extract_content_from_ast(tree):
103
103
constants = {}
104
104
const_dcls = tree .find_data ('const_dcl' )
105
105
for const_dcl in const_dcls :
106
+ annotations = get_annotations (const_dcl )
106
107
const_type = next (const_dcl .find_data ('const_type' ))
107
- const_expr = next (const_dcl .find_data ('const_expr' ))
108
108
module_identifiers = get_module_identifier_values (tree , const_dcl )
109
109
module_comments = constants .setdefault (
110
110
module_identifiers [- 1 ], [])
111
- value = get_const_expr_value (const_expr )
112
- module_comments . append ( Constant (
113
- get_first_identifier_value (const_dcl ),
111
+ value = get_const_expr_value (const_dcl . children [ - 1 ] )
112
+ constant = Constant (
113
+ get_child_identifier_value (const_dcl ),
114
114
get_abstract_type_from_const_expr (const_type , value ),
115
- value ))
115
+ value )
116
+ constant .annotations = annotations
117
+ module_comments .append (constant )
116
118
117
119
typedefs = {}
118
120
typedef_dcls = tree .find_data ('typedef_dcl' )
You can’t perform that action at this time.
0 commit comments