Commit 0bdd5e1f authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

More type annotations.

parent b3e03c41
......@@ -24,16 +24,17 @@
# import re
from ..commonPy import asnParser
from ..commonPy.cleanupNodes import SetOfBadTypenames
g_outputDir = ""
g_asnFile = ""
def Version():
def Version() -> None:
print("Code generator: " + "$Id: og_A_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $") # pragma: no cover
def OnStartup(unused_modelingLanguage, asnFile, outputDir, unused_badTypes):
def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, unused_badTypes: SetOfBadTypenames) -> None:
global g_asnFile
g_asnFile = asnFile
global g_outputDir
......
......@@ -36,6 +36,7 @@ from ..commonPy.asnAST import (
AsnSetOf, AsnSequence, AsnSequenceOf, AsnChoice
)
from ..commonPy import asnParser
from ..commonPy.cleanupNodes import SetOfBadTypenames
g_lookup = {
"INTEGER": "int",
......@@ -63,7 +64,7 @@ g_doc = None
g_Declarations = None
def Version():
def Version() -> None:
print("Code generator: " + "$Id: scade612_A_mapper.py 1842 2010-03-10 14:16:42Z ttsiodras $") # pragma: no cover
......@@ -78,7 +79,7 @@ def RandomHex(digits: int) -> str:
return result
def FixupNestedStringsAndEnumerated():
def FixupNestedStringsAndEnumerated() -> None:
names = asnParser.g_names
leafTypeDict = asnParser.g_leafTypeDict
for nodeTypename in list(names.keys()):
......@@ -102,7 +103,7 @@ def FixupNestedStringsAndEnumerated():
node._containedType = newName # pragma: no cover
def OnStartup(unused_modelingLanguage, asnFile: str, outputDir: str, unused_badTypes) -> None:
def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, unused_badTypes: SetOfBadTypenames) -> None:
outputFilename = CleanNameAsScadeWants(os.path.basename(os.path.splitext(asnFile)[0])) + ".xscade"
FixupNestedStringsAndEnumerated()
......
......@@ -36,38 +36,51 @@ class ASynchronousToolGlueGenerator:
################################################
# Parts to override for each asynchronous tool
def Version(self): # pylint: disable=no-self-use
def Version(self) -> None: # pylint: disable=no-self-use
panicWithCallStack("Method undefined in a ASynchronousToolGlueGenerator...") # pragma: no cover
def HeadersOnStartup(self, unused_asnFile, unused_outputDir, unused_maybeFVname): # pylint: disable=no-self-use
def HeadersOnStartup(self,
unused_asnFile: str,
unused_outputDir: str,
unused_maybeFVname: str) -> None: # pylint: disable=no-self-use
panicWithCallStack("Method undefined in a ASynchronousToolGlueGenerator...") # pragma: no cover
def Encoder(self, unused_nodeTypename, unused_node, unused_leafTypeDict, unused_names, unused_encoding): # pylint: disable=no-self-use
def Encoder(self,
unused_nodeTypename: str,
unused_node: AsnNode,
unused_leafTypeDict: AST_Leaftypes,
unused_names: AST_Lookup,
unused_encoding: str) -> None: # pylint: disable=no-self-use
panicWithCallStack("Method undefined in a ASynchronousToolGlueGenerator...") # pragma: no cover
def Decoder(self, unused_nodeTypename, unused_node, unused_leafTypeDict, unused_names, unused_encoding): # pylint: disable=no-self-use
def Decoder(self,
unused_nodeTypename: str,
unused_node: AsnNode,
unused_leafTypeDict: AST_Leaftypes,
unused_names: AST_Lookup,
unused_encoding: str) -> None: # pylint: disable=no-self-use
panicWithCallStack("Method undefined in a ASynchronousToolGlueGenerator...") # pragma: no cover
########################################################
# Parts to possibly override for each synchronous tool
# noinspection PyMethodMayBeStatic
def CleanNameAsToolWants(self, name): # pylint: disable=no-self-use
def CleanNameAsToolWants(self, name: str) -> str: # pylint: disable=no-self-use
return re.sub(r'[^a-zA-Z0-9_]', '_', name)
##########################################
# Common parts for all asynchronous tools
def __init__(self):
def __init__(self) -> None:
# The files written to
self.C_HeaderFile = None # type: IO[Any]
self.C_SourceFile = None # type: IO[Any]
self.asn_name = ""
self.supportedEncodings = ['native', 'uper', 'acn']
self.useOSS = None # type: bool
self.typesToWorkOn = {} # type: Dict[str, Tuple[Typename, AST_Lookup, AST_Leaftypes]]
self.typesToWorkOn = {} # type: Dict[str, Tuple[AsnNode, AST_Leaftypes, AST_Lookup]]
def OnStartup(self, modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
def OnStartup(self, modelingLanguage: str, asnFile: str, outputDir: str, maybeFVname: str, useOSS: bool) -> None:
self.useOSS = useOSS
prefix = modelingLanguage
if prefix == "SDL":
......@@ -96,9 +109,9 @@ class ASynchronousToolGlueGenerator:
self.HeadersOnStartup(asnFile, outputDir, maybeFVname)
self.typesToWorkOn = {}
self.typesToWorkOn = {} # type: Dict[str, Tuple[AsnNode, AST_Leaftypes, AST_Lookup]]
def Common(self, nodeTypename, node, leafTypeDict, names):
def Common(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
# Async backends are different: they work on ASN.1 types, not SP params.
# OG for example, needs macros to be generated, not functions. This breaks the normal
......@@ -120,37 +133,37 @@ class ASynchronousToolGlueGenerator:
self.Decoder(nodeTypename, node, leafTypeDict, names, 'acn')
self.Decoder(nodeTypename, node, leafTypeDict, names, 'native')
def OnBasic(self, nodeTypename, node, leafTypeDict, names):
def OnBasic(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
realLeafType = leafTypeDict[nodeTypename]
inform(str(self.__class__) + ": BASE: %s (%s)", nodeTypename, realLeafType)
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names]
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names)
def OnSequence(self, nodeTypename, node, leafTypeDict, names):
def OnSequence(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
inform(str(self.__class__) + ": SEQUENCE: %s", nodeTypename)
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names]
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names)
def OnSet(self, nodeTypename, node, leafTypeDict, names):
def OnSet(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
inform(str(self.__class__) + ": SET: %s", nodeTypename) # pragma: nocover
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names] # pragma: nocover
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names) # pragma: nocover
def OnEnumerated(self, nodeTypename, node, leafTypeDict, names):
def OnEnumerated(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
inform(str(self.__class__) + ": ENUMERATED: %s", nodeTypename)
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names]
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names)
def OnSequenceOf(self, nodeTypename, node, leafTypeDict, names):
def OnSequenceOf(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
inform(str(self.__class__) + ": SEQUENCEOF: %s", nodeTypename)
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names]
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names)
def OnSetOf(self, nodeTypename, node, leafTypeDict, names):
def OnSetOf(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
inform(str(self.__class__) + ": SETOF: %s", nodeTypename) # pragma: nocover
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names] # pragma: nocover
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names) # pragma: nocover
def OnChoice(self, nodeTypename, node, leafTypeDict, names):
def OnChoice(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
inform(str(self.__class__) + ": CHOICE: %s", nodeTypename)
self.typesToWorkOn[nodeTypename] = [node, leafTypeDict, names]
self.typesToWorkOn[nodeTypename] = (node, leafTypeDict, names)
def OnShutdown(self, unused_modelingLanguage, unused_asnFile, unused_maybeFVname):
for nodeTypename, value in list(self.typesToWorkOn.items()):
def OnShutdown(self, unused_modelingLanguage: str, unused_asnFile: str, unused_maybeFVname: str) -> None:
for nodeTypename, value in self.typesToWorkOn.items():
inform(str(self.__class__) + "Really working on " + nodeTypename)
(node, leafTypeDict, names) = value
self.Common(nodeTypename, node, leafTypeDict, names)
......
This diff is collapsed.
......@@ -48,14 +48,13 @@ def CleanName(name: str) -> str:
# Called once per RI (i.e. per SUBPROGRAM IMPLEMENTATION)
def OnStartup(
modelingLanguage: str,
asnFile: str,
subProgram: ApLevelContainer,
unused_subProgramImplementation: str,
outputDir: str,
maybeFVname: str,
unused_useOSS: bool) -> None:
def OnStartup(modelingLanguage: str,
asnFile: str,
subProgram: ApLevelContainer,
unused_subProgramImplementation: str,
outputDir: str,
maybeFVname: str,
unused_useOSS: bool) -> None:
g_langPerSP[subProgram] = modelingLanguage
CleanSP = CleanName(subProgram._id)
......@@ -241,39 +240,39 @@ def Common(unused_nodeTypename: str, unused_node: AsnNode, unused_subProgram: Ap
pass
def OnBasic(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnBasic(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSequence(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnSequence(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSet(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnSet(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
def OnEnumerated(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnEnumerated(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSequenceOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnSequenceOf(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSetOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnSetOf(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
def OnChoice(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names):
def OnChoice(nodeTypename: str, node: AsnNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnShutdown(unused_modelingLanguage, unused_asnFile, unused_sp, unused_subProgramImplementation, unused_maybeFVname):
def OnShutdown(unused_modelingLanguage: str, unused_asnFile: str, unused_sp: ApLevelContainer, unused_subProgramImplementation: str, unused_maybeFVname: str) -> None:
pass
def OnFinal():
def OnFinal() -> None:
g_HeaderFile.write("\n#endif\n")
g_PythonFile.write('\n'.join(g_headerPython))
g_PythonFile.write('\n\n')
......
......@@ -91,8 +91,8 @@ hpredef.h :
from typing import Set # NOQA pylint: disable=unused-import
from ..commonPy.asnAST import isSequenceVariable, sourceSequenceLimit, AsnInt, AsnBool, AsnReal, AsnEnumerated
from ..commonPy.asnParser import Typename # NOQA pylint: disable=unused-import
from ..commonPy.asnAST import isSequenceVariable, sourceSequenceLimit, AsnInt, AsnBool, AsnReal, AsnEnumerated, AsnNode, AsnOctetString
from ..commonPy.asnParser import Typename, AST_Lookup, AST_Leaftypes # NOQA pylint: disable=unused-import
from ..commonPy.recursiveMapper import RecursiveMapper
from .asynchronousTool import ASynchronousToolGlueGenerator
......@@ -101,33 +101,33 @@ isAsynchronous = True
ogBackend = None
def Version():
def Version() -> None:
print(("Code generator: " + "$Id: og_B_mapper.py 2390 2012-07-19 12:39:17Z ttsiodras $"))
# noinspection PyListCreation
# pylint: disable=no-self-use
class FromObjectGeodeToASN1SCC(RecursiveMapper):
def __init__(self):
def __init__(self) -> None:
self.uniqueID = 0
def UniqueID(self):
def UniqueID(self) -> int:
self.uniqueID += 1
return self.uniqueID
def DecreaseUniqueID(self):
def DecreaseUniqueID(self) -> None:
self.uniqueID -= 1
def MapInteger(self, srcSDLVariable, destVar, _, __, ___):
def MapInteger(self, srcSDLVariable: str, destVar: str, _: AsnNode, __: AST_Leaftypes, ___: AST_Lookup) -> List[str]:
return ["%s = (asn1SccSint) %s;\n" % (destVar, srcSDLVariable)]
def MapReal(self, srcSDLVariable, destVar, _, __, ___):
def MapReal(self, srcSDLVariable: str, destVar: str, _: AsnNode, __: AST_Leaftypes, ___: AST_Lookup) -> List[str]:
return ["%s = (double)%s;\n" % (destVar, srcSDLVariable)]
def MapBoolean(self, srcSDLVariable, destVar, _, __, ___):
def MapBoolean(self, srcSDLVariable: str, destVar: str, _: AsnNode, __: AST_Leaftypes, ___: AST_Lookup) -> List[str]:
return ["%s = (%s==SDL_TRUE)?0xff:0;\n" % (destVar, srcSDLVariable)]
def MapOctetString(self, srcSDLVariable, destVar, node, __, ___):
def MapOctetString(self, srcSDLVariable: str, destVar: str, node: AsnOctetString, __: AST_Leaftypes, ___: AST_Lookup) -> List[str]:
lines = [] # type: List[str]
lines.append("{\n")
lines.append(" int i;\n")
......@@ -150,10 +150,10 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
lines.append("}\n")
return lines
def MapEnumerated(self, srcSDLVariable, destVar, _, __, ___):
def MapEnumerated(self, srcSDLVariable: str, destVar: str, _: AsnNode, __: AST_Leaftypes, ___: AST_Lookup) -> List[str]:
return ["%s = %s;\n" % (destVar, srcSDLVariable)]
def MapSequence(self, srcSDLVariable, destVar, node, leafTypeDict, names):
def MapSequence(self, srcSDLVariable, destVar, node, leafTypeDict, names) -> List[str]:
lines = [] # type: List[str]
for child in node._members:
lines.extend(
......@@ -165,10 +165,10 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
names))
return lines
def MapSet(self, srcSDLVariable, destVar, node, leafTypeDict, names):
def MapSet(self, srcSDLVariable: str, destVar: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> List[str]:
return self.MapSequence(srcSDLVariable, destVar, node, leafTypeDict, names) # pragma: nocover
def MapChoice(self, srcSDLVariable, destVar, node, leafTypeDict, names):
def MapChoice(self, srcSDLVariable: str, destVar: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> List[str]:
lines = [] # type: List[str]
childNo = 0
for child in node._members:
......@@ -186,7 +186,7 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
lines.append("}\n")
return lines
def MapSequenceOf(self, srcSDLVariable, destVar, node, leafTypeDict, names):
def MapSequenceOf(self, srcSDLVariable: str, destVar: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> List[str]:
lines = [] # type: List[str]
lines.append("{\n")
uniqueId = self.UniqueID()
......@@ -207,7 +207,7 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
self.DecreaseUniqueID()
return lines
def MapSetOf(self, srcSDLVariable, destVar, node, leafTypeDict, names):
def MapSetOf(self, srcSDLVariable: str, destVar: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> List[str]:
return self.MapSequenceOf(srcSDLVariable, destVar, node, leafTypeDict, names) # pragma: nocover
......
......@@ -17,7 +17,7 @@ from . import cleanupNodes
__version__ = "2.0.2"
def print_version():
def print_version() -> None:
print("TASTE Data Modelling Tools version {}\n\n"
"The following tools are available:\n"
" asn2aadlPlus - Convert ASN.1 models to AADL\n"
......
......@@ -61,9 +61,8 @@ def ScanChildren(
node: AsnNode,
names: Dict[str, AsnNode],
results: List[str], # pylint: disable=invalid-sequence-index
isRoot=False,
createInnerNodesInNames=True):
isRoot: bool=False,
createInnerNodesInNames: bool=True) -> None:
'''
Find all the types that this one (nodeTypename, node) depends on.
and return them in the 'results' list. Use 'names' to lookup
......
......@@ -24,7 +24,8 @@ from typing import Union, List, Dict, TypeVar, Generic
from .utility import panicWithCallStack
from .asnAST import (
AsnBasicNode, AsnSequence, AsnSet, AsnChoice, AsnSequenceOf,
AsnSetOf, AsnEnumerated, AsnMetaMember, AsnNode
AsnSetOf, AsnEnumerated, AsnMetaMember, AsnNode, AsnInt, AsnReal, AsnBool,
AsnOctetString
)
from .asnParser import AST_Leaftypes, AST_Lookup
......@@ -48,34 +49,34 @@ class RecursiveMapperGeneric(Generic[TSrc, TDest]):
def Version(self) -> None: # pylint: disable=no-self-use
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapInteger(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapInteger(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnInt, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapReal(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapReal(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnReal, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapBoolean(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapBoolean(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnBool, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapOctetString(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapOctetString(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnOctetString, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapEnumerated(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapEnumerated(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapSequence(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapSequence(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSequence, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapSet(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapSet(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSet, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapChoice(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapChoice(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapSequenceOf(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapSequenceOf(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSequenceOf, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def MapSetOf(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
def MapSetOf(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSetOf, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index
panicWithCallStack("Method undefined in a RecursiveMapper...")
def Map(self,
......@@ -89,18 +90,14 @@ class RecursiveMapperGeneric(Generic[TSrc, TDest]):
else:
node = node_or_str
lines = [] # type: List[str]
if isinstance(node, AsnBasicNode):
realLeafType = leafTypeDict[node._leafType]
if realLeafType == "INTEGER":
lines.extend(self.MapInteger(srcVar, destVar, node, leafTypeDict, names))
elif realLeafType == "REAL":
lines.extend(self.MapReal(srcVar, destVar, node, leafTypeDict, names))
elif realLeafType == "BOOLEAN":
lines.extend(self.MapBoolean(srcVar, destVar, node, leafTypeDict, names))
elif realLeafType == "OCTET STRING":
lines.extend(self.MapOctetString(srcVar, destVar, node, leafTypeDict, names))
else:
panicWithCallStack("Basic type %s can't be mapped..." % realLeafType)
if isinstance(node, AsnInt):
lines.extend(self.MapInteger(srcVar, destVar, node, leafTypeDict, names))
elif isinstance(node, AsnReal):
lines.extend(self.MapReal(srcVar, destVar, node, leafTypeDict, names))
elif isinstance(node, AsnBool):
lines.extend(self.MapBoolean(srcVar, destVar, node, leafTypeDict, names))
elif isinstance(node, AsnOctetString):
lines.extend(self.MapOctetString(srcVar, destVar, node, leafTypeDict, names))
elif isinstance(node, AsnSequence):
lines.extend(self.MapSequence(srcVar, destVar, node, leafTypeDict, names))
elif isinstance(node, AsnSet):
......
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