Commit 91120d54 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

flake8 pass over the B mappers

parent 1fd4855f
......@@ -312,10 +312,10 @@ def OnStartup(unused_modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
global cBackend
# 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada)
# we no longer need these Ada-specific Dumpable structures.
#global adaBackend
#adaBackend = Ada_GlueGenerator()
# global adaBackend
# adaBackend = Ada_GlueGenerator()
cBackend = c_B_mapper.C_GlueGenerator()
#adaBackend.OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS)
# adaBackend.OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS)
cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS)
......
......@@ -8,7 +8,7 @@ import sys
def main():
if len(sys.argv)>1:
if len(sys.argv) > 1:
L = AadlLexer.Lexer(sys.argv[1])
else:
L = AadlLexer.Lexer()
......
......@@ -18,7 +18,7 @@
# Note that in both cases, there are no charges (royalties) for the
# generated code.
#
__doc__ = '''
'''
Base class for all asynchronous tools
'''
......@@ -117,31 +117,31 @@ class ASynchronousToolGlueGenerator:
def OnBasic(self, nodeTypename, node, leafTypeDict, names):
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):
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):
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):
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):
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):
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):
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()):
......
......@@ -253,13 +253,13 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_HeaderFile.write(needDefine)
self.C_HeaderFile.write(
"size_t %s(void *pBuffer, size_t iMaxBufferSize, %sasn1Scc%s *pSrc);\n" %
(tmpSpName, "" if encoding.lower()=="acn" else "const ",
(tmpSpName, "" if encoding.lower() == "acn" else "const ",
self.CleanNameAsToolWants(nodeTypename)))
self.C_HeaderFile.write("#endif\n\n")
self.C_SourceFile.write(needDefine)
self.C_SourceFile.write(
"size_t %s(void *pBuffer, size_t iMaxBufferSize, %sasn1Scc%s *pSrc)\n{\n" %
(tmpSpName, "" if encoding.lower()=="acn" else "const ",
(tmpSpName, "" if encoding.lower() == "acn" else "const ",
self.CleanNameAsToolWants(nodeTypename)))
if self.useOSS and encoding.lower() == "uper":
......@@ -307,7 +307,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
elif encoding.lower() in ["uper", "acn"]:
self.C_SourceFile.write(" if (asn1Scc%s_%sEncode(pSrc, &strm, &errorCode, TRUE) == FALSE) {\n" %
(self.CleanNameAsToolWants(nodeTypename),
("ACN_" if encoding.lower()=="acn" else "")))
("ACN_" if encoding.lower() == "acn" else "")))
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d\\n", __FILE__, __LINE__, errorCode);\n' % (nodeTypename))
self.C_SourceFile.write(" return -1;\n")
......@@ -365,7 +365,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_SourceFile.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\n\n")
self.C_SourceFile.write(" if (asn1Scc%s_%sDecode(pDst, &strm, &errorCode)) {\n" %
(self.CleanNameAsToolWants(nodeTypename),
"ACN_" if encoding.lower()=="acn" else ""))
"ACN_" if encoding.lower() == "acn" else ""))
self.C_SourceFile.write(" /* Decoding succeeded */\n")
elif encoding.lower() == "native":
self.C_SourceFile.write(" *pDst = *(asn1Scc%s *) pBuffer;\n {\n" %
......
This diff is collapsed.
......@@ -138,8 +138,8 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.arr[i] = value;\n" % destVar)
lines.append(" }\n")
#for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
# for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
if isSequenceVariable(node):
lines.append(" %s.nCount = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n")
......@@ -238,8 +238,8 @@ class FromObjectGeodeToOSS(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.value[i] = value;\n" % destVar)
lines.append(" }\n")
#for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
# for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
lines.append(" %s.length = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n")
return lines
......@@ -321,8 +321,8 @@ class FromASN1SCCtoObjectGeode(RecursiveMapper):
return ["%s = (%s)?SDL_TRUE:SDL_FALSE;\n" % (dstSDLVariable, srcVar)]
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines = []
limit = sourceSequenceLimit(node, srcVar)
lines.append("{\n")
......@@ -435,8 +435,8 @@ class FromOSStoObjectGeode(RecursiveMapper):
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
lines = []
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines.append("{\n")
lines.append(" int i;\n")
lines.append(" for(i=0; i<%s.length; i++) {\n" % srcVar)
......@@ -593,7 +593,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
fileOutHeader.write(
"\\\n BitStream_Init(&strm, varName, asn1Scc%s_REQUIRED_BYTES_FOR_%sENCODING);\\\n" %
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower()=="acn" else ""))
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower() == "acn" else ""))
else:
fileOutHeader.write(
" STATIC asn1Scc%s var_%s;\\\n" %
......@@ -605,7 +605,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
# Write the mapping code for the message
if self.useOSS and encoding.lower() == "uper":
lines = self.FromObjectGeodeToOSS.Map(
#(isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
# (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
"(param1)",
"var_" + self.CleanNameAsToolWants(nodeTypename),
node,
......@@ -613,7 +613,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
names)
else:
lines = self.FromObjectGeodeToASN1SCC.Map(
#(isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
# (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
"(param1)",
"var_" + self.CleanNameAsToolWants(nodeTypename),
node,
......@@ -715,7 +715,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
fileOutHeader.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\\\n")
fileOutHeader.write(
" if(asn1Scc%s_%sDecode(&var_%s, &strm, &errorCode)) {\\\n" %
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower()=="acn" else "", self.CleanNameAsToolWants(nodeTypename)))
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower() == "acn" else "", self.CleanNameAsToolWants(nodeTypename)))
else:
fileOutHeader.write(
" STATIC asn1Scc%s var_%s;\\\n" %
......@@ -728,8 +728,8 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
fileOutHeader.write(" {\\\n")
#dstSDLVariable = (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(pSdlVar)" or "(*(pSdlVar))"
#dstSDLVariable = (isinstance(node, AsnInt)) and "(pSdlVar)" or "(*(pSdlVar))"
# dstSDLVariable = (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(pSdlVar)" or "(*(pSdlVar))"
# dstSDLVariable = (isinstance(node, AsnInt)) and "(pSdlVar)" or "(*(pSdlVar))"
dstSDLVariable = "(*(pSdlVar))"
if self.useOSS and encoding.lower() == "uper":
......@@ -770,9 +770,9 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
fileOutHeader.write(" }\\\n")
fileOutHeader.write("}\n\n")
#fileOutHeader.write(
# "#define DECODE_%s(pBuffer, iBufferSize, pSdlVar) DECODE_UPER_%s(pBuffer, iBufferSize, pSdlVar)\n\n" %
# (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
# fileOutHeader.write(
# "#define DECODE_%s(pBuffer, iBufferSize, pSdlVar) DECODE_UPER_%s(pBuffer, iBufferSize, pSdlVar)\n\n" %
# (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
def OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
......
This diff is collapsed.
......@@ -200,7 +200,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, unused_subProgramImplementa
for param in subProgram._params:
nodeTypename = param._signal._asnNodename
CleanParam = CleanName(param._id)
#parms.append("%s *p_%s" % (CleanName(nodeTypename), CleanParam))
# parms.append("%s *p_%s" % (CleanName(nodeTypename), CleanParam))
parms.append("void *p_%s" % (CleanParam))
g_HeaderFile.write('int SendTC_%s(%s);\n' % (CleanSP, ",".join(parms)))
g_SourceFile.write('int SendTC_%s(%s)\n' % (CleanSP, ",".join(parms)))
......@@ -209,7 +209,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, unused_subProgramImplementa
g_SourceFile.write(' if (((mqd_t)-2) == q) {\n')
g_SourceFile.write(' static char QName[1024];\n')
g_SourceFile.write(' sprintf(QName, "%%d_%s_RI_queue", geteuid());\n' % cleanFVname)
#g_SourceFile.write(' q = mq_open(QName, O_RDWR | O_NONBLOCK);\n')
# g_SourceFile.write(' q = mq_open(QName, O_RDWR | O_NONBLOCK);\n')
g_SourceFile.write(' open_exchange_queue_for_writing(QName, &q);\n')
g_SourceFile.write(' }\n')
g_SourceFile.write(' %s_TCDATA data;\n' % CleanSP)
......
......@@ -60,10 +60,10 @@ def OnStartup(unused_modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
global cBackend
# 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada)
# we no longer need these Ada-specific Dumpable structures.
#global adaBackend
#adaBackend = Ada_GlueGenerator()
# global adaBackend
# adaBackend = Ada_GlueGenerator()
cBackend = c_B_mapper.C_GlueGenerator()
#adaBackend.OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS)
# adaBackend.OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS)
cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS)
......
......@@ -79,8 +79,8 @@ class FromQGenCToASN1SCC(RecursiveMapper):
if isSequenceVariable(node):
lines.append("%s.nCount = %s.length;\n" % (destVar, srcQGenC))
# No nCount anymore
#else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
# else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
return lines
def MapEnumerated(self, srcQGenC, destVar, _, __, ___):
......@@ -132,8 +132,8 @@ class FromQGenCToASN1SCC(RecursiveMapper):
if isSequenceVariable(node):
lines.append("%s.nCount = %s.length;\n" % (destVar, srcQGenC))
# No nCount anymore
#else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
# else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
return lines
def MapSetOf(self, srcQGenC, destVar, node, leafTypeDict, names):
......@@ -159,7 +159,7 @@ class FromASN1SCCtoQGenC(RecursiveMapper):
for i in range(0, node._range[-1]):
lines.append("if (%s>=%d) %s.element_data[%d] = %s.arr[%d]; else %s.element_data[%d] = 0;\n" %
(limit, i+1, dstQGenC, i, srcVar, i, dstQGenC, i))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s;\n" % (dstQGenC, limit))
return lines
......@@ -235,7 +235,7 @@ class FromQGenCToOSS(RecursiveMapper):
panicWithCallStack("OCTET STRING (in %s) must have a SIZE constraint inside ASN.1,\nor else we can't generate C code!" % node.Location()) # pragma: no cover
for i in range(0, node._range[-1]):
lines.append("%s.value[%d] = %s.element_data[%d];\n" % (destVar, i, srcQGenC, i))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s.length;\n" % (destVar, srcQGenC))
else:
lines.append("%s.length = %s;\n" % (destVar, node._range[-1]))
......@@ -287,7 +287,7 @@ class FromQGenCToOSS(RecursiveMapper):
node._containedType,
leafTypeDict,
names))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.count = %s.length;\n" % (destVar, srcQGenC))
else:
lines.append("%s.count = %s;\n" % (destVar, node._range[-1]))
......@@ -314,7 +314,7 @@ class FromOSStoQGenC(RecursiveMapper):
for i in range(0, node._range[-1]):
lines.append("if (%s.length >= %d) %s.element_data[%d] = %s.value[%d]; else %s.element_data[%d] = 0;\n" %
(srcVar, i+1, dstQGenC, i, srcVar, i, dstQGenC, i))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s.length;" % (dstQGenC, srcVar))
return lines
......@@ -366,7 +366,7 @@ class FromOSStoQGenC(RecursiveMapper):
node._containedType,
leafTypeDict,
names))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s.count;\n" % (dstQGenC, srcVar))
return lines
......
......@@ -18,7 +18,7 @@
# Note that in both cases, there are no charges (royalties) for the
# generated code.
#
__doc__ = '''
'''
This is the code generator for the PragmaDev RTDS code mappers.
This backend is called by aadl2glueC, when an RTDS subprogram
is identified in the input concurrency view.
......@@ -72,8 +72,8 @@ class FromRTDSToASN1SCC(RecursiveMapper):
lines.append(" for(i=0; i<%s.__length; i++) {\n" % srcSDLVariable)
lines.append(" %s.arr[i] = %s.__string[i];\n" % (destVar, srcSDLVariable))
lines.append(" }\n")
#for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
# for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
if isSequenceVariable(node):
lines.append(" %s.nCount = %s.__length;\n" % (destVar, srcSDLVariable))
lines.append("}\n")
......@@ -172,8 +172,8 @@ class FromRTDSToOSS(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.value[i] = value;\n" % destVar)
lines.append(" }\n")
#for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
# for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
lines.append(" %s.length = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n")
return lines
......@@ -255,8 +255,8 @@ class FromASN1SCCtoRTDS(RecursiveMapper):
return ["%s = (%s)?TRUE:FALSE;\n" % (dstSDLVariable, srcVar)]
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines = []
limit = sourceSequenceLimit(node, srcVar)
lines.append("{\n")
......@@ -352,8 +352,8 @@ class FromOSStoRTDS(RecursiveMapper):
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
lines = []
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines.append("{\n")
lines.append(" int i;\n")
lines.append(" for(i=0; i<%s.length; i++) {\n" % srcVar)
......@@ -466,18 +466,13 @@ class RTDS_GlueGenerator(ASynchronousToolGlueGenerator):
isPointer = True
if isinstance(node, AsnBasicNode) or isinstance(node, AsnEnumerated):
isPointer = False
cleaned = self.CleanNameAsToolWants(nodeTypename)
fileOutHeader.write(
"void Convert_%s_from_RTDS_to_ASN1SCC(asn1Scc%s *ptrASN1SCC, %s %sRTDS);\n" %
(self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename),
"*" if isPointer else ""))
(cleaned, cleaned, cleaned, "*" if isPointer else ""))
fileOutSource.write(
"void Convert_%s_from_RTDS_to_ASN1SCC(asn1Scc%s *ptrASN1SCC, %s %sRTDS)\n{\n" %
(self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename),
"*" if isPointer else ""))
(cleaned, cleaned, cleaned, "*" if isPointer else ""))
# Write the mapping code for the message
if self.useOSS:
......@@ -504,17 +499,14 @@ class RTDS_GlueGenerator(ASynchronousToolGlueGenerator):
return
fileOutHeader = self.C_HeaderFile
fileOutSource = self.C_SourceFile
cleaned = self.CleanNameAsToolWants(nodeTypename)
fileOutHeader.write(
"void Convert_%s_from_ASN1SCC_to_RTDS(%s *ptrRTDS, const asn1Scc%s *ptrASN1SCC);\n" %
(self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename)))
(cleaned, cleaned, cleaned))
fileOutSource.write(
"void Convert_%s_from_ASN1SCC_to_RTDS(%s *ptrRTDS, const asn1Scc%s *ptrASN1SCC)\n{\n" %
(self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename)))
(cleaned, cleaned, cleaned))
if self.useOSS:
lines = self.FromOSStoRTDS.Map(
......
......@@ -47,8 +47,8 @@ scadeBackend = None
def Version():
print("Code generator: " + \
"$Id: scade6_B_mapper.py 2390 2012-07-19 12:39:17Z ttsiodras $")
print("Code generator: " +
"$Id: scade6_B_mapper.py 2390 2012-07-19 12:39:17Z ttsiodras $")
class FromSCADEtoASN1SCC(RecursiveMapper):
......@@ -151,8 +151,8 @@ class FromASN1SCCtoSCADE(RecursiveMapper):
"inside ASN.1,\nor else SCADE can't generate C code!" % node.Location()) # pragma: no cover
lines = []
limit = sourceSequenceLimit(node, srcVar)
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstScadeMacro, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstScadeMacro, i, srcVar, i))
lines.append("{\n")
lines.append(" int i;\n")
lines.append(" for(i=0; i<%s; i++) %s[i] = %s.arr[i];\n" % (limit, dstScadeMacro, srcVar))
......@@ -373,7 +373,7 @@ class FromOSStoSCADE(RecursiveMapper):
lines.append("{\n")
lines.append(" int i%d;\n" % seqIndex)
lines.append(" for(i%d=0; i%d<%s.count; i%d++) {\n" % (seqIndex, seqIndex, srcVar, seqIndex))
#for i in xrange(0, node._range[-1]):
# for i in xrange(0, node._range[-1]):
lines.extend([" "+x for x in self.Map(
srcVar + ".value[i%d]" % seqIndex,
"%s[i%d]" % (dstScadeMacro, seqIndex),
......@@ -415,10 +415,10 @@ class ScadeGlueGenerator(SynchronousToolGlueGenerator):
"#include \"%s.h\" // Space certified compiler generated\n\n" % self.asn_name)
self.C_SourceFile.write("#include \"%s\"\n\n" % (self.CleanNameAsToolWants(maybeFVname) + ".h"))
# Declare and define staging inputs and outputs
#self.C_SourceFile.write("AADL2SCADE_%s_%s_DECLARE(var_%s_%s);\n\n" % \
# (subProgram._id, subProgramImplementation, subProgram._id, subProgramImplementation))
#self.C_SourceFile.write("AADL2SCADE_%s_%s_DEFINE(var_%s_%s);\n\n" % \
# (subProgram._id, subProgramImplementation, subProgram._id, subProgramImplementation))
# self.C_SourceFile.write("AADL2SCADE_%s_%s_DECLARE(var_%s_%s);\n\n" % \
# (subProgram._id, subProgramImplementation, subProgram._id, subProgramImplementation))
# self.C_SourceFile.write("AADL2SCADE_%s_%s_DEFINE(var_%s_%s);\n\n" % \
# (subProgram._id, subProgramImplementation, subProgram._id, subProgramImplementation))
for param in subProgram._params:
self.C_SourceFile.write("%s %s;\n" % (self.CleanNameAsToolWants(param._signal._asnNodename), param._id))
self.C_SourceFile.write("\n")
......@@ -426,15 +426,15 @@ class ScadeGlueGenerator(SynchronousToolGlueGenerator):
def SourceVar(self, unused_nodeTypename, unused_encoding, unused_node, subProgram, subProgramImplementation, param, unused_leafTypeDict, unused_names):
if isinstance(param._sourceElement, AadlPort): # Both AadlPort and AadlEventDataPort
panic("Unsupported old construct") # pragma: no cover
#srcScadeMacro = "AADL2SCADE_OUTPUT_DATA_PORT(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
# srcScadeMacro = "AADL2SCADE_OUTPUT_DATA_PORT(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
elif isinstance(param._sourceElement, AadlParameter):
#srcScadeMacro = "AADL2SCADE_OUTPUT_PARAMETER(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
# srcScadeMacro = "AADL2SCADE_OUTPUT_PARAMETER(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
srcScadeMacro = self.CleanNameAsToolWants(param._id)
else: # pragma: no cover
panic(str(self.__class__) + ": %s not supported (yet?)\n" % str(param._sourceElement)) # pragma: no cover
......@@ -443,15 +443,15 @@ class ScadeGlueGenerator(SynchronousToolGlueGenerator):
def TargetVar(self, unused_nodeTypename, unused_encoding, unused_node, subProgram, subProgramImplementation, param, unused_leafTypeDict, unused_names):
if isinstance(param._sourceElement, AadlPort): # Both AadlPort and AadlEventDataPort
panic("Unsupported old construct") # pragma: no cover
#dstScadeMacro = "AADL2SCADE_INPUT_DATA_PORT(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
# dstScadeMacro = "AADL2SCADE_INPUT_DATA_PORT(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
elif isinstance(param._sourceElement, AadlParameter):
#dstScadeMacro = "AADL2SCADE_INPUT_PARAMETER(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
# dstScadeMacro = "AADL2SCADE_INPUT_PARAMETER(var_%s, %s, %s)" % \
# (self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(subProgram._id + "_" + subProgramImplementation),
# self.CleanNameAsToolWants(param._id).upper())
dstScadeMacro = self.CleanNameAsToolWants(param._id)
else: # pragma: no cover
panic(str(self.__class__) + ": %s not supported (yet?)\n" % str(param._sourceElement)) # pragma: no cover
......
......@@ -138,8 +138,8 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.arr[i] = value;\n" % destVar)
lines.append(" }\n")
#for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
# for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
if isSequenceVariable(node):
lines.append(" %s.nCount = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n")
......@@ -238,8 +238,8 @@ class FromObjectGeodeToOSS(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.value[i] = value;\n" % destVar)
lines.append(" }\n")
#for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
# for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
lines.append(" %s.length = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n")
return lines
......@@ -321,8 +321,8 @@ class FromASN1SCCtoObjectGeode(RecursiveMapper):
return ["%s = (%s)?SDL_TRUE:SDL_FALSE;\n" % (dstSDLVariable, srcVar)]
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines = []
limit = sourceSequenceLimit(node, srcVar)
lines.append("{\n")
......@@ -435,8 +435,8 @@ class FromOSStoObjectGeode(RecursiveMapper):
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
lines = []
#for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
# for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines.append("{\n")
lines.append(" int i;\n")
lines.append(" for(i=0; i<%s.length; i++) {\n" % srcVar)
......@@ -593,7 +593,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
fileOutHeader.write(
"\\\n BitStream_Init(&strm, varName, asn1Scc%s_REQUIRED_BYTES_FOR_%sENCODING);\\\n" %
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower()=="acn" else ""))
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower() == "acn" else ""))
else:
fileOutHeader.write(
" STATIC asn1Scc%s var_%s;\\\n" %
......@@ -605,7 +605,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
# Write the mapping code for the message
if self.useOSS and encoding.lower() == "uper":
lines = self.FromObjectGeodeToOSS.Map(
#(isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
# (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
"(param1)",
"var_" + self.CleanNameAsToolWants(nodeTypename),
node,
......@@ -613,7 +613,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
names)
else:
lines = self.FromObjectGeodeToASN1SCC.Map(
#(isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
# (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(param1)" or "(*(param1))",
"(param1)",
"var_" + self.CleanNameAsToolWants(nodeTypename),
node,
......@@ -715,7 +715,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
fileOutHeader.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\\\n")
fileOutHeader.write(
" if(asn1Scc%s_%sDecode(&var_%s, &strm, &errorCode)) {\\\n" %
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower()=="acn" else "", self.CleanNameAsToolWants(nodeTypename)))
(self.CleanNameAsToolWants(nodeTypename), "ACN_" if encoding.lower() == "acn" else "", self.CleanNameAsToolWants(nodeTypename)))
else:
fileOutHeader.write(
" STATIC asn1Scc%s var_%s;\\\n" %
......@@ -728,8 +728,8 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
fileOutHeader.write(" {\\\n")
#dstSDLVariable = (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(pSdlVar)" or "(*(pSdlVar))"
#dstSDLVariable = (isinstance(node, AsnInt)) and "(pSdlVar)" or "(*(pSdlVar))"
# dstSDLVariable = (isinstance(node, AsnInt) or isinstance(node, AsnBool)) and "(pSdlVar)" or "(*(pSdlVar))"
# dstSDLVariable = (isinstance(node, AsnInt)) and "(pSdlVar)" or "(*(pSdlVar))"
dstSDLVariable = "(*(pSdlVar))"
if self.useOSS and encoding.lower() == "uper":
......@@ -770,9 +770,9 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
fileOutHeader.write(" }\\\n")
fileOutHeader.write("}\n\n")
#fileOutHeader.write(
# "#define DECODE_%s(pBuffer, iBufferSize, pSdlVar) DECODE_UPER_%s(pBuffer, iBufferSize, pSdlVar)\n\n" %
# (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
# fileOutHeader.write(
# "#define DECODE_%s(pBuffer, iBufferSize, pSdlVar) DECODE_UPER_%s(pBuffer, iBufferSize, pSdlVar)\n\n" %
# (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
def OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
......
......@@ -76,8 +76,8 @@ class FromSimulinkToASN1SCC(RecursiveMapper):
if isSequenceVariable(node):
lines.append("%s.nCount = %s.length;\n" % (destVar, srcSimulink))
# No nCount anymore
#else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
# else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
return lines
def MapEnumerated(self, srcSimulink, destVar, _, __, ___):
......@@ -129,8 +129,8 @@ class FromSimulinkToASN1SCC(RecursiveMapper):
if isSequenceVariable(node):
lines.append("%s.nCount = %s.length;\n" % (destVar, srcSimulink))
# No nCount anymore
#else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
# else:
# lines.append("%s.nCount = %s;\n" % (destVar, node._range[-1]))
return lines
def MapSetOf(self, srcSimulink, destVar, node, leafTypeDict, names):
......@@ -156,7 +156,7 @@ class FromASN1SCCtoSimulink(RecursiveMapper):
for i in range(0, node._range[-1]):
lines.append("if (%s>=%d) %s.element_data[%d] = %s.arr[%d]; else %s.element_data[%d] = 0;\n" %
(limit, i+1, dstSimulink, i, srcVar, i, dstSimulink, i))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s;\n" % (dstSimulink, limit))
return lines
......@@ -232,7 +232,7 @@ class FromSimulinkToOSS(RecursiveMapper):
panicWithCallStack("OCTET STRING (in %s) must have a SIZE constraint inside ASN.1,\nor else we can't generate C code!" % node.Location()) # pragma: no cover
for i in range(0, node._range[-1]):
lines.append("%s.value[%d] = %s.element_data[%d];\n" % (destVar, i, srcSimulink, i))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s.length;\n" % (destVar, srcSimulink))
else:
lines.append("%s.length = %s;\n" % (destVar, node._range[-1]))
......@@ -284,7 +284,7 @@ class FromSimulinkToOSS(RecursiveMapper):
node._containedType,
leafTypeDict,
names))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.count = %s.length;\n" % (destVar, srcSimulink))
else:
lines.append("%s.count = %s;\n" % (destVar, node._range[-1]))
......@@ -311,7 +311,7 @@ class FromOSStoSimulink(RecursiveMapper):
for i in range(0, node._range[-1]):
lines.append("if (%s.length >= %d) %s.element_data[%d] = %s.value[%d]; else %s.element_data[%d] = 0;\n" %
(srcVar, i+1, dstSimulink, i, srcVar, i, dstSimulink, i))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s.length;" % (dstSimulink, srcVar))
return lines
......@@ -363,7 +363,7 @@ class FromOSStoSimulink(RecursiveMapper):
node._containedType,
leafTypeDict,
names))
if len(node._range)>1 and node._range[0]!=node._range[1]:
if len(node._range) > 1 and node._range[0] != node._range[1]:
lines.append("%s.length = %s.count;\n" % (dstSimulink, srcVar))