diff options
author | John Wiegley <johnw@newartisans.com> | 2004-09-14 05:05:56 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-09-14 05:05:56 -0400 |
commit | bd72c0cf908492abb99a1419f7f8136729747061 (patch) | |
tree | 2ee9bfbf02c94fa9fdf4cd344901e4cc48e65a0a | |
parent | a013b520ba151b9da3adec97d124676a96741b04 (diff) | |
download | fork-ledger-bd72c0cf908492abb99a1419f7f8136729747061.tar.gz fork-ledger-bd72c0cf908492abb99a1419f7f8136729747061.tar.bz2 fork-ledger-bd72c0cf908492abb99a1419f7f8136729747061.zip |
added more math operators for value_t types
-rw-r--r-- | python.cc | 11 | ||||
-rw-r--r-- | value.cc | 20 | ||||
-rw-r--r-- | value.h | 17 |
3 files changed, 38 insertions, 10 deletions
@@ -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 @@ -642,6 +642,26 @@ void export_value() .def(self / other<amount_t>()) .def(self / int()) + .def(other<balance_pair_t>() + self) + .def(other<balance_t>() + self) + .def(other<amount_t>() + self) + .def(int() + self) + + .def(other<balance_pair_t>() - self) + .def(other<balance_t>() - self) + .def(other<amount_t>() - self) + .def(int() - self) + + .def(other<balance_pair_t>() * self) + .def(other<balance_t>() * self) + .def(other<amount_t>() * self) + .def(int() * self) + + .def(other<balance_pair_t>() / self) + .def(other<balance_t>() / self) + .def(other<amount_t>() / self) + .def(int() / self) + .def(self += self) .def(self += other<balance_pair_t>()) .def(self += other<balance_t>()) @@ -250,6 +250,23 @@ class value_t }; template <typename T> +value_t operator+(const T& value, const value_t& obj) { + return value_t(value) + obj; +} +template <typename T> +value_t operator-(const T& value, const value_t& obj) { + return value_t(value) - obj; +} +template <typename T> +value_t operator*(const T& value, const value_t& obj) { + return value_t(value) * obj; +} +template <typename T> +value_t operator/(const T& value, const value_t& obj) { + return value_t(value) / obj; +} + +template <typename T> value_t::operator T() const { switch (type) { |