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

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" %
......
......@@ -221,15 +221,15 @@ def OneTimeOnly(unused_modelingLanguage, asnFile, subProgram, subProgramImplemen
''')
global g_IDs
g_HeaderFile.write("#define ID_MENU_RI "+str(g_IDs)+"\n")
g_IDs+=1
g_IDs += 1
g_HeaderFile.write("#define ID_MENU_SAVE "+str(g_IDs)+"\n")
g_IDs+=1
g_IDs += 1
g_HeaderFile.write("#define ID_MENU_LOAD "+str(g_IDs)+"\n")
g_IDs+=1
g_IDs += 1
g_HeaderFile.write("#define ID_MENU_ABOUT "+str(g_IDs)+"\n")
g_IDs+=1
g_IDs += 1
g_HeaderFile.write("#define ID_MENU_QUIT "+str(g_IDs)+"\n")
g_IDs+=1
g_IDs += 1
g_HeaderFile.write("\n")
g_HeaderFile.write('''
class TeleCmds : public wxFrame
......@@ -338,7 +338,7 @@ public:
# Called once per RI (i.e. per SUBPROGRAM IMPLEMENTATION)
def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, outputDir, maybeFVname, useOSS):
#print modelingLanguage, subProgram, subProgramImplementation, maybeFVname
# print modelingLanguage, subProgram, subProgramImplementation, maybeFVname
g_langPerSP[subProgram] = modelingLanguage
global g_bStarted
if not g_bStarted:
......@@ -347,7 +347,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
global g_IDs
CleanSP = CleanName(subProgram._id)
g_HeaderFile.write("#define ID_SCROLWND_"+CleanSP+" "+str(g_IDs)+"\n")
g_IDs+=1
g_IDs += 1
g_MyEvents.write(" EVT_MENU( ID_MENU_RI, TeleCmds::OnMenu_Click )\n")
g_MyEvents.write(" EVT_MENU( ID_MENU_LOAD, TeleCmds::OnMenu_Load )\n")
g_MyEvents.write(" EVT_MENU( ID_MENU_SAVE, TeleCmds::OnMenu_Save )\n")
......@@ -390,7 +390,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
if modelingLanguage.lower() == "gui_pi":
# We have telemetry, we need a thread polling the /xyz_PI_queue (xyz: g_maybeFVname)
cleanFVname = CleanName(g_maybeFVname)
#g_MyThreadsH.write("#include \"%s_GUI_reader.h\"\n" % cleanFVname)
# g_MyThreadsH.write("#include \"%s_GUI_reader.h\"\n" % cleanFVname)
g_MyThreadsH.write("class %s_telemetry : public wxThread {\n" % cleanFVname)
g_MyThreadsH.write("public:\n")
g_MyThreadsH.write(" %s_telemetry(TeleCmds *);\n" % cleanFVname)
......@@ -400,7 +400,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
g_MyThreadsH.write(" mqd_t _queue_id;\n")
g_MyThreadsH.write(" char QName[1024];\n")
g_MyThreadsH.write(" TeleCmds *_pFrame;\n")
#g_MyThreadsH.write(" int _queue_was_bad;\n")
# g_MyThreadsH.write(" int _queue_was_bad;\n")
g_MyThreadsH.write("};\n\n")
g_MyThreadsInc.write("%s_telemetry::%s_telemetry(TeleCmds *pFrame)\n{\n" % (cleanFVname, cleanFVname))
g_MyThreadsInc.write(" _queue_id = (mqd_t)-1;\n")
......@@ -410,11 +410,11 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
g_MyThreadsInc.write(" cerr << \"Failed to open communication channel with ASSERT binary\" << endl;\n")
g_MyThreadsInc.write(" exit(1);\n")
g_MyThreadsInc.write(" }\n")
#g_MyThreadsInc.write(" _queue_was_bad = GUI_%s_reader_initialize();\n" % cleanFVname)
# g_MyThreadsInc.write(" _queue_was_bad = GUI_%s_reader_initialize();\n" % cleanFVname)
g_MyThreadsInc.write("}\n\n")
g_MyThreadsInc.write("void *%s_telemetry::Entry()\n{\n" % cleanFVname)
g_MyThreadsInc.write(" if (_queue_id == (mqd_t)-1) { cout << \"queue \" << QName << \" does not exist!\\n\"; return NULL; }\n")
#g_MyThreadsInc.write(" if (_queue_was_bad) { cout << \"queue for %s does not exist!\\n\"; return NULL; }\n" % g_maybeFVname)
# g_MyThreadsInc.write(" if (_queue_was_bad) { cout << \"queue for %s does not exist!\\n\"; return NULL; }\n" % g_maybeFVname)
g_MyThreadsInc.write(" struct mq_attr mqstat;\n")
g_MyThreadsInc.write(" mq_getattr(_queue_id, &mqstat);\n")
g_MyThreadsInc.write(" void* message_data_received = malloc(mqstat.mq_msgsize);\n")
......@@ -423,7 +423,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
g_MyThreadsInc.write(" while(1) {\n")
g_MyThreadsInc.write(" if (TestDestroy()) break;\n")
g_MyThreadsInc.write(" message_received_type = -1;\n")
#g_MyThreadsInc.write(" GUI_%s_read_data();\n" % cleanFVname)
# g_MyThreadsInc.write(" GUI_%s_read_data();\n" % cleanFVname)
g_MyThreadsInc.write(" retrieve_message_from_queue(_queue_id, mqstat.mq_msgsize, message_data_received, &message_received_type);\n")
g_MyThreadsInc.write(" if (message_received_type != -1) {\n")
g_MyThreadsInc.write(" //cout << \"Received telemetry of type\" << message_received_type << endl;\n")
......@@ -589,11 +589,11 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
(varPrefix, varPrefix))
g_MyCreation.write("%s->Add(_itemStaticBoxSizer_%s, 0, wxALIGN_LEFT|wxALL, 5);\n\n" %
(parentControl, varPrefix))
if len(node._range)==2 and node._range[0] != node._range[1]:
if len(node._range) == 2 and node._range[0] != node._range[1]:
g_MyCreation.write("wxStaticText* itemStaticTextNoElements_%s = new wxStaticText( %s, wxID_STATIC, _(\"Number of Elements\"), wxDefaultPosition, wxDefaultSize, 0 );\n" %
(varPrefix, ScrollWnd))
g_MyCreation.write("%s->Add(itemStaticTextNoElements_%s, 0, wxALIGN_LEFT|wxALL, 5);\n" %
("_itemStaticBoxSizer_%s"%varPrefix, varPrefix))
("_itemStaticBoxSizer_%s" % varPrefix, varPrefix))
g_MyControls.write("wxTextCtrl* _itemTextCtrl_%s;\n" % varPrefix)
g_MyCreation.write("_itemTextCtrl_%s = new wxTextCtrl( %s, ID_TEXTCTRL_%s, _T(\"%s\"), wxDefaultPosition, wxDefaultSize, 0 );\n" %
(varPrefix, ScrollWnd, varPrefix, str(node._range[0])))
......@@ -608,7 +608,7 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
control = "_itemStaticBoxSizer_%s" % varPrefix
for i in range(0, node._range[-1]):
WriteCodeForGUIControls(
prefix + "::Elem_" + ("%02d"%i),
prefix + "::Elem_" + ("%02d" % i),
control, containedNode, subProgram, subProgramImplementation, param, leafTypeDict, names)
else: # pragma: no cover
panic("GUI codegen doesn't support this type yet (%s)" % str(node)) # pragma: no cover
......@@ -642,7 +642,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
elif isinstance(node, AsnEnumerated):
enumNo = 0
for enumOption in node._members:
f.write(("%sif (_itemChoice_"%maybeElseZero(enumNo))+srcVar+"->GetCurrentSelection() == "+str(enumNo)+") {\n")
f.write(("%sif (_itemChoice_" % maybeElseZero(enumNo))+srcVar+"->GetCurrentSelection() == "+str(enumNo)+") {\n")
f.write(" "+destVar+" = ENUM_asn1Scc" + CleanName(enumOption[0]) + ";\n")
f.write("}\n")
enumNo += 1
......@@ -658,7 +658,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
for child in node._members:
CleanChild = CleanName(child[0])
childType = child[1]
f.write(("%sif (%d == _itemChoice_"%(maybeElseZero(childNo), childNo)) + srcVar + "->GetCurrentSelection()) {\n")
f.write(("%sif (%d == _itemChoice_" % (maybeElseZero(childNo), childNo)) + srcVar + "->GetCurrentSelection()) {\n")
if isinstance(childType, AsnMetaMember):
childType = names[childType._containedType]
CopyDataFromDlgToASN1(f, srcVar + "_" + CleanChild, destVar + ".u." + CleanChild, childType, leafTypeDict, names)
......@@ -676,13 +676,13 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
f.write(" _itemTextCtrl_%s->SetFocus();\n" % srcVar)
f.write(" return;\n")
f.write("}\n")
#No nCount anymore!
#else:
# f.write(destVar + ".nCount = %s;\n" % str(node._range[-1]))
# No nCount anymore!
# else:
# f.write(destVar + ".nCount = %s;\n" % str(node._range[-1]))
for i in range(0, node._range[-1]):
if isSequenceVariable(node):
f.write("if ("+destVar+".nCount>"+str(i)+") {\n")
CopyDataFromDlgToASN1(f, srcVar + "_Elem_" + ("%02d"%i), destVar + ".arr[" + str(i) + "]", containedNode, leafTypeDict, names)
CopyDataFromDlgToASN1(f, srcVar + "_Elem_" + ("%02d" % i), destVar + ".arr[" + str(i) + "]", containedNode, leafTypeDict, names)
if isSequenceVariable(node):
f.write("}\n")
......@@ -723,7 +723,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
enumNo = 0
if not bClear:
for enumOption in node._members:
fDesc.write(("%sif ("%maybeElseZero(enumNo))+srcVar+" == ENUM_asn1Scc" + CleanName(enumOption[0]) + ") {\n")
fDesc.write(("%sif (" % maybeElseZero(enumNo))+srcVar+" == ENUM_asn1Scc" + CleanName(enumOption[0]) + ") {\n")
fDesc.write(" "+prefix+"_itemChoice_"+destVar+"->SetSelection(%d);\n" % enumNo)
fDesc.write("}\n")
enumNo += 1
......@@ -745,7 +745,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
(maybeElseZero(childNo), srcVar, child[2]))
fDesc.write(" "+prefix+"_itemChoice_" + destVar + "->SetSelection(%d);\n" % childNo)
fDesc.write(" wxCommandEvent dum;\n")
fDesc.write(" %sUpdateChoice_"%prefix + destVar + "(dum);\n")
fDesc.write(" %sUpdateChoice_" % prefix + destVar + "(dum);\n")
if isinstance(childType, AsnMetaMember):
childType = names[childType._containedType]
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".u." + CleanChild, destVar + "_" + CleanChild, childType, leafTypeDict, names, bClear)
......@@ -759,12 +759,12 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
for i in range(0, node._range[-1]):
if isSequenceVariable(node):
fDesc.write("if ("+str(i)+"<"+srcVar+".nCount) {\n")
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d"%i), containedNode, leafTypeDict, names, bClear)
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d" % i), containedNode, leafTypeDict, names, bClear)
fDesc.write("} else {\n")
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d"%i), containedNode, leafTypeDict, names, True)
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d" % i), containedNode, leafTypeDict, names, True)
fDesc.write("}\n")
else:
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d"%i), containedNode, leafTypeDict, names, bClear)
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d" % i), containedNode, leafTypeDict, names, bClear)
if isSequenceVariable(node):
fDesc.write("{\n")
fDesc.write(" ostringstream s;\n")
......@@ -923,7 +923,7 @@ def Common(nodeTypename, node, subProgram, subProgramImplementation, param, leaf
control = "itemBoxSizer_%s" % CleanName(subProgram._id)
WriteCodeForGUIControls('', control, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
global g_bBraceOpen
if len(g_SPs)==0 or subProgram._id != g_SPs[-1]:
if len(g_SPs) == 0 or subProgram._id != g_SPs[-1]:
if g_bBraceOpen:
g_MyAction.write("} // %s\n" % g_SPs[-1])
g_MySave.write("} // %s\n" % g_SPs[-1])
......
......@@ -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):
......
......@@ -201,8 +201,8 @@ def setSharedLib(dll=None):
'''.format(fvName=FVname, tcName=CleanSP))
g_PyDataModel.write('\ntc["{tcName}"] = '.format(tcName=CleanSP))
buttons=([["sendButton", "Send TC"], ["loadButton", "Load TC"],
["saveButton", "Save TC"]])
buttons = ([["sendButton", "Send TC"], ["loadButton", "Load TC"],
["saveButton", "Save TC"]])
classType = "asn1Editor"
elif modelingLanguage.lower() == 'gui_pi':
g_BackendFile.write('''
......@@ -249,7 +249,7 @@ def setSharedLib(dll=None):
'''.format(tmName=CleanSP, fvName=FVname))
g_PyDataModel.write('\ntm["{tmName}"] = '.format(tmName=CleanSP))
buttons = ([["plotButton", "Plot"], ["meterButton", "Meter"],
["unusedButton", "Unused"]])
["unusedButton", "Unused"]])
classType = "asn1Viewer"
global g_QUiFile
......@@ -524,14 +524,14 @@ def WriteCodeForGUIControls(prefixes, parentControl, node, subProgram,
pyStr = ""
asnStr = prefixes[0]
for i in range(1, len(prefixes)):
if (len(parentControl)>=i):
if (len(parentControl) >= i):
asnStr += "[{index}]".format(index=parentControl[i-1])
asnStr += prefixes[i][len(prefixes[i-1]):]
for item in prefixes[0].split('.'):
pyStr += '''["{prefixKey}"]'''.format(prefixKey=item)
for i in range(1, len(prefixes)):
if (len(parentControl)>=i):
if (len(parentControl) >= i):
pyStr += "[{index}]".format(index=parentControl[i-1])
for item in prefixes[i][len(prefixes[i-1]):].split('.'):
if len(item) > 0:
......@@ -540,80 +540,74 @@ def WriteCodeForGUIControls(prefixes, parentControl, node, subProgram,
# Write code for mapping of data between Pyside and ASN1Scc structures
if isinstance(node, AsnInt):
g_fromPysideToASN1.append(
g_iter * " " + asnStr + ".Set(int(val" + pyStr + "))\n")
g_iter * " " + asnStr + ".Set(int(val" + pyStr + "))\n")
elif isinstance(node, AsnReal):
g_fromPysideToASN1.append(
g_iter * " " + asnStr + ".Set(float(val" + pyStr + "))\n")
g_iter * " " + asnStr + ".Set(float(val" + pyStr + "))\n")
elif isinstance(node, AsnBool):
g_fromPysideToASN1.append(
g_iter * " " + asnStr + ".Set(val" + pyStr + ")\n")
g_iter * " " + asnStr + ".Set(val" + pyStr + ")\n")
if isinstance(node, AsnBool):
g_fromASN1ToPyside.append(
g_iter * " " + "val" + pyStr + " = bool("
+ asnStr + ".Get())\n")
g_iter * " " + "val" + pyStr + " = bool(" + asnStr + ".Get())\n")
elif isinstance(node, AsnReal) or isinstance(node, AsnInt):
g_fromASN1ToPyside.append(
g_iter * " " + "val" + pyStr + " = " + asnStr + ".Get()\n")
g_iter * " " + "val" + pyStr + " = " + asnStr + ".Get()\n")
if isinstance(node, AsnOctetString):
g_fromPysideToASN1.append(
g_iter * " " + asnStr + ".SetFromPyString(val"
+ pyStr + ")\n")
g_iter * " " + asnStr + ".SetFromPyString(val" + pyStr + ")\n")
g_fromASN1ToPyside.append(
g_iter * " " + "val" + pyStr + " = "
+ asnStr + ".GetPyString()\n")
g_iter * " " + "val" + pyStr + " = " + asnStr + ".GetPyString()\n")
if isinstance(node, AsnEnumerated):
g_fromASN1ToPyside.append(g_iter * " "+"val" + pyStr + " = {}\n")
for enum_value in node._members:
g_fromPysideToASN1.append(
g_iter * " " + "if val" + pyStr
+ '''["Enum"] == "%s":\n''' % CleanName(enum_value[0]))
g_iter * " " + "if val" + pyStr +
'''["Enum"] == "%s":\n''' % CleanName(enum_value[0]))
g_fromASN1ToPyside.append(
g_iter * " " + "if " + asnStr + ".Get() == "
+ asnStr + "." + CleanName(enum_value[0]) + ":\n")
g_iter * " " + "if " + asnStr + ".Get() == " +
asnStr + "." + CleanName(enum_value[0]) + ":\n")
g_iter += 1
g_fromPysideToASN1.append(
g_iter * " " + asnStr + ".Set(" + asnStr + ".%s)\n" %
CleanName(enum_value[0]))
g_iter * " " + asnStr + ".Set(" + asnStr + ".%s)\n" % CleanName(enum_value[0]))
g_fromASN1ToPyside.append(
g_iter * " " + "val" + pyStr + "[\"Enum\"] = \""
+ CleanName(enum_value[0]) + "\"\n")
g_iter * " " + "val" + pyStr + "[\"Enum\"] = \"" + CleanName(enum_value[0]) + "\"\n")
g_iter -= 1
if isinstance(node, AsnInt) or isinstance(node, AsnReal) or isinstance(
node, AsnOctetString):
if isinstance(node, AsnInt) or isinstance(node, AsnReal):
if isinstance(node, (AsnInt, AsnReal, AsnOctetString)):
if isinstance(node, (AsnInt, AsnReal)):
if g_onceOnly:
g_PyDataModel.write('''\
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', 'minR': %d, 'maxR': %d}''' %
(nodeTypename, node._name, txtPrefix,
node._range[0], node._range[1]))
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', 'minR': %d, 'maxR': %d}''' % (
nodeTypename, node._name, txtPrefix,
node._range[0], node._range[1]))
elif isinstance(node, AsnOctetString):
if g_onceOnly:
g_PyDataModel.write('''\
{'nodeTypename': '%s', 'type': 'STRING',\
'id': '%s', 'minSize': %d, 'maxSize': %d}''' %
(nodeTypename, txtPrefix, node._range[0], node._range[1]))
'id': '%s', 'minSize': %d, 'maxSize': %d}''' % (
nodeTypename, txtPrefix, node._range[0], node._range[1]))
elif isinstance(node, AsnBool):
if g_onceOnly:
g_PyDataModel.write('''\
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', 'default': 'False'}''' %
(nodeTypename, node._name, txtPrefix))
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', 'default': 'False'}''' % (
nodeTypename, node._name, txtPrefix))
elif isinstance(node, AsnEnumerated):
if g_onceOnly:
global g_needsComa
g_needsComa = False
g_PyDataModel.write('''\
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', 'values':[''' %
(nodeTypename, node._name, txtPrefix))
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', 'values':[''' % (
nodeTypename, node._name, txtPrefix))
for enum_value in node._members:
if g_needsComa:
g_PyDataModel.write(',')
......@@ -625,8 +619,8 @@ def WriteCodeForGUIControls(prefixes, parentControl, node, subProgram,
node, AsnChoice) or isinstance(node, AsnSet):
if g_onceOnly:
g_PyDataModel.write('''\
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', ''' %
(nodeTypename, node._name, txtPrefix))
{'nodeTypename': '%s', 'type': '%s', 'id': '%s', ''' % (
nodeTypename, node._name, txtPrefix))
if isinstance(node, AsnChoice):
g_PyDataModel.write('''"choices":[''')
elif isinstance(node, AsnSequence) or isinstance(node, AsnSet):
......@@ -645,18 +639,18 @@ def WriteCodeForGUIControls(prefixes, parentControl, node, subProgram,
CleanChild = CleanName(child[0])
if isinstance(node, AsnChoice):
g_fromPysideToASN1.append(
g_iter * " " + "if val" + pyStr
+ "[\"Choice\"] == \"" + CleanChild + "\":\n")
g_iter * " " + "if val" + pyStr +
"[\"Choice\"] == \"" + CleanChild + "\":\n")
g_fromASN1ToPyside.append(
g_iter * " " + "if " + asnStr
+ ".kind.Get() == DV." + child[2]+ ":\n")
g_iter * " " + "if " + asnStr +
".kind.Get() == DV." + child[2] + ":\n")
g_iter += 1
g_fromPysideToASN1.append(
g_iter * " " + asnStr
+ ".kind.Set(DV." + child[2] + ")\n")
g_iter * " " + asnStr +
".kind.Set(DV." + child[2] + ")\n")
g_fromASN1ToPyside.append(
g_iter * " " + "val" + pyStr
+ "[\"Choice\"] = \"" + CleanChild + "\"\n")
g_iter * " " + "val" + pyStr +
"[\"Choice\"] = \"" + CleanChild + "\"\n")
childType = child[1]
if isinstance(childType, AsnMetaMember):
childType = names[childType._containedType]
......@@ -675,8 +669,8 @@ def WriteCodeForGUIControls(prefixes, parentControl, node, subProgram,
if g_onceOnly:
g_PyDataModel.write('''\
{'nodeTypename': '%s', 'type': 'SEQOF', 'id': '%s', 'minSize': %d,\
'maxSize': %d, 'seqoftype':''' %
(nodeTypename, txtPrefix, node._range[0], node._range[1]))
'maxSize': %d, 'seqoftype':''' % (
nodeTypename, txtPrefix, node._range[0], node._range[1]))
containedNode = node._containedType
if isinstance(containedNode, str):
......@@ -685,24 +679,20 @@ def WriteCodeForGUIControls(prefixes, parentControl, node, subProgram,
# Write sequence of size for encoding
if node._range[0] != node._range[1]:
g_fromPysideToASN1.append(
g_iter * " " + asnStr + ".SetLength (len(val"
+ pyStr + "))\n")
g_iter * " " + asnStr + ".SetLength (len(val" + pyStr + "))\n")
g_fromASN1ToPyside.append(g_iter * " " + "val" + pyStr + " = []\n")
#g_iter += 1
# g_iter += 1
prefixes.append(prefixes[-1])
l_lock = False