WebCore:
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Sep 2006 22:06:21 +0000 (22:06 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Sep 2006 22:06:21 +0000 (22:06 +0000)
        Reviewed by Darin and Tim H.

        Patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10774
        Auto-generate the Objective-C DOM Traversal bindings

        - Auto-generates DOMNodeIterator and DOMTreeWalker.

        - Splits out DOMNodeFilter into its own file.

        * DerivedSources.make:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/objc/DOM.mm:
        * bindings/objc/DOMNodeFilter.h: Added.
        * bindings/objc/DOMTraversal.h:
        * bindings/objc/PublicDOMInterfaces.h:
        * bindings/scripts/CodeGeneratorObjC.pm:
        * dom/NodeFilter.idl:
        * dom/NodeIterator.idl:
        * dom/Range.idl:
        * dom/TreeWalker.idl:

WebKit:

        Reviewed by Darin and Tim H.

        Patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10774
        Auto-generate the Objective-C DOM Traversal bindings

        * MigrateHeaders.make:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16267 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/objc/DOM.mm
WebCore/bindings/objc/DOMNodeFilter.h [new file with mode: 0644]
WebCore/bindings/objc/DOMTraversal.h
WebCore/bindings/objc/PublicDOMInterfaces.h
WebCore/bindings/scripts/CodeGeneratorObjC.pm
WebCore/dom/NodeFilter.idl
WebCore/dom/NodeIterator.idl
WebCore/dom/Range.idl
WebCore/dom/TreeWalker.idl
WebKit/ChangeLog
WebKit/MigrateHeaders.make

index 48d566f06d249c5c5b71646a2cbea97c811505b8..0b4d8803069eae17ae37d09820730134c94d659b 100644 (file)
@@ -1,3 +1,26 @@
+2006-09-07  Sam Weinig  <sam.weinig@gmail.com>
+
+        Reviewed by Darin and Tim H.
+
+        Patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10774
+        Auto-generate the Objective-C DOM Traversal bindings
+
+        - Auto-generates DOMNodeIterator and DOMTreeWalker.
+
+        - Splits out DOMNodeFilter into its own file.
+
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/objc/DOM.mm:
+        * bindings/objc/DOMNodeFilter.h: Added.
+        * bindings/objc/DOMTraversal.h:
+        * bindings/objc/PublicDOMInterfaces.h:
+        * bindings/scripts/CodeGeneratorObjC.pm:
+        * dom/NodeFilter.idl:
+        * dom/NodeIterator.idl:
+        * dom/Range.idl:
+        * dom/TreeWalker.idl:
+
 2006-09-07  MorganL  <morlmor@yahoo.com>
 
         Reviewed by Darin, landed by Adam.
index 0f35723c35b4a741614500270bfeea9756087995..7dd19a907e4ae1bed9d8368bc15f6ba84de34a10 100644 (file)
@@ -127,6 +127,7 @@ all : \
     DOMMouseEvent.h \
     DOMMutationEvent.h \
     DOMNamedNodeMap.h \
+    DOMNodeIterator.h \
     DOMNodeList.h \
     DOMNotation.h \
     DOMOverflowEvent.h \
@@ -135,6 +136,7 @@ all : \
     DOMStyleSheet.h \
     DOMStyleSheetList.h \
     DOMText.h \
+    DOMTreeWalker.h \
     DOMUIEvent.h \
     DOMWheelEvent.h
 endif
index 312db2c4c35556d69a94f02f4cc86c0b18bb1a28..95a1e36207a7a8a02364e14d61183880a4c77c10 100644 (file)
                854FE7370A2297BE0058D7AD /* Traversal.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE72D0A2297BE0058D7AD /* Traversal.h */; };
                854FE7380A2297BE0058D7AD /* TreeWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */; };
                854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE72F0A2297BE0058D7AD /* TreeWalker.h */; };
