Commit 35502930 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Support -renamePolicy in the call to asn1scc

When generating C code, the rename policy is different from Ada (EnumID
is different in the ASN.1 AST)
parent 269cf0a5
......@@ -46,6 +46,9 @@ class ASN1(Enum):
NoConstraintReference = 3
UniqueEnumeratedNames = 4
AstOnly = 5
NoRename = 0
RenameOnlyConflicting = 1
RenameAllEnumerants = 2
def parse_asn1(*files, **options):
......@@ -57,8 +60,10 @@ def parse_asn1(*files, **options):
global AST
ast_version = options.get('ast_version', ASN1.UniqueEnumeratedNames)
rename_policy = options.get('rename_policy', ASN1.NoRename)
flags = options.get('flags', [ASN1.AstOnly])
assert isinstance(ast_version, ASN1)
assert isinstance(rename_policy, ASN1)
assert isinstance(flags, list)
#if os.name == 'posix' and hasattr(sys, 'frozen'):
# Frozen Linux binaries are expected to use the frozen ASN.1 compiler
......@@ -94,7 +99,7 @@ def parse_asn1(*files, **options):
args = [arg0, '-customStgAstVerion', str(ast_version.value),
'-customStg', stg + '::' + filepath,
'-renamePolicy', '0'] + list(*files)
'-renamePolicy', str(rename_policy.value)] + list(*files)
asn1scc = QProcess()
LOG.debug(os.getcwd())
LOG.debug(binary + ' ' + ' '.join(args))
......
......@@ -151,9 +151,14 @@ types = lambda: getattr(DV, 'types', {})
def set_global_DV(asn1_filenames):
''' Call ASN.1 parser and set the global dataview AST entry (DV) '''
global DV
if '--toC' in sys.argv:
rename_policy = ASN1.RenameOnlyConflicting
else:
rename_policy = ASN1.NoRename
try:
DV = parse_asn1(tuple(asn1_filenames),
ast_version=ASN1.UniqueEnumeratedNames,
rename_policy=rename_policy,
flags=[ASN1.AstOnly])
except (ImportError, NameError) as err:
# Can happen if DataView.py is not there
......
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