Browse Source

robustify WeakPointerTo, publish ConstPointerTo

David Rose 21 years ago
parent
commit
475196cbef

+ 7 - 7
panda/src/express/pointerTo.I

@@ -79,7 +79,7 @@ operator TYPENAME PointerToBase<T>::To *() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerTo::p
 //     Function: PointerTo::p
-//       Access: Public
+//       Access: Published
 //  Description: Returns an ordinary pointer instead of a PointerTo.
 //  Description: Returns an ordinary pointer instead of a PointerTo.
 //               Useful to work around compiler problems, particularly
 //               Useful to work around compiler problems, particularly
 //               for implicit upcasts.
 //               for implicit upcasts.
@@ -92,7 +92,7 @@ p() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerTo::Assignment operator
 //     Function: PointerTo::Assignment operator
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class T>
 template<class T>
@@ -104,7 +104,7 @@ operator = (To *ptr) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerTo::Assignment operator
 //     Function: PointerTo::Assignment operator
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class T>
 template<class T>
@@ -191,7 +191,7 @@ operator const TYPENAME PointerToBase<T>::To *() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerTo::p
 //     Function: ConstPointerTo::p
-//       Access: Public
+//       Access: Published
 //  Description: Returns an ordinary pointer instead of a ConstPointerTo.
 //  Description: Returns an ordinary pointer instead of a ConstPointerTo.
 //               Useful to work around compiler problems, particularly
 //               Useful to work around compiler problems, particularly
 //               for implicit upcasts.
 //               for implicit upcasts.
@@ -204,7 +204,7 @@ p() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerTo::Assignment operator
 //     Function: ConstPointerTo::Assignment operator
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class T>
 template<class T>
@@ -216,7 +216,7 @@ operator = (const To *ptr) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerTo::Assignment operator
 //     Function: ConstPointerTo::Assignment operator
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class T>
 template<class T>
@@ -228,7 +228,7 @@ operator = (const PointerTo<T> &copy) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerTo::Assignment operator
 //     Function: ConstPointerTo::Assignment operator
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class T>
 template<class T>

+ 2 - 3
panda/src/express/pointerTo.h

@@ -155,11 +155,10 @@ PUBLISHED:
   INLINE ConstPointerTo<T> &operator = (const PointerTo<T> &copy);
   INLINE ConstPointerTo<T> &operator = (const PointerTo<T> &copy);
   INLINE ConstPointerTo<T> &operator = (const ConstPointerTo<T> &copy);
   INLINE ConstPointerTo<T> &operator = (const ConstPointerTo<T> &copy);
 
 
-  // These functions normally wouldn't need to be redefined here, but
+  // This functions normally wouldn't need to be redefined here, but
   // we do so anyway just to help out interrogate (which doesn't seem
   // we do so anyway just to help out interrogate (which doesn't seem
   // to want to automatically export the PointerToBase class).  When
   // to want to automatically export the PointerToBase class).  When
-  // this works again in interrogate, we can remove these.
-  INLINE bool is_null() const { return PointerToBase<T>::is_null(); }
+  // this works again in interrogate, we can remove this.
   INLINE void clear() { PointerToBase<T>::clear(); }
   INLINE void clear() { PointerToBase<T>::clear(); }
 };
 };
 
 

+ 43 - 28
panda/src/express/pointerToArray.I

@@ -509,7 +509,7 @@ clear() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::Constructor
 //     Function: ConstPointerToArray::Constructor
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
@@ -521,7 +521,7 @@ ConstPointerToArray() :
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::Copy Constructor
 //     Function: ConstPointerToArray::Copy Constructor
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
@@ -533,7 +533,7 @@ ConstPointerToArray(const PointerToArray<Element> &copy) :
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::Copy Constructor
 //     Function: ConstPointerToArray::Copy Constructor
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
@@ -601,7 +601,7 @@ rend() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::size
 //     Function: ConstPointerToArray::size
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
@@ -649,69 +649,84 @@ capacity() const {
   return ((To *)(this->_void_ptr))->capacity();
   return ((To *)(this->_void_ptr))->capacity();
 }
 }
 
 
