Notes |
|
|
Implemented in r7677.
Types now contain a member that returns a tuple - (isValid, errorCode).
Example use:
#!/usr/bin/env python2
#
# With this sample.asn:
#
# MY-MODULE DEFINITIONS AUTOMATIC TAGS ::= BEGIN
#
# Nested ::= SEQUENCE {
# somethingElse INTEGER(0..100)
# }
#
# END
from sample_asn import *
msg = Nested()
msg.somethingElse.Set(100)
isValid, _ = msg.IsConstraintValid()
assert isValid is True
msg.somethingElse.Set(500)
isValid, err = msg.IsConstraintValid()
assert isValid is False
# Names of errors come from sample.h
assert err == DV.ERR_Nested_somethingElse |
|
|
(0002565)
|
maxime
|
2016-01-27 18:04
|
|
Thanks for implementing this function into Stubs.py
However I had something else in mind with this ticket. Using Stubs,py means having gone through C -> Swig -> Compilation -> import
My need is to have native IsConstraintValid functions in Python for allowing live checks of ASN.1 variables in Python in Opengeode.
So that if the user has such a type:
X ::= INTEGER (10 | 20) -- allowing only value 10 or 20
And the user tries to assign a value such as :
TASK hello := 5; -- hello of type X
the semantic checker should be able to figure out that there is a range error.
At the moment the generic stg backend (used for xml.stg and python.stg) only reports min and max ranges ; the idea is to get the complete algorithm for checking the constraints from python. This involves modification of asn1scc to feed the python STG backend with the same information as the C/Ada backends.
So: not a simple task. |
|
|
|
I see - so if I understand you correctly, this is about the compiler's "generic-STG" related AST, not DMT stuff.
Shouldn't this be assigned to George, then? |
|
|
(0003826)
|
maxime
|
2024-03-20 13:22
|
|
Closing - will be addressed when a native Python backend for asn1scc is made available |
|