From 8bd16b2e8e61f914767e3d0973e83f7326f11cbc Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 02:27:08 -0500 Subject: Simplified usage of Boost.Python in several cases --- src/py_commodity.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/py_commodity.cc') 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()), + 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()), + return_internal_reference<>()), make_setter(&commodity_pool_t::default_commodity, with_custodian_and_ward<1, 2>())) -- cgit v1.2.3 From 060fc0e00bacb96d1d16163779d98c45c3999014 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 02:27:29 -0500 Subject: Made many object methods in Python properties --- src/py_account.cc | 10 ++++++---- src/py_commodity.cc | 9 +++++---- src/py_item.cc | 15 +++++++++------ src/py_post.cc | 5 +++-- src/py_utils.cc | 15 +++++++++------ 5 files changed, 32 insertions(+), 22 deletions(-) (limited to 'src/py_commodity.cc') diff --git a/src/py_account.cc b/src/py_account.cc index b0d0a843..8310f5ec 100644 --- a/src/py_account.cc +++ b/src/py_account.cc @@ -142,9 +142,10 @@ void export_account() class_< account_t::xdata_t > ("AccountXData") #if 1 - .def("flags", &supports_flags::flags) + .add_property("flags", + &supports_flags::flags, + &supports_flags::set_flags) .def("has_flags", &supports_flags::has_flags) - .def("set_flags", &supports_flags::set_flags) .def("clear_flags", &supports_flags::clear_flags) .def("add_flags", &supports_flags::add_flags) .def("drop_flags", &supports_flags::drop_flags) @@ -162,9 +163,10 @@ void export_account() class_< account_t > ("Account") #if 1 - .def("flags", &supports_flags<>::flags) + .add_property("flags", + &supports_flags<>::flags, + &supports_flags<>::set_flags) .def("has_flags", &supports_flags<>::has_flags) - .def("set_flags", &supports_flags<>::set_flags) .def("clear_flags", &supports_flags<>::clear_flags) .def("add_flags", &supports_flags<>::add_flags) .def("drop_flags", &supports_flags<>::drop_flags) diff --git a/src/py_commodity.cc b/src/py_commodity.cc index 7cd84f1c..c20053ad 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -189,9 +189,10 @@ void export_commodity() class_< commodity_t, boost::noncopyable > ("Commodity", no_init) #if 1 - .def("flags", &delegates_flags::flags) + .add_property("flags", + &supports_flags::flags, + &supports_flags::set_flags) .def("has_flags", &delegates_flags::has_flags) - .def("set_flags", &delegates_flags::set_flags) .def("clear_flags", &delegates_flags::clear_flags) .def("add_flags", &delegates_flags::add_flags) .def("drop_flags", &delegates_flags::drop_flags) @@ -248,9 +249,9 @@ void export_commodity() class_< annotation_t > ("Annotation", no_init) #if 1 - .def("flags", &supports_flags<>::flags) + .add_property("flags", &supports_flags<>::flags, + &supports_flags<>::set_flags) .def("has_flags", &supports_flags<>::has_flags) - .def("set_flags", &supports_flags<>::set_flags) .def("clear_flags", &supports_flags<>::clear_flags) .def("add_flags", &supports_flags<>::add_flags) .def("drop_flags", &supports_flags<>::drop_flags) diff --git a/src/py_item.cc b/src/py_item.cc index ac544c6a..8a6e495a 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -109,9 +109,9 @@ void export_item() class_< item_t > ("JournalItem", init()) #endif #if 1 - .def("flags", &supports_flags<>::flags) + .add_property("flags", &supports_flags<>::flags, + &supports_flags<>::set_flags) .def("has_flags", &supports_flags<>::has_flags) - .def("set_flags", &supports_flags<>::set_flags) .def("clear_flags", &supports_flags<>::clear_flags) .def("add_flags", &supports_flags<>::add_flags) .def("drop_flags", &supports_flags<>::drop_flags) @@ -138,6 +138,9 @@ void export_item() .def("get_tag", py_get_tag_1s) .def("get_tag", py_get_tag_1m) .def("get_tag", py_get_tag_2m) + .def("tag", py_get_tag_1s) + .def("tag", py_get_tag_1m) + .def("tag", py_get_tag_2m) .def("set_tag", &item_t::set_tag) @@ -148,11 +151,11 @@ void export_item() make_getter(&item_t::use_effective_date), make_setter(&item_t::use_effective_date)) - .def("date", &item_t::date) - .def("effective_date", &item_t::effective_date) + .add_property("date", &item_t::date, make_setter(&item_t::_date)) + .add_property("effective_date", &item_t::effective_date, + make_setter(&item_t::_date_eff)) - .def("set_state", &item_t::set_state) - .def("state", &item_t::state) + .add_property("state", &item_t::state, &item_t::set_state) .def("lookup", &item_t::lookup) diff --git a/src/py_post.cc b/src/py_post.cc index 9f7476d1..64bdde83 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -87,9 +87,10 @@ void export_post() class_< post_t::xdata_t > ("PostingXData") #if 1 - .def("flags", &supports_flags::flags) + .add_property("flags", + &supports_flags::flags, + &supports_flags::set_flags) .def("has_flags", &supports_flags::has_flags) - .def("set_flags", &supports_flags::set_flags) .def("clear_flags", &supports_flags::clear_flags) .def("add_flags", &supports_flags::add_flags) .def("drop_flags", &supports_flags::drop_flags) diff --git a/src/py_utils.cc b/src/py_utils.cc index c2177c20..b2b9d0f8 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -172,9 +172,10 @@ void export_utils() .def(init >()) .def(init()) - .def("flags", &supports_flags::flags) + .add_property("flags", + &supports_flags::flags, + &supports_flags::set_flags) .def("has_flags", &supports_flags::has_flags) - .def("set_flags", &supports_flags::set_flags) .def("clear_flags", &supports_flags::clear_flags) .def("add_flags", &supports_flags::add_flags) .def("drop_flags", &supports_flags::drop_flags) @@ -184,9 +185,10 @@ void export_utils() .def(init >()) .def(init()) - .def("flags", &supports_flags::flags) + .add_property("flags", + &supports_flags::flags, + &supports_flags::set_flags) .def("has_flags", &supports_flags::has_flags) - .def("set_flags", &supports_flags::set_flags) .def("clear_flags", &supports_flags::clear_flags) .def("add_flags", &supports_flags::add_flags) .def("drop_flags", &supports_flags::drop_flags) @@ -204,9 +206,10 @@ void export_utils() class_< delegates_flags, boost::noncopyable > ("DelegatesFlags16", no_init) - .def("flags", &delegates_flags::flags) + .add_property("flags", + &delegates_flags::flags, + &delegates_flags::set_flags) .def("has_flags", &delegates_flags::has_flags) - .def("set_flags", &delegates_flags::set_flags) .def("clear_flags", &delegates_flags::clear_flags) .def("add_flags", &delegates_flags::add_flags) .def("drop_flags", &delegates_flags::drop_flags) -- cgit v1.2.3