From 15f29d4852e01bc6c6fb802ee818d991142e2f36 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 12 Apr 2023 11:00:35 +0200 Subject: Refactor flag and pstream related types into ledger namespace --- src/amount.h | 2 +- src/flags.h | 3 +++ src/pstream.h | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/amount.h b/src/amount.h index 8d0018d7..45e5a68f 100644 --- a/src/amount.h +++ b/src/amount.h @@ -76,7 +76,7 @@ enum parse_flags_enum_t { PARSE_SOFT_FAIL = 0x80 }; -typedef basic_flags_t parse_flags_t; +typedef ledger::basic_flags_t parse_flags_t; /** * @brief Encapsulate infinite-precision commoditized amounts diff --git a/src/flags.h b/src/flags.h index fb7096c0..cd01fc29 100644 --- a/src/flags.h +++ b/src/flags.h @@ -41,6 +41,7 @@ */ #pragma once +namespace ledger { template class supports_flags @@ -182,3 +183,5 @@ public: _flags.drop_flags(arg); } }; + +} // namespace ledger diff --git a/src/pstream.h b/src/pstream.h index 2502fdac..a012e628 100644 --- a/src/pstream.h +++ b/src/pstream.h @@ -44,6 +44,8 @@ //#include //#include +namespace ledger { + class ptristream : public std::istream { class ptrinbuf : public std::streambuf @@ -109,3 +111,5 @@ public: rdbuf(&buf); } }; + +} // namespace ledger -- cgit v1.2.3 From 5f78556078d2e61d5c0ef44e36d58f3864cd84d1 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 12 Apr 2023 11:14:08 +0200 Subject: Refactor basic_flags_t to ledger::flags::basic_t --- flake.nix | 3 ++- src/account.h | 2 +- src/amount.cc | 2 +- src/amount.h | 2 +- src/annotate.h | 2 +- src/commodity.h | 4 ++-- src/flags.h | 38 +++++++++++++++++++------------------- src/format.h | 2 +- src/item.h | 2 +- src/py_account.cc | 1 + src/py_commodity.cc | 1 + src/py_item.cc | 1 + src/py_post.cc | 1 + src/py_utils.cc | 1 + 14 files changed, 34 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index a992594b..ef87e0c6 100644 --- a/flake.nix +++ b/flake.nix @@ -30,11 +30,12 @@ then [ python3 (boost.override { enablePython = true; python = python3; }) ] else [ boost ]); - nativeBuildInputs = [ cmake texinfo tzdata ]; + nativeBuildInputs = [ cmake texinfo tzdata doxygen graphviz ninja ]; enableParallelBuilding = true; cmakeFlags = [ + "-GNinja" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_DOCS:BOOL=ON" "-DUSE_PYTHON:BOOL=${if usePython then "ON" else "OFF"}" diff --git a/src/account.h b/src/account.h index 871a3516..be8fddaf 100644 --- a/src/account.h +++ b/src/account.h @@ -53,7 +53,7 @@ typedef std::list posts_list; typedef std::map accounts_map; typedef std::map deferred_posts_map_t; -class account_t : public supports_flags<>, public scope_t +class account_t : public flags::supports_flags<>, public scope_t { #define ACCOUNT_NORMAL 0x00 // no flags at all, a basic account #define ACCOUNT_KNOWN 0x01 diff --git a/src/amount.cc b/src/amount.cc index eb5e0196..484c3099 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -52,7 +52,7 @@ static mpfr_t tempfnum; static mpfr_t tempfden; #endif -struct amount_t::bigint_t : public supports_flags<> +struct amount_t::bigint_t : public flags::supports_flags<> { #define BIGINT_BULK_ALLOC 0x01 #define BIGINT_KEEP_PREC 0x02 diff --git a/src/amount.h b/src/amount.h index 45e5a68f..7abaa1c9 100644 --- a/src/amount.h +++ b/src/amount.h @@ -76,7 +76,7 @@ enum parse_flags_enum_t { PARSE_SOFT_FAIL = 0x80 }; -typedef ledger::basic_flags_t parse_flags_t; +typedef flags::basic_t parse_flags_t; /** * @brief Encapsulate infinite-precision commoditized amounts diff --git a/src/annotate.h b/src/annotate.h index 1564b812..9f8bde00 100644 --- a/src/annotate.h +++ b/src/annotate.h @@ -49,7 +49,7 @@ namespace ledger { -struct annotation_t : public supports_flags<>, +struct annotation_t : public flags::supports_flags<>, public equality_comparable { #define ANNOTATION_PRICE_CALCULATED 0x01 diff --git a/src/commodity.h b/src/commodity.h index 8177fb4e..3a253297 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -70,14 +70,14 @@ struct price_point_t }; class commodity_t - : public delegates_flags, + : public flags::delegates_flags, public equality_comparable1 { protected: friend class commodity_pool_t; friend class annotated_commodity_t; - class base_t : public noncopyable, public supports_flags + class base_t : public noncopyable, public flags::supports_flags { public: #define COMMODITY_STYLE_DEFAULTS 0x000 diff --git a/src/flags.h b/src/flags.h index cd01fc29..4d7e653c 100644 --- a/src/flags.h +++ b/src/flags.h @@ -41,7 +41,7 @@ */ #pragma once -namespace ledger { +namespace ledger { namespace flags { template class supports_flags @@ -93,33 +93,33 @@ public: }; template -class basic_flags_t : public supports_flags +class basic_t : public supports_flags { public: - basic_flags_t() { - TRACE_CTOR(basic_flags_t, ""); + basic_t() { + TRACE_CTOR(basic_t, ""); } - basic_flags_t(const T& bits) { - TRACE_CTOR(basic_flags_t, "const T&"); + basic_t(const T& bits) { + TRACE_CTOR(basic_t, "const T&"); supports_flags::set_flags(bits); } - basic_flags_t(const U& bits) { - TRACE_CTOR(basic_flags_t, "const U&"); + basic_t(const U& bits) { + TRACE_CTOR(basic_t, "const U&"); supports_flags::set_flags(static_cast(bits)); } - ~basic_flags_t() throw() { - TRACE_DTOR(basic_flags_t); + ~basic_t() throw() { + TRACE_DTOR(basic_t); } - basic_flags_t(const basic_flags_t& other) + basic_t(const basic_t& other) : supports_flags(other) { - TRACE_CTOR(basic_flags_t, "copy"); + TRACE_CTOR(basic_t, "copy"); } - basic_flags_t& operator=(const basic_flags_t& other) { + basic_t& operator=(const basic_t& other) { set_flags(other.flags()); return *this; } - basic_flags_t& operator=(const T& bits) { + basic_t& operator=(const T& bits) { set_flags(bits); return *this; } @@ -131,13 +131,13 @@ public: return supports_flags::flags(); } - basic_flags_t plus_flags(const T& arg) const { - basic_flags_t temp(*this); + basic_t plus_flags(const T& arg) const { + basic_t temp(*this); temp.add_flags(arg); return temp; } - basic_flags_t minus_flags(const T& arg) const { - basic_flags_t temp(*this); + basic_t minus_flags(const T& arg) const { + basic_t temp(*this); temp.drop_flags(arg); return temp; } @@ -184,4 +184,4 @@ public: } }; -} // namespace ledger +} } // namespace ledger::flags diff --git a/src/format.h b/src/format.h index c1c8701a..c021f219 100644 --- a/src/format.h +++ b/src/format.h @@ -56,7 +56,7 @@ class format_t : public expr_base_t, public noncopyable { typedef expr_base_t base_type; - struct element_t : public supports_flags<>, public noncopyable + struct element_t : public flags::supports_flags<>, public noncopyable { #define ELEMENT_ALIGN_LEFT 0x01 diff --git a/src/item.h b/src/item.h index faebe61f..c21450e8 100644 --- a/src/item.h +++ b/src/item.h @@ -79,7 +79,7 @@ struct position_t } }; -class item_t : public supports_flags, public scope_t +class item_t : public flags::supports_flags, public scope_t { public: #define ITEM_NORMAL 0x00 // no flags at all, a basic posting diff --git a/src/py_account.cc b/src/py_account.cc index cc9008c9..67218c8b 100644 --- a/src/py_account.cc +++ b/src/py_account.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_commodity.cc b/src/py_commodity.cc index 577254db..28074b5c 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_item.cc b/src/py_item.cc index 9fbccc98..a23ebe5f 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_post.cc b/src/py_post.cc index f2af16eb..0065cf3f 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -37,6 +37,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_utils.cc b/src/py_utils.cc index 1f5e448f..1a28f087 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -36,6 +36,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; struct bool_to_python -- cgit v1.2.3 From 9244a27f9548a1d39fb01348fde66ff81f5150a4 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 12 Apr 2023 20:33:40 +0200 Subject: Refactor python related types into ledger::python namespace --- flake.nix | 3 +-- src/py_account.cc | 7 ++++--- src/py_amount.cc | 1 + src/py_balance.cc | 1 + src/py_commodity.cc | 13 +++++++------ src/py_item.cc | 1 + src/py_journal.cc | 12 ++++++------ src/py_session.cc | 7 ++++--- src/py_times.cc | 6 ++---- src/py_utils.cc | 2 +- src/py_value.cc | 1 + src/py_xact.cc | 5 +++-- src/pyinterp.cc | 31 ++++++++++++++++--------------- src/pyinterp.h | 24 ++++++++++++------------ src/pyutils.h | 6 +++++- src/textual.cc | 2 +- 16 files changed, 66 insertions(+), 56 deletions(-) diff --git a/flake.nix b/flake.nix index ef87e0c6..a992594b 100644 --- a/flake.nix +++ b/flake.nix @@ -30,12 +30,11 @@ then [ python3 (boost.override { enablePython = true; python = python3; }) ] else [ boost ]); - nativeBuildInputs = [ cmake texinfo tzdata doxygen graphviz ninja ]; + nativeBuildInputs = [ cmake texinfo tzdata ]; enableParallelBuilding = true; cmakeFlags = [ - "-GNinja" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_DOCS:BOOL=ON" "-DUSE_PYTHON:BOOL=${if usePython then "ON" else "OFF"}" diff --git a/src/py_account.cc b/src/py_account.cc index 67218c8b..2e1fd35b 100644 --- a/src/py_account.cc +++ b/src/py_account.cc @@ -40,6 +40,7 @@ namespace ledger { using namespace flags; +using namespace python; using namespace boost::python; namespace { @@ -232,11 +233,11 @@ void export_account() .def("__len__", accounts_len) .def("__getitem__", accounts_getitem, return_internal_reference<>()) - .def("__iter__", python::range > + .def("__iter__", boost::python::range > (&account_t::accounts_begin, &account_t::accounts_end)) - .def("accounts", python::range > + .def("accounts", boost::python::range > (&account_t::accounts_begin, &account_t::accounts_end)) - .def("posts", python::range > + .def("posts", boost::python::range > (&account_t::posts_begin, &account_t::posts_end)) .def("has_xdata", &account_t::has_xdata) diff --git a/src/py_amount.cc b/src/py_amount.cc index ce5c26d8..ae554f58 100644 --- a/src/py_amount.cc +++ b/src/py_amount.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace python; using namespace boost::python; namespace { diff --git a/src/py_balance.cc b/src/py_balance.cc index 9b476244..47cd7fc9 100644 --- a/src/py_balance.cc +++ b/src/py_balance.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace python; using namespace boost::python; namespace { diff --git a/src/py_commodity.cc b/src/py_commodity.cc index 28074b5c..3ae6801f 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -40,6 +40,7 @@ namespace ledger { using namespace flags; +using namespace python; using namespace boost::python; namespace { @@ -120,8 +121,8 @@ namespace { return (*i).second.get(); } - python::list py_pool_keys(commodity_pool_t& pool) { - python::list keys; + list py_pool_keys(commodity_pool_t& pool) { + list keys; BOOST_REVERSE_FOREACH (const commodity_pool_t::commodities_map::value_type& pair, pool.commodities) { @@ -296,15 +297,15 @@ void export_commodity() .def("has_key", py_pool_contains) .def("__contains__", py_pool_contains) .def("__iter__", - python::range > + boost::python::range > (py_pool_commodities_begin, py_pool_commodities_end)) .def("iteritems", - python::range > + boost::python::range > (py_pool_commodities_begin, py_pool_commodities_end)) - .def("iterkeys", python::range<>(py_pool_commodities_keys_begin, + .def("iterkeys", boost::python::range<>(py_pool_commodities_keys_begin, py_pool_commodities_keys_end)) .def("itervalues", - python::range > + boost::python::range > (py_pool_commodities_values_begin, py_pool_commodities_values_end)) ; diff --git a/src/py_item.cc b/src/py_item.cc index a23ebe5f..3a458000 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -40,6 +40,7 @@ namespace ledger { using namespace flags; +using namespace python; using namespace boost::python; namespace { diff --git a/src/py_journal.cc b/src/py_journal.cc index 08a4ebf1..d96618e7 100644 --- a/src/py_journal.cc +++ b/src/py_journal.cc @@ -241,7 +241,7 @@ void export_journal() boost::noncopyable >("PostCollectorWrapper", no_init) .def("__len__", &collector_wrapper::length) .def("__getitem__", posts_getitem, return_internal_reference<>()) - .def("__iter__", python::range > + .def("__iter__", boost::python::range > (&collector_wrapper::begin, &collector_wrapper::end)) ; @@ -306,15 +306,15 @@ void export_journal() with_custodian_and_ward_postcall<1, 0> >()) #endif - .def("__iter__", python::range > + .def("__iter__", boost::python::range > (&journal_t::xacts_begin, &journal_t::xacts_end)) - .def("xacts", python::range > + .def("xacts", boost::python::range > (&journal_t::xacts_begin, &journal_t::xacts_end)) - .def("auto_xacts", python::range > + .def("auto_xacts", boost::python::range > (&journal_t::auto_xacts_begin, &journal_t::auto_xacts_end)) - .def("period_xacts", python::range > + .def("period_xacts", boost::python::range > (&journal_t::period_xacts_begin, &journal_t::period_xacts_end)) - .def("sources", python::range > + .def("sources", boost::python::range > (&journal_t::sources_begin, &journal_t::sources_end)) #if 0 .def("read", py_read) diff --git a/src/py_session.cc b/src/py_session.cc index 02529334..3606adc6 100644 --- a/src/py_session.cc +++ b/src/py_session.cc @@ -38,6 +38,7 @@ namespace ledger { +using namespace python; using namespace boost::python; namespace { @@ -78,12 +79,12 @@ void export_session() scope().attr("session") = object(ptr(static_cast(python_session.get()))); scope().attr("close_journal_files") = - python::make_function(&py_close_journal_files); + boost::python::make_function(&py_close_journal_files); scope().attr("read_journal") = - python::make_function(&py_read_journal, + boost::python::make_function(&py_read_journal, return_internal_reference<>()); scope().attr("read_journal_from_string") = - python::make_function(&py_read_journal_from_string, + boost::python::make_function(&py_read_journal_from_string, return_internal_reference<>()); } diff --git a/src/py_times.cc b/src/py_times.cc index 79bacad7..d2afb5c8 100644 --- a/src/py_times.cc +++ b/src/py_times.cc @@ -40,6 +40,7 @@ namespace ledger { +using namespace python; using namespace boost::python; struct date_to_python @@ -81,7 +82,6 @@ struct date_from_python typedef register_python_conversion date_python_conversion; - struct datetime_to_python { static PyObject* convert(const datetime_t& moment) @@ -145,7 +145,6 @@ typedef register_python_conversion datetime_python_conversion; - /* Convert time_duration to/from python */ struct duration_to_python { @@ -185,7 +184,7 @@ struct duration_from_python } static void construct(PyObject* obj_ptr, - python::converter::rvalue_from_python_stage1_data * data) + converter::rvalue_from_python_stage1_data * data) { PyDateTime_Delta const* pydelta = reinterpret_cast(obj_ptr); @@ -217,7 +216,6 @@ typedef register_python_conversion duration_python_conversion; - datetime_t py_parse_datetime(const string& str) { return parse_datetime(str); } diff --git a/src/py_utils.cc b/src/py_utils.cc index 1a28f087..5dae1ab9 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -37,6 +37,7 @@ namespace ledger { using namespace flags; +using namespace python; using namespace boost::python; struct bool_to_python @@ -74,7 +75,6 @@ struct bool_from_python typedef register_python_conversion bool_python_conversion; - struct string_to_python { static PyObject* convert(const string& str) diff --git a/src/py_value.cc b/src/py_value.cc index 30c32e94..52597c9a 100644 --- a/src/py_value.cc +++ b/src/py_value.cc @@ -38,6 +38,7 @@ namespace ledger { +using namespace python; using namespace boost::python; BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(value_overloads, value, 0, 2) diff --git a/src/py_xact.cc b/src/py_xact.cc index a0aa24d6..9a1017ba 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -38,6 +38,7 @@ namespace ledger { +using namespace python; using namespace boost::python; namespace { @@ -104,9 +105,9 @@ void export_xact() .def("finalize", &xact_base_t::finalize) - .def("__iter__", python::range > + .def("__iter__", boost::python::range > (&xact_t::posts_begin, &xact_t::posts_end)) - .def("posts", python::range > + .def("posts", boost::python::range > (&xact_t::posts_begin, &xact_t::posts_end)) .def("valid", &xact_base_t::valid) diff --git a/src/pyinterp.cc b/src/pyinterp.cc index 6a261609..71bbea22 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -41,6 +41,7 @@ namespace ledger { using namespace python; +using namespace boost::python; shared_ptr python_session; @@ -110,7 +111,7 @@ python_module_t::python_module_t(const string& name) import_module(name); } -python_module_t::python_module_t(const string& name, python::object obj) +python_module_t::python_module_t(const string& name, object obj) : scope_t(), module_name(name), module_globals() { module_object = obj; @@ -119,7 +120,7 @@ python_module_t::python_module_t(const string& name, python::object obj) void python_module_t::import_module(const string& name, bool import_direct) { - object mod = python::import(name.c_str()); + object mod = import(name.c_str()); if (! mod) throw_(std::runtime_error, _f("Module import failed (couldn't find %1%)") % name); @@ -177,27 +178,27 @@ void python_interpreter_t::initialize() void python_interpreter_t::hack_system_paths() { // Hack ledger.__path__ so it points to a real location - python::object sys_module = python::import("sys"); - python::object sys_dict = sys_module.attr("__dict__"); + object sys_module = import("sys"); + object sys_dict = sys_module.attr("__dict__"); - python::list paths(sys_dict["path"]); + list paths(sys_dict["path"]); #if DEBUG_ON bool path_initialized = false; #endif - int n = python::extract(paths.attr("__len__")()); + int n = extract(paths.attr("__len__")()); for (int i = 0; i < n; i++) { - python::extract str(paths[i]); + extract str(paths[i]); path pathname(str()); DEBUG("python.interp", "sys.path = " << pathname); if (exists(pathname / "ledger" / "__init__.py")) { - if (python::object module_ledger = python::import("ledger")) { + if (object module_ledger = import("ledger")) { DEBUG("python.interp", "Setting ledger.__path__ = " << (pathname / "ledger")); - python::object ledger_dict = module_ledger.attr("__dict__"); - python::list temp_list; + object ledger_dict = module_ledger.attr("__dict__"); + list temp_list; temp_list.append((pathname / "ledger").string()); ledger_dict["__path__"] = temp_list; @@ -223,12 +224,12 @@ object python_interpreter_t::import_option(const string& str) if (! is_initialized) initialize(); - python::object sys_module = python::import("sys"); - python::object sys_dict = sys_module.attr("__dict__"); + object sys_module = import("sys"); + object sys_dict = sys_module.attr("__dict__"); path file(str); string name(str); - python::list paths(sys_dict["path"]); + list paths(sys_dict["path"]); if (contains(str, ".py")) { path& cwd(parsing_context.get_current().current_directory); @@ -380,7 +381,7 @@ expr_t::ptr_op_t python_module_t::lookup(const symbol_t::kind_t kind, case symbol_t::FUNCTION: DEBUG("python.interp", "Python lookup: " << name); if (module_globals.has_key(name.c_str())) { - if (python::object obj = module_globals.get(name.c_str())) { + if (object obj = module_globals.get(name.c_str())) { if (PyModule_Check(obj.ptr())) { shared_ptr mod; python_module_map_t::iterator i = @@ -527,7 +528,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args) arglist.append(convert_value_to_python(args.value())); if (PyObject * val = - PyObject_CallObject(func.ptr(), python::tuple(arglist).ptr())) { + PyObject_CallObject(func.ptr(), boost::python::tuple(arglist).ptr())) { extract xval(val); value_t result; if (xval.check()) { diff --git a/src/pyinterp.h b/src/pyinterp.h index 57fb176b..45bb7adb 100644 --- a/src/pyinterp.h +++ b/src/pyinterp.h @@ -52,19 +52,19 @@ namespace ledger { class python_module_t : public scope_t, public noncopyable { public: - string module_name; - python::object module_object; - python::dict module_globals; + string module_name; + boost::python::object module_object; + boost::python::dict module_globals; explicit python_module_t(const string& name); - explicit python_module_t(const string& name, python::object obj); + explicit python_module_t(const string& name, boost::python::object obj); void import_module(const string& name, bool import_direct = false); virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string& name); - void define_global(const string& name, python::object obj) { + void define_global(const string& name, boost::python::object obj) { module_globals[name] = obj; } @@ -102,7 +102,7 @@ public: void initialize(); void hack_system_paths(); - python::object import_option(const string& name); + boost::python::object import_option(const string& name); enum py_eval_mode_t { PY_EVAL_EXPR, @@ -110,9 +110,9 @@ public: PY_EVAL_MULTI }; - python::object eval(std::istream& in, py_eval_mode_t mode = PY_EVAL_EXPR); - python::object eval(const string& str, py_eval_mode_t mode = PY_EVAL_EXPR); - python::object eval(const char * c_str, py_eval_mode_t mode = PY_EVAL_EXPR) { + boost::python::object eval(std::istream& in, py_eval_mode_t mode = PY_EVAL_EXPR); + boost::python::object eval(const string& str, py_eval_mode_t mode = PY_EVAL_EXPR); + boost::python::object eval(const char * c_str, py_eval_mode_t mode = PY_EVAL_EXPR) { return eval(string(c_str), mode); } @@ -122,14 +122,14 @@ public: functor_t(); protected: - python::object func; + boost::python::object func; public: string name; - functor_t(python::object _func, const string& _name) + functor_t(boost::python::object _func, const string& _name) : func(_func), name(_name) { - TRACE_CTOR(functor_t, "python::object, const string&"); + TRACE_CTOR(functor_t, "boost::python::object, const string&"); } functor_t(const functor_t& other) : func(other.func), name(other.name) { diff --git a/src/pyutils.h b/src/pyutils.h index aa9c4451..c02be37b 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -39,6 +39,8 @@ */ #pragma once +namespace ledger { namespace python { + template struct object_from_python { @@ -142,6 +144,8 @@ PyObject * str_to_py_unicode(const T& str) return object(handle<>(borrowed(uni))).ptr(); } +} } // namespace ledger::python + namespace boost { namespace python { // Use expr to create the PyObject corresponding to x @@ -178,7 +182,7 @@ namespace boost { namespace python { : handle<> \ { \ arg_to_python(T const& x) \ - : python::handle<>(expr) {} \ + : boost::python::handle<>(expr) {} \ }; \ } diff --git a/src/textual.cc b/src/textual.cc index 5276c92b..38142119 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1257,7 +1257,7 @@ void instance_t::python_directive(char * line) python_session->initialize(); python_session->main_module->define_global - ("journal", python::object(python::ptr(context.journal))); + ("journal", boost::python::object(boost::python::ptr(context.journal))); python_session->eval(script.str(), python_interpreter_t::PY_EVAL_MULTI); } -- cgit v1.2.3