TASTE bugtrack - Taste
View Issue Details
0000414Taste[All Projects] ASN.1 Compilerpublic2015-01-26 09:362024-03-20 13:22
ttsiodras 
maxime 
normalfeatureN/A
closedfixed 
0000414: Add _IsConstraintValid functions to the Python backend output
In the Python backend, generate functions with suffix “_IsConstraintValid” that are aligned with the C and Ada backends ; the format of the argument of the function has to be agreed with ESA.
No tags attached.
Issue History
2015-01-26 09:36ttsiodrasNew Issue
2015-01-26 09:36ttsiodrasStatusnew => assigned
2015-01-26 09:36ttsiodrasAssigned To => ttsiodras
2015-04-16 08:26user28Assigned Tottsiodras => user28
2015-06-24 16:12gmamaisAssigned Touser28 => gmamais
2015-06-25 07:37maximeAssigned Togmamais => maxime
2016-01-27 13:20ttsiodrasNote Added: 0002564
2016-01-27 13:38ttsiodrasStatusassigned => resolved
2016-01-27 13:38ttsiodrasResolutionopen => fixed
2016-01-27 18:04maximeNote Added: 0002565
2016-01-27 18:04maximeStatusresolved => new
2016-01-28 14:52ttsiodrasNote Added: 0002566
2024-03-20 13:22maximeNote Added: 0003826
2024-03-20 13:22maximeStatusnew => closed

Notes
(0002564)
ttsiodras   
2016-01-27 13:20   
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.
(0002566)
ttsiodras   
2016-01-28 14:52   
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