From fc8dd144673675d959a3a8c7c2049f6bf12dd814 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 23 Jan 2009 15:59:01 -0400 Subject: Create a py_value module, for translating value_t objects to/from Python. --- python/pyinterp.cc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'python/pyinterp.cc') diff --git a/python/pyinterp.cc b/python/pyinterp.cc index 582b8e78..6af17170 100644 --- a/python/pyinterp.cc +++ b/python/pyinterp.cc @@ -43,7 +43,9 @@ void export_amount(); void export_commodity(); #if 0 void export_balance(); +#endif void export_value(); +#if 0 void export_journal(); void export_parser(); void export_option(); @@ -61,7 +63,9 @@ void initialize_for_python() export_commodity(); #if 0 export_balance(); +#endif export_value(); +#if 0 export_journal(); export_parser(); export_option(); @@ -223,21 +227,11 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args) { try { if (! PyCallable_Check(func.ptr())) { - if (PyBool_Check(func.ptr())) - return extract(func)(); - else if (PyInt_Check(func.ptr())) - return long(extract(func)()); - else if (PyString_Check(func.ptr())) - return string_value(extract(func)()); - - extract d(func); - if (d.check()) - return value_t(d()); - extract dt(func); - if (dt.check()) - return value_t(dt()); - - return extract(func); + extract val(func); + if (val.check()) + return val(); + throw_(calc_error, + "Could not evaluate Python variable '" << name << "'"); } else { if (args.size() > 0) { list arglist; -- cgit v1.2.3