Commit 07c44894 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Support simple sequences

parent 05e05533
......@@ -366,10 +366,17 @@ class asn1Editor(QTreeView):
boolValue = value == 'True'
ptr.Set(boolValue)
elif asnType == 'ENUMERATED':
valNb = getattr(self.backend.DV, value.replace('-', '_'))
intMappings = root.child(i, 3).data(INTMAP)
for enumerant, num in intMappings.viewitems():
if enumerant == value:
ptr.Set(num)
break
else:
raise TypeError('ENUMERATED value not found')
#valNb = getattr(self.backend.DV, value.replace('-', '_'))
# XXX not correct, get the value from the data field
# (there could be prefixes)
ptr.Set(valNb)
#ptr.Set(valNb)
else: # Strings
ptr.SetFromPyString(value)
for i in xrange(nbRows): # for each child row
......
......@@ -240,7 +240,7 @@ def valueNotationToCTypes(gser, dest, sort, ASN1Mod, ASN1_AST, var=None):
def rec(inp, outp, sort):
''' Recursively fill up the value '''
if sort.kind == 'ReferenceType':
sort = ASN1_AST[sort.ReferencedTypeName]
sort = ASN1_AST[sort.ReferencedTypeName].type
if isinstance(inp, list):
# SEQUENCE OF
# get the path to the sequence of
......
......@@ -17,6 +17,14 @@ Type-SingleChoice ::= CHOICE {
choice-a Type-SingleInt,
choice-b Type-SingleBool
}
Type-SimpleSeq ::= SEQUENCE {
item-a Type-SingleInt,
item-b Type-SingleBool,
item-c Type-SingleEnum,
item-d Type-SingleString
}
Type-Seq ::= SEQUENCE {
item-a Type-SingleReal,
item-b Type-SingleChoice,
......
......@@ -62,6 +62,13 @@ def test_string(qtbot):
result = common(typeName, defValue)
assert result == defValue
def test_seq(qtbot):
''' Test SEQUENCE '''
typeName = "Type-SimpleSeq"
defValue = '{ item-a 42 , item-b TRUE , item-c enum-two , item-d "Hello world" }'
result = common(typeName, defValue)
assert result == defValue
if __name__ == '__main__':
print('You must run py.test-2.7 to execute this test script')
print('Make sure you have pytest-qt (pip install --user pytest-qt)')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment