added more math operators for value_t types
This commit is contained in:
parent
a013b520ba
commit
bd72c0cf90
3 changed files with 38 additions and 10 deletions
11
python.cc
11
python.cc
|
|
@ -63,16 +63,7 @@ void init_python()
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
python_interpretor = new python_support;
|
python_interpretor = new python_support;
|
||||||
|
|
||||||
#if 1
|
detail::init_module("ledger", &init_module);
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
|
||||||
20
value.cc
20
value.cc
|
|
@ -642,6 +642,26 @@ void export_value()
|
||||||
.def(self / other<amount_t>())
|
.def(self / other<amount_t>())
|
||||||
.def(self / int())
|
.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 += self)
|
||||||
.def(self += other<balance_pair_t>())
|
.def(self += other<balance_pair_t>())
|
||||||
.def(self += other<balance_t>())
|
.def(self += other<balance_t>())
|
||||||
|
|
|
||||||
17
value.h
17
value.h
|
|
@ -249,6 +249,23 @@ class value_t
|
||||||
value_t cost() const;
|
value_t cost() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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>
|
template <typename T>
|
||||||
value_t::operator T() const
|
value_t::operator T() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue