2010-01-07 Nate Chapin <japhet@chromium.org>
[WebKit.git] / WebCore / bindings / v8 / custom / V8CustomBinding.h
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  * 
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  * 
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  * 
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30  
31 #ifndef V8CustomBinding_h
32 #define V8CustomBinding_h
33
34 #include "V8Index.h"
35 #include <v8.h>
36
37 namespace WebCore {
38     class V8Custom {
39     public:
40         // Constants.
41         static const int kDOMWrapperTypeIndex = 0;
42         static const int kDOMWrapperObjectIndex = 1;
43         static const int kDefaultWrapperInternalFieldCount = 2;
44
45         static const int kNPObjectInternalFieldCount = kDefaultWrapperInternalFieldCount + 0;
46
47         static const int kNodeEventListenerCacheIndex = kDefaultWrapperInternalFieldCount + 0;
48         static const int kNodeMinimumInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
49
50         static const int kDocumentImplementationIndex = kNodeMinimumInternalFieldCount + 0;
51         static const int kDocumentMinimumInternalFieldCount = kNodeMinimumInternalFieldCount + 1;
52
53         static const int kHTMLDocumentMarkerIndex = kDocumentMinimumInternalFieldCount + 0;
54         static const int kHTMLDocumentShadowIndex = kDocumentMinimumInternalFieldCount + 1;
55         static const int kHTMLDocumentInternalFieldCount = kDocumentMinimumInternalFieldCount + 2;
56
57         static const int kXMLHttpRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
58         static const int kXMLHttpRequestInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
59
60         static const int kMessageChannelPort1Index = kDefaultWrapperInternalFieldCount + 0;
61         static const int kMessageChannelPort2Index = kDefaultWrapperInternalFieldCount + 1;
62         static const int kMessageChannelInternalFieldCount = kDefaultWrapperInternalFieldCount + 2;
63
64         static const int kMessagePortRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
65         static const int kMessagePortInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
66
67 #if ENABLE(WORKERS)
68         static const int kAbstractWorkerRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
69         static const int kAbstractWorkerInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
70
71         static const int kWorkerRequestCacheIndex = kAbstractWorkerInternalFieldCount + 0;
72         static const int kWorkerInternalFieldCount = kAbstractWorkerInternalFieldCount + 1;
73
74         static const int kWorkerContextRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
75         static const int kWorkerContextMinimumInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
76
77         static const int kDedicatedWorkerContextRequestCacheIndex = kWorkerContextMinimumInternalFieldCount + 0;
78         static const int kDedicatedWorkerContextInternalFieldCount = kWorkerContextMinimumInternalFieldCount + 1;
79 #endif
80
81 #if ENABLE(SHARED_WORKERS)
82         static const int kSharedWorkerRequestCacheIndex = kAbstractWorkerInternalFieldCount + 0;
83         static const int kSharedWorkerInternalFieldCount = kAbstractWorkerInternalFieldCount + 1;
84
85         static const int kSharedWorkerContextRequestCacheIndex = kWorkerContextMinimumInternalFieldCount + 0;
86         static const int kSharedWorkerContextInternalFieldCount = kWorkerContextMinimumInternalFieldCount + 1;
87 #endif
88
89 #if ENABLE(NOTIFICATIONS)
90         static const int kNotificationRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
91         static const int kNotificationInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
92 #endif
93
94 #if ENABLE(SVG)
95         static const int kSVGElementInstanceEventListenerCacheIndex = kDefaultWrapperInternalFieldCount + 0;
96         static const int kSVGElementInstanceInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
97 #endif
98
99         static const int kDOMWindowConsoleIndex = kDefaultWrapperInternalFieldCount + 0;
100         static const int kDOMWindowHistoryIndex = kDefaultWrapperInternalFieldCount + 1;
101         static const int kDOMWindowLocationbarIndex = kDefaultWrapperInternalFieldCount + 2;
102         static const int kDOMWindowMenubarIndex = kDefaultWrapperInternalFieldCount + 3;
103         static const int kDOMWindowNavigatorIndex = kDefaultWrapperInternalFieldCount + 4;
104         static const int kDOMWindowPersonalbarIndex = kDefaultWrapperInternalFieldCount + 5;
105         static const int kDOMWindowScreenIndex = kDefaultWrapperInternalFieldCount + 6;
106         static const int kDOMWindowScrollbarsIndex = kDefaultWrapperInternalFieldCount + 7;
107         static const int kDOMWindowSelectionIndex = kDefaultWrapperInternalFieldCount + 8;
108         static const int kDOMWindowStatusbarIndex = kDefaultWrapperInternalFieldCount + 9;
109         static const int kDOMWindowToolbarIndex = kDefaultWrapperInternalFieldCount + 10;
110         static const int kDOMWindowLocationIndex = kDefaultWrapperInternalFieldCount + 11;
111         static const int kDOMWindowDOMSelectionIndex = kDefaultWrapperInternalFieldCount + 12;
112         static const int kDOMWindowEventListenerCacheIndex = kDefaultWrapperInternalFieldCount + 13;
113         static const int kDOMWindowEnteredIsolatedWorldIndex = kDefaultWrapperInternalFieldCount + 14;
114         static const int kDOMWindowInternalFieldCount = kDefaultWrapperInternalFieldCount + 15;
115
116         static const int kStyleSheetOwnerNodeIndex = kDefaultWrapperInternalFieldCount + 0;
117         static const int kStyleSheetInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
118         static const int kNamedNodeMapOwnerNodeIndex = kDefaultWrapperInternalFieldCount + 0;
119         static const int kNamedNodeMapInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
120
121 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
122         static const int kDOMApplicationCacheCacheIndex = kDefaultWrapperInternalFieldCount + 0;
123         static const int kDOMApplicationCacheFieldCount = kDefaultWrapperInternalFieldCount + 1;
124 #endif
125
126 #if ENABLE(WEB_SOCKETS)
127         static const int kWebSocketCacheIndex = kDefaultWrapperInternalFieldCount + 0;
128         static const int kWebSocketInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
129 #endif
130
131 #define DECLARE_CALLBACK(NAME) static v8::Handle<v8::Value> v8##NAME##Callback(const v8::Arguments& args)
132 #define USE_CALLBACK(NAME) V8Custom::v8##NAME##Callback
133
134         DECLARE_CALLBACK(DOMParserConstructor);
135         DECLARE_CALLBACK(HTMLAudioElementConstructor);
136         DECLARE_CALLBACK(HTMLImageElementConstructor);
137         DECLARE_CALLBACK(HTMLOptionElementConstructor);
138         DECLARE_CALLBACK(MessageChannelConstructor);
139         DECLARE_CALLBACK(WebKitCSSMatrixConstructor);
140         DECLARE_CALLBACK(WebKitPointConstructor);
141         DECLARE_CALLBACK(XMLHttpRequestConstructor);
142         DECLARE_CALLBACK(XMLSerializerConstructor);
143         DECLARE_CALLBACK(XPathEvaluatorConstructor);
144         DECLARE_CALLBACK(XSLTProcessorConstructor);
145
146 #if ENABLE(3D_CANVAS)
147         DECLARE_CALLBACK(WebGLArrayBufferConstructor);
148         DECLARE_CALLBACK(WebGLByteArrayConstructor);
149         DECLARE_CALLBACK(WebGLFloatArrayConstructor);
150         DECLARE_CALLBACK(WebGLIntArrayConstructor);
151         DECLARE_CALLBACK(WebGLShortArrayConstructor);
152         DECLARE_CALLBACK(WebGLUnsignedByteArrayConstructor);
153         DECLARE_CALLBACK(WebGLUnsignedIntArrayConstructor);
154         DECLARE_CALLBACK(WebGLUnsignedShortArrayConstructor);
155 #endif
156
157 #if ENABLE(WORKERS)
158         DECLARE_CALLBACK(WorkerConstructor);
159 #endif
160
161 #if ENABLE(SHARED_WORKERS)
162         DECLARE_CALLBACK(SharedWorkerConstructor);
163 #endif
164
165 #if ENABLE(WEB_SOCKETS)
166         DECLARE_CALLBACK(WebSocketConstructor);
167 #endif
168
169 #undef DECLARE_CALLBACK
170     };
171
172 } // namespace WebCore
173
174 #endif // V8CustomBinding_h