K
Kasper Middelboe Petersen
Hello,
I'm porting a python library to C++.
Part of this takes a string (in this case the variable action could be
something like a function call or simply "i = 25") and both compiles
and runs it within the context it is running as shown here:
....snip...
# Compiling and executing string
# Fetch process frame and namespace
processframe= inspect.currentframe()
steps = self.execute_frame
while (steps < 0):
processframe = processframe.f_back
steps += 1
# Compile source provided in a string.
code = compile(action,processframe.f_code.co_filename + ' line ' +
str(processframe.f_lineno) + ' in string' ,'exec')
f_globals = processframe.f_globals
f_locals = processframe.f_locals
if op==READ:
f_locals.update({'channel_input':req.msg})
# Execute action
exec(code, f_globals, f_locals)
....snip...
Is this possible to do in C++? And if so, please point me in the right
direction
Thanks,
Kasper
I'm porting a python library to C++.
Part of this takes a string (in this case the variable action could be
something like a function call or simply "i = 25") and both compiles
and runs it within the context it is running as shown here:
....snip...
# Compiling and executing string
# Fetch process frame and namespace
processframe= inspect.currentframe()
steps = self.execute_frame
while (steps < 0):
processframe = processframe.f_back
steps += 1
# Compile source provided in a string.
code = compile(action,processframe.f_code.co_filename + ' line ' +
str(processframe.f_lineno) + ' in string' ,'exec')
f_globals = processframe.f_globals
f_locals = processframe.f_locals
if op==READ:
f_locals.update({'channel_input':req.msg})
# Execute action
exec(code, f_globals, f_locals)
....snip...
Is this possible to do in C++? And if so, please point me in the right
direction
Thanks,
Kasper