Commit 78ea9c98 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

[mypy] More type annotations added.

parent a044a609
......@@ -25,7 +25,10 @@ Base class for all asynchronous tools
import re
import os
from typing import IO, Any # NOQA pylint: disable=unused-import
from ..commonPy.utility import inform, panicWithCallStack
from ..commonPy.asnParser import Typename, AsnNode, AST_Lookup, AST_Leaftypes # NOQA pylint: disable=unused-import
class ASynchronousToolGlueGenerator:
......@@ -57,12 +60,12 @@ class ASynchronousToolGlueGenerator:
def __init__(self):
# The files written to
self.C_HeaderFile = None
self.C_SourceFile = None
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
self.typesToWorkOn = {}
self.useOSS = None # type: bool
self.typesToWorkOn = {} # type: Dict[str, Tuple[Typename, AST_Lookup, AST_Leaftypes]]
def OnStartup(self, modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
self.useOSS = useOSS
......
......@@ -48,7 +48,7 @@ g_IDs = 20000
g_asn_name = ""
g_outputDir = ""
g_maybeFVname = ""
g_perFV = {}
g_perFV = set()
g_langPerSP = {}
......@@ -386,7 +386,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
# have we ever seen before the combination of FVname and Language?
if maybeFVname + modelingLanguage.lower() not in g_perFV:
# No, check for things that must be instantiated once per FV+Lang
g_perFV[maybeFVname + modelingLanguage.lower()] = maybeFVname
g_perFV.add(maybeFVname + modelingLanguage.lower())
# The first time you see an FV with an sp_impl that is also a GUI_PI, create a thread to poll /FVName_PI_queue
if modelingLanguage.lower() == "gui_pi":
......
......@@ -21,10 +21,11 @@
import re
import os
from typing import Set, Dict # NOQA pylint: disable=unused-import
g_HeaderFile = None
g_SourceFile = None
g_PythonFile = None
g_SWIGFile = None
# Python statement list
g_headerPython = []
......@@ -35,8 +36,8 @@ g_footerPython = []
g_asn_name = ""
g_outputDir = ""
g_maybeFVname = ""
g_perFV = {}
g_langPerSP = {}
g_perFV = set() # type: Set[str]
g_langPerSP = {} # type: Dict[str, str]
def CleanName(name):
......@@ -116,26 +117,10 @@ def OnStartup(modelingLanguage, asnFile, subProgram, unused_subProgramImplementa
g_SourceFile.write(" return(message_received_type);\n")
g_SourceFile.write("}\n\n")
global g_SWIGFile # WE CAN REMOVE EVERYTHING RELATED TO g_SWIGFile
if g_SWIGFile is None:
g_SWIGFile = open(outputDir + "python/PythonAccess.i", "w")
g_SWIGFile.write('''%%module PythonAccess
%%{
#include "gui_swig.h"
#include "%(FVname)s_enums_def.h"
%%}
%%include "carrays.i"
%%array_functions(byte,byte_SWIG_PTR)
#include "gui_swig.h"
#include "%(FVname)s_enums_def.h"
''' % {"FVname": maybeFVname})
# have we ever seen before the combination of FVname and Language?
if maybeFVname + modelingLanguage.lower() not in g_perFV:
# No, check for things that must be instantiated once per FV+Lang
g_perFV[maybeFVname + modelingLanguage.lower()] = maybeFVname
g_perFV.add(maybeFVname + modelingLanguage.lower())
# The first time you see an FV with an sp_impl that is also a GUI_PI, create a thread to poll /FVName_PI_queue
if modelingLanguage.lower() == "gui_pi":
......
......@@ -24,6 +24,8 @@ Base class for all synchronous tools
import re
import os
from typing import IO, Any # NOQA pylint: disable=unused-import
from ..commonPy.utility import panic, inform, panicWithCallStack
from ..commonPy.aadlAST import InParam, OutParam, InOutParam
......@@ -79,14 +81,14 @@ class SynchronousToolGlueGenerator:
def __init__(self):
# The files written to
self.C_HeaderFile = None
self.C_SourceFile = None
self.ADA_HeaderFile = None
self.ADA_SourceFile = None
self.C_HeaderFile = None # type: IO[Any]
self.C_SourceFile = None # type: IO[Any]
self.ADA_HeaderFile = None # type: IO[Any]
self.ADA_SourceFile = None # type: IO[Any]
self.asn_name = ""
self.supportedEncodings = ['native', 'uper', 'acn']
self.dir = None
self.useOSS = None
self.dir = None # type: str
self.useOSS = None # type: bool
def OnStartup(self, modelingLanguage, asnFile, subProgram, subProgramImplementation, outputDir, maybeFVname, useOSS):
if modelingLanguage == "QGenAda":
......
......@@ -36,15 +36,14 @@
# support
#
# Charge for Runtimes None None
#
g_signals = {}
g_apLevelContainers = {}
g_subProgramImplementations = []
g_processImplementations = []
g_threadImplementations = []
from typing import Tuple, Dict # NOQA pylint: disable=unused-import
g_apLevelContainers = {} # type: Dict[str, ApLevelContainer]
g_systems = {}
g_subProgramImplementations = [] # type: List[Tuple[str,str,str,str]]
g_processImplementations = [] # type: List[Tuple[str,str,str,str]]
g_threadImplementations = [] # type: List[Tuple[str,str,str,str]]
# AST classes
......@@ -144,31 +143,6 @@ class OutgoingUniPort(UniPort):
UniPort.__init__(self, signal)
class ApLevelContainer:
def __init__(self, iid):
self._id = iid
self._calls = []
self._params = []
self._connections = []
self._language = None
def AddCalledAPLC(self, idAPLC):
self._calls.append(idAPLC)
def AddConnection(self, srcUniquePortId, destUniquePortId):
if srcUniquePortId._componentId is None:
srcUniquePortId._componentId = self._id
if destUniquePortId._componentId is None:
destUniquePortId._componentId = self._id
self._connections.append(Connection(srcUniquePortId, destUniquePortId))
def AddParam(self, param):
self._params.append(param)
def SetLanguage(self, language):
self._language = language
class Param:
def __init__(self, aplcID, iid, signal, sourceElement):
self._id = iid
......@@ -194,6 +168,27 @@ class InOutParam(Param):
Param.__init__(self, aplcID, iid, signal, sourceElement)
class ApLevelContainer:
def __init__(self, iid):
self._id = iid
self._params = [] # type: List[Param]
self._connections = [] # type: List[Connection]
self._language = None # type: str
def AddConnection(self, srcUniquePortId, destUniquePortId):
if srcUniquePortId._componentId is None:
srcUniquePortId._componentId = self._id
if destUniquePortId._componentId is None:
destUniquePortId._componentId = self._id
self._connections.append(Connection(srcUniquePortId, destUniquePortId))
def AddParam(self, param: Param):
self._params.append(param)
def SetLanguage(self, language: str):
self._language = language
class UniquePortIdentifier:
def __init__(self, componentId, portId):
self._componentId = componentId
......
......@@ -36,7 +36,7 @@ class MagicSmp2SimpleTypesDict(dict):
# ---------------------------------------------------------------------------
def has_key(self, name):
name = re.sub(r'/\d{4}/\d{2}/', '/', name)
return name in super(MagicSmp2SimpleTypesDict, self) # pylint: disable=unsupported-membership-test
return name in super(MagicSmp2SimpleTypesDict, self) # type: ignore pylint: disable=unsupported-membership-test
simpleTypesTable = MagicSmp2SimpleTypesDict({
......
Supports Markdown
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