* SUMMARY I think we should implement our own PassOwnPtr templates and get rid of std::auto_ptr. 1. You can't do this with auto_ptr without getting compilation errors: class SomeClass; [...] virtual auto_ptr<SomeClass> createSomeClass() { return 0; } 2. When you fix the above code, it requires you do the following *and* include the whole SomeClass.h header instead of just using a class predeclaration: #include "SomeClass.h" [...] virtual auto_ptr<SomeClass> createSomeClass() { return auto_ptr<SomeClass>(); } Lame. 3. Looking at auto_ptr and OwnPtr, you wouldn't know they're related (like PassRefPtr and RefPtr).
(In reply to comment #0) > 2. When you fix the above code, it requires you do the following *and* include > the whole SomeClass.h header instead of just using a class predeclaration: > > #include "SomeClass.h" > [...] > virtual auto_ptr<SomeClass> createSomeClass() { return > auto_ptr<SomeClass>(); } After implementing PassOwnPtr, I realized that you still must #include "SomeClass.h" anyway, but you can just return 0: #include "SomeClass.h" [...] virtual auto_ptr<SomeClass> createSomeClass() { return 0; }
(In reply to comment #1) > After implementing PassOwnPtr, I realized that you still must #include > "SomeClass.h" anyway, but you can just return 0: > > #include "SomeClass.h" > [...] > virtual auto_ptr<SomeClass> createSomeClass() { return 0; } If you do that, it will compile, but it will crash (at least in MSVC).
(In reply to comment #2) > (In reply to comment #1) > > After implementing PassOwnPtr, I realized that you still must #include > > "SomeClass.h" anyway, but you can just return 0: > > > > #include "SomeClass.h" > > [...] > > virtual auto_ptr<SomeClass> createSomeClass() { return 0; } > > If you do that, it will compile, but it will crash (at least in MSVC). Sorry, that was a typo. I meant to change it to: > > virtual PassOwnPtr<SomeClass> createSomeClass() { return 0; }
Created attachment 30083 [details] Part 1 of 2: Implement PassOwnPtr
Created attachment 30084 [details] Part 2 of 2: Use PassOwnPtr
Created attachment 30430 [details] Part 1 of 2 (v2): Implement PassOwnPtr Rebased against ToT WebKit.
Created attachment 30431 [details] Part 2 of 2 (v2): Use PassOwnPtr Rebased against ToT WebKit.
Comment on attachment 30430 [details] Part 1 of 2 (v2): Implement PassOwnPtr r=me
Comment on attachment 30431 [details] Part 2 of 2 (v2): Use PassOwnPtr r=me, yay !
$ git svn dcommit Committing to http://svn.webkit.org/repository/webkit/trunk ... M JavaScriptCore/ChangeLog M JavaScriptCore/GNUmakefile.am M JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj M JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj M JavaScriptCore/wtf/OwnPtr.h A JavaScriptCore/wtf/OwnPtrCommon.h A JavaScriptCore/wtf/PassOwnPtr.h M JavaScriptGlue/ChangeLog A JavaScriptGlue/ForwardingHeaders/wtf/OwnPtrCommon.h A JavaScriptGlue/ForwardingHeaders/wtf/PassOwnPtr.h M WebCore/ChangeLog A WebCore/ForwardingHeaders/wtf/OwnPtrCommon.h A WebCore/ForwardingHeaders/wtf/PassOwnPtr.h M WebCore/WebCore.vcproj/WebCore.vcproj M WebKit/mac/ChangeLog A WebKit/mac/ForwardingHeaders/wtf/OwnPtrCommon.h A WebKit/mac/ForwardingHeaders/wtf/PassOwnPtr.h M WebKitTools/ChangeLog A WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/OwnPtrCommon.h A WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/PassOwnPtr.h Committed r44095 http://trac.webkit.org/changeset/44095 $ git svn dcommit Committing to http://svn.webkit.org/repository/webkit/trunk ... M WebCore/ChangeLog M WebCore/WebCore.base.exp M WebCore/dom/Node.cpp M WebCore/dom/NodeRareData.h M WebCore/history/HistoryItem.cpp M WebCore/history/HistoryItem.h M WebCore/html/CanvasRenderingContext2D.cpp M WebCore/html/HTMLCanvasElement.cpp M WebCore/loader/EmptyClients.h M WebCore/page/ChromeClient.h M WebCore/platform/graphics/GeneratedImage.cpp M WebCore/platform/graphics/ImageBuffer.h M WebCore/platform/mac/ScrollbarThemeMac.mm M WebCore/platform/text/TextCodec.h M WebCore/platform/text/TextCodecICU.cpp M WebCore/platform/text/TextCodecLatin1.cpp M WebCore/platform/text/TextCodecUTF16.cpp M WebCore/platform/text/TextCodecUserDefined.cpp M WebCore/platform/text/TextEncodingRegistry.cpp M WebCore/platform/text/TextEncodingRegistry.h M WebCore/platform/text/mac/TextCodecMac.cpp M WebCore/rendering/RenderBoxModelObject.cpp M WebCore/svg/SVGMaskElement.cpp M WebCore/svg/SVGMaskElement.h M WebCore/svg/SVGPatternElement.cpp M WebCore/svg/graphics/SVGImage.cpp M WebCore/svg/graphics/SVGPaintServerGradient.cpp M WebCore/svg/graphics/SVGPaintServerPattern.cpp M WebCore/svg/graphics/SVGPaintServerPattern.h M WebCore/svg/graphics/SVGResourceMasker.cpp M WebKit/gtk/ChangeLog M WebKit/gtk/WebCoreSupport/ChromeClientGtk.h M WebKit/mac/ChangeLog M WebKit/mac/History/WebHistory.mm M WebKit/mac/History/WebHistoryItem.mm M WebKit/mac/WebCoreSupport/WebChromeClient.h M WebKit/qt/ChangeLog M WebKit/qt/WebCoreSupport/ChromeClientQt.h M WebKit/win/ChangeLog M WebKit/win/WebCoreSupport/WebChromeClient.h M WebKit/wx/ChangeLog M WebKit/wx/WebKitSupport/ChromeClientWx.h Committed r44096 http://trac.webkit.org/changeset/44096
Attempted Windows build fix: $ git svn dcommit Committing to http://svn.webkit.org/repository/webkit/trunk ... M WebKit/win/ChangeLog M WebKit/win/WebHistory.cpp M WebKit/win/WebHistoryItem.cpp Committed r44098 http://trac.webkit.org/changeset/44098
Attempted to fix Gtk and Qt builds: $ git svn dcommit Committing to http://svn.webkit.org/repository/webkit/trunk ... M WebCore/ChangeLog M WebCore/platform/graphics/cairo/ImageCairo.cpp M WebCore/platform/graphics/qt/PathQt.cpp Committed r44099 http://trac.webkit.org/changeset/44099