diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-05 02:27:08 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-05 02:27:42 -0500 |
commit | 8bd16b2e8e61f914767e3d0973e83f7326f11cbc (patch) | |
tree | b7438f5e856b6d1be7fd1ab0c806d9eed9fa081e /src | |
parent | 34ee358f5e16d4018adf3db5dac31d2d9c16b9f5 (diff) | |
download | fork-ledger-8bd16b2e8e61f914767e3d0973e83f7326f11cbc.tar.gz fork-ledger-8bd16b2e8e61f914767e3d0973e83f7326f11cbc.tar.bz2 fork-ledger-8bd16b2e8e61f914767e3d0973e83f7326f11cbc.zip |
Simplified usage of Boost.Python in several cases
Diffstat (limited to 'src')
-rw-r--r-- | src/py_account.cc | 4 | ||||
-rw-r--r-- | src/py_balance.cc | 6 | ||||
-rw-r--r-- | src/py_commodity.cc | 4 | ||||
-rw-r--r-- | src/py_journal.cc | 12 | ||||
-rw-r--r-- | src/py_post.cc | 4 | ||||
-rw-r--r-- | src/py_value.cc | 4 | ||||
-rw-r--r-- | src/py_xact.cc | 4 | ||||
-rw-r--r-- | src/pyutils.h | 1 | ||||
-rw-r--r-- | src/system.hh.in | 6 |
9 files changed, 23 insertions, 22 deletions
diff --git a/src/py_account.cc b/src/py_account.cc index 3341c948..b0d0a843 100644 --- a/src/py_account.cc +++ b/src/py_account.cc @@ -172,7 +172,7 @@ void export_account() .add_property("parent", make_getter(&account_t::parent, - return_value_policy<reference_existing_object>())) + return_internal_reference<>())) .def_readwrite("name", &account_t::name) .def_readwrite("note", &account_t::note) @@ -197,7 +197,7 @@ void export_account() .def("valid", &account_t::valid) .def("__len__", accounts_len) - .def("__getitem__", accounts_getitem, return_internal_reference<1>()) + .def("__getitem__", accounts_getitem, return_internal_reference<>()) .def("__iter__", range<return_internal_reference<> > (&account_t::accounts_begin, &account_t::accounts_end)) diff --git a/src/py_balance.cc b/src/py_balance.cc index effc6937..6d0ad500 100644 --- a/src/py_balance.cc +++ b/src/py_balance.cc @@ -214,6 +214,12 @@ void export_balance() .def("valid", &balance_t::valid) ; + register_optional_to_python<balance_t>(); + + implicitly_convertible<long, balance_t>(); + implicitly_convertible<string, balance_t>(); + implicitly_convertible<amount_t, balance_t>(); + #define EXC_TRANSLATE(type) \ register_exception_translator<type>(&exc_translate_ ## type); diff --git a/src/py_commodity.cc b/src/py_commodity.cc index c0412a45..7cd84f1c 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -130,12 +130,12 @@ void export_commodity() class_< commodity_pool_t, boost::noncopyable > ("CommodityPool", no_init) .add_property("null_commodity", make_getter(&commodity_pool_t::null_commodity, - return_value_policy<reference_existing_object>()), + return_internal_reference<>()), make_setter(&commodity_pool_t::null_commodity, with_custodian_and_ward<1, 2>())) .add_property("default_commodity", make_getter(&commodity_pool_t::default_commodity, - return_value_policy<reference_existing_object>()), + return_internal_reference<>()), make_setter(&commodity_pool_t::default_commodity, with_custodian_and_ward<1, 2>())) diff --git a/src/py_journal.cc b/src/py_journal.cc index a9789840..9b3e7513 100644 --- a/src/py_journal.cc +++ b/src/py_journal.cc @@ -192,15 +192,15 @@ void export_journal() .def(init<string>()) .add_property("master", make_getter(&journal_t::master, - return_internal_reference<1>())) + return_internal_reference<>())) .add_property("basket", make_getter(&journal_t::basket, - return_internal_reference<1>()), + return_internal_reference<>()), make_setter(&journal_t::basket)) .add_property("was_loaded", make_getter(&journal_t::was_loaded)) .add_property("commodity_pool", make_getter(&journal_t::commodity_pool, - return_internal_reference<1>())) + return_internal_reference<>())) #if 0 .add_property("xact_finalize_hooks", make_getter(&journal_t::xact_finalize_hooks), @@ -210,10 +210,10 @@ void export_journal() .def("add_account", &journal_t::add_account) .def("remove_account", &journal_t::remove_account) - .def("find_account", py_find_account_1, return_internal_reference<1>()) - .def("find_account", py_find_account_2, return_internal_reference<1>()) + .def("find_account", py_find_account_1, return_internal_reference<>()) + .def("find_account", py_find_account_2, return_internal_reference<>()) .def("find_account_re", &journal_t::find_account_re, - return_internal_reference<1>()) + return_internal_reference<>()) .def("add_xact", &journal_t::add_xact) .def("remove_xact", &journal_t::remove_xact) diff --git a/src/py_post.cc b/src/py_post.cc index b4849c3d..9f7476d1 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -131,12 +131,12 @@ void export_post() .add_property("xact", make_getter(&post_t::xact, - return_value_policy<reference_existing_object>()), + return_internal_reference<>()), make_setter(&post_t::xact, with_custodian_and_ward<1, 2>())) .add_property("account", make_getter(&post_t::account, - return_value_policy<reference_existing_object>()), + return_internal_reference<>()), make_setter(&post_t::account, with_custodian_and_ward<1, 2>())) .add_property("amount", diff --git a/src/py_value.cc b/src/py_value.cc index eec3b833..6e4afaf7 100644 --- a/src/py_value.cc +++ b/src/py_value.cc @@ -314,7 +314,9 @@ void export_value() implicitly_convertible<long, value_t>(); implicitly_convertible<string, value_t>(); - // jww (2009-11-02): Add implicit conversion of mask objects + implicitly_convertible<amount_t, value_t>(); + implicitly_convertible<balance_t, value_t>(); + implicitly_convertible<mask_t, value_t>(); implicitly_convertible<date_t, value_t>(); implicitly_convertible<datetime_t, value_t>(); diff --git a/src/py_xact.cc b/src/py_xact.cc index 86e2e067..f5453d15 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -85,7 +85,7 @@ void export_xact() class_< xact_base_t, bases<item_t> > ("TransactionBase") .add_property("journal", make_getter(&xact_base_t::journal, - return_value_policy<reference_existing_object>()), + return_internal_reference<>()), make_setter(&xact_base_t::journal, with_custodian_and_ward<1, 2>())) @@ -146,7 +146,7 @@ void export_xact() ("AutomatedTransactionFinalizer") .add_property("journal", make_getter(&auto_xact_finalizer_t::journal, - return_value_policy<reference_existing_object>()), + return_internal_reference<>()), make_setter(&auto_xact_finalizer_t::journal, with_custodian_and_ward<1, 2>())) .def("__call__", &auto_xact_finalizer_t::operator()) diff --git a/src/pyutils.h b/src/pyutils.h index d9b94d50..5709eb35 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -32,7 +32,6 @@ #ifndef _PY_UTILS_H #define _PY_UTILS_H - template <typename T, typename TfromPy> struct object_from_python { diff --git a/src/system.hh.in b/src/system.hh.in index 96febb22..b0b8f1eb 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -243,12 +243,6 @@ void serialize(Archive& ar, istream_pos_type& pos, const unsigned int) #include <boost/python/detail/wrap_python.hpp> #include <datetime.h> -#include <boost/python/exception_translator.hpp> -#include <boost/python/implicit.hpp> -#include <boost/python/args.hpp> -#include <boost/python/module.hpp> -#include <boost/python/def.hpp> -#include <boost/python/to_python_converter.hpp> #include <boost/python/module_init.hpp> #endif // HAVE_BOOST_PYTHON |