From ea1642b3f969463a49e5a671478c92e4ef129665 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 13 Jun 2010 05:02:14 -0400 Subject: Completely reworked argument passing in expressions --- src/expr.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/expr.h') diff --git a/src/expr.h b/src/expr.h index fa49cdc4..e6eeebf6 100644 --- a/src/expr.h +++ b/src/expr.h @@ -58,7 +58,6 @@ public: class op_t; typedef intrusive_ptr ptr_op_t; typedef intrusive_ptr const_ptr_op_t; - protected: ptr_op_t ptr; @@ -142,6 +141,25 @@ private: #endif // HAVE_BOOST_SERIALIZATION }; +/** + * Dealing with expr pointers tucked into value objects. + */ +inline bool is_expr(const value_t& val) { + return val.is_any() && val.as_any().type() == typeid(expr_t::ptr_op_t); +} +inline expr_t::ptr_op_t as_expr(const value_t& val) { + VERIFY(val.is_any()); + return val.as_any(); +} +inline void set_expr(value_t& val, expr_t::ptr_op_t op) { + val.set_any(op); +} +inline value_t expr_value(expr_t::ptr_op_t op) { + value_t temp; + temp.set_any(op); + return temp; +} + } // namespace ledger #endif // _EXPR_H -- cgit v1.2.3