Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
cff1c1a3
Commit
cff1c1a3
authored
Jun 21, 2014
by
Maxime Perrotin
Browse files
Added function returning sorted field list in SEQ/CHOICE types
parent
44a59893
Changes
3
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
cff1c1a3
...
...
@@ -1515,6 +1515,7 @@ def path_type(path):
continue
# Sequence, Choice (case insensitive)
if
current
.
kind
in
(
'SequenceType'
,
'ChoiceType'
):
#print list(Helper.sorted_fields(current))
elem_asn1
=
elem
.
replace
(
'_'
,
'-'
).
lower
()
type_idx
,
=
(
c
for
c
in
current
.
Children
if
c
.
lower
()
==
elem_asn1
)
...
...
Helper.py
View file @
cff1c1a3
...
...
@@ -11,6 +11,8 @@
inner_labels_to_floating(process) : remove labels from transitions
map_input_state(process) -> mapping: create a mapping
input-state-transition
sorted_fields(SEQ/CHOICE) : returns the ordered list of fields
of an ASN.1 SEQUENCE or CHOICE type
Copyright (c) 2012-2014 European Space Agency
...
...
@@ -19,6 +21,7 @@
Contact: maxime.perrotin@esa.int
"""
import
operator
import
logging
from
itertools
import
chain
from
collections
import
defaultdict
...
...
@@ -30,7 +33,7 @@ import ogAST
LOG
=
logging
.
getLogger
(
__name__
)
__all__
=
[
'flatten'
,
'rename_everything'
,
'inner_labels_to_floating'
,
'map_input_state'
]
'map_input_state'
,
'sorted_fields'
]
def
map_input_state
(
process
):
...
...
@@ -436,3 +439,12 @@ def find_labels(trans):
[
slice
(
idx
+
1
,
len
(
trans
.
actions
))])
new_fl
.
transition
.
terminator
=
trans
.
terminator
yield
new_fl
def
sorted_fields
(
atype
):
''' Return the sorted list of a SEQUENCE or CHOICE type fields '''
if
atype
.
kind
not
in
(
'SequenceType'
,
'ChoiceType'
):
raise
TypeError
(
'Not a SEQUENCE nor a CHOICE'
)
tmp
=
([
k
,
val
.
Line
,
val
.
CharPositionInLine
]
for
k
,
val
in
atype
.
Children
.
viewitems
())
return
(
x
[
0
]
for
x
in
sorted
(
tmp
,
key
=
operator
.
itemgetter
(
1
,
2
)))
tests/regression/test3/dataview-uniq.asn
View file @
cff1c1a3
...
...
@@ -22,8 +22,8 @@ IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
FCE-SGM-EEPROM ::= SEQUENCE {
sit-1 FCE-SIT-1,
sit-2 FCE-SIT-2,
sit-3 FCE-SIT-3,
sit-2 FCE-SIT-2,
sit-4 FCE-SIT-4
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment