Commit a51da808 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Added configuration file for flake8 pass, too

parent 8c985d5f
[flake8]
ignore = E501,E225,C103
max-line-length = 160
......@@ -219,8 +219,8 @@ An example for SetLength:
return "Choose the information you want - whole-structure or sequence dump not supported."
def __getattr__(self, x):
self._Caccessor += "_"+Clean(x)
self._accessPath += "."+x
self._Caccessor += "_" + Clean(x)
self._accessPath += "." + x
return self
def __setattr__(self, name, value):
......@@ -237,7 +237,7 @@ An example for SetLength:
def Get(self, **args): # postfix="", reset=True
try:
bridgeFuncName = Clean(self._nodeTypeName) + "_" + self._Caccessor + "_Get"+args.get("postfix", "")
bridgeFuncName = Clean(self._nodeTypeName) + "_" + self._Caccessor + "_Get" + args.get("postfix", "")
if bridgeFuncName not in DV_Types.funcTypeLookup:
raise AsnCoderError("Function %s not found in lookup - contact support." % bridgeFuncName)
resType = DV_Types.funcTypeLookup[bridgeFuncName]
......@@ -269,7 +269,7 @@ An example for SetLength:
def Set(self, value, **args): # postfix="", reset=True
try:
# print Clean(self._nodeTypeName) + "_" + self._Caccessor + "_Set"+postfix
bridgeFunc = getattr(JMP, Clean(self._nodeTypeName) + "_" + self._Caccessor + "_Set"+args.get("postfix", ""))
bridgeFunc = getattr(JMP, Clean(self._nodeTypeName) + "_" + self._Caccessor + "_Set" + args.get("postfix", ""))
if isinstance(value, float):
ctypesValue = c_double(value)
elif isinstance(value, int):
......@@ -283,8 +283,9 @@ An example for SetLength:
oldAP = self._accessPath
if args.get("reset", True):
self.Reset()
raise AsnCoderError("The access path you used (%s) or the value you tried to assign (%s) is not valid. %s" %
(oldAP, str(value), str(e)))
raise AsnCoderError(
"The access path you used (%s) or the value you tried to assign (%s) is not valid. %s" % (
oldAP, str(value), str(e)))
if args.get("reset", True):
self.Reset()
......@@ -298,7 +299,7 @@ An example for SetLength:
def getErrCode(pErr):
errCode = 0
for i in range(4):
errCode = (errCode << 8) | GetBufferByte(pErr, (3-i))
errCode = (errCode << 8) | GetBufferByte(pErr, (3 - i))
return errCode
def Encode(self, bitstream, bACN=False):
......
......@@ -46,6 +46,7 @@ from commonPy.recursiveMapper import RecursiveMapper
import commonPy.verify
def usage():
'''Print usage instructions.'''
msg = 'Usage: %s <options> input1.asn1 [input2.asn1]...\nWhere options are:\n'
......@@ -114,7 +115,7 @@ class Printer(RecursiveMapper):
lines.append(
"%sif (%s.kind == %s) {" %
(self.maybeElse(childNo), srcCVariable, self.CleanName(child[2])))
lines.extend([' '+x
lines.extend([' ' + x
for x in self.Map(
"%s.u.%s" % (srcCVariable, self.CleanName(child[0])),
prefix + "::" + self.CleanName(child[0]),
......@@ -131,7 +132,7 @@ class Printer(RecursiveMapper):
lines.append(" int i%s;" % uniqueId)
limit = sourceSequenceLimit(node, srcCVariable)
lines.append(" for(i%s=0; i%s<%s; i%s++) {" % (uniqueId, uniqueId, limit, uniqueId))
lines.extend([" "+x
lines.extend([" " + x
for x in self.Map(
"%s.arr[i%s]" % (srcCVariable, uniqueId),
prefix + "::Elem",
......@@ -153,7 +154,7 @@ def main():
if sys.argv.count("-o") != 0:
idx = sys.argv.index("-o")
try:
commonPy.configMT.outputDir = os.path.normpath(sys.argv[idx+1]) + os.sep
commonPy.configMT.outputDir = os.path.normpath(sys.argv[idx + 1]) + os.sep
except: # pragma: no cover
usage() # pragma: no cover
del sys.argv[idx]
......@@ -239,7 +240,7 @@ def main():
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write(' pthread_mutex_lock(&g_printing_mutex);\n')
C_SourceFile.write('#endif\n')
lines = [" "+x
lines = [" " + x
for x in printer.Map(
'(*pData)',
'',
......
......@@ -129,7 +129,7 @@ class Printer(RecursiveMapper):
(self.maybeElse(childNo), srcCVariable, self.CleanName(child[2])))
lines.append(" printf(\"%s:\");" % child[0]) # Choices need the field name printed
lines.extend(
[' '+x
[' ' + x
for x in self.Map(
"%s.u.%s" % (srcCVariable, self.CleanName(child[0])),
prefix + "::" + self.CleanName(child[0]),
......@@ -150,7 +150,7 @@ class Printer(RecursiveMapper):
lines.append(" if (i%s) " % uniqueId)
lines.append(" printf(\",\");")
lines.extend(
[" "+x
[" " + x
for x in self.Map(
"%s.arr[i%s]" % (srcCVariable, uniqueId),
prefix + "::Elem",
......@@ -173,7 +173,7 @@ def main():
if sys.argv.count("-o") != 0:
idx = sys.argv.index("-o")
try:
commonPy.configMT.outputDir = os.path.normpath(sys.argv[idx+1]) + os.sep
commonPy.configMT.outputDir = os.path.normpath(sys.argv[idx + 1]) + os.sep
except: # pragma: no cover
usage() # pragma: no cover
del sys.argv[idx]
......@@ -262,7 +262,7 @@ def main():
C_SourceFile.write(' //printf("%%s %s ::= ", paramName);\n' % nodeTypename)
C_SourceFile.write(' printf("%s ", paramName);\n')
# C_SourceFile.write('\n'.join(printer.Map('(*pData)', '', node, leafTypeDict, commonPy.asnParser.g_names)))
lines = [" "+x for x in printer.Map('(*pData)', '', node, leafTypeDict, commonPy.asnParser.g_names)]
lines = [" " + x for x in printer.Map('(*pData)', '', node, leafTypeDict, commonPy.asnParser.g_names)]
C_SourceFile.write("\n".join(lines))
C_SourceFile.write('\n#ifdef __linux__\n')
C_SourceFile.write(' pthread_mutex_unlock(&g_printing_mutex);\n')
......
......@@ -350,17 +350,17 @@ def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDi
if node._range == []:
panic("Python_A_mapper: string (in %s) must have a SIZE constraint!\n" % node.Location()) # pragma: no cover
if isSequenceVariable(node):
CommonBaseImpl("OCTETSTRING", "long", path, params, accessPathInC+".nCount", "Length")
CommonBaseImpl("OCTETSTRING", "long", path, params, accessPathInC + ".nCount", "Length")
else:
CommonBaseImplSequenceFixed("OCTETSTRING", "long", path, params, accessPathInC+".nCount", node, "Length")
CommonBaseImplSequenceFixed("OCTETSTRING", "long", path, params, accessPathInC + ".nCount", node, "Length")
params.AddParam('int', "iDx", leafTypeDict)
CommonBaseImpl("OCTETSTRING_bytes", "byte", path+"_iDx", params, accessPathInC + (".arr["+params._vars[-1]+"]"), "")
CommonBaseImpl("OCTETSTRING_bytes", "byte", path + "_iDx", params, accessPathInC + (".arr[" + params._vars[-1] + "]"), "")
params.Pop()
elif isinstance(node, AsnEnumerated):
CommonBaseImpl("ENUMERATED", "int", path, params, accessPathInC)
elif isinstance(node, AsnSequence) or isinstance(node, AsnSet) or isinstance(node, AsnChoice):
if isinstance(node, AsnChoice):
CommonBaseImpl("CHOICE selector", "int", path+"_kind", params, accessPathInC+".kind")
CommonBaseImpl("CHOICE selector", "int", path + "_kind", params, accessPathInC + ".kind")
union = ""
if isinstance(node, AsnChoice):
union = ".u"
......@@ -372,18 +372,18 @@ def CreateGettersAndSetters(path, params, accessPathInC, node, names, leafTypeDi
baseTypeOfChild = leafTypeDict.get(baseTypeOfChild, baseTypeOfChild)
if baseTypeOfChild not in ['INTEGER', 'REAL', 'BOOLEAN', 'OCTET STRING', 'ENUMERATED']:
useStar = '' if baseTypeOfChild.endswith('OF') else '*'
CommonBaseImpl("Field " + childVarname + " selector", CleanNameAsPythonWants(childNode._containedType)+useStar, path+"_"+childVarname, params, accessPathInC+union+"."+childVarname, returnPointer=not baseTypeOfChild.endswith('OF'))
CreateGettersAndSetters(path+"_"+childVarname, params, accessPathInC+union+"."+childVarname, child[1], names, leafTypeDict)
CommonBaseImpl("Field " + childVarname + " selector", CleanNameAsPythonWants(childNode._containedType) + useStar, path + "_" + childVarname, params, accessPathInC + union + "." + childVarname, returnPointer=not baseTypeOfChild.endswith('OF'))
CreateGettersAndSetters(path + "_" + childVarname, params, accessPathInC + union + "." + childVarname, child[1], names, leafTypeDict)
elif isinstance(node, AsnSequenceOf) or isinstance(node, AsnSetOf):
containedNode = node._containedType
if isinstance(containedNode, str):
containedNode = names[containedNode]
if isSequenceVariable(node):
CommonBaseImpl("SEQUENCEOF/SETOF", "long", path, params, accessPathInC+".nCount", "Length")
CommonBaseImpl("SEQUENCEOF/SETOF", "long", path, params, accessPathInC + ".nCount", "Length")
else:
CommonBaseImplSequenceFixed("SEQUENCEOF/SETOF", "long", path, params, accessPathInC+".nCount", node, "Length")
CommonBaseImplSequenceFixed("SEQUENCEOF/SETOF", "long", path, params, accessPathInC + ".nCount", node, "Length")
params.AddParam('int', "iDx", leafTypeDict)
CreateGettersAndSetters(path+"_iDx", params, accessPathInC + (".arr["+params._vars[-1]+"]"), node._containedType, names, leafTypeDict)
CreateGettersAndSetters(path + "_iDx", params, accessPathInC + (".arr[" + params._vars[-1] + "]"), node._containedType, names, leafTypeDict)
params.Pop()
......@@ -448,8 +448,8 @@ def DumpTypeDumper(codeIndent, outputIndent, lines, variableName, node, names):
lines.append(codeIndent + 'def emitElem(i):')
lines.append(codeIndent + ' if i>0:')
lines.append(codeIndent + ' lines.append(",")')
DumpTypeDumper(codeIndent+" ", outputIndent+" ", lines,
variableName+'[i]', containedNode, names)
DumpTypeDumper(codeIndent + " ", outputIndent + " ", lines,
variableName + '[i]', containedNode, names)
lines.append(codeIndent + "map(emitElem, xrange(%s.GetLength()))" % variableName)
lines.append(codeIndent + 'lines.append("}")')
......@@ -480,7 +480,7 @@ def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict:
g_outputFile.write(" super(" + name + ", self).__init__(\"" + name + "\", ptr)\n")
if isinstance(node, AsnString):
g_outputFile.write('''#\n''')
CreateGettersAndSetters(name+"_", Params(nodeTypename), "", node, names, leafTypeDict)
CreateGettersAndSetters(name + "_", Params(nodeTypename), "", node, names, leafTypeDict)
g_outputFile.write("\n def GSER(self):\n")
g_outputFile.write(" ''' Return the GSER representation of the value '''\n")
g_outputFile.write(" lines = []\n")
......
......@@ -284,7 +284,7 @@ def CreateDeclarationForType(nodeTypename, names, leafTypeDict):
if elemNo > 1:
g_outputFile.write('[')
for i in range(0, elemNo):
g_outputFile.write("%s_elem%02d " % (CleanNameAsSimulinkWants(nodeTypename), i+1))
g_outputFile.write("%s_elem%02d " % (CleanNameAsSimulinkWants(nodeTypename), i + 1))
if elemNo > 1:
g_outputFile.write(']')
g_outputFile.write(";\n\n")
......
......@@ -263,7 +263,7 @@ def CreateDeclarationForType(nodeTypename, names, leafTypeDict):
if elemNo > 1:
g_outputFile.write('[')
for i in range(0, elemNo):
g_outputFile.write("%s_elem%02d " % (CleanNameAsSimulinkWants(nodeTypename), i+1))
g_outputFile.write("%s_elem%02d " % (CleanNameAsSimulinkWants(nodeTypename), i + 1))
if elemNo > 1:
g_outputFile.write(']')
g_outputFile.write(";\n\n")
......
......@@ -302,14 +302,14 @@ def OnEnumerated(nodeTypename, node, unused_leafTypeDict):
# g_outputFile.write("\t %s[%s]" % (CleanNameAsScadeWants(member[0]), member[1]))
controlString += 'Value$name=%(enumerant)s`values,pragmas,ed:Value$oid=%(oid)s,kcg:Pragma`pragmas,TEXTenum_val %(value)s,' % {
"enumerant": CleanNameAsScadeWants(member[0]),
"oid": GetOID(nodeTypename+"_"+member[0]),
"oid": GetOID(nodeTypename + "_" + member[0]),
"value": member[1]
}
else: # pragma: no cover
controlString += 'Value$name=%(enumerant)s`values,pragmas,ed:Value$oid=%(oid)s,' % \
{ # pragma: no cover
"enumerant": CleanNameAsScadeWants(member[0]), # pragma: no cover
"oid": GetOID(nodeTypename+"_"+member[0]) # pragma: no cover
"oid": GetOID(nodeTypename + "_" + member[0]) # pragma: no cover
} # pragma: no cover
controlString += 'pragmas`Type,ed:Type$oid=!ed/%(oid)s' % {"oid": oid}
RenderElements(controlString)
......
......@@ -261,7 +261,7 @@ def CreateDeclarationForType(nodeTypename, names, leafTypeDict):
if elemNo > 1:
g_outputFile.write('[')
for i in range(0, elemNo):
g_outputFile.write("%s_elem%02d " % (CleanNameAsSimulinkWants(nodeTypename), i+1))
g_outputFile.write("%s_elem%02d " % (CleanNameAsSimulinkWants(nodeTypename), i + 1))
if elemNo > 1:
g_outputFile.write(']')
g_outputFile.write(";\n\n")
......
......@@ -363,8 +363,8 @@ class {cleanTypename}_SQL(Base):
def CreateEnumerated(nodeTypename, node, unused_leafTypeDict):
checkConstraint = ' OR '.join('data='+x[1] for x in node._members)
constants = '\n '.join(CleanName(x[0])+' = '+x[1]
checkConstraint = ' OR '.join('data=' + x[1] for x in node._members)
constants = '\n '.join(CleanName(x[0]) + ' = ' + x[1]
for x in node._members)
# defValue = CleanName(nodeTypename) + "_SQL." + CleanName(node._members[0][0])
g_sqlalchemyOutput.write('''
......
......@@ -26,7 +26,7 @@ def main():
for si in SystemsAndImplementations:
sp, sp_impl, modelingLanguage, fv_name = si[0], si[1], si[2], si[3]
sp = commonPy.aadlAST.g_apLevelContainers[sp]
print(sp._id+"."+sp_impl, "(", modelingLanguage, ") FV_name:", fv_name)
print(sp._id + "." + sp_impl, "(", modelingLanguage, ") FV_name:", fv_name)
for param in sp._params:
print("\t", end=' ')
if isinstance(param, commonPy.aadlAST.InParam):
......@@ -43,7 +43,7 @@ def main():
if len(sp._connections):
print("\tConnections:")
for pair in sp._connections:
print("\t\tfrom", pair._from._componentId+':'+pair._from._portId, "to", pair._to._componentId+':'+pair._to._portId)
print("\t\tfrom", pair._from._componentId + ':' + pair._from._portId, "to", pair._to._componentId + ':' + pair._to._portId)
print()
if __name__ == "__main__":
......
......@@ -104,7 +104,7 @@ class FromCtoOSS(RecursiveMapper):
lines.append("%sif (%s.kind == %s) {\n" %
(self.maybeElse(childNo), srcCVariable, self.CleanName(child[2])))
lines.extend(
[' '+x
[' ' + x
for x in self.Map(
"%s.u.%s" % (srcCVariable, self.CleanName(child[0])),
destVar + ".u." + self.CleanName(child[0]),
......@@ -123,7 +123,7 @@ class FromCtoOSS(RecursiveMapper):
limit = sourceSequenceLimit(node, srcCVariable)
lines.append(" for(i%s=0; i%s<%s; i%s++) {\n" % (uniqueId, uniqueId, limit, uniqueId))
lines.extend(
[" "+x
[" " + x
for x in self.Map(
"%s.arr[i%s]" % (srcCVariable, uniqueId),
"%s.value[i%s]" % (destVar, uniqueId),
......@@ -194,7 +194,7 @@ class FromOSStoC(RecursiveMapper):
lines.append("%sif (%s.choice == OSS_%s_chosen) {\n" %
(self.maybeElse(childNo), srcVar, self.CleanName(child[0])))
lines.extend(
[' '+x
[' ' + x
for x in self.Map(
srcVar + ".u." + self.CleanName(child[0]),
"%s.u.%s" % (dstCVariable, self.CleanName(child[0])),
......@@ -215,7 +215,7 @@ class FromOSStoC(RecursiveMapper):
lines.append(" for(i%s=0; i%s<%s; i%s++) {\n" %
(uniqueId, uniqueId, targetSequenceLimit(node, dstCVariable), uniqueId))
lines.extend(
[" "+x
[" " + x
for x in self.Map(
srcVar + ".value[i%s]" % uniqueId,
"%s.arr[i%s]" % (dstCVariable, uniqueId),
......@@ -291,7 +291,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
node,
leafTypeDict,
names)
lines = [" "+x for x in lines]
lines = [" " + x for x in lines]
self.C_SourceFile.write("".join(lines))
if self.useOSS and encoding.lower() == "uper":
......@@ -386,7 +386,7 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
node,
leafTypeDict,
names)
lines = [" "+x for x in lines]
lines = [" " + x for x in lines]
self.C_SourceFile.write("".join(lines))
if self.useOSS and encoding.lower() == "uper":
......
......@@ -220,15 +220,15 @@ def OneTimeOnly(unused_modelingLanguage, asnFile, subProgram, subProgramImplemen
#define SYMBOL_TELECMDS_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxDIALOG_MODAL|wxTAB_TRAVERSAL
''')
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_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_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_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_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_HeaderFile.write("\n")
g_HeaderFile.write('''
......@@ -257,13 +257,13 @@ public:
};
''')
global g_MyEvents
g_MyEvents = open(outputDir+"MyEvents.inc", "w")
g_MyEvents = open(outputDir + "MyEvents.inc", "w")
global g_MyCreation
g_MyCreation = open(outputDir+"MyCreation.inc", "w")
g_MyCreation = open(outputDir + "MyCreation.inc", "w")
global g_MyClickPrototypes
g_MyClickPrototypes = open(outputDir+"MyClickPrototypes.inc", "w")
g_MyClickPrototypes = open(outputDir + "MyClickPrototypes.inc", "w")
global g_MyControls
g_MyControls = open(outputDir+"MyControls.inc", "w")
g_MyControls = open(outputDir + "MyControls.inc", "w")
global g_MyLoad
g_MyLoad = open(g_outputDir + 'MyLoad.inc', 'w')
global g_MySave
......@@ -283,7 +283,7 @@ public:
WriteSourceFileStart()
g_SourceFile.write("\n")
if maybeFVname == "":
panic("GUI APLCs must have an FV_Name attribute! (%s)\n" % subProgram._id+"."+subProgramImplementation) # pragma: no cover
panic("GUI APLCs must have an FV_Name attribute! (%s)\n" % subProgram._id + "." + subProgramImplementation) # pragma: no cover
g_SourceFile.write("#include \"%s_gui_header.h\"\n\n" % maybeFVname)
g_SourceFile.write("#include \"queue_manager.h\"\n\n")
g_SourceFile.write("void TeleCmds::OnMenu_Click( wxCommandEvent& event )\n{\n")
......@@ -346,7 +346,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
OneTimeOnly(modelingLanguage, asnFile, subProgram, subProgramImplementation, outputDir, maybeFVname, useOSS)
global g_IDs
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_MyEvents.write(" EVT_MENU( ID_MENU_RI, TeleCmds::OnMenu_Click )\n")
g_MyEvents.write(" EVT_MENU( ID_MENU_LOAD, TeleCmds::OnMenu_Load )\n")
......@@ -382,9 +382,9 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
# g_MyCreation.write("itemBoxSizerButtons_%s->Add(itemButton_quit_%s, 0, wxALIGN_RIGHT|wxALL, 5);\n\n" % (CleanSP, CleanSP))
# have we ever seen before the combination of FVname and Language?
if maybeFVname+modelingLanguage.lower() not in g_perFV:
if maybeFVname + modelingLanguage.lower() not in g_perFV:
# No, check for things that must be instantiated once per FV+Lang
g_perFV[maybeFVname+modelingLanguage.lower()] = maybeFVname
g_perFV[maybeFVname + modelingLanguage.lower()] = maybeFVname
# The first time you see an FV with an sp_impl that is also a GUI_PI, create a thread to poll /FVName_PI_queue
if modelingLanguage.lower() == "gui_pi":
......@@ -465,7 +465,7 @@ def OnStartup(modelingLanguage, asnFile, subProgram, subProgramImplementation, o
g_MyTelemetryActions.write(" asn1Scc%s var_%s;\n" % (CleanASNType, CleanParam))
g_MyTelemetryActions.write(" memcpy(&var_%s, pData, sizeof(var_%s));\n" % (CleanParam, CleanParam))
g_MyTelemetryActions.write(" pData += sizeof(var_%s);\n" % CleanParam)
CopyDataFromASN1ToDlg(g_MyTelemetryActions, "_pFrame->", "var_"+CleanParam, "%s_%s" %
CopyDataFromASN1ToDlg(g_MyTelemetryActions, "_pFrame->", "var_" + CleanParam, "%s_%s" %
(CleanSP, CleanParam), node, leafTypeDict, names)
g_MyTelemetryActions.write(' PrintASN1%s("TMDATA: %s::%s", &var_%s);\n' %
(CleanASNType, CleanSP, CleanParam, CleanParam))
......@@ -482,7 +482,7 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
CleanParam = CleanName(param._id)
ScrollWnd = "_itemScrolledWindow_%s" % CleanSP
if prefix == "":
prefix = CleanSP+"::"+CleanParam
prefix = CleanSP + "::" + CleanParam
varPrefix = prefix.replace("::", "_")
txtPrefix = re.sub(r'^.*::', '', prefix)
# Depending on the type of the node, create the appropriate controls
......@@ -546,7 +546,7 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
(varPrefix, child[0]))
g_HeaderFile.write("#define ID_CHOICE_%s %s\n" % (varPrefix, g_IDs))
g_IDs += 1
g_MyEvents.write(" EVT_CHOICE( ID_CHOICE_"+varPrefix+", TeleCmds::UpdateChoice_"+varPrefix+" )\n")
g_MyEvents.write(" EVT_CHOICE( ID_CHOICE_" + varPrefix + ", TeleCmds::UpdateChoice_" + varPrefix + " )\n")
g_MyControls.write("wxChoice* _itemChoice_%s;\n" % varPrefix)
g_MyCreation.write("_itemChoice_%s = new wxChoice(%s, ID_CHOICE_%s, wxDefaultPosition, wxDefaultSize, _itemChoiceStrings_%s, 0);\n" %
(varPrefix, ScrollWnd, varPrefix, varPrefix))
......@@ -569,11 +569,11 @@ def WriteCodeForGUIControls(prefix, parentControl, node, subProgram, subProgramI
count = 0
for child in node._members:
g_SourceFile.write(" if (%d == _itemChoice_%s->GetCurrentSelection()) {\n" % (count, varPrefix))
g_SourceFile.write(" _itemStaticBoxSizer_%s->Show((size_t)%d);\n" % (varPrefix, count+1))
g_SourceFile.write(" _itemStaticBoxSizer_%s->Show((size_t)%d);\n" % (varPrefix, count + 1))
oCount = 0
for child in node._members:
if oCount != count:
g_SourceFile.write(" _itemStaticBoxSizer_%s->Show((size_t)%d);\n" % (varPrefix, oCount+1))
g_SourceFile.write(" _itemStaticBoxSizer_%s->Show((size_t)%d);\n" % (varPrefix, oCount + 1))
oCount += 1
g_SourceFile.write(" }\n")
count += 1
......@@ -632,18 +632,18 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
elif isinstance(node, AsnOctetString):
f.write("{\n")
control = "_itemTextCtrl_" + srcVar + "->GetValue()"
f.write(" for(size_t i=0; i<"+control+".size(); i++)\n")
f.write(" "+destVar+".arr[i] = "+control+".at(i);\n")
f.write(" for(size_t i=0; i<" + control + ".size(); i++)\n")
f.write(" " + destVar + ".arr[i] = " + control + ".at(i);\n")
if isSequenceVariable(node):
f.write(" "+destVar+".nCount = _itemTextCtrl_" + srcVar + "->GetValue().size();\n")
f.write(" " + destVar + ".nCount = _itemTextCtrl_" + srcVar + "->GetValue().size();\n")
f.write("}\n")
elif isinstance(node, AsnBool):
f.write(destVar + " = (asn1SccUint) (_itemCheckBox_" + srcVar + "->Get3StateValue() == wxCHK_CHECKED);\n")
elif isinstance(node, AsnEnumerated):
enumNo = 0
for enumOption in node._members:
f.write(("%sif (_itemChoice_" % maybeElseZero(enumNo))+srcVar+"->GetCurrentSelection() == "+str(enumNo)+") {\n")
f.write(" "+destVar+" = ENUM_asn1Scc" + CleanName(enumOption[0]) + ";\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
elif isinstance(node, AsnSequence) or isinstance(node, AsnSet):
......@@ -662,7 +662,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
if isinstance(childType, AsnMetaMember):
childType = names[childType._containedType]
CopyDataFromDlgToASN1(f, srcVar + "_" + CleanChild, destVar + ".u." + CleanChild, childType, leafTypeDict, names)
f.write(" "+destVar+".kind = CHOICE_" + child[2] + ";\n")
f.write(" " + destVar + ".kind = CHOICE_" + child[2] + ";\n")
f.write("}\n")
childNo += 1
elif isinstance(node, AsnSequenceOf) or isinstance(node, AsnSetOf):
......@@ -681,7 +681,7 @@ def CopyDataFromDlgToASN1(f, srcVar, destVar, node, leafTypeDict, names):
# 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")
f.write("if (" + destVar + ".nCount>" + str(i) + ") {\n")
CopyDataFromDlgToASN1(f, srcVar + "_Elem_" + ("%02d" % i), destVar + ".arr[" + str(i) + "]", containedNode, leafTypeDict, names)
if isSequenceVariable(node):
f.write("}\n")
......@@ -691,7 +691,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
if isinstance(node, AsnInt):
fDesc.write("{\n")
fDesc.write(" ostringstream s;\n")
fDesc.write(" s << "+srcVar+";\n")
fDesc.write(" s << " + srcVar + ";\n")
if not bClear:
fDesc.write(" %s_itemTextCtrl_%s->SetValue(wxString(wxConvLocal.cMB2WC(s.str().c_str())));\n" % (prefix, destVar))
else:
......@@ -700,35 +700,35 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
elif isinstance(node, AsnReal):
fDesc.write("{\n")
fDesc.write(" ostringstream s;\n")
fDesc.write(" s << fixed << setprecision(8) <<"+srcVar+";\n")
fDesc.write(" s << fixed << setprecision(8) <<" + srcVar + ";\n")
if not bClear:
fDesc.write(" %s_itemTextCtrl_%s->SetValue(wxString(wxConvLocal.cMB2WC(s.str().c_str())));\n" % (prefix, destVar))
else:
fDesc.write(" %s_itemTextCtrl_%s->SetValue(wxString(wxConvLocal.cMB2WC(\"\")));\n" % (prefix, destVar))
fDesc.write("}\n")
elif isinstance(node, AsnOctetString):
control = prefix+"_itemTextCtrl_" + destVar
control = prefix + "_itemTextCtrl_" + destVar
limit = sourceSequenceLimit(node, srcVar)
if not bClear:
fDesc.write(control+"->SetValue(wxString(wxConvLocal.cMB2WC(string((const char *)"+srcVar+".arr, "+limit+").c_str())));\n")
fDesc.write(control + "->SetValue(wxString(wxConvLocal.cMB2WC(string((const char *)" + srcVar + ".arr, " + limit + ").c_str())));\n")
else:
fDesc.write(control+"->SetValue(wxString(wxConvLocal.cMB2WC(\"\")));\n")
fDesc.write(control + "->SetValue(wxString(wxConvLocal.cMB2WC(\"\")));\n")
elif isinstance(node, AsnBool):
control = prefix+"_itemCheckBox_" + destVar
control = prefix + "_itemCheckBox_" + destVar
if not bClear:
fDesc.write(control + "->Set3StateValue("+srcVar+"?wxCHK_CHECKED:wxCHK_UNCHECKED);\n")
fDesc.write(control + "->Set3StateValue(" + srcVar + "?wxCHK_CHECKED:wxCHK_UNCHECKED);\n")
else:
fDesc.write(control + "->Set3StateValue(wxCHK_UNCHECKED);\n")
elif isinstance(node, AsnEnumerated):
enumNo = 0
if not bClear:
for enumOption in node._members:
fDesc.write(("%sif (" % maybeElseZero(enumNo))+srcVar+" == ENUM_asn1Scc" + CleanName(enumOption[0]) + ") {\n")
fDesc.write(" "+prefix+"_itemChoice_"+destVar+"->SetSelection(%d);\n" % enumNo)
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
else:
fDesc.write(" "+prefix+"_itemChoice_"+destVar+"->SetSelection(0);\n")
fDesc.write(" " + prefix + "_itemChoice_" + destVar + "->SetSelection(0);\n")
elif isinstance(node, AsnSequence) or isinstance(node, AsnSet):
for child in node._members:
CleanChild = CleanName(child[0])
......@@ -743,7 +743,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
childType = child[1]
fDesc.write("%sif (%s.kind == CHOICE_%s) {\n" %
(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(" %sUpdateChoice_" % prefix + destVar + "(dum);\n")
if isinstance(childType, AsnMetaMember):
......@@ -758,7 +758,7 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
# The decoding code has been executed, so the .nCount member is ready...
for i in range(0, node._range[-1]):
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)
fDesc.write("} else {\n")
CopyDataFromASN1ToDlg(fDesc, prefix, srcVar + ".arr[" + str(i) + "]", destVar + "_Elem_" + ("%02d" % i), containedNode, leafTypeDict, names, True)
......@@ -768,15 +768,15 @@ def CopyDataFromASN1ToDlg(fDesc, prefix, srcVar, destVar, node, leafTypeDict, na
if isSequenceVariable(node):
fDesc.write("{\n")
fDesc.write(" ostringstream s;\n")
fDesc.write(" s << "+srcVar+".nCount;\n")
fDesc.write(" "+prefix+"_itemTextCtrl_%s->SetValue(wxString(wxConvLocal.cMB2WC(s.str().c_str())));\n" % destVar)
fDesc.write(" s << " + srcVar + ".nCount;\n")
fDesc.write(" " + prefix + "_itemTextCtrl_%s->SetValue(wxString(wxConvLocal.cMB2WC(s.str().c_str())));\n" % destVar)
fDesc.write("}\n")
def WriteCodeForSave(nodeTypename, node, subProgram, unused_subProgramImplementation, param, leafTypeDict, names):
CleanSP = CleanName(subProgram._id)
CleanParam = CleanName(param._id)
CopyDataFromDlgToASN1(g_MySave, "%s_%s" % (CleanSP, CleanParam), "var_"+CleanParam, node, leafTypeDict, names)
CopyDataFromDlgToASN1(g_MySave, "%s_%s" % (CleanSP, CleanParam), "var_" + CleanParam, node, leafTypeDict, names)
g_MySave.write("{\n int ErrCode;\n")
g_MySave.write(" if (0 == asn1Scc%s_IsConstraintValid(&var_%s, &ErrCode)) {\n" % (CleanName(nodeTypename), CleanParam))