7 #include <lib/python/swig.h>
9 inline void ptrAssert(void *p) { if (!p) *(unsigned long*)0=0; }
16 char m_ptrStr[sizeof(void*)*2+1];
20 if (sizeof(void*) > 4)
21 sprintf(m_ptrStr, "%llx", (unsigned long long)ptr);
23 sprintf(m_ptrStr, "%lx", (unsigned long)ptr);
26 strcpy(m_ptrStr, "NIL");
29 T &operator*() { return *ptr; }
39 ePtr(const ePtr &c): ptr(c.ptr)
55 ePtr &operator=(ePtr<T> &c)
75 T* grabRef() { if (!ptr) return 0; ptr->AddRef(); return ptr; }
76 T* &ptrref() { ASSERT(!ptr); return ptr; }
77 operator bool() const { return !!this->ptr; }
79 T* operator->() const { ptrAssert(ptr); return ptr; }
80 operator T*() const { return this->ptr; }
90 T &operator*() { return *ptr; }
102 eUsePtr(const eUsePtr &c)
111 eUsePtr &operator=(T *c)
126 eUsePtr &operator=(eUsePtr<T> &c)
150 T* grabRef() { if (!ptr) return 0; ptr->AddRef(); ptr->AddUse(); return ptr; }
151 T* &ptrref() { ASSERT(!ptr); return ptr; }
153 T* operator->() const { ptrAssert(ptr); return ptr; }
154 operator T*() const { return this->ptr; }
161 class eMutablePtr: public ePtr<T>
163 /* read doc/iObject about the ePtrHelper */
169 inline ePtrHelper(T1 *obj): m_obj(obj)
177 inline T1* operator->() { return m_obj; }
182 eMutablePtr(): ePtr<T>(0)
185 eMutablePtr(T *c): ePtr<T>(c)
188 eMutablePtr(const eMutablePtr &c): ePtr<T>(c)
191 eMutablePtr &operator=(T *c)
193 ePtr<T>::operator=(c);
196 ePtrHelper<T> operator->() { ptrAssert(ptr); return ePtrHelper<T>(ptr); }
197 /* for const objects, we don't need the helper, as they can't */
198 /* be changed outside the program flow. at least this is */
199 /* what the compiler assumes, so in case you're using const */
200 /* eMutablePtrs note that they have to be const. */
201 const T* operator->() const { ptrAssert(ptr); return ptr; }