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
d6036636
Commit
d6036636
authored
May 08, 2016
by
Maxime Perrotin
Browse files
Fully support optional fields in ASN.1 types
parent
72aafa41
Changes
3
Hide whitespace changes
Inline
Side-by-side
opengeode/AdaGenerator.py
View file @
d6036636
...
...
@@ -1437,6 +1437,10 @@ def _prim_selector(prim):
field_name
=
field_name
,
ada_string
=
ada_string
))
else
:
# SEQUENCE, check for field optionality first
child
=
child_spelling
(
field_name
,
receiver_bty
)
if
receiver_bty
.
Children
[
child
].
Optional
==
'True'
:
stmts
.
append
(
'{}.Exist.{} := 1;'
.
format
(
ada_string
,
field_name
))
ada_string
+=
'.'
+
field_name
return
stmts
,
unicode
(
ada_string
),
local_decl
...
...
@@ -2466,6 +2470,14 @@ def type_name(a_type, use_prefix=True):
raise
NotImplementedError
(
'Type name for {}'
.
format
(
a_type
.
kind
))
def
child_spelling
(
name
,
bty
):
''' Return the index in Children with the proper spelling (case, dash) '''
for
each
in
bty
.
Children
:
if
name
.
lower
().
replace
(
'_'
,
'-'
)
==
each
.
lower
():
return
each
raise
TypeError
(
'Child not found: {}'
.
format
(
name
))
def
find_var
(
var
):
''' Return a variable from the scope, with proper case '''
for
visible_var
in
VARIABLES
.
viewkeys
():
...
...
tests/regression/test-optionalfield/dataview.asn
View file @
d6036636
TASTE-Dataview DEFINITIONS ::=
BEGIN
-- Data view with optional fields, including mixed case,
-- and dash
Seq ::= SEQUENCE {
a BOOLEAN OPTIONAL
a BOOLEAN OPTIONAL,
b SEQUENCE {
b-C BOOLEAN OPTIONAL
} OPTIONAL
}
--SeqPresent ::= Seq (WITH COMPONENTS {a PRESENT})
--SeqAbsent ::= Seq (WITH COMPONENTS {a ABSENT})
...
...
tests/regression/test-optionalfield/og.pr
View file @
d6036636
...
...
@@ -26,17 +26,21 @@ dcl s2 Seq;
/* CIF ENDTEXT */
/* CIF START (97, 224), (70, 35) */
START;
/* CIF TASK (6
6
, 274), (130, 35) */
/* CIF TASK (6
7
, 274), (130, 35) */
TASK s2 := { a FALSE};
/* CIF TASK (7
4
, 324), (114, 35) */
/* CIF TASK (7
5
, 324), (114, 35) */
TASK s2!a := TRUE;
/* CIF NEXTSTATE (97, 374), (70, 35) */
/* CIF TASK (62, 374), (139, 35) */
TASK s2!b!b_c := TRUE;
/* CIF TASK (52, 424), (159, 35) */
TASK s2 :={ b { b_c TRUE }};
/* CIF NEXTSTATE (97, 474), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (97,
3
74), (70, 35) */
/* CIF STATE (97,
4
74), (70, 35) */
STATE wait;
/* CIF INPUT (89,
4
29), (84, 35) */
/* CIF INPUT (89,
5
29), (84, 35) */
INPUT run;
/* CIF NEXTSTATE (87,
4
79), (88, 35) */
/* CIF NEXTSTATE (87,
5
79), (88, 35) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS og;
...
...
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