[webkit-changes] cvs commit: WebCore/khtml/xml DocPtr.h

Maciej mjs at opensource.apple.com
Thu Dec 1 00:38:16 PST 2005


mjs         05/12/01 00:38:15

  Modified:    .        ChangeLog
               kjs      protect.h
               kxmlcore SharedPtr.h
               .        ChangeLog
               khtml/xml DocPtr.h
  Log:
  JavaScriptCore:
  
  	Reviewed by Dave Hyatt.
  
          - change idiom used for implicit bool conversion of smart pointers, because the old one gives weird error messages sometimes
  
          * kjs/protect.h:
          (KJS::ProtectedPtr::operator UnspecifiedBoolType):
          * kxmlcore/SharedPtr.h:
          (KXMLCore::SharedPtr::operator UnspecifiedBoolType):
  
  WebCore:
  
  	Reviewed by Dave Hyatt.
  
          - change idiom used for implicit bool conversion of smart pointers, because the old one gives weird error messages sometimes
  
          * khtml/xml/DocPtr.h:
          (DOM::DocPtr::operator UnspecifiedBoolType):
  
  Revision  Changes    Path
  1.887     +11 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.886
  retrieving revision 1.887
  diff -u -r1.886 -r1.887
  --- ChangeLog	29 Nov 2005 10:33:19 -0000	1.886
  +++ ChangeLog	1 Dec 2005 08:38:10 -0000	1.887
  @@ -1,3 +1,14 @@
  +2005-11-30  Maciej Stachowiak  <mjs at apple.com>
  +
  +	Reviewed by Dave Hyatt.
  +
  +        - change idiom used for implicit bool conversion of smart pointers, because the old one gives weird error messages sometimes
  +
  +        * kjs/protect.h:
  +        (KJS::ProtectedPtr::operator UnspecifiedBoolType):
  +        * kxmlcore/SharedPtr.h:
  +        (KXMLCore::SharedPtr::operator UnspecifiedBoolType):
  +
   2005-11-29  Mitz Pettel  <opendarwin.org at mitzpettel.com>
   
           Reviewed by ggaren.  Committed by eseidel.
  
  
  
  1.13      +9 -3      JavaScriptCore/kjs/protect.h
  
  Index: protect.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/protect.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- protect.h	27 Nov 2005 07:54:44 -0000	1.12
  +++ protect.h	1 Dec 2005 08:38:11 -0000	1.13
  @@ -66,15 +66,21 @@
           T *operator->() const { return m_ptr; }
           
           bool operator!() const { return m_ptr == NULL; }
  -        operator bool() const { return m_ptr != NULL; }
  +
  +        // this type conversion operator allows implicit conversion to
  +        // bool but not to other integer types
  +
  +        typedef T * (ProtectedPtr::*UnspecifiedBoolType)() const;
  +        operator UnspecifiedBoolType() const
  +        {
  +            return m_ptr ? &ProtectedPtr::get : 0;
  +        }
           
           ProtectedPtr &operator=(const ProtectedPtr &);
           ProtectedPtr &operator=(T *);
           
       private:
           T *m_ptr;
  -        
  -        operator int() const; // deliberately not implemented; helps prevent operator bool from converting to int accidentally
       };
   
       template <class T> ProtectedPtr<T>::ProtectedPtr(T *ptr)
  
  
  
  1.2       +10 -3     JavaScriptCore/kxmlcore/SharedPtr.h
  
  Index: SharedPtr.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kxmlcore/SharedPtr.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SharedPtr.h	27 Sep 2005 22:36:53 -0000	1.1
  +++ SharedPtr.h	1 Dec 2005 08:38:11 -0000	1.2
  @@ -50,15 +50,22 @@
           T *operator->() const { return m_ptr; }
           
           bool operator!() const { return m_ptr == NULL; }
  -        operator bool() const { return m_ptr != NULL; }
  +
  +    
  +        // this type conversion operator allows implicit conversion to
  +        // bool but not to other integer types
  +
  +        typedef T * (SharedPtr::*UnspecifiedBoolType)() const;
  +        operator UnspecifiedBoolType() const
  +        {
  +            return m_ptr ? &SharedPtr::get : 0;
  +        }
           
           SharedPtr &operator=(const SharedPtr &);
           SharedPtr &operator=(T *);
           
       private:
           T *m_ptr;
  -        
  -        operator int() const; // deliberately not implemented; helps prevent operator bool from converting to int accidentally
       };
       
       template <class T> SharedPtr<T> &SharedPtr<T>::operator=(const SharedPtr<T> &o) 
  
  
  
  1.443     +9 -0      WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.442
  retrieving revision 1.443
  diff -u -r1.442 -r1.443
  --- ChangeLog	30 Nov 2005 23:04:07 -0000	1.442
  +++ ChangeLog	1 Dec 2005 08:38:12 -0000	1.443
  @@ -1,3 +1,12 @@
  +2005-11-30  Maciej Stachowiak  <mjs at apple.com>
  +
  +	Reviewed by Dave Hyatt.
  +	
  +        - change idiom used for implicit bool conversion of smart pointers, because the old one gives weird error messages sometimes
  +
  +        * khtml/xml/DocPtr.h:
  +        (DOM::DocPtr::operator UnspecifiedBoolType):
  +
   2005-11-30  Eric Seidel  <eseidel at apple.com>
   
           Reviewed by darin.
  
  
  
  1.2       +9 -3      WebCore/khtml/xml/DocPtr.h
  
  Index: DocPtr.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/DocPtr.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DocPtr.h	8 Nov 2005 08:11:11 -0000	1.1
  +++ DocPtr.h	1 Dec 2005 08:38:15 -0000	1.2
  @@ -50,15 +50,21 @@
       T *operator->() const { return m_ptr; }
       
       bool operator!() const { return m_ptr == NULL; }
  -    operator bool() const { return m_ptr != NULL; }
  +
  +    // this type conversion operator allows implicit conversion to
  +    // bool but not to other integer types
  +    
  +    typedef T * (DocPtr::*UnspecifiedBoolType)() const;
  +    operator UnspecifiedBoolType() const
  +    {
  +        return m_ptr ? &DocPtr::get : 0;
  +    }
       
       DocPtr &operator=(const DocPtr &);
       DocPtr &operator=(T *);
       
    private:
       T *m_ptr;
  -    
  -    operator int() const; // deliberately not implemented; helps prevent operator bool from converting to int accidentally
   };
   
   template <class T> DocPtr<T> &DocPtr<T>::operator=(const DocPtr<T> &o) 
  
  
  



More information about the webkit-changes mailing list