template< class T > T* extract_cegui_object(PyObject* obj) { const char thisStr[] = "this"; if (!PyObject_HasAttrString(obj, thisStr)) return NULL; PyObject* thisAttr = PyObject_GetAttrString(obj, thisStr); if (thisAttr == NULL) return NULL; return reinterpret_cast< T* >(((PySwigObject*)thisAttr)->ptr); }