From bd72c0cf908492abb99a1419f7f8136729747061 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 14 Sep 2004 05:05:56 -0400 Subject: added more math operators for value_t types --- python.cc | 11 +---------- value.cc | 20 ++++++++++++++++++++ value.h | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/python.cc b/python.cc index 9699873c..288825aa 100644 --- a/python.cc +++ b/python.cc @@ -63,16 +63,7 @@ void init_python() Py_Initialize(); python_interpretor = new python_support; -#if 1 - boost::python::detail::init_module("ledger", &init_module); -#else - object m_obj(python_interpretor->main_module); - scope current_module(m_obj); - - python_interpretor->main_namespace.attr("bar") = 10; - - handle_exception(init_module_main); -#endif + detail::init_module("ledger", &init_module); } } // namespace ledger diff --git a/value.cc b/value.cc index 2a211fd1..4a273abc 100644 --- a/value.cc +++ b/value.cc @@ -642,6 +642,26 @@ void export_value() .def(self / other()) .def(self / int()) + .def(other() + self) + .def(other() + self) + .def(other() + self) + .def(int() + self) + + .def(other() - self) + .def(other() - self) + .def(other() - self) + .def(int() - self) + + .def(other() * self) + .def(other() * self) + .def(other() * self) + .def(int() * self) + + .def(other() / self) + .def(other() / self) + .def(other() / self) + .def(int() / self) + .def(self += self) .def(self += other()) .def(self += other()) diff --git a/value.h b/value.h index 617b5fb7..819f985f 100644 --- a/value.h +++ b/value.h @@ -249,6 +249,23 @@ class value_t value_t cost() const; }; +template +value_t operator+(const T& value, const value_t& obj) { + return value_t(value) + obj; +} +template +value_t operator-(const T& value, const value_t& obj) { + return value_t(value) - obj; +} +template +value_t operator*(const T& value, const value_t& obj) { + return value_t(value) * obj; +} +template +value_t operator/(const T& value, const value_t& obj) { + return value_t(value) / obj; +} + template value_t::operator T() const { -- cgit v1.2.3