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): ...@@ -312,10 +312,10 @@ def OnStartup(unused_modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
global cBackend global cBackend
# 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada) # 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada)
# we no longer need these Ada-specific Dumpable structures. # we no longer need these Ada-specific Dumpable structures.
#global adaBackend # global adaBackend
#adaBackend = Ada_GlueGenerator() # adaBackend = Ada_GlueGenerator()
cBackend = c_B_mapper.C_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) cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS)
......
...@@ -8,7 +8,7 @@ import sys ...@@ -8,7 +8,7 @@ import sys
def main(): def main():
if len(sys.argv)>1: if len(sys.argv) > 1:
L = AadlLexer.Lexer(sys.argv[1]) L = AadlLexer.Lexer(sys.argv[1])
else: else:
L = AadlLexer.Lexer() L = AadlLexer.Lexer()
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# Note that in both cases, there are no charges (royalties) for the # Note that in both cases, there are no charges (royalties) for the
# generated code. # generated code.
# #
__doc__ = ''' '''
Base class for all asynchronous tools Base class for all asynchronous tools
''' '''
...@@ -117,31 +117,31 @@ class ASynchronousToolGlueGenerator: ...@@ -117,31 +117,31 @@ class ASynchronousToolGlueGenerator:
def OnBasic(self, nodeTypename, node, leafTypeDict, names): def OnBasic(self, nodeTypename, node, leafTypeDict, names):
realLeafType = leafTypeDict[nodeTypename] realLeafType = leafTypeDict[nodeTypename]
inform(str(self.__class__) + ": BASE: %s (%s)", nodeTypename, realLeafType) 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, node, leafTypeDict, names):
inform(str(self.__class__) + ": SEQUENCE: %s", nodeTypename) 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, node, leafTypeDict, names):
inform(str(self.__class__) + ": SET: %s", nodeTypename) # pragma: nocover 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, node, leafTypeDict, names):
inform(str(self.__class__) + ": ENUMERATED: %s", nodeTypename) 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, node, leafTypeDict, names):
inform(str(self.__class__) + ": SEQUENCEOF: %s", nodeTypename) 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, node, leafTypeDict, names):
inform(str(self.__class__) + ": SETOF: %s", nodeTypename) # pragma: nocover 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, node, leafTypeDict, names):
inform(str(self.__class__) + ": CHOICE: %s", nodeTypename) 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): def OnShutdown(self, unused_modelingLanguage, unused_asnFile, unused_maybeFVname):
for nodeTypename, value in list(self.typesToWorkOn.items()): for nodeTypename, value in list(self.typesToWorkOn.items()):
......
...@@ -253,13 +253,13 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -253,13 +253,13 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_HeaderFile.write(needDefine) self.C_HeaderFile.write(needDefine)
self.C_HeaderFile.write( self.C_HeaderFile.write(
"size_t %s(void *pBuffer, size_t iMaxBufferSize, %sasn1Scc%s *pSrc);\n" % "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.CleanNameAsToolWants(nodeTypename)))
self.C_HeaderFile.write("#endif\n\n") self.C_HeaderFile.write("#endif\n\n")
self.C_SourceFile.write(needDefine) self.C_SourceFile.write(needDefine)
self.C_SourceFile.write( self.C_SourceFile.write(
"size_t %s(void *pBuffer, size_t iMaxBufferSize, %sasn1Scc%s *pSrc)\n{\n" % "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))) self.CleanNameAsToolWants(nodeTypename)))
if self.useOSS and encoding.lower() == "uper": if self.useOSS and encoding.lower() == "uper":
...@@ -307,7 +307,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -307,7 +307,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
elif encoding.lower() in ["uper", "acn"]: elif encoding.lower() in ["uper", "acn"]:
self.C_SourceFile.write(" if (asn1Scc%s_%sEncode(pSrc, &strm, &errorCode, TRUE) == FALSE) {\n" % self.C_SourceFile.write(" if (asn1Scc%s_%sEncode(pSrc, &strm, &errorCode, TRUE) == FALSE) {\n" %
(self.CleanNameAsToolWants(nodeTypename), (self.CleanNameAsToolWants(nodeTypename),
("ACN_" if encoding.lower()=="acn" else ""))) ("ACN_" if encoding.lower() == "acn" else "")))
self.C_SourceFile.write( self.C_SourceFile.write(
'\tfprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d\\n", __FILE__, __LINE__, errorCode);\n' % (nodeTypename)) '\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") self.C_SourceFile.write(" return -1;\n")
...@@ -365,7 +365,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -365,7 +365,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_SourceFile.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\n\n") self.C_SourceFile.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\n\n")
self.C_SourceFile.write(" if (asn1Scc%s_%sDecode(pDst, &strm, &errorCode)) {\n" % self.C_SourceFile.write(" if (asn1Scc%s_%sDecode(pDst, &strm, &errorCode)) {\n" %
(self.CleanNameAsToolWants(nodeTypename), (self.CleanNameAsToolWants(nodeTypename),
"ACN_" if encoding.lower()=="acn" else "")) "ACN_" if encoding.lower() == "acn" else ""))
self.C_SourceFile.write(" /* Decoding succeeded */\n") self.C_SourceFile.write(" /* Decoding succeeded */\n")
elif encoding.lower() == "native": elif encoding.lower() == "native":
self.C_SourceFile.write(" *pDst = *(asn1Scc%s *) pBuffer;\n {\n" % self.C_SourceFile.write(" *pDst = *(asn1Scc%s *) pBuffer;\n {\n" %
......
...@@ -221,15 +221,15 @@ def OneTimeOnly(unused_modelingLanguage, asnFile, subProgram, subProgramImplemen ...@@ -221,15 +221,15 @@ def OneTimeOnly(unused_modelingLanguage, asnFile, subProgram, subProgramImplemen
''') ''')
global g_IDs global g_IDs
g_HeaderFile.write("#define ID_MENU_RI "+str(g_IDs)+"\n") 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_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_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_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_HeaderFile.write("#define ID_MENU_QUIT "+str(g_IDs)+"\n")
g_IDs+=1 g_IDs += 1
g_HeaderFile.write("\n") g_HeaderFile.write("\n")
g_HeaderFile.write(''' g_HeaderFile.write('''
class TeleCmds : public wxFrame class TeleCmds : public wxFrame
...@@ -338,7 +338,7 @@ public: ...@@ -338,7 +338,7 @@ public:
# Called once per RI (i.e. per SUBPROGRAM IMPLEMENTATION) # Called once per RI (i.e. per SUBPROGRAM IMPLEMENTATION)
def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, outputDir, maybeFVname, useOSS): def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, outputDir, maybeFVname, useOSS):
#print modelingLanguage, subProgram, subProgramImplementation, maybeFVname # print modelingLanguage, subProgram, subProgramImplementation, maybeFVname
g_langPerSP[subProgram] = modelingLanguage g_langPerSP[subProgram] = modelingLanguage
global g_bStarted global g_bStarted
if not g_bStarted: if not g_bStarted:
...@@ -347,7 +347,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o ...@@ -347,7 +347,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
global g_IDs global g_IDs
CleanSP = CleanName(subProgram._id) CleanSP = CleanName(subProgram._id)
g_HeaderFile.write("#define ID_SCROLWND_"+CleanSP+" "+str(g_IDs)+"\n") 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_RI, TeleCmds::OnMenu_Click )\n")
g_MyEvents.write(" EVT_MENU( ID_MENU_LOAD, TeleCmds::OnMenu_Load )\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") g_MyEvents.write(" EVT_MENU( ID_MENU_SAVE, TeleCmds::OnMenu_Save )\n")
...@@ -390,7 +390,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o ...@@ -390,7 +390,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
if modelingLanguage.lower() == "gui_pi": if modelingLanguage.lower() == "gui_pi":
# We have telemetry, we need a thread polling the /xyz_PI_queue (xyz: g_maybeFVname) # We have telemetry, we need a thread polling the /xyz_PI_queue (xyz: g_maybeFVname)
cleanFVname = CleanName(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("class %s_telemetry : public wxThread {\n" % cleanFVname)
g_MyThreadsH.write("public:\n") g_MyThreadsH.write("public:\n")
g_MyThreadsH.write(" %s_telemetry(TeleCmds *);\n" % cleanFVname) g_MyThreadsH.write(" %s_telemetry(TeleCmds *);\n" % cleanFVname)
...@@ -400,7 +400,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o ...@@ -400,7 +400,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
g_MyThreadsH.write(" mqd_t _queue_id;\n") g_MyThreadsH.write(" mqd_t _queue_id;\n")
g_MyThreadsH.write(" char QName[1024];\n") g_MyThreadsH.write(" char QName[1024];\n")
g_MyThreadsH.write(" TeleCmds *_pFrame;\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_MyThreadsH.write("};\n\n")
g_MyThreadsInc.write("%s_telemetry::%s_telemetry(TeleCmds *pFrame)\n{\n" % (cleanFVname, cleanFVname)) g_MyThreadsInc.write("%s_telemetry::%s_telemetry(TeleCmds *pFrame)\n{\n" % (cleanFVname, cleanFVname))
g_MyThreadsInc.write(" _queue_id = (mqd_t)-1;\n") g_MyThreadsInc.write(" _queue_id = (mqd_t)-1;\n")
...@@ -410,11 +410,11 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o ...@@ -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(" cerr << \"Failed to open communication channel with ASSERT binary\" << endl;\n")
g_MyThreadsInc.write(" exit(1);\n") g_MyThreadsInc.write(" exit(1);\n")
g_MyThreadsInc.write(" }\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("}\n\n")
g_MyThreadsInc.write("void *%s_telemetry::Entry()\n{\n" % cleanFVname) 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_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(" struct mq_attr mqstat;\n")
g_MyThreadsInc.write(" mq_getattr(_queue_id, &mqstat);\n") g_MyThreadsInc.write(" mq_getattr(_queue_id, &mqstat);\n")
g_MyThreadsInc.write(" void* message_data_received = malloc(mqstat.mq_msgsize);\n") g_MyThreadsInc.write(" void* message_data_received = malloc(mqstat.mq_msgsize);\n")
...@@ -423,7 +423,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o ...@@ -423,7 +423,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
g_MyThreadsInc.write(" while(1) {\n") g_MyThreadsInc.write(" while(1) {\n")
g_MyThreadsInc.write(" if (TestDestroy()) break;\n") g_MyThreadsInc.write(" if (TestDestroy()) break;\n")
g_MyThreadsInc.write(" message_received_type = -1;\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(" 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(" if (message_received_type != -1) {\n")
g_MyThreadsInc.write(" //cout << \"Received telemetry of type\" << message_received_type << endl;\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 ...@@ -589,11 +589,11 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
(varPrefix, varPrefix)) (varPrefix, varPrefix))
g_MyCreation.write("%s->Add(_itemStaticBoxSizer_%s, 0, wxALIGN_LEFT|wxALL, 5);\n\n" % g_MyCreation.write("%s->Add(_itemStaticBoxSizer_%s, 0, wxALIGN_LEFT|wxALL, 5);\n\n" %
(parentControl, varPrefix)) (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" % g_MyCreation.write("wxStaticText* itemStaticTextNoElements_%s = new wxStaticText( %s, wxID_STATIC, _(\"Number of Elements\"), wxDefaultPosition, wxDefaultSize, 0 );\n" %
(varPrefix, ScrollWnd)) (varPrefix, ScrollWnd))
g_MyCreation.write("%s->Add(itemStaticTextNoElements_%s, 0, wxALIGN_LEFT|wxALL, 5);\n" % 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_MyControls.write("wxTextCtrl* _itemTextCtrl_%s;\n" % varPrefix)
g_MyCreation.write("_itemTextCtrl_%s = new wxTextCtrl( %s, ID_TEXTCTRL_%s, _T(\"%s\"), wxDefaultPosition, wxDefaultSize, 0 );\n" % g_MyCreation.write("_itemTextCtrl_%s = new wxTextCtrl( %s, ID_TEXTCTRL_%s, _T(\"%s\"), wxDefaultPosition, wxDefaultSize, 0 );\n" %
(varPrefix, ScrollWnd, varPrefix, str(node._range[0]))) (varPrefix, ScrollWnd, varPrefix, str(node._range[0])))
...@@ -608,7 +608,7 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI ...@@ -608,7 +608,7 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
control = "_itemStaticBoxSizer_%s" % varPrefix control = "_itemStaticBoxSizer_%s" % varPrefix
for i in range(0, node._range[-1]): for i in range(0, node._range[-1]):
WriteCodeForGUIControls( WriteCodeForGUIControls(
prefix + "::Elem_" + ("%02d"%i), prefix + "::Elem_" + ("%02d" % i),
control, containedNode, subProgram, subProgramImplementation, param, leafTypeDict, names) control, containedNode, subProgram, subProgramImplementation, param, leafTypeDict, names)
else: # pragma: no cover else: # pragma: no cover
panic("GUI codegen doesn't support this type yet (%s)" % str(node)) # 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): ...@@ -642,7 +642,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
elif isinstance(node, AsnEnumerated): elif isinstance(node, AsnEnumerated):
enumNo = 0 enumNo = 0
for enumOption in node._members: 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(" "+destVar+" = ENUM_asn1Scc" + CleanName(enumOption[0]) + ";\n")
f.write("}\n") f.write("}\n")
enumNo += 1 enumNo += 1
...@@ -658,7 +658,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names): ...@@ -658,7 +658,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
for child in node._members: for child in node._members:
CleanChild = CleanName(child[0]) CleanChild = CleanName(child[0])
childType = child[1] 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): if isinstance(childType, AsnMetaMember):
childType = names[childType._containedType] childType = names[childType._containedType]
CopyDataFromDlgToASN1(f, srcVar + "_" + CleanChild, destVar + ".u." + CleanChild, childType, leafTypeDict, names) CopyDataFromDlgToASN1(f, srcVar + "_" + CleanChild, destVar + ".u." + CleanChild, childType, leafTypeDict, names)
...@@ -676,13 +676,13 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names): ...@@ -676,13 +676,13 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
f.write(" _itemTextCtrl_%s->SetFocus();\n" % srcVar) f.write(" _itemTextCtrl_%s->SetFocus();\n" % srcVar)
f.write(" return;\n") f.write(" return;\n")
f.write("}\n") f.write("}\n")
#No nCount anymore! # No nCount anymore!
#else: # else:
# f.write(destVar + ".nCount = %s;\n" % str(node._range[-1])) # f.write(destVar + ".nCount = %s;\n" % str(node._range[-1]))
for i in range(0, node._range[-1]): for i in range(0, node._range[-1]):
if isSequenceVariable(node): if isSequenceVariable(node):
f.write("if ("+destVar+".nCount>"+str(i)+") {\n") 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): if isSequenceVariable(node):
f.write("}\n") f.write("}\n")
...@@ -723,7 +723,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na ...@@ -723,7 +723,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
enumNo = 0 enumNo = 0
if not bClear: if not bClear:
for enumOption in node._members: 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(" "+prefix+"_itemChoice_"+destVar+"->SetSelection(%d);\n" % enumNo)
fDesc.write("}\n") fDesc.write("}\n")
enumNo += 1 enumNo += 1
...@@ -745,7 +745,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na ...@@ -745,7 +745,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
(maybeElseZero(childNo), srcVar, child[2])) (maybeElseZero(childNo), srcVar, child[2]))
fDesc.write(" "+prefix+"_itemChoice_" + destVar + "->SetSelection(%d);\n" % childNo) fDesc.write(" "+prefix+"_itemChoice_" + destVar + "->SetSelection(%d);\n" % childNo)
fDesc.write(" wxCommandEvent dum;\n") fDesc.write(" wxCommandEvent dum;\n")
fDesc.write(" %sUpdateChoice_"%prefix + destVar + "(dum);\n") fDesc.write(" %sUpdateChoice_" % prefix + destVar + "(dum);\n")
if isinstance(childType, AsnMetaMember): if isinstance(childType, AsnMetaMember):
childType = names[childType._containedType] childType = names[childType._containedType]
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".u." + CleanChild, destVar + "_" + CleanChild, childType, leafTypeDict, names, bClear) 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 ...@@ -759,12 +759,12 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
for i in range(0, node._range[-1]): for i in range(0, node._range[-1]):
if isSequenceVariable(node): if isSequenceVariable(node):
fDesc.write("if ("+str(i)+"<"+srcVar+".nCount) {\n") 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") 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") fDesc.write("}\n")
else: 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): if isSequenceVariable(node):
fDesc.write("{\n") fDesc.write("{\n")
fDesc.write(" ostringstream s;\n") fDesc.write(" ostringstream s;\n")
...@@ -923,7 +923,7 @@ def Common(nodeTypename, node, subProgram, subProgramImplementation, param, leaf ...@@ -923,7 +923,7 @@ def Common(nodeTypename, node, subProgram, subProgramImplementation, param, leaf
control = "itemBoxSizer_%s" % CleanName(subProgram._id) control = "itemBoxSizer_%s" % CleanName(subProgram._id)
WriteCodeForGUIControls('', control, node, subProgram, subProgramImplementation, param, leafTypeDict, names) WriteCodeForGUIControls('', control, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
global g_bBraceOpen 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: if g_bBraceOpen:
g_MyAction.write("} // %s\n" % g_SPs[-1]) g_MyAction.write("} // %s\n" % g_SPs[-1])
g_MySave.write("} // %s\n" % g_SPs[-1]) g_MySave.write("} // %s\n" % g_SPs[-1])
......
...@@ -138,8 +138,8 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper): ...@@ -138,8 +138,8 @@ class FromObjectGeodeToASN1SCC(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable) lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.arr[i] = value;\n" % destVar) lines.append(" %s.arr[i] = value;\n" % destVar)
lines.append(" }\n") lines.append(" }\n")
#for i in xrange(0, node._range[-1]): # for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i)) # lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
if isSequenceVariable(node): if isSequenceVariable(node):
lines.append(" %s.nCount = %s.length;\n" % (destVar, srcSDLVariable)) lines.append(" %s.nCount = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n") lines.append("}\n")
...@@ -238,8 +238,8 @@ class FromObjectGeodeToOSS(RecursiveMapper): ...@@ -238,8 +238,8 @@ class FromObjectGeodeToOSS(RecursiveMapper):
lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable) lines.append(" if(%s.cont[i].cont[7]) value |= 1;\n" % srcSDLVariable)
lines.append(" %s.value[i] = value;\n" % destVar) lines.append(" %s.value[i] = value;\n" % destVar)
lines.append(" }\n") lines.append(" }\n")
#for i in xrange(0, node._range[-1]): # for i in xrange(0, node._range[-1]):
# lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i)) # lines.append(" placeHolder[%d] = %s[%d];\n" % (i, srcSDLVariable, i))
lines.append(" %s.length = %s.length;\n" % (destVar, srcSDLVariable)) lines.append(" %s.length = %s.length;\n" % (destVar, srcSDLVariable))
lines.append("}\n") lines.append("}\n")
return lines return lines
...@@ -321,8 +321,8 @@ class FromASN1SCCtoObjectGeode(RecursiveMapper): ...@@ -321,8 +321,8 @@ class FromASN1SCCtoObjectGeode(RecursiveMapper):
return ["%s = (%s)?SDL_TRUE:SDL_FALSE;\n" % (dstSDLVariable, srcVar)] return ["%s = (%s)?SDL_TRUE:SDL_FALSE;\n" % (dstSDLVariable, srcVar)]
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __): def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
#for i in xrange(0, node._range[-1]): # for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i)) # lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines = [] lines = []
limit = sourceSequenceLimit(node, srcVar) limit = sourceSequenceLimit(node, srcVar)
lines.append("{\n") lines.append("{\n")
...@@ -435,8 +435,8 @@ class FromOSStoObjectGeode(RecursiveMapper): ...@@ -435,8 +435,8 @@ class FromOSStoObjectGeode(RecursiveMapper):
def MapOctetString(self, srcVar, dstSDLVariable, node, _, __): def MapOctetString(self, srcVar, dstSDLVariable, node, _, __):
lines = [] lines = []
#for i in xrange(0, node._range[-1]): # for i in xrange(0, node._range[-1]):
# lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i)) # lines.append("%s[%d] = %s->buf[%d];\n" % (dstSDLVariable, i, srcVar, i))
lines.append("{\n") lines.append("{\n")
lines.append(" int i;\n") lines.append(" int i;\n")
lines.append(" for(i=0; i<%s.length; i++) {\n" % srcVar) lines.append(" for(i=0; i<%s.length; i++) {\n" % srcVar)
...@@ -593,7 +593,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -593,7 +593,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename))) (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
fileOutHeader.write( fileOutHeader.write(
"\\\n BitStream_Init(&strm, varName, asn1Scc%s_REQUIRED_BYTES_FOR_%sENCODING);\\\n" % "\\\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: else:
fileOutHeader.write( fileOutHeader.write(
" STATIC asn1Scc%s var_%s;\\\n" % " STATIC asn1Scc%s var_%s;\\\n" %
...@@ -605,7 +605,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -605,7 +605,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
# Write the mapping code for the message # Write the mapping code for the message
if self.useOSS and encoding.lower() == "uper": if self.useOSS and encoding.lower() == "uper":
lines = self.FromObjectGeodeToOSS.Map( 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)", "(param1)",
"var_" + self.CleanNameAsToolWants(nodeTypename), "var_" + self.CleanNameAsToolWants(nodeTypename),
node, node,
...@@ -613,7 +613,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -613,7 +613,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
names) names)
else: else:
lines = self.FromObjectGeodeToASN1SCC.Map( 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)", "(param1)",
"var_" + self.CleanNameAsToolWants(nodeTypename), "var_" + self.CleanNameAsToolWants(nodeTypename),
node, node,
...@@ -715,7 +715,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -715,7 +715,7 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
fileOutHeader.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\\\n") fileOutHeader.write(" BitStream_AttachBuffer(&strm, pBuffer, iBufferSize);\\\n")
fileOutHeader.write( fileOutHeader.write(
" if(asn1Scc%s_%sDecode(&var_%s, &strm, &errorCode)) {\\\n" % " 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: else:
fileOutHeader.write( fileOutHeader.write(
" STATIC asn1Scc%s var_%s;\\\n" % " STATIC asn1Scc%s var_%s;\\\n" %
...@@ -728,8 +728,8 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -728,8 +728,8 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename))) (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
fileOutHeader.write(" {\\\n") fileOutHeader.write(" {\\\n")
#dstSDLVariable = (isinstance(node, AsnInt) or isinstance(node, AsnBool)) 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 = (isinstance(node, AsnInt)) and "(pSdlVar)" or "(*(pSdlVar))"
dstSDLVariable = "(*(pSdlVar))" dstSDLVariable = "(*(pSdlVar))"
if self.useOSS and encoding.lower() == "uper": if self.useOSS and encoding.lower() == "uper":
...@@ -770,9 +770,9 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator): ...@@ -770,9 +770,9 @@ class OG_GlueGenerator(ASynchronousToolGlueGenerator):
fileOutHeader.write(" }\\\n") fileOutHeader.write(" }\\\n")
fileOutHeader.write("}\n\n") fileOutHeader.write("}\n\n")
#fileOutHeader.write( # fileOutHeader.write(
# "#define DECODE_%s(pBuffer, iBufferSize, pSdlVar) DECODE_UPER_%s(pBuffer, iBufferSize, pSdlVar)\n\n" % # "#define DECODE_%s(pBuffer, iBufferSize, pSdlVar) DECODE_UPER_%s(pBuffer, iBufferSize, pSdlVar)\n\n" %
# (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename))) # (self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
def OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS): def OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
......
...@@ -201,8 +201,8 @@ def setSharedLib(dll=None): ...@@ -201,8 +201,8 @@ def setSharedLib(dll=None):
'''.format(fvName=FVname, tcName=CleanSP)) '''.format(fvName=FVname, tcName=CleanSP))
g_PyDataModel.write('\ntc["{tcName}"] = '.format(tcName=CleanSP)) g_PyDataModel.write('\ntc["{tcName}"] = '.format(