Simplified usage of Boost.Python in several cases
This commit is contained in:
parent
34ee358f5e
commit
8bd16b2e8e
9 changed files with 23 additions and 22 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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>()))
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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>();
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#ifndef _PY_UTILS_H
|
||||
#define _PY_UTILS_H
|
||||
|
||||
|
||||
template <typename T, typename TfromPy>
|
||||
struct object_from_python
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue