Changeset 10084 in webkit for trunk/JavaScriptCore/kjs/protected_object.h
- Timestamp:
- Aug 7, 2005, 9:07:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/protected_object.h
r10076 r10084 1 // -*- c-basic-offset: 2 -*-2 1 /* 3 2 * This file is part of the KDE libraries … … 21 20 */ 22 21 23 24 #ifndef _KJS_PROTECTED_OBJECT_H_ 25 #define _KJS_PROTECTED_OBJECT_H_ 22 #ifndef KJS_PROTECTED_OBJECT_H 23 #define KJS_PROTECTED_OBJECT_H 26 24 27 25 #include "protect.h" … … 31 29 namespace KJS { 32 30 33 class ProtectedObject : public Object { 34 public: 35 ProtectedObject() : Object() {} 36 ProtectedObject(const Object &o) : Object(o) { gcProtectNullTolerant(o.imp()); }; 37 ProtectedObject(const ProtectedObject &o) : Object(o) { gcProtectNullTolerant(o.imp()); }; 38 ~ProtectedObject() { gcUnprotectNullTolerant(imp());} 39 ProtectedObject& operator=(const Object &o) 40 { 41 ValueImp *old = imp(); 42 Object::operator=(o); 43 gcProtectNullTolerant(o.imp()); 44 gcUnprotectNullTolerant(old); 45 return *this; 46 } 47 ProtectedObject& operator=(const ProtectedObject &o) 48 { 49 ValueImp *old = imp(); 50 Object::operator=(o); 51 gcProtectNullTolerant(o.imp()); 52 gcUnprotectNullTolerant(old); 53 return *this; 54 } 55 private: 56 explicit ProtectedObject(ObjectImp *o); 57 }; 58 31 class ProtectedObject : private ProtectedValue { 32 public: 33 ProtectedObject() { } 34 ProtectedObject(ObjectImp *v) : ProtectedValue(v) { } 35 ProtectedObject(const ProtectedObject& v) : ProtectedValue(v) { } 36 ProtectedObject& operator=(ObjectImp *v) { ProtectedValue::operator=(v); return *this; } 37 ProtectedObject& operator=(const ProtectedObject& v) { ProtectedValue::operator=(v); return *this; } 38 operator ValueImp *() const { return m_value; } 39 operator ObjectImp *() const { return static_cast<ObjectImp *>(m_value); } 40 ObjectImp *operator->() const { return static_cast<ObjectImp *>(m_value); } 41 }; 59 42 60 43 class ProtectedReference : public Reference { 61 44 public: 62 ProtectedReference(const Reference& r) : Reference(r) { gcProtectNullTolerant(r.base.imp()); };63 ~ProtectedReference() { gcUnprotectNullTolerant(base .imp());}45 ProtectedReference(const Reference& r) : Reference(r) { gcProtectNullTolerant(r.base); }; 46 ~ProtectedReference() { gcUnprotectNullTolerant(base);} 64 47 ProtectedReference& operator=(const Reference &r) 65 48 { 66 ValueImp *old = base .imp();49 ValueImp *old = base; 67 50 Reference::operator=(r); 68 gcProtectNullTolerant(r.base .imp());51 gcProtectNullTolerant(r.base); 69 52 gcUnprotectNullTolerant(old); 70 53 return *this; … … 72 55 private: 73 56 ProtectedReference(); 74 ProtectedReference(const Object& b, const Identifier& p);75 ProtectedReference(const Object& b, unsigned p);76 57 ProtectedReference(ObjectImp *b, const Identifier& p); 77 58 ProtectedReference(ObjectImp *b, unsigned p); 78 ProtectedReference(const Null& b, constIdentifier& p);79 ProtectedReference( const Null& b,unsigned p);59 ProtectedReference(const Identifier& p); 60 ProtectedReference(unsigned p); 80 61 }; 81 62
Note:
See TracChangeset
for help on using the changeset viewer.