Commit 6369e391 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

B_mappers done, adding type specs to A_mappers now.

parent a9d13f08
...@@ -29,6 +29,8 @@ import distutils.spawn as spawn ...@@ -29,6 +29,8 @@ import distutils.spawn as spawn
from typing import List from typing import List
from ..commonPy.utility import panic from ..commonPy.utility import panic
from ..commonPy.cleanupNodes import SetOfBadTypenames from ..commonPy.cleanupNodes import SetOfBadTypenames
from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice
from ..commonPy.asnParser import AST_Leaftypes
def Version(): def Version():
...@@ -51,31 +53,31 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, ...@@ -51,31 +53,31 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str,
os.system("rm -f \"" + outputDir + "\"/*.adb") os.system("rm -f \"" + outputDir + "\"/*.adb")
def OnBasic(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSequence(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSet(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnEnumerated(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSequenceOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSetOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnChoice(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
......
...@@ -29,6 +29,8 @@ from typing import List ...@@ -29,6 +29,8 @@ from typing import List
from ..commonPy.utility import panic from ..commonPy.utility import panic
from ..commonPy.cleanupNodes import SetOfBadTypenames from ..commonPy.cleanupNodes import SetOfBadTypenames
from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice
from ..commonPy.asnParser import AST_Leaftypes
def Version() -> None: def Version() -> None:
...@@ -55,33 +57,33 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, ...@@ -55,33 +57,33 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str,
os.system("rm -f \"" + outputDir + os.sep + os.path.basename(os.path.splitext(tmp)[0]) + ".c\"") os.system("rm -f \"" + outputDir + os.sep + os.path.basename(os.path.splitext(tmp)[0]) + ".c\"")
def OnBasic(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSequence(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSet(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnEnumerated(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSequenceOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnSetOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnChoice(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: no cover pass # pragma: no cover
def OnShutdown(unused_badTypes): def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None:
pass # pragma: no cover pass # pragma: no cover
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
from ..commonPy import asnParser from ..commonPy import asnParser
from ..commonPy.cleanupNodes import SetOfBadTypenames from ..commonPy.cleanupNodes import SetOfBadTypenames
from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice
from ..commonPy.asnParser import AST_Leaftypes
g_outputDir = "" g_outputDir = ""
g_asnFile = "" g_asnFile = ""
...@@ -41,31 +43,31 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, unused ...@@ -41,31 +43,31 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, unused
g_outputDir = outputDir g_outputDir = outputDir
def OnBasic(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSequence(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSet(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnEnumerated(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSequenceOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSetOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnChoice(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
# obsolete, now the grammar is re-created from the AST (PrintGrammarFromAST) # obsolete, now the grammar is re-created from the AST (PrintGrammarFromAST)
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
import re import re
import os import os
from typing import List # NOQA pylint: disable=unused-import from typing import Union, List # NOQA pylint: disable=unused-import
from ..commonPy import asnParser from ..commonPy import asnParser
from ..commonPy.utility import panic, inform from ..commonPy.utility import panic, inform
from ..commonPy.asnAST import ( from ..commonPy.asnAST import (
AsnBool, AsnInt, AsnReal, AsnString, isSequenceVariable, AsnEnumerated, AsnBool, AsnInt, AsnReal, AsnString, isSequenceVariable, AsnEnumerated,
AsnSequence, AsnSet, AsnChoice, AsnMetaMember, AsnSequenceOf, AsnSetOf, AsnSequence, AsnSet, AsnChoice, AsnMetaMember, AsnSequenceOf, AsnSetOf,
AsnBasicNode, AsnNode) AsnBasicNode, AsnNode, AsnSequenceOrSet, AsnSequenceOrSetOf)
from ..commonPy.asnParser import AST_Lookup, AST_Leaftypes from ..commonPy.asnParser import AST_Lookup, AST_Leaftypes
from ..commonPy.cleanupNodes import SetOfBadTypenames from ..commonPy.cleanupNodes import SetOfBadTypenames
...@@ -42,7 +42,7 @@ g_outputGetSetC = None ...@@ -42,7 +42,7 @@ g_outputGetSetC = None
g_bHasStartupRunOnce = False g_bHasStartupRunOnce = False
def Version(): def Version() -> None:
print("Code generator: " + print("Code generator: " +
"$Id: python_A_mapper.py 2400 2012-09-04 10:40:19Z ttsiodras $") # pragma: no cover "$Id: python_A_mapper.py 2400 2012-09-04 10:40:19Z ttsiodras $") # pragma: no cover
...@@ -51,7 +51,7 @@ def CleanNameAsPythonWants(name: str) -> str: ...@@ -51,7 +51,7 @@ def CleanNameAsPythonWants(name: str) -> str:
return re.sub(r'[^a-zA-Z0-9_]', '_', name) return re.sub(r'[^a-zA-Z0-9_]', '_', name)
def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTypes: SetOfBadTypenames): def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTypes: SetOfBadTypenames) -> None:
os.system("bash -c '[ ! -f \"" + outputDir + "/" + asnFile + "\" ] && cp \"" + asnFile + "\" \"" + outputDir + "\"'") os.system("bash -c '[ ! -f \"" + outputDir + "/" + asnFile + "\" ] && cp \"" + asnFile + "\" \"" + outputDir + "\"'")
this_path = os.path.dirname(__file__) this_path = os.path.dirname(__file__)
stubs = this_path + os.sep + 'Stubs.py' stubs = this_path + os.sep + 'Stubs.py'
...@@ -181,7 +181,7 @@ clean: ...@@ -181,7 +181,7 @@ clean:
g_outputGetSetH.write('\n/* Helper functions for NATIVE encodings */\n\n') g_outputGetSetH.write('\n/* Helper functions for NATIVE encodings */\n\n')
g_outputGetSetC.write('\n/* Helper functions for NATIVE encodings */\n\n') g_outputGetSetC.write('\n/* Helper functions for NATIVE encodings */\n\n')
def WorkOnType(nodeTypeName: str): def WorkOnType(nodeTypeName: str) -> None:
typ = CleanNameAsPythonWants(nodeTypeName) typ = CleanNameAsPythonWants(nodeTypeName)
g_outputGetSetH.write('void SetDataFor_%s(void *dest, void *src);\n' % typ) g_outputGetSetH.write('void SetDataFor_%s(void *dest, void *src);\n' % typ)
g_outputGetSetH.write("byte* MovePtrBySizeOf_%s(byte *pData);\n" % typ) g_outputGetSetH.write("byte* MovePtrBySizeOf_%s(byte *pData);\n" % typ)
...@@ -226,35 +226,35 @@ clean: ...@@ -226,35 +226,35 @@ clean:
g_outputGetSetC.close() g_outputGetSetC.close()
def OnBasic(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSequence(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSet(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnEnumerated(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSequenceOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnSetOf(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnChoice(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None:
pass pass
def OnShutdown(unused_badTypes): def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None:
pass pass
...@@ -272,7 +272,7 @@ class Params(object): ...@@ -272,7 +272,7 @@ class Params(object):
self._types = [] # type: List[str] self._types = [] # type: List[str]
self._nodeTypeName = nodeTypename self._nodeTypeName = nodeTypename
def AddParam(self, node, varName, unused_leafTypeDict): def AddParam(self, node: str, varName: str, unused_leafTypeDict: AST_Leaftypes) -> bool:
# Handle variable name # Handle variable name
while varName in self._vars: while varName in self._vars:
varName += "_" varName += "_"
...@@ -297,18 +297,24 @@ class Params(object): ...@@ -297,18 +297,24 @@ class Params(object):
# panic("Python_A_mapper: Can't map (%s,%s) to C type\n" % (varName, realLeafType)) # panic("Python_A_mapper: Can't map (%s,%s) to C type\n" % (varName, realLeafType))
# return True # return True
def Pop(self): def Pop(self) -> None:
self._vars.pop() self._vars.pop()
self._types.pop() self._types.pop()
def GetDecl(self): def GetDecl(self) -> str:
params = CleanNameAsPythonWants(self._nodeTypeName) + "* root" params = CleanNameAsPythonWants(self._nodeTypeName) + "* root"
for vvv, ttt in zip(self._vars, self._types): for vvv, ttt in zip(self._vars, self._types):
params += ", " + ttt + " " + vvv params += ", " + ttt + " " + vvv
return params return params
def CommonBaseImpl(comment, ctype, path, params, accessPathInC, postfix="", returnPointer=False): def CommonBaseImpl(comment: str,
ctype: str,
path: str,
params: Params,
accessPathInC: str,
postfix: str="",
returnPointer: bool=False) -> None:
takeAddr = '&' if returnPointer else '' takeAddr = '&' if returnPointer else ''
g_outputGetSetH.write("\n/* %s */\n%s %s_Get%s(%s);\n" % (comment, ctype, path, postfix, params.GetDecl())) g_outputGetSetH.write("\n/* %s */\n%s %s_Get%s(%s);\n" % (comment, ctype, path, postfix, params.GetDecl()))
g_outputGetSetC.write("\n/* %s */\n%s %s_Get%s(%s)\n" % (comment, ctype, path, postfix, params.GetDecl())) g_outputGetSetC.write("\n/* %s */\n%s %s_Get%s(%s)\n" % (comment, ctype, path, postfix, params.GetDecl()))
...@@ -324,7 +330,13 @@ def CommonBaseImpl(comment, ctype, path, params, accessPathInC, postfix="", retu ...@@ -324,7 +330,13 @@ def CommonBaseImpl(comment, ctype, path, params, accessPathInC, postfix="", retu
# def CommonBaseImplSequenceFixed(comment, ctype, path, params, accessPathInC, node, postfix = ""): # def CommonBaseImplSequenceFixed(comment, ctype, path, params, accessPathInC, node, postfix = ""):
def CommonBaseImplSequenceFixed(comment, ctype, path, params, _, node, postfix=""): def CommonBaseImplSequenceFixed(comment: str,
ctype: str,
path: str,
params: Params,
_: str,
node: Union[AsnSequenceOf, AsnSetOf, AsnString],
postfix: str="") -> None:
g_outputGetSetH.write("\n/* %s */\n%s %s_Get%s(%s);\n" % (comment, ctype, path, postfix, params.GetDecl())) g_outputGetSetH.write("\n/* %s */\n%s %s_Get%s(%s);\n" % (comment, ctype, path, postfix, params.GetDecl()))
g_outputGetSetC.write("\n/* %s */\n%s %s_Get%s(%s)\n" % (comment, ctype, path, postfix, params.GetDecl())) g_outputGetSetC.write("\n/* %s */\n%s %s_Get%s(%s)\n" % (comment, ctype, path, postfix, params.GetDecl()))
g_outputGetSetC.write("{\n") g_outputGetSetC.write("{\n")
...@@ -337,7 +349,13 @@ def CommonBaseImplSequenceFixed(comment, ctype, path, params, _, node, postfix=" ...@@ -337,7 +349,13 @@ def CommonBaseImplSequenceFixed(comment, ctype, path, params, _, node, postfix="
g_outputGetSetC.write("}\n") g_outputGetSetC.write("}\n")
def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDict): def CreateGettersAndSetters(
path: str,
params: Params,
accessPathInC: str,
node: AsnNode,
names: AST_Lookup,
leafTypeDict: AST_Leaftypes) -> None:
if isinstance(node, str): if isinstance(node, str):
node = names[node] node = names[node]
if isinstance(node, AsnMetaMember): if isinstance(node, AsnMetaMember):
...@@ -361,7 +379,7 @@ def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDi ...@@ -361,7 +379,7 @@ def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDi
params.Pop() params.Pop()
elif isinstance(node, AsnEnumerated): elif isinstance(node, AsnEnumerated):
CommonBaseImpl("ENUMERATED", "int", path, params, accessPathInC) CommonBaseImpl("ENUMERATED", "int", path, params, accessPathInC)
elif isinstance(node, AsnSequence) or isinstance(node, AsnSet) or isinstance(node, AsnChoice): elif isinstance(node, (AsnSequence, AsnSet, AsnChoice)):
if isinstance(node, AsnChoice): if isinstance(node, AsnChoice):
CommonBaseImpl("CHOICE selector", "int", path + "_kind", params, accessPathInC + ".kind") CommonBaseImpl("CHOICE selector", "int", path + "_kind", params, accessPathInC + ".kind")
union = "" union = ""
...@@ -377,7 +395,7 @@ def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDi ...@@ -377,7 +395,7 @@ def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDi
useStar = '' if baseTypeOfChild.endswith('OF') else '*' useStar = '' if baseTypeOfChild.endswith('OF') else '*'
CommonBaseImpl("Field " + childVarname + " selector", CleanNameAsPythonWants(childNode._containedType) + useStar, path + "_" + childVarname, params, accessPathInC + union + "." + childVarname, returnPointer=not baseTypeOfChild.endswith('OF')) CommonBaseImpl("Field " + childVarname + " selector", CleanNameAsPythonWants(childNode._containedType) + useStar, path + "_" + childVarname, params, accessPathInC + union + "." + childVarname, returnPointer=not baseTypeOfChild.endswith('OF'))
CreateGettersAndSetters(path + "_" + childVarname, params, accessPathInC + union + "." + childVarname, child[1], names, leafTypeDict) CreateGettersAndSetters(path + "_" + childVarname, params, accessPathInC + union + "." + childVarname, child[1], names, leafTypeDict)
elif isinstance(node, AsnSequenceOf) or isinstance(node, AsnSetOf): elif isinstance(node, (AsnSequenceOf, AsnSetOf)):
containedNode = node._containedType containedNode = node._containedType
if isinstance(containedNode, str): if isinstance(containedNode, str):
containedNode = names[containedNode] containedNode = names[containedNode]
...@@ -396,7 +414,7 @@ def DumpTypeDumper( ...@@ -396,7 +414,7 @@ def DumpTypeDumper(
lines: List[str], # pylint: disable=invalid-sequence-index lines: List[str], # pylint: disable=invalid-sequence-index
variableName: str, variableName: str,
node: AsnNode, node: AsnNode,
names: AST_Lookup): names: AST_Lookup) -> None:
''' Return the lines of code needed to display the value of a variable ''' Return the lines of code needed to display the value of a variable
of a given type, in the ASN.1 Value Notation format (aka GSER) ''' of a given type, in the ASN.1 Value Notation format (aka GSER) '''
if isinstance(node, AsnBool): if isinstance(node, AsnBool):
...@@ -481,7 +499,7 @@ def DumpTypeDumper( ...@@ -481,7 +499,7 @@ def DumpTypeDumper(
lines.append(codeIndent + 'lines.append("}")') lines.append(codeIndent + 'lines.append("}")')
def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes): def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> None:
node = names[nodeTypename] node = names[nodeTypename]
name = CleanNameAsPythonWants(nodeTypename) name = CleanNameAsPythonWants(nodeTypename)
if isinstance(node, (AsnBasicNode, AsnEnumerated, AsnSequence, AsnSet, if isinstance(node, (AsnBasicNode, AsnEnumerated, AsnSequence, AsnSet,
...@@ -523,7 +541,7 @@ def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict: ...@@ -523,7 +541,7 @@ def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict:
panic("Unexpected ASN.1 type... Send this grammar to Semantix") # pragma: no cover panic("Unexpected ASN.1 type... Send this grammar to Semantix") # pragma: no cover
def CreateDeclarationsForAllTypes(names, leafTypeDict, badTypes: SetOfBadTypenames): def CreateDeclarationsForAllTypes(names: AST_Lookup, leafTypeDict: AST_Leaftypes, badTypes: SetOfBadTypenames) -> None:
for nodeTypename in names: for nodeTypename in names:
if not names[nodeTypename]._isArtificial and nodeTypename not in badTypes: if not names[nodeTypename]._isArtificial and nodeTypename not in badTypes:
CreateDeclarationForType(nodeTypename, names, leafTypeDict) CreateDeclarationForType(nodeTypename, names, leafTypeDict)
......
...@@ -30,13 +30,17 @@ import sys ...@@ -30,13 +30,17 @@ import sys
import re import re
import distutils.spawn as spawn import distutils.spawn as spawn
from typing import List from typing import List, Union
from ..commonPy import asnParser from ..commonPy import asnParser
from ..commonPy.utility import panic, inform from ..commonPy.utility import panic, inform
from ..commonPy.asnAST import AsnBool, AsnInt, AsnReal, AsnString, AsnEnumerated, AsnSequence, AsnSet, AsnChoice, AsnMetaMember, AsnSequenceOf, AsnSetOf
from ..commonPy.createInternalTypes import ScanChildren from ..commonPy.createInternalTypes import ScanChildren
from ..commonPy.cleanupNodes import SetOfBadTypenames from ..commonPy.cleanupNodes import SetOfBadTypenames
from ..commonPy.asnAST import (
AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnBool, AsnInt,
AsnReal, AsnString, AsnEnumerated, AsnSequence, AsnSet, AsnChoice,
AsnMetaMember, AsnSequenceOf, AsnSetOf, AsnNode)
from ..commonPy.asnParser import AST_Leaftypes, AST_Lookup
# The file written to # The file written to
g_outputFile = None g_outputFile = None
...@@ -49,11 +53,11 @@ g_octetStrings = 0 ...@@ -49,11 +53,11 @@ g_octetStrings = 0
g_bHasStartupRunOnce = False g_bHasStartupRunOnce = False
def Version(): def Version() -> None:
print("Code generator: " + "$Id: qgenada_A_mapper.py $") # pragma: no cover print("Code generator: " + "$Id: qgenada_A_mapper.py $") # pragma: no cover
def CleanNameAsSimulinkWants(name): def CleanNameAsSimulinkWants(name: str) -> str:
return re.sub(r'[^a-zA-Z0-9_]', '_', name) return re.sub(r'[^a-zA-Z0-9_]', '_', name)
...@@ -91,39 +95,39 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, ...@@ -91,39 +95,39 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str,
CreateDeclarationsForAllTypes(asnParser.g_names, asnParser.g_leafTypeDict) CreateDeclarationsForAllTypes(asnParser.g_names, asnParser.g_leafTypeDict)
def OnBasic(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnSequence(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnSet(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover
def OnEnumerated(unused_nodeTypename, unused_node, unused_leafTypeDict): def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None:
pass # pragma: nocover pass # pragma: nocover