Skip to content

Commit

Permalink
Solve generation of code not working
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-panda committed Jun 23, 2019
1 parent a7c665d commit 4041e8f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/visualstates/generators/cpprosgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def generateStateNamespaceClass(self, classStr):
classStr.append('class Namespace' + str(state.id) + ' {\n')
classStr.append('public:\n')
classStr.append('\tGlobalNamespace* globalNamespace;\n')
types, varNames, initialValues = CPPParser.parseVariables(state.getNamespace().variables)
types, varNames, initialValues = CPPParser.parseVariables(state.getNamespace().variables, state.getNamespace().params)
for i in range(len(types)):
classStr.append(types[i] + ' ' + varNames[i] + ';\n')
classStr.append('\n')
Expand Down
9 changes: 2 additions & 7 deletions src/visualstates/generators/pythonrosgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PythonRosGenerator(BaseGenerator):
def __init__(self, libraries, config, states, globalNamespace):
BaseGenerator.__init__(self, libraries, config, states, globalNamespace)

def generate(self, params, projectPath, projectName):
def generate(self, projectPath, projectName):
stringList = []
self.generateImports(stringList)
self.generateSignalHandling(stringList)
Expand All @@ -47,11 +47,6 @@ def generate(self, params, projectPath, projectName):
xmlDoc = self.generatePackageXml(self.config, projectName)
xmlStr = xmlDoc.toprettyxml(indent=' ')

# replacing parameters with their values
for param in params:
findText = '${' + param.name + '}'
sourceCode = sourceCode.replace(findText, param.value)

# writing to files
fp = open(projectPath + os.sep + projectName + '.py', 'w')
fp.write(sourceCode)
Expand Down Expand Up @@ -162,7 +157,7 @@ def generateStateClass(self, state, stateStr):
else:
varValue = param.value

stateStr.append('\t\t' + param.name + ' = ' + varValue + '\n')
stateStr.append('\t\tself.' + param.name + ' = ' + varValue + '\n')
stateStr.append('\n')

if (len(state.namespace.functions) > 0):
Expand Down
2 changes: 1 addition & 1 deletion src/visualstates/parsers/cppparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def parseFunctions(funcStr):
funcNames = []
codes = []
funcExists = True
while funcExists and len(funcStr) > 0 and funcStr.index('{') >= 0:
while funcExists and len(funcStr) > 0 and funcStr.find('{') >= 0:
funcStr = funcStr.strip()
funcStartIndex = funcStr.index('{')
funcSignature = funcStr[0:funcStartIndex].strip()
Expand Down

0 comments on commit 4041e8f

Please sign in to comment.