From 45e74103607a77c5945615692c3a35f9ce6aadde Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 9 Jun 2015 00:00:04 +0200 Subject: enable access to item's position in python bindings --- src/py_item.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/py_item.cc') diff --git a/src/py_item.cc b/src/py_item.cc index 473bbef8..4dd104c9 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -32,6 +32,7 @@ #include #include "pyinterp.h" +#include "pyutils.h" #include "scope.h" #include "mask.h" #include "item.h" @@ -64,6 +65,13 @@ namespace { return item.get_tag(tag_mask, value_mask); } + std::string py_position_pathname(position_t const& pos) { + return pos.pathname.native(); + } + void py_position_set_pathname(position_t& pos, string const& s) { + pos.pathname = s; + } + } // unnamed namespace #if 0 @@ -79,8 +87,8 @@ void export_item() { class_< position_t > ("Position") .add_property("pathname", - make_getter(&position_t::pathname), - make_setter(&position_t::pathname)) + make_function(py_position_pathname), + make_function(py_position_set_pathname)) .add_property("beg_pos", make_getter(&position_t::beg_pos), make_setter(&position_t::beg_pos)) @@ -169,6 +177,8 @@ void export_item() .def("valid", &item_t::valid) ; + + register_optional_to_python(); } } // namespace ledger -- cgit v1.2.3