#include "python.h" namespace python { template mapref::mapref (MapBase& map, const std::string& k) : s(map), the_item() { key = String(k); if(map.hasKey(key)) the_item = map.getItem(key); }; template mapref::mapref (MapBase& map, const Object& k) : s(map), key(k), the_item() { if(map.hasKey(key)) the_item = map.getItem(key); }; template mapref::~mapref() {} // MapBase stuff // lvalue template mapref& mapref::operator=(const mapref& other) { if(this == &other) return *this; the_item = other.the_item; s.setItem(key, other.the_item); return *this; }; template mapref& mapref::operator= (const T& ob) { the_item = ob; s.setItem (key, ob); return *this; } // rvalue template mapref::operator T() const { return the_item; } // forward everything else to the_item template PyObject* mapref::ptr () const { return the_item.ptr(); } template int mapref::reference_count () const { // the mapref count return the_item.reference_count(); } template Type mapref::type () const { return the_item.type(); } template String mapref::str () const { return the_item.str(); } template String mapref::repr () const { return the_item.repr(); } template bool mapref::has_attr (const std::string& attr_name) const { return the_item.has_attr(attr_name); } template Object mapref::get_attr (const std::string& attr_name) const { return the_item.get_attr(attr_name); } template Object mapref::get_item (const Object& k) const { return the_item.get_item(k); } template long mapref::hash_value () const { return the_item.hash_value(); } template bool mapref::is_callable () const { return the_item.is_callable(); } template bool mapref::is_list () const { return the_item.is_list(); } template bool mapref::is_mapping () const { return the_item.is_mapping(); } template bool mapref::is_numeric () const { return the_item.is_numeric(); } template bool mapref::is_sequence () const { return the_item.is_sequence(); } template bool mapref::is_true () const { return the_item.is_true(); } template bool mapref::is_type (const Type& t) const { return the_item.is_type (t); } template bool mapref::is_tuple() const { return the_item.is_tuple(); } template bool mapref::is_string() const { return the_item.is_string(); } // Commands template void mapref::set_attr (const std::string& attr_name, const Object& value) { the_item.set_attr(attr_name, value); } template void mapref::del_attr (const std::string& attr_name) { the_item.del_attr(attr_name); } template void mapref::del_item (const Object& k) { the_item.del_item(k); } }