diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-23 15:59:01 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-23 15:59:01 -0400 |
commit | fc8dd144673675d959a3a8c7c2049f6bf12dd814 (patch) | |
tree | f07b2b76e68e89cf3e526b9ad1200b3802bf395c /python/pyinterp.cc | |
parent | 7aa42aa8b3947a43e128d1fe9123aef9c9c1b844 (diff) | |
download | fork-ledger-fc8dd144673675d959a3a8c7c2049f6bf12dd814.tar.gz fork-ledger-fc8dd144673675d959a3a8c7c2049f6bf12dd814.tar.bz2 fork-ledger-fc8dd144673675d959a3a8c7c2049f6bf12dd814.zip |
Create a py_value module, for translating value_t objects to/from Python.
Diffstat (limited to 'python/pyinterp.cc')
-rw-r--r-- | python/pyinterp.cc | 24 |
1 files changed, 9 insertions, 15 deletions
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<bool>(func)(); - else if (PyInt_Check(func.ptr())) - return long(extract<int>(func)()); - else if (PyString_Check(func.ptr())) - return string_value(extract<string>(func)()); - - extract<date_t> d(func); - if (d.check()) - return value_t(d()); - extract<datetime_t> dt(func); - if (dt.check()) - return value_t(dt()); - - return extract<value_t>(func); + extract<value_t> val(func); + if (val.check()) + return val(); + throw_(calc_error, + "Could not evaluate Python variable '" << name << "'"); } else { if (args.size() > 0) { list arglist; |