diff options
Diffstat (limited to 'py_eval.h')
-rw-r--r-- | py_eval.h | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -1,7 +1,7 @@ #ifndef _PY_EVAL_H #define _PY_EVAL_H -#include "valexpr.h" +#include "xpath.h" #include "pyfstream.h" #include <string> @@ -15,13 +15,14 @@ namespace ledger { void shutdown_ledger_for_python(); -class python_interpreter_t : public valexpr_t::scope_t +class python_interpreter_t : public xml::xpath_t::scope_t { handle<> mmodule; - dict nspace; public: - python_interpreter_t(valexpr_t::scope_t * parent); + dict nspace; + + python_interpreter_t(xml::xpath_t::scope_t * parent); virtual ~python_interpreter_t() { Py_Finalize(); @@ -42,35 +43,35 @@ class python_interpreter_t : public valexpr_t::scope_t return eval(str, mode); } - class functor_t : public valexpr_t::functor_t { + class functor_t : public xml::xpath_t::functor_t { protected: object func; public: - python_functor_t(const std::string& name, object _func) - : valexpr_t::functor_t(name), func(_func) {} + functor_t(const std::string& name, object _func) + : xml::xpath_t::functor_t(name), func(_func) {} - virtual void operator()(value_t& result, valexpr_t::scope_t * locals); + virtual void operator()(value_t& result, xml::xpath_t::scope_t * locals); }; - virtual void define(const std::string& name, valexpr_t::node_t * def) { + virtual void define(const std::string& name, xml::xpath_t::op_t * def) { // Pass any definitions up to our parent parent->define(name, def); } - virtual node_t * lookup(const std::string& name) { + virtual xml::xpath_t::op_t * lookup(const std::string& name) { object func = eval(name); if (! func) return parent ? parent->lookup(name) : NULL; - return valexpr_t::wrap_functor(new python_functor_t(name, func)); + return xml::xpath_t::wrap_functor(new functor_t(name, func)); } class lambda_t : public functor_t { public: - python_lambda_t(object code) : python_functor_t("<lambda>"> code) {} + lambda_t(object code) : functor_t("<lambda>", code) {} - virtual void operator()(value_t& result, valexpr_t::scope_t * locals); + virtual void operator()(value_t& result, xml::xpath_t::scope_t * locals); }; -; +}; } // namespace ledger |