Changeset 27763 in webkit for trunk/JavaScriptCore/wtf/Shared.h


Ignore:
Timestamp:
Nov 13, 2007, 4:30:19 PM (18 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Sam Weinig.

Moved Shared.h into wtf so it could be used in more places. Deployed
Shared in places where JSCore previously had hand-rolled ref-counting
classes.

  • API/JSClassRef.cpp: (OpaqueJSClass::OpaqueJSClass):
  • API/JSClassRef.h:
  • API/JSObjectRef.cpp: (JSClassRetain): (JSClassRelease):
  • JavaScriptCore.vcproj/WTF/WTF.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/interpreter.cpp: (KJS::Interpreter::init):
  • kjs/interpreter.h:
  • kjs/regexp.cpp: (KJS::RegExp::RegExp):
  • kjs/regexp.h:
  • wtf/Shared.h: Copied from WebCore/platform/Shared.h.

JavaScriptGlue:

Reviewed by Sam Weinig.

Moved Shared.h into wtf so it could be used in more places.

  • ForwardingHeaders/wtf/Shared.h: Added.

WebCore:

Reviewed by Sam Weinig.

Moved Shared.h into wtf so it could be used in more places. Retained
TreeShared, but moved it to its own file, TreeShared.h.

  • ForwardingHeaders/wtf/Shared.h: Added.
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSSVGPODTypeWrapper.h:
  • css/CSSFontFace.h:
  • css/CSSRuleList.h:
  • css/Counter.h:
  • css/Pair.h:
  • css/Rect.h:
  • css/StyleBase.h:
  • css/StyleSheetList.h:
  • dom/Clipboard.h:
  • dom/DOMImplementation.h:
  • dom/Event.h:
  • dom/EventListener.h:
  • dom/NamedNodeMap.h:
  • dom/NodeFilterCondition.h:
  • dom/NodeList.h:
  • dom/Range.h:
  • dom/RangeException.h:
  • dom/RegisteredEventListener.h:
  • dom/Traversal.h:
  • history/BackForwardList.h:
  • history/CachedPage.h:
  • history/HistoryItem.h:
  • html/CanvasGradient.h:
  • html/CanvasPattern.h:
  • html/HTMLCollection.h:
  • html/MediaError.h:
  • html/TimeRanges.h:
  • html/VoidCallback.h:
  • ksvg2/css/SVGRenderStyleDefs.h:
  • ksvg2/svg/SVGAnimatedTemplate.h:
  • ksvg2/svg/SVGElementInstanceList.h:
  • ksvg2/svg/SVGList.h:
  • ksvg2/svg/SVGPathSeg.h:
  • ksvg2/svg/SVGPreserveAspectRatio.h:
  • ksvg2/svg/SVGRenderingIntent.h:
  • ksvg2/svg/SVGTransform.h:
  • ksvg2/svg/SVGUnitTypes.h:
  • loader/DocumentLoader.h:
  • loader/FormState.h:
  • loader/ResourceLoader.h:
  • loader/TextResourceDecoder.h:
  • loader/icon/IconRecord.h:
  • page/BarInfo.h:
  • page/Console.h:
  • page/DOMSelection.h:
  • page/DOMWindow.h:
  • page/History.h:
  • page/InspectorController.cpp:
  • page/Plugin.h:
  • page/Screen.h:
  • platform/ArrayImpl.h:
  • platform/CString.h:
  • platform/DeprecatedValueListImpl.cpp:
  • platform/FontFallbackList.h:
  • platform/FontFamily.h:
  • platform/FontSelector.h:
  • platform/GlyphPageTreeNode.h:
  • platform/PopupMenu.h:
  • platform/RegularExpression.cpp:
  • platform/ScrollBar.h:
  • platform/Shared.h: Removed.
  • platform/SharedBuffer.h:
  • platform/StringImpl.h:
  • platform/graphics/Icon.h:
  • platform/graphics/svg/SVGResource.h:
  • platform/network/FormData.h:
  • platform/network/ResourceHandleClient.h:
  • rendering/RenderStyle.h:
  • rendering/SVGCharacterLayoutInfo.h:
  • storage/SQLResultSetRowList.h:
  • xml/DOMParser.h:
  • xml/XMLSerializer.h:
  • xml/XPathEvaluator.h:
  • xml/XPathExpression.h:
  • xml/XPathNSResolver.h:
  • xml/XPathResult.h:

WebKit/mac:

Reviewed by Sam Weinig.

Moved Shared.h into wtf so it could be used in more places.

  • ChangeLog:
  • WebCoreSupport/WebContextMenuClient.h:
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/Shared.h

    r27721 r27763  
    2525#include <wtf/Noncopyable.h>
    2626
    27 namespace WebCore {
     27namespace WTF {
    2828
    2929template<class T> class Shared : Noncopyable {
     
    7272};
    7373
    74 template<class T> class TreeShared : Noncopyable {
    75 public:
    76     TreeShared()
    77         : m_refCount(0)
    78         , m_parent(0)
    79     {
    80 #ifndef NDEBUG
    81         m_deletionHasBegun = false;
    82         m_inRemovedLastRefFunction = false;
    83 #endif
    84     }
    85     TreeShared(T* parent)
    86         : m_refCount(0)
    87         , m_parent(0)
    88     {
    89 #ifndef NDEBUG
    90         m_deletionHasBegun = false;
    91         m_inRemovedLastRefFunction = false;
    92 #endif
    93     }
    94     virtual ~TreeShared()
    95     {
    96         ASSERT(m_deletionHasBegun);
    97     }
     74} // namespace WTF
    9875
    99     void ref()
    100     {
    101         ASSERT(!m_deletionHasBegun);
    102         ASSERT(!m_inRemovedLastRefFunction);
    103         ++m_refCount;
    104     }
    105 
    106     void deref()
    107     {
    108         ASSERT(!m_deletionHasBegun);
    109         ASSERT(!m_inRemovedLastRefFunction);
    110         if (--m_refCount <= 0 && !m_parent) {
    111 #ifndef NDEBUG
    112             m_inRemovedLastRefFunction = true;
    113 #endif
    114             removedLastRef();
    115         }
    116     }
    117 
    118     bool hasOneRef() const
    119     {
    120         ASSERT(!m_deletionHasBegun);
    121         ASSERT(!m_inRemovedLastRefFunction);
    122         return m_refCount == 1;
    123     }
    124 
    125     int refCount() const
    126     {
    127         return m_refCount;
    128     }
    129 
    130     void setParent(T* parent) { m_parent = parent; }
    131     T* parent() const { return m_parent; }
    132 
    133 #ifndef NDEBUG
    134     bool m_deletionHasBegun;
    135     bool m_inRemovedLastRefFunction;
    136 #endif
    137 
    138 private:
    139     virtual void removedLastRef()
    140     {
    141 #ifndef NDEBUG
    142         m_deletionHasBegun = true;
    143 #endif
    144         delete this;
    145     }
    146 
    147     int m_refCount;
    148     T* m_parent;
    149 };
    150 
    151 }
     76using WTF::Shared;
    15277
    15378#endif
Note: See TracChangeset for help on using the changeset viewer.