-#ifndef WIN32_VC
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ConstPointerToArray::Indexing operator
+//     Function: ConstPointerToArray::front
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
 INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
-operator [](size_type n) const {
+front() const {
   nassertd((this->_void_ptr) != NULL) {
   nassertd((this->_void_ptr) != NULL) {
     ((ConstPointerToArray<Element> *)this)->reassign(new RefCountObj<pvector<Element> >);
     ((ConstPointerToArray<Element> *)this)->reassign(new RefCountObj<pvector<Element> >);
   }
   }
   nassertd(!((To *)(this->_void_ptr))->empty()) {
   nassertd(!((To *)(this->_void_ptr))->empty()) {
     ((To *)(this->_void_ptr))->push_back(Element());
     ((To *)(this->_void_ptr))->push_back(Element());
   }
   }
-  nassertr(n < ((To *)(this->_void_ptr))->size(), ((To *)(this->_void_ptr))->operator[](0));
-  return ((To *)(this->_void_ptr))->operator[](n);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: ConstPointerToArray::Indexing operator
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-template<class Element>
-INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
-operator [](int n) const {
-  return operator[]((size_type)n);
+  return ((To *)(this->_void_ptr))->front();
 }
 }
-#endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ConstPointerToArray::front
+//     Function: ConstPointerToArray::back
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
 INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
-front() const {
+back() const {
   nassertd((this->_void_ptr) != NULL) {
   nassertd((this->_void_ptr) != NULL) {
     ((ConstPointerToArray<Element> *)this)->reassign(new RefCountObj<pvector<Element> >);
     ((ConstPointerToArray<Element> *)this)->reassign(new RefCountObj<pvector<Element> >);
   }
   }
   nassertd(!((To *)(this->_void_ptr))->empty()) {
   nassertd(!((To *)(this->_void_ptr))->empty()) {
     ((To *)(this->_void_ptr))->push_back(Element());
     ((To *)(this->_void_ptr))->push_back(Element());
   }
   }
-  return ((To *)(this->_void_ptr))->front();
+  return ((To *)(this->_void_ptr))->back();
 }
 }
 
 
+#ifndef WIN32_VC
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ConstPointerToArray::back
-//       Access: Public
+//     Function: ConstPointerToArray::Indexing operator
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
 INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
-back() const {
+operator [](size_type n) const {
   nassertd((this->_void_ptr) != NULL) {
   nassertd((this->_void_ptr) != NULL) {
     ((ConstPointerToArray<Element> *)this)->reassign(new RefCountObj<pvector<Element> >);
     ((ConstPointerToArray<Element> *)this)->reassign(new RefCountObj<pvector<Element> >);
   }
   }
   nassertd(!((To *)(this->_void_ptr))->empty()) {
   nassertd(!((To *)(this->_void_ptr))->empty()) {
     ((To *)(this->_void_ptr))->push_back(Element());
     ((To *)(this->_void_ptr))->push_back(Element());
   }
   }
-  return ((To *)(this->_void_ptr))->back();
+  nassertr(n < ((To *)(this->_void_ptr))->size(), ((To *)(this->_void_ptr))->operator[](0));
+  return ((To *)(this->_void_ptr))->operator[](n);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::Indexing operator
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
+operator [](int n) const {
+  return operator[]((size_type)n);
+}
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::get_element
+//       Access: Published
+//  Description: This method exists mainly to access the elements of
+//               the array easily from a high-level language such as
+//               Python, especially on Windows, where the above index
+//               element accessor methods can't be defined because of
+//               a confusion with the pointer typecast operator.
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE const Element &ConstPointerToArray<Element>::
+get_element(size_type n) const {
+  return (*this)[n];
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 11 - 3
panda/src/express/pointerToArray.h

@@ -104,7 +104,6 @@ public:
 
 
 PUBLISHED:
 PUBLISHED:
   INLINE PointerToArray();
   INLINE PointerToArray();
-  //  INLINE PointerToArray(size_type n);  this is too dangerous to use, since arrays created automatically for any const parameter, use empty_array instead
   INLINE static PointerToArray<Element> empty_array(size_type n);
   INLINE static PointerToArray<Element> empty_array(size_type n);
   INLINE PointerToArray(size_type n, const Element &value);
   INLINE PointerToArray(size_type n, const Element &value);
   INLINE PointerToArray(const PointerToArray<Element> &copy);
   INLINE PointerToArray(const PointerToArray<Element> &copy);
@@ -217,10 +216,12 @@ public:
   typedef TYPENAME pvector<Element>::difference_type difference_type;
   typedef TYPENAME pvector<Element>::difference_type difference_type;
   typedef TYPENAME pvector<Element>::size_type size_type;
   typedef TYPENAME pvector<Element>::size_type size_type;
 
 
+PUBLISHED:
   INLINE ConstPointerToArray();
   INLINE ConstPointerToArray();
   INLINE ConstPointerToArray(const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const ConstPointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const ConstPointerToArray<Element> &copy);
 
 
+public:
   // Duplicating the interface of vector.
   // Duplicating the interface of vector.
 
 
   INLINE iterator begin() const;
   INLINE iterator begin() const;
@@ -231,19 +232,26 @@ public:
   // Equality and comparison operators are pointerwise for
   // Equality and comparison operators are pointerwise for
   // PointerToArrays, not elementwise as in vector.
   // PointerToArrays, not elementwise as in vector.
 
 
+PUBLISHED:
   INLINE size_type size() const;
   INLINE size_type size() const;
+
+public:
   INLINE size_type max_size() const;
   INLINE size_type max_size() const;
   INLINE bool empty() const;
   INLINE bool empty() const;
 
 
   // Functions specific to vectors.
   // Functions specific to vectors.
   INLINE size_type capacity() const;
   INLINE size_type capacity() const;
+  INLINE reference front() const;
+  INLINE reference back() const;
+
+PUBLISHED:
 #ifndef WIN32_VC
 #ifndef WIN32_VC
   INLINE reference operator [](size_type n) const;
   INLINE reference operator [](size_type n) const;
   INLINE reference operator [](int n) const;
   INLINE reference operator [](int n) const;
 #endif
 #endif
-  INLINE reference front() const;
-  INLINE reference back() const;
+  INLINE const Element &get_element(size_type n) const;
 
 
+public:
   INLINE operator const Element *() const;
   INLINE operator const Element *() const;
   INLINE const Element *p() const;
   INLINE const Element *p() const;
   INLINE const pvector<Element> &v() const;
   INLINE const pvector<Element> &v() const;

+ 2 - 15
panda/src/express/pointerToBase.I

@@ -309,22 +309,9 @@ get_hash() const {
 
 
 
 
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: PointerToBase::is_null
-//       Access: Public
-//  Description: Returns true if the PointerTo is a NULL pointer,
-//               false otherwise.  (Direct comparison to a NULL
-//               pointer also works.)
-////////////////////////////////////////////////////////////////////
-template<class T>
-INLINE bool PointerToBase<T>::
-is_null() const {
-  return (_void_ptr == (void *)NULL);
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToBase::clear
 //     Function: PointerToBase::clear
-//       Access: Public
+//       Access: Published
 //  Description: A convenient way to set the PointerTo object to NULL.
 //  Description: A convenient way to set the PointerTo object to NULL.
 //               (Assignment to a NULL pointer also works, of course.)
 //               (Assignment to a NULL pointer also works, of course.)
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -336,7 +323,7 @@ clear() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToBase::output
 //     Function: PointerToBase::output
-//       Access: Public
+//       Access: Published
 //  Description: A handy function to output PointerTo's as a hex
 //  Description: A handy function to output PointerTo's as a hex
 //               pointer followed by a reference count.
 //               pointer followed by a reference count.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 0 - 1
panda/src/express/pointerToBase.h

@@ -77,7 +77,6 @@ public:
   INLINE size_t get_hash() const;
   INLINE size_t get_hash() const;
 
 
 PUBLISHED:
 PUBLISHED:
-  INLINE bool is_null() const;
   INLINE void clear();
   INLINE void clear();
 
 
   void output(ostream &out) const;
   void output(ostream &out) const;

+ 12 - 0
panda/src/express/pointerToVoid.I

@@ -36,3 +36,15 @@ INLINE PointerToVoid::
 ~PointerToVoid() {
 ~PointerToVoid() {
   nassertv(_void_ptr == (void *)NULL);
   nassertv(_void_ptr == (void *)NULL);
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PointerToVoid::is_null
+//       Access: Published
+//  Description: Returns true if the PointerTo is a NULL pointer,
+//               false otherwise.  (Direct comparison to a NULL
+//               pointer also works.)
+////////////////////////////////////////////////////////////////////
+INLINE bool PointerToVoid::
+is_null() const {
+  return (_void_ptr == (void *)NULL);
+}

+ 4 - 0
panda/src/express/pointerToVoid.h

@@ -38,6 +38,10 @@ protected:
   INLINE PointerToVoid();
   INLINE PointerToVoid();
   INLINE ~PointerToVoid();
   INLINE ~PointerToVoid();
 
 
+PUBLISHED:
+  INLINE bool is_null() const;
+
+protected:
   // Within the PointerToVoid class, we only store a void pointer.
   // Within the PointerToVoid class, we only store a void pointer.
   // This is actually the (To *) pointer that is typecast to (void *)
   // This is actually the (To *) pointer that is typecast to (void *)
   // from the derived template classes.
   // from the derived template classes.

+ 18 - 18
panda/src/express/weakPointerTo.I

@@ -59,8 +59,8 @@ WeakPointerTo(const WeakPointerTo<T> &copy) :
 template<class T>
 template<class T>
 INLINE TYPENAME WeakPointerTo<T>::To &WeakPointerTo<T>::
 INLINE TYPENAME WeakPointerTo<T>::To &WeakPointerTo<T>::
 operator *() const {
 operator *() const {
-  nassertr(!is_null(), *((To *)NULL));
-  return *((To *)(this->_void_ptr));
+  nassertr(!this->was_deleted(), *((To *)NULL));
+  return *((To *)_void_ptr);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -71,8 +71,8 @@ operator *() const {
 template<class T>
 template<class T>
 INLINE TYPENAME WeakPointerTo<T>::To *WeakPointerTo<T>::
 INLINE TYPENAME WeakPointerTo<T>::To *WeakPointerTo<T>::
 operator -> () const {
 operator -> () const {
-  nassertr(!is_null(), (To *)NULL);
-  return (To *)(this->_void_ptr);
+  nassertr(!this->was_deleted(), (To *)NULL);
+  return (To *)_void_ptr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -88,8 +88,8 @@ operator -> () const {
 template<class T>
 template<class T>
 INLINE WeakPointerTo<T>::
 INLINE WeakPointerTo<T>::
 operator TYPENAME WeakPointerToBase<T>::To *() const {
 operator TYPENAME WeakPointerToBase<T>::To *() const {
-  nassertr(!is_null(), (To *)NULL);
-  return (To *)(this->_void_ptr);
+  nassertr(!this->was_deleted(), (To *)NULL);
+  return (To *)_void_ptr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -102,8 +102,8 @@ operator TYPENAME WeakPointerToBase<T>::To *() const {
 template<class T>
 template<class T>
 INLINE TYPENAME WeakPointerTo<T>::To *WeakPointerTo<T>::
 INLINE TYPENAME WeakPointerTo<T>::To *WeakPointerTo<T>::
 p() const {
 p() const {
-  nassertr(!is_null(), (To *)NULL);
-  return (To *)(this->_void_ptr);
+  nassertr(!this->was_deleted(), (To *)NULL);
+  return (To *)_void_ptr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -149,8 +149,8 @@ operator = (const WeakPointerTo<T> &copy) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class T>
 template<class T>
 INLINE WeakConstPointerTo<T>::
 INLINE WeakConstPointerTo<T>::
-WeakConstPointerTo(const TYPENAME WeakConstPointerTo<T>::To *ptr) :
-  WeakPointerToBase<T>((TYPENAME WeakConstPointerTo<T>::To *)ptr)
+WeakConstPointerTo(const To *ptr) :
+  WeakPointerToBase<T>((WeakConstPointerTo<T>::To *)ptr)
 {
 {
 }
 }
 
 
@@ -210,8 +210,8 @@ WeakConstPointerTo(const WeakConstPointerTo<T> &copy) :
 template<class T>
 template<class T>
 INLINE const TYPENAME WeakConstPointerTo<T>::To &WeakConstPointerTo<T>::
 INLINE const TYPENAME WeakConstPointerTo<T>::To &WeakConstPointerTo<T>::
 operator *() const {
 operator *() const {
-  nassertr(!is_null(), *((To *)NULL));
-  return *((To *)(this->_void_ptr));
+  nassertr(!this->was_deleted(), *((To *)NULL));
+  return *((To *)_void_ptr);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -222,8 +222,8 @@ operator *() const {
 template<class T>
 template<class T>
 INLINE const TYPENAME WeakConstPointerTo<T>::To *WeakConstPointerTo<T>::
 INLINE const TYPENAME WeakConstPointerTo<T>::To *WeakConstPointerTo<T>::
 operator -> () const {
 operator -> () const {
-  nassertr(!is_null(), (To *)NULL);
-  return (To *)(this->_void_ptr);
+  nassertr(!this->was_deleted(), (To *)NULL);
+  return (To *)_void_ptr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -240,8 +240,8 @@ operator -> () const {
 template<class T>
 template<class T>
 INLINE WeakConstPointerTo<T>::
 INLINE WeakConstPointerTo<T>::
 operator const TYPENAME WeakPointerToBase<T>::To *() const {
 operator const TYPENAME WeakPointerToBase<T>::To *() const {
-  nassertr(!is_null(), (To *)NULL);
-  return (To *)(this->_void_ptr);
+  nassertr(!this->was_deleted(), (To *)NULL);
+  return (To *)_void_ptr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -254,8 +254,8 @@ operator const TYPENAME WeakPointerToBase<T>::To *() const {
 template<class T>
 template<class T>
 INLINE const TYPENAME WeakConstPointerTo<T>::To *WeakConstPointerTo<T>::
 INLINE const TYPENAME WeakConstPointerTo<T>::To *WeakConstPointerTo<T>::
 p() const {
 p() const {
-  nassertr(!is_null(), (To *)NULL);
-  return (To *)(this->_void_ptr);
+  nassertr(!this->was_deleted(), (To *)NULL);
+  return (To *)_void_ptr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 2 - 3
panda/src/express/weakPointerTo.h

@@ -52,11 +52,10 @@ PUBLISHED:
   INLINE WeakPointerTo<T> &operator = (const PointerTo<T> &copy);
   INLINE WeakPointerTo<T> &operator = (const PointerTo<T> &copy);
   INLINE WeakPointerTo<T> &operator = (const WeakPointerTo<T> &copy);
   INLINE WeakPointerTo<T> &operator = (const WeakPointerTo<T> &copy);
 
 
-  // These functions normally wouldn't need to be redefined here, but
+  // This function normally wouldn't need to be redefined here, but
   // we do so anyway just to help out interrogate (which doesn't seem
   // we do so anyway just to help out interrogate (which doesn't seem
   // to want to automatically export the WeakPointerToBase class).  When
   // to want to automatically export the WeakPointerToBase class).  When
-  // this works again in interrogate, we can remove these.
-  INLINE bool is_null() const { return WeakPointerToBase<T>::is_null(); }
+  // this works again in interrogate, we can remove this.
   INLINE void clear() { WeakPointerToBase<T>::clear(); }
   INLINE void clear() { WeakPointerToBase<T>::clear(); }
 };
 };
 
 

+ 2 - 15
panda/src/express/weakPointerToBase.I

@@ -387,22 +387,9 @@ operator < (const PointerToBase<To> &other) const {
 
 
 
 
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: WeakPointerToBase::is_null
-//       Access: Public
-//  Description: Returns true if the PointerTo is a NULL pointer,
-//               false otherwise.  (Direct comparison to a NULL
-//               pointer also works.)
-////////////////////////////////////////////////////////////////////
-template<class T>
-INLINE bool WeakPointerToBase<T>::
-is_null() const {
-  return (_void_ptr == (void *)NULL);
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: WeakPointerToBase::clear
 //     Function: WeakPointerToBase::clear
-//       Access: Public
+//       Access: Published
 //  Description: A convenient way to set the PointerTo object to NULL.
 //  Description: A convenient way to set the PointerTo object to NULL.
 //               (Assignment to a NULL pointer also works, of course.)
 //               (Assignment to a NULL pointer also works, of course.)
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -414,7 +401,7 @@ clear() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: WeakPointerToBase::output
 //     Function: WeakPointerToBase::output
-//       Access: Public
+//       Access: Published
 //  Description: A handy function to output PointerTo's as a hex
 //  Description: A handy function to output PointerTo's as a hex
 //               pointer followed by a reference count.
 //               pointer followed by a reference count.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 0 - 1
panda/src/express/weakPointerToBase.h

@@ -82,7 +82,6 @@ public:
 #endif  // CPPPARSER
 #endif  // CPPPARSER
 
 
 PUBLISHED:
 PUBLISHED:
-  INLINE bool is_null() const;
   INLINE void clear();
   INLINE void clear();
 
 
   void output(ostream &out) const;
   void output(ostream &out) const;

+ 12 - 1
panda/src/express/weakPointerToVoid.I

@@ -43,7 +43,7 @@ mark_deleted() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: WeakPointerToVoid::was_deleted
 //     Function: WeakPointerToVoid::was_deleted
-//       Access: Public
+//       Access: Published
 //  Description: Returns true if the object we are pointing to has
 //  Description: Returns true if the object we are pointing to has
 //               been deleted, false otherwise.
 //               been deleted, false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -51,3 +51,14 @@ INLINE bool WeakPointerToVoid::
 was_deleted() const {
 was_deleted() const {
   return _ptr_was_deleted;
   return _ptr_was_deleted;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: WeakPointerToVoid::is_valid_pointer
+//       Access: Published
+//  Description: Returns true if the pointer is not null and the
+//               object has not been deleted.
+////////////////////////////////////////////////////////////////////
+INLINE bool WeakPointerToVoid::
+is_valid_pointer() const {
+  return (_void_ptr != (void *)NULL) && !_ptr_was_deleted;
+}

+ 1 - 0
panda/src/express/weakPointerToVoid.h

@@ -37,6 +37,7 @@ public:
 
 
 PUBLISHED:
 PUBLISHED:
   INLINE bool was_deleted() const;
   INLINE bool was_deleted() const;
+  INLINE bool is_valid_pointer() const;
 
 
 protected:
 protected:
   bool _ptr_was_deleted;
   bool _ptr_was_deleted;