+               85526C370AB0A17E000302EA /* DOMNodeIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 85526C350AB0A17E000302EA /* DOMNodeIterator.h */; };
+               85526C380AB0A17E000302EA /* DOMNodeIterator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85526C360AB0A17E000302EA /* DOMNodeIterator.mm */; };
+               85526C3E0AB0A76F000302EA /* DOMNodeIteratorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 85526C3D0AB0A76F000302EA /* DOMNodeIteratorPrivate.h */; };
+               85526C720AB0AE2F000302EA /* DOMNodeIterator.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 85526C350AB0A17E000302EA /* DOMNodeIterator.h */; };
+               85526C730AB0AE2F000302EA /* DOMNodeIteratorPrivate.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 85526C3D0AB0A76F000302EA /* DOMNodeIteratorPrivate.h */; };
+               85526CD20AB0B7D9000302EA /* DOMTreeWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 85526CD00AB0B7D9000302EA /* DOMTreeWalker.h */; };
+               85526CD30AB0B7DA000302EA /* DOMTreeWalker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85526CD10AB0B7D9000302EA /* DOMTreeWalker.mm */; };
+               85526D050AB0B979000302EA /* DOMTreeWalker.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 85526CD00AB0B7D9000302EA /* DOMTreeWalker.h */; };
                856C89FC0A90F068005C687B /* DOMNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 856C89FA0A90F068005C687B /* DOMNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                856C89FD0A90F068005C687B /* DOMNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 856C89FB0A90F068005C687B /* DOMNode.mm */; };
                856C8AE40A912649005C687B /* DOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 856C8AE20A912649005C687B /* DOMObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                859A9C4E0AA5E3BD00B694B2 /* DOMHTMLMetaElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 859A9C440AA5E3BD00B694B2 /* DOMHTMLMetaElement.mm */; };
                859A9C4F0AA5E3BD00B694B2 /* DOMHTMLStyleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 859A9C450AA5E3BD00B694B2 /* DOMHTMLStyleElement.h */; };
                859A9C500AA5E3BD00B694B2 /* DOMHTMLStyleElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 859A9C460AA5E3BD00B694B2 /* DOMHTMLStyleElement.mm */; };
+               859FA5FB0AB0BF20004FAEE9 /* DOMNodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 859FA5FA0AB0BF20004FAEE9 /* DOMNodeFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                85ACA9860A9B520300671E90 /* DOMCharacterData.h in Headers */ = {isa = PBXBuildFile; fileRef = 85ACA9840A9B520300671E90 /* DOMCharacterData.h */; settings = {ATTRIBUTES = (); }; };
                85ACA9870A9B520300671E90 /* DOMCharacterData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85ACA9850A9B520300671E90 /* DOMCharacterData.mm */; };
                85ACA99C0A9B575900671E90 /* DOMText.h in Headers */ = {isa = PBXBuildFile; fileRef = 85ACA99A0A9B575900671E90 /* DOMText.h */; settings = {ATTRIBUTES = (); }; };
                        dstPath = Versions/A/PrivateHeaders;
                        dstSubfolderSpec = 1;
                        files = (
+                               85526D050AB0B979000302EA /* DOMTreeWalker.h in CopyFiles */,
+                               85526C720AB0AE2F000302EA /* DOMNodeIterator.h in CopyFiles */,
+                               85526C730AB0AE2F000302EA /* DOMNodeIteratorPrivate.h in CopyFiles */,
                                857E0B310AB044780036E447 /* DOMMouseEvent.h in CopyFiles */,
                                857E0B320AB044780036E447 /* DOMMouseEventPrivate.h in CopyFiles */,
                                85DF345D0AAFC2D400E59AE3 /* DOMMutationEvent.h in CopyFiles */,
                854FE72D0A2297BE0058D7AD /* Traversal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Traversal.h; sourceTree = "<group>"; };
                854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TreeWalker.cpp; sourceTree = "<group>"; };
                854FE72F0A2297BE0058D7AD /* TreeWalker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TreeWalker.h; sourceTree = "<group>"; };
+               85526C350AB0A17E000302EA /* DOMNodeIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMNodeIterator.h; sourceTree = "<group>"; };
+               85526C360AB0A17E000302EA /* DOMNodeIterator.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMNodeIterator.mm; sourceTree = "<group>"; };
+               85526C3D0AB0A76F000302EA /* DOMNodeIteratorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMNodeIteratorPrivate.h; sourceTree = "<group>"; };
+               85526CD00AB0B7D9000302EA /* DOMTreeWalker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMTreeWalker.h; sourceTree = "<group>"; };
+               85526CD10AB0B7D9000302EA /* DOMTreeWalker.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMTreeWalker.mm; sourceTree = "<group>"; };
                855542570AA48B1E00BA89F2 /* HTMLTableCaptionElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLTableCaptionElement.idl; sourceTree = "<group>"; };
                855542580AA48B1E00BA89F2 /* HTMLTableCellElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLTableCellElement.idl; sourceTree = "<group>"; };
                855542590AA48B1E00BA89F2 /* HTMLTableColElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLTableColElement.idl; sourceTree = "<group>"; };
                859A9C450AA5E3BD00B694B2 /* DOMHTMLStyleElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLStyleElement.h; sourceTree = "<group>"; };
                859A9C460AA5E3BD00B694B2 /* DOMHTMLStyleElement.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLStyleElement.mm; sourceTree = "<group>"; };
                859B7FB90A8D288800A5F1EA /* CodeGeneratorObjC.pm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.perl; name = CodeGeneratorObjC.pm; path = bindings/scripts/CodeGeneratorObjC.pm; sourceTree = SOURCE_ROOT; tabWidth = 8; usesTabs = 0; };
+               859FA5FA0AB0BF20004FAEE9 /* DOMNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMNodeFilter.h; sourceTree = "<group>"; };
                85ACA9840A9B520300671E90 /* DOMCharacterData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMCharacterData.h; sourceTree = "<group>"; };
                85ACA9850A9B520300671E90 /* DOMCharacterData.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMCharacterData.mm; sourceTree = "<group>"; };
                85ACA99A0A9B575900671E90 /* DOMText.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMText.h; sourceTree = "<group>"; };
                        name = Core;
                        sourceTree = "<group>";
                };
+               85526C150AB0A12A000302EA /* Traversal */ = {
+                       isa = PBXGroup;
+                       children = (
+                               85526C3D0AB0A76F000302EA /* DOMNodeIteratorPrivate.h */,
+                               85526C350AB0A17E000302EA /* DOMNodeIterator.h */,
+                               85526C360AB0A17E000302EA /* DOMNodeIterator.mm */,
+                               85526CD00AB0B7D9000302EA /* DOMTreeWalker.h */,
+                               85526CD10AB0B7D9000302EA /* DOMTreeWalker.mm */,
+                       );
+                       name = Traversal;
+                       sourceTree = "<group>";
+               };
                858C39510AA9024C00B187A4 /* CSS */ = {
                        isa = PBXGroup;
                        children = (
                        name = HTML;
                        sourceTree = "<group>";
                };
+               859FA5F20AB0BEE2004FAEE9 /* Traversal */ = {
+                       isa = PBXGroup;
+                       children = (
+                               859FA5FA0AB0BF20004FAEE9 /* DOMNodeFilter.h */,
+                       );
+                       name = Traversal;
+                       sourceTree = "<group>";
+               };
                85AFA7AB0AAF3BB000E84305 /* Events */ = {
                        isa = PBXGroup;
                        children = (
                                85AFA7AB0AAF3BB000E84305 /* Events */,
                                85C56D030AA8BAA700D95755 /* HTML */,
                                850657040AAB476C002D15C0 /* StyleSheets */,
+                               85526C150AB0A12A000302EA /* Traversal */,
                        );
                        name = "Derived Sources";
                        path = DerivedSources/WebCore;
                                858C39510AA9024C00B187A4 /* CSS */,
                                85C7F4430AAF7686004014DD /* Events */,
                                85992FC20AA5DD4600AC0785 /* HTML */,
+                               859FA5F20AB0BEE2004FAEE9 /* Traversal */,
                                859B7FB90A8D288800A5F1EA /* CodeGeneratorObjC.pm */,
                                1CD0B6200AABDB5000D0A3FF /* PublicDOMInterfaces.h */,
                                BC1A3797097C715F0019F3D8 /* DOM.h */,
                                85DF34400AAFC0ED00E59AE3 /* DOMKeyboardEventPrivate.h in Headers */,
                                857E0B250AB043460036E447 /* DOMMouseEvent.h in Headers */,
                                857E0B2C0AB043FC0036E447 /* DOMMouseEventPrivate.h in Headers */,
+                               85526C370AB0A17E000302EA /* DOMNodeIterator.h in Headers */,
+                               85526C3E0AB0A76F000302EA /* DOMNodeIteratorPrivate.h in Headers */,
+                               85526CD20AB0B7D9000302EA /* DOMTreeWalker.h in Headers */,
+                               859FA5FB0AB0BF20004FAEE9 /* DOMNodeFilter.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                85C7F5E80AAFBAFB004014DD /* DOMWheelEvent.mm in Sources */,
                                85FF315B0AAFBFCB00374F38 /* DOMKeyboardEvent.mm in Sources */,
                                857E0B260AB043460036E447 /* DOMMouseEvent.mm in Sources */,
+                               85526C380AB0A17E000302EA /* DOMNodeIterator.mm in Sources */,
+                               85526CD30AB0B7DA000302EA /* DOMTreeWalker.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 560211571cd0336fc77253bac177b0895d63aa0c..c69857b38d6e3c1ce6520f2afa6d7c955d87acf7 100644 (file)
@@ -1101,7 +1101,7 @@ static Class elementClass(const AtomicString& tagName)
 //------------------------------------------------------------------------------------------
 // DOMNodeIterator
 
-@implementation DOMNodeIterator
+@implementation DOMNodeIterator(WebCoreInternal)
 
 - (id)_initWithNodeIterator:(NodeIterator *)impl filter:(id <DOMNodeFilter>)filter
 {
@@ -1120,75 +1120,6 @@ static Class elementClass(const AtomicString& tagName)
     return DOM_cast<NodeIterator *>(_internal);
 }
 
-- (void)dealloc
-{
-    [m_filter release];
-    if (_internal) {
-        [self detach];
-        DOM_cast<NodeIterator *>(_internal)->deref();
-    }
-    [super dealloc];
-}
-
-- (void)finalize
-{
-    if (_internal) {
-        [self detach];
-        DOM_cast<NodeIterator *>(_internal)->deref();
-    }
-    [super finalize];
-}
-
-- (DOMNode *)root
-{
-    return [DOMNode _nodeWith:[self _nodeIterator]->root()];
-}
-
-- (unsigned)whatToShow
-{
-    return [self _nodeIterator]->whatToShow();
-}
-
-- (id <DOMNodeFilter>)filter
-{
-    if (m_filter)
-        // This node iterator was created from the objc side
-        return [[m_filter retain] autorelease];
-
-    // This node iterator was created from the c++ side
-    return [DOMNodeFilter _nodeFilterWith:[self _nodeIterator]->filter()];
-}
-
-- (BOOL)expandEntityReferences
-{
-    return [self _nodeIterator]->expandEntityReferences();
-}
-
-- (DOMNode *)nextNode
-{
-    ExceptionCode ec = 0;
-    DOMNode *result = [DOMNode _nodeWith:[self _nodeIterator]->nextNode(ec)];
-    raiseOnDOMError(ec);
-    return result;
-}
-
-- (DOMNode *)previousNode
-{
-    ExceptionCode ec = 0;
-    DOMNode *result = [DOMNode _nodeWith:[self _nodeIterator]->previousNode(ec)];
-    raiseOnDOMError(ec);
-    return result;
-}
-
-- (void)detach
-{
-    [self _nodeIterator]->detach();
-}
-
-@end
-
-@implementation DOMNodeIterator(WebCoreInternal)
-
 + (DOMNodeIterator *)_nodeIteratorWith:(NodeIterator *)impl filter:(id <DOMNodeFilter>)filter
 {
     if (!impl)
@@ -1208,7 +1139,7 @@ static Class elementClass(const AtomicString& tagName)
 //------------------------------------------------------------------------------------------
 // DOMTreeWalker
 
-@implementation DOMTreeWalker
+@implementation DOMTreeWalker (WebCoreInternal)
 
 - (id)_initWithTreeWalker:(TreeWalker *)impl filter:(id <DOMNodeFilter>)filter
 {
@@ -1227,100 +1158,6 @@ static Class elementClass(const AtomicString& tagName)
     return DOM_cast<TreeWalker *>(_internal);
 }
 
-- (void)dealloc
-{
-    if (m_filter)
-        [m_filter release];
-    if (_internal) {
-        DOM_cast<TreeWalker *>(_internal)->deref();
-    }
-    [super dealloc];
-}
-
-- (void)finalize
-{
-    if (_internal) {
-        DOM_cast<TreeWalker *>(_internal)->deref();
-    }
-    [super finalize];
-}
-
-- (DOMNode *)root
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->root()];
-}
-
-- (unsigned)whatToShow
-{
-    return [self _treeWalker]->whatToShow();
-}
-
-- (id <DOMNodeFilter>)filter
-{
-    if (m_filter)
-        // This tree walker was created from the objc side
-        return [[m_filter retain] autorelease];
-
-    // This tree walker was created from the c++ side
-    return [DOMNodeFilter _nodeFilterWith:[self _treeWalker]->filter()];
-}
-
-- (BOOL)expandEntityReferences
-{
-    return [self _treeWalker]->expandEntityReferences();
-}
-
-- (DOMNode *)currentNode
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->currentNode()];
-}
-
-- (void)setCurrentNode:(DOMNode *)currentNode
-{
-    ExceptionCode ec = 0;
-    [self _treeWalker]->setCurrentNode([currentNode _node], ec);
-    raiseOnDOMError(ec);
-}
-
-- (DOMNode *)parentNode
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->parentNode()];
-}
-
-- (DOMNode *)firstChild
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->firstChild()];
-}
-
-- (DOMNode *)lastChild
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->lastChild()];
-}
-
-- (DOMNode *)previousSibling
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->previousSibling()];
-}
-
-- (DOMNode *)nextSibling
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->nextSibling()];
-}
-
-- (DOMNode *)previousNode
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->previousNode()];
-}
-
-- (DOMNode *)nextNode
-{
-    return [DOMNode _nodeWith:[self _treeWalker]->nextNode()];
-}
-
-@end
-
-@implementation DOMTreeWalker (WebCoreInternal)
-
 + (DOMTreeWalker *)_treeWalkerWith:(TreeWalker *)impl filter:(id <DOMNodeFilter>)filter
 {
     if (!impl)
diff --git a/WebCore/bindings/objc/DOMNodeFilter.h b/WebCore/bindings/objc/DOMNodeFilter.h
new file mode 100644 (file)
index 0000000..a29d728
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+@class DOMNode;
+
+enum {
+    // Constants returned by acceptNode
+    DOM_FILTER_ACCEPT                  = 1,
+    DOM_FILTER_REJECT                  = 2,
+    DOM_FILTER_SKIP                    = 3
+};
+
+enum {
+    // Constants for whatToShow
+    DOM_SHOW_ALL                       = 0xFFFFFFFF,
+    DOM_SHOW_ELEMENT                   = 0x00000001,
+    DOM_SHOW_ATTRIBUTE                 = 0x00000002,
+    DOM_SHOW_TEXT                      = 0x00000004,
+    DOM_SHOW_CDATA_SECTION             = 0x00000008,
+    DOM_SHOW_ENTITY_REFERENCE          = 0x00000010,
+    DOM_SHOW_ENTITY                    = 0x00000020,
+    DOM_SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
+    DOM_SHOW_COMMENT                   = 0x00000080,
+    DOM_SHOW_DOCUMENT                  = 0x00000100,
+    DOM_SHOW_DOCUMENT_TYPE             = 0x00000200,
+    DOM_SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
+    DOM_SHOW_NOTATION                  = 0x00000800
+};
+
+@protocol DOMNodeFilter <NSObject>
+- (short)acceptNode:(DOMNode *)n;
+@end
index f2ef221fafb085de7150e761a580642a80798929..2222cbde6c017271ad41ae4c0a67925cb4a1e91e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
 #import <WebCore/DOMDocument.h>
 #import <WebCore/DOMObject.h>
 
-@class DOMNodeFilter;
-
-enum {
-    // Constants returned by acceptNode
-    DOM_FILTER_ACCEPT                  = 1,
-    DOM_FILTER_REJECT                  = 2,
-    DOM_FILTER_SKIP                    = 3
-};
-
-enum {
-    // Constants for whatToShow
-    DOM_SHOW_ALL                       = 0xFFFFFFFF,
-    DOM_SHOW_ELEMENT                   = 0x00000001,
-    DOM_SHOW_ATTRIBUTE                 = 0x00000002,
-    DOM_SHOW_TEXT                      = 0x00000004,
-    DOM_SHOW_CDATA_SECTION             = 0x00000008,
-    DOM_SHOW_ENTITY_REFERENCE          = 0x00000010,
-    DOM_SHOW_ENTITY                    = 0x00000020,
-    DOM_SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
-    DOM_SHOW_COMMENT                   = 0x00000080,
-    DOM_SHOW_DOCUMENT                  = 0x00000100,
-    DOM_SHOW_DOCUMENT_TYPE             = 0x00000200,
-    DOM_SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
-    DOM_SHOW_NOTATION                  = 0x00000800
-};
-
-@protocol DOMNodeFilter <NSObject>
-- (short)acceptNode:(DOMNode *)n;
-@end
-
-@interface DOMNodeIterator : DOMObject
-{
-    id <DOMNodeFilter> m_filter;
-}
-- (DOMNode *)root;
-- (unsigned)whatToShow;
-- (id <DOMNodeFilter>)filter;
-- (BOOL)expandEntityReferences;
-- (DOMNode *)nextNode;
-- (DOMNode *)previousNode;
-- (void)detach;
-@end
-
-@interface DOMTreeWalker : DOMObject
-{
-    id <DOMNodeFilter> m_filter;
-}
-- (DOMNode *)root;
-- (unsigned)whatToShow;
-- (id <DOMNodeFilter>)filter;
-- (BOOL)expandEntityReferences;
-- (DOMNode *)currentNode;
-- (void)setCurrentNode:(DOMNode *)currentNode;
-- (DOMNode *)parentNode;
-- (DOMNode *)firstChild;
-- (DOMNode *)lastChild;
-- (DOMNode *)previousSibling;
-- (DOMNode *)nextSibling;
-- (DOMNode *)previousNode;
-- (DOMNode *)nextNode;
-@end
+#import <WebCore/DOMNodeFilter.h>
+#import <WebCore/DOMNodeIterator.h>
+#import <WebCore/DOMTreeWalker.h>
 
 @interface DOMDocument (DOMDocumentTraversal)
 - (DOMNodeIterator *)createNodeIterator:(DOMNode *)root :(unsigned)whatToShow :(id <DOMNodeFilter>)filter :(BOOL)expandEntityReferences;
index fc6f462a587345d1a0f0e26d85d9cb7eceee01a0..53b1ba73753ce6d649442e2fc6551f0260931068 100644 (file)
 //- (void)initMouseEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view detail:(int)detail screenX:(int)screenX screenY:(int)screenY clientX:(int)clientX clientY:(int)clientY ctrlKey:(BOOL)ctrlKey altKey:(BOOL)altKey shiftKey:(BOOL)shiftKey metaKey:(BOOL)metaKey button:(unsigned short)button relatedTarget:(id <DOMEventTarget>)relatedTarget;
 - (void)initMouseEvent:(NSString *)type :(BOOL)canBubble :(BOOL)cancelable :(DOMAbstractView *)view :(int)detail :(int)screenX :(int)screenY :(int)clientX :(int)clientY :(BOOL)ctrlKey :(BOOL)altKey :(BOOL)shiftKey :(BOOL)metaKey :(unsigned short)button :(id <DOMEventTarget>)relatedTarget;
 @end
+
+@interface DOMNodeIterator : DOMObject
+@property(readonly) DOMNode *root;
+@property(readonly) unsigned whatToShow;
+@property(readonly) id <DOMNodeFilter> filter;
+@property(readonly) BOOL expandEntityReferences;
+- (DOMNode *)nextNode;
+- (DOMNode *)previousNode;
+- (void)detach;
+@end
+
+@interface DOMTreeWalker : DOMObject
+@property(readonly) DOMNode *root;
+@property(readonly) unsigned whatToShow;
+@property(readonly) id <DOMNodeFilter> filter;
+@property(readonly) BOOL expandEntityReferences;
+@property DOMNode *currentNode;
+- (DOMNode *)parentNode;
+- (DOMNode *)firstChild;
+- (DOMNode *)lastChild;
+- (DOMNode *)previousSibling;
+- (DOMNode *)nextSibling;
+- (DOMNode *)previousNode;
+- (DOMNode *)nextNode;
+@end
index b5314d77a209587477e58252df7386d90df57283..0c5349c58ea53656c0db9a905a3ba150e0da8c9b 100644 (file)
@@ -34,6 +34,7 @@ my %privateHeaderForwardDeclarationsForProtocols = ();
 my %publicInterfaces = ();
 my $newPublicClass = 0;
 my $isProtocol = 0;
+my @ivars = ();
 my $buildingForTigerOrEarlier = 1 if $ENV{"MACOSX_DEPLOYMENT_TARGET"} and $ENV{"MACOSX_DEPLOYMENT_TARGET"} <= 10.4;
 my $buildingForLeopardOrLater = 1 if $ENV{"MACOSX_DEPLOYMENT_TARGET"} and $ENV{"MACOSX_DEPLOYMENT_TARGET"} >= 10.5;
 
@@ -169,8 +170,8 @@ sub GenerateInterface
     ReadPublicInterfaces($className, $parentClassName, $defines);
 
     # Start actual generation..
-    $object->GenerateImplementation($dataNode) unless $isProtocol;
     $object->GenerateHeader($dataNode);
+    $object->GenerateImplementation($dataNode) unless $isProtocol;
 
     # Write changes.
     $object->WriteData("DOM" . $name);
@@ -246,7 +247,7 @@ sub IsProtocolType
 {
     $type = shift;
 
-    return 1 if $type eq "XPathNSResolver" or $type eq "EventListener" or $type eq "EventTarget";
+    return 1 if $type eq "XPathNSResolver" or $type eq "EventListener" or $type eq "EventTarget" or $type eq "NodeFilter";
     return 0;
 }
 
@@ -462,6 +463,22 @@ sub GenerateHeader
 
     # - Add attribute getters/setters.
     if ($numAttributes > 0) {
+        # Add ivars, if any, first
+        @ivars = ();
+        foreach my $attribute (@{$dataNode->attributes}) {
+            push(@ivars, $attribute) if $attribute->signature->extendedAttributes->{"ObjCIvar"};
+        }
+        if (@ivars > 0) {
+            push(@headerAttributes, "{\n");
+            foreach my $attribute (@ivars) {
+                my $type = GetObjCType($attribute->signature->type);;
+                my $name = "m_" . $attribute->signature->name;
+                my $ivarDeclaration = "$type $name";
+                push(@headerAttributes, "    $ivarDeclaration;\n");
+            }
+            push(@headerAttributes, "}\n");
+        }
+
         foreach my $attribute (@{$dataNode->attributes}) {
             my $attributeName = $attribute->signature->name;
 
@@ -643,17 +660,40 @@ sub GenerateImplementation
 
             push(@implContent, "#define IMPL reinterpret_cast<$implClassNameWithNamespace*>(_internal)\n\n");
 
+            my @ivarsToRelease = ();
+            if (@ivars > 0) {
+                foreach $attribute (@ivars) {
+                    my $name = "m_" . $attribute->signature->name;
+                    push(@ivarsToRelease, "    [$name release];\n");
+                }
+            }
+
             push(@implContent, "- (void)dealloc\n");
             push(@implContent, "{\n");
-            push(@implContent, "    if (_internal)\n");
-            push(@implContent, "        IMPL->deref();\n");
+            push(@implContent, @ivarsToRelease);
+            if ($interfaceName eq "NodeIterator") {
+                push(@implContent, "    if (_internal) {\n");
+                push(@implContent, "        [self detach];\n");
+                push(@implContent, "        IMPL->deref();\n");
+                push(@implContent, "    };\n");
+            } else {
+                push(@implContent, "    if (_internal)\n");
+                push(@implContent, "        IMPL->deref();\n");
+            }
             push(@implContent, "    [super dealloc];\n");
             push(@implContent, "}\n\n");
 
             push(@implContent, "- (void)finalize\n");
             push(@implContent, "{\n");
-            push(@implContent, "    if (_internal)\n");
-            push(@implContent, "        IMPL->deref();\n");
+            if ($interfaceName eq "NodeIterator") {
+                push(@implContent, "    if (_internal) {\n");
+                push(@implContent, "        [self detach];\n");
+                push(@implContent, "        IMPL->deref();\n");
+                push(@implContent, "    };\n");
+            } else {
+                push(@implContent, "    if (_internal)\n");
+                push(@implContent, "        IMPL->deref();\n");
+            }
             push(@implContent, "    [super finalize];\n");
             push(@implContent, "}\n\n");
         } elsif ($interfaceName eq "CSSStyleSheet") {
@@ -687,6 +727,7 @@ sub GenerateImplementation
             my $attributeName = $attribute->signature->name;
             my $attributeType = GetObjCType($attribute->signature->type);
             my $attributeIsReadonly = ($attribute->type =~ /^readonly/);
+            my $attributeClassName = GetClassName($attribute->signature->type);
 
             my $attributeInterfaceName = $attributeName;
             if ($attributeName eq "id") {
@@ -714,6 +755,7 @@ sub GenerateImplementation
             my $typeMaker = GetObjCTypeMaker($attribute->signature->type);
 
             # Special cases
+            my @customGetterContent = (); 
             if ($attributeTypeSansPtr eq "DOMImplementation") {
                 # FIXME: We have to special case DOMImplementation until DOMImplementationFront is removed
                 $getterContentHead = "[$attributeTypeSansPtr $typeMaker:implementationFront(IMPL";
@@ -731,6 +773,13 @@ sub GenerateImplementation
                     $getterContentTail = "\@\"src\"]";
                 }
                 $implIncludes{"DOMPrivate.h"} = 1;
+            } elsif ($idlType eq "NodeFilter") {
+                push(@customGetterContent, "    if (m_filter)\n");
+                push(@customGetterContent, "        // This node iterator was created from the Objective-C side.\n");
+                push(@customGetterContent, "        return [[m_filter retain] autorelease];\n\n");
+                push(@customGetterContent, "    // This node iterator was created from the C++ side.\n");
+                $getterContentHead = "[$attributeClassName $typeMaker:WTF::getPtr(" . $getterContentHead;
+                $getterContentTail .= ")]";
             } elsif ($typeMaker ne "") {
                 # Surround getter with TypeMaker
                 $getterContentHead = "[$attributeTypeSansPtr $typeMaker:WTF::getPtr(" . $getterContentHead;
@@ -755,11 +804,13 @@ sub GenerateImplementation
                     $getterContent = $attributeType . " result = " . $getterContent;
                 }
 
+                push(@implContent, @customGetterContent);
                 push(@implContent, "    $exceptionInit\n");
                 push(@implContent, "    $getterContent;\n");
                 push(@implContent, "    $exceptionRaiseOnError\n");
                 push(@implContent, "    return result;\n");
             } else {
+                push(@implContent, @customGetterContent);
                 push(@implContent, "    return $getterContent;\n");
             }
             push(@implContent, "}\n\n");
index 282ed9f5fefcf3c9596d47a71204742803835941..f8679574bc94c30b8f70a4ccd8f0e86e68d977a0 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,7 +21,7 @@
 module traversal {
 
     // Introduced in DOM Level 2:
-    interface [LegacyParent=KJS::DOMNodeFilter, GenerateConstructor] NodeFilter {
+    interface [LegacyParent=KJS::DOMNodeFilter, GenerateConstructor, ObjCProtocol] NodeFilter {
 
         // Constants returned by acceptNode
         const short               FILTER_ACCEPT                  = 1;
@@ -41,6 +42,9 @@ module traversal {
         const unsigned long       SHOW_DOCUMENT_TYPE             = 0x00000200;
         const unsigned long       SHOW_DOCUMENT_FRAGMENT         = 0x00000400;
         const unsigned long       SHOW_NOTATION                  = 0x00000800;
+
+        [Exclude=JS] short acceptNode(in Node n);
+
     };
-  
+
 }
index a33270df09cbd133954e7e89bbde58e364eaa374..e1941722233eab06c2c5d08851739d5a801c706d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 module traversal {
 
+    // Introduced in DOM Level 2:
     interface [CustomMarkFunction] NodeIterator {
         readonly attribute Node root;
         readonly attribute unsigned long whatToShow;
-        readonly attribute NodeFilter filter;
+        readonly attribute [ObjCIvar] NodeFilter filter;
         readonly attribute boolean expandEntityReferences;
         readonly attribute Node referenceNode;
         readonly attribute boolean pointerBeforeReferenceNode;
index e244768042091e7e4b87e222efcd3debe89fd69c..4f2677a9f799e419b555c50a2d463c7825c9f860 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 module ranges {
 
+    // Introduced in DOM Level 2:
     interface [GenerateConstructor] Range {
 
-        // DOM Level 2
-
         readonly attribute Node startContainer
             getter raises (DOMException);
         readonly attribute long startOffset
@@ -36,11 +36,11 @@ module ranges {
         readonly attribute Node commonAncestorContainer
             getter raises (DOMException);
 
-        void setStart(in Node refNode, 
-                      in long offset)
+        [OldStyleObjC] void setStart(in Node refNode, 
+                                     in long offset)
             raises(RangeException, dom::DOMException);
-        void setEnd(in Node refNode, 
-                    in long offset)
+        [OldStyleObjC] void setEnd(in Node refNode, 
+                                   in long offset)
             raises(RangeException, dom::DOMException);
         void setStartBefore(in Node refNode)
             raises(RangeException, dom::DOMException);
@@ -63,8 +63,8 @@ module ranges {
         const unsigned short END_TO_END     = 2;
         const unsigned short END_TO_START   = 3;
 
-        short compareBoundaryPoints(in CompareHow how,
-                                    in Range sourceRange)
+        [OldStyleObjC] short compareBoundaryPoints(in CompareHow how,
+                                                   in Range sourceRange)
             raises(dom::DOMException);
         short comparePoint(in Node refNode, 
                            in long offset)
index d17ed1f1db428dfc5c0349b858a847e8767d45f2..bc8058377afdca94c4807b4574e5df11018a57d7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 module traversal {
 
+    // Introduced in DOM Level 2:
     interface [CustomMarkFunction] TreeWalker {
         readonly attribute Node root;
         readonly attribute unsigned long whatToShow;
-        readonly attribute NodeFilter filter;
+        readonly attribute [ObjCIvar] NodeFilter filter;
         readonly attribute boolean expandEntityReferences;        
         attribute Node currentNode
             setter raises (DOMException);
@@ -35,6 +37,7 @@ module traversal {
         Node previousNode();
         Node nextNode();
     };
+
 }
 
  
\ No newline at end of file
index 7df3daa3aafda38ade8de862608ac21defe756b6..fc73663ed030192b74f6dfa361c35f0d5ed51041 100644 (file)
@@ -1,3 +1,12 @@
+2006-09-07  Sam Weinig  <sam.weinig@gmail.com>
+
+        Reviewed by Darin and Tim H.
+
+        Patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10774
+        Auto-generate the Objective-C DOM Traversal bindings
+
+        * MigrateHeaders.make:
+
 2006-09-07  Sam Weinig  <sam.weinig@gmail.com>
 
         Reviewed by Darin.
index 8a4ad97b160d4d49db46ad36f2fd7143b2a5ebd1..af40e9d6ab1687e69425c58c84a64aaab9ed4ea5 100644 (file)
@@ -156,6 +156,9 @@ all : \
     $(PUBLIC_HEADERS_DIR)/DOMNamedNodeMap.h \
     $(PRIVATE_HEADERS_DIR)/DOMNamedNodeMapPrivate.h \
     $(PUBLIC_HEADERS_DIR)/DOMNode.h \
+    $(PUBLIC_HEADERS_DIR)/DOMNodeFilter.h \
+    $(PUBLIC_HEADERS_DIR)/DOMNodeIterator.h \
+    $(PRIVATE_HEADERS_DIR)/DOMNodeIteratorPrivate.h \
     $(PUBLIC_HEADERS_DIR)/DOMNodeList.h \
     $(PUBLIC_HEADERS_DIR)/DOMNotation.h \
     $(PUBLIC_HEADERS_DIR)/DOMObject.h \
@@ -171,6 +174,7 @@ all : \
     $(PUBLIC_HEADERS_DIR)/DOMStylesheets.h \
     $(PUBLIC_HEADERS_DIR)/DOMText.h \
     $(PUBLIC_HEADERS_DIR)/DOMTraversal.h \
+    $(PUBLIC_HEADERS_DIR)/DOMTreeWalker.h \
     $(PUBLIC_HEADERS_DIR)/DOMUIEvent.h \
     $(PRIVATE_HEADERS_DIR)/DOMUIEventPrivate.h \
     $(PUBLIC_HEADERS_DIR)/DOMViews.h \