OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WrapperTypeInfo_h | 31 #ifndef WrapperTypeInfo_h |
32 #define WrapperTypeInfo_h | 32 #define WrapperTypeInfo_h |
33 | 33 |
34 #include <v8.h> | 34 #include <v8.h> |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 class ActiveDOMObject; | 38 class ActiveDOMObject; |
39 class DOMDataStore; | 39 class DOMDataStore; |
40 class EventTarget; | 40 class EventTarget; |
41 class Node; | 41 class Node; |
42 | 42 |
43 static const int v8DOMWrapperTypeIndex = 0; | 43 static const int v8DOMWrapperTypeIndex = 0; |
44 static const int v8DOMWrapperObjectIndex = 1; | 44 static const int v8DOMWrapperObjectIndex = 1; |
45 static const int v8DefaultWrapperInternalFieldCount = 2; | 45 static const int v8DefaultWrapperInternalFieldCount = 2; |
46 static const int v8PrototypeTypeIndex = 0; | 46 static const int v8PrototypeTypeIndex = 0; |
47 static const int v8PrototypeInternalFieldcount = 1; | 47 static const int v8PrototypeInternalFieldcount = 1; |
(...skipping 21 matching lines...) Expand all Loading... |
69 | 69 |
70 // This struct provides a way to store a bunch of information that is helpfu
l when unwrapping | 70 // This struct provides a way to store a bunch of information that is helpfu
l when unwrapping |
71 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo
member, so | 71 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo
member, so |
72 // comparing pointers is a safe way to determine if types match. | 72 // comparing pointers is a safe way to determine if types match. |
73 struct WrapperTypeInfo { | 73 struct WrapperTypeInfo { |
74 | 74 |
75 static WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapper) | 75 static WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapper) |
76 { | 76 { |
77 return reinterpret_cast<WrapperTypeInfo*>(v8::External::Cast(*typeIn
foWrapper)->Value()); | 77 return reinterpret_cast<WrapperTypeInfo*>(v8::External::Cast(*typeIn
foWrapper)->Value()); |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 bool equals(const WrapperTypeInfo* that) const | 81 bool equals(const WrapperTypeInfo* that) const |
82 { | 82 { |
83 return this == that; | 83 return this == that; |
84 } | 84 } |
85 | 85 |
86 bool isSubclass(const WrapperTypeInfo* that) const | 86 bool isSubclass(const WrapperTypeInfo* that) const |
87 { | 87 { |
88 for (const WrapperTypeInfo* current = this; current; current = curre
nt->parentClass) { | 88 for (const WrapperTypeInfo* current = this; current; current = curre
nt->parentClass) { |
89 if (current == that) | 89 if (current == that) |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
96 v8::Handle<v8::FunctionTemplate> getTemplate(v8::Isolate* isolate, Wrapp
erWorldType worldType) { return getTemplateFunction(isolate, worldType); } | 96 v8::Handle<v8::FunctionTemplate> getTemplate(v8::Isolate* isolate, Wrapp
erWorldType worldType) { return getTemplateFunction(isolate, worldType); } |
97 | 97 |
98 void derefObject(void* object) | 98 void derefObject(void* object) |
99 { | 99 { |
100 if (derefObjectFunction) | 100 if (derefObjectFunction) |
101 derefObjectFunction(object); | 101 derefObjectFunction(object); |
102 } | 102 } |
103 | 103 |
104 void installPerContextPrototypeProperties(v8::Handle<v8::Object> proto,
v8::Isolate* isolate) | 104 void installPerContextPrototypeProperties(v8::Handle<v8::Object> proto,
v8::Isolate* isolate) |
105 { | 105 { |
106 if (installPerContextPrototypePropertiesFunction) | 106 if (installPerContextPrototypePropertiesFunction) |
107 installPerContextPrototypePropertiesFunction(proto, isolate); | 107 installPerContextPrototypePropertiesFunction(proto, isolate); |
108 } | 108 } |
109 | 109 |
110 ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object> object) | 110 ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object> object) |
111 { | 111 { |
112 if (!toActiveDOMObjectFunction) | 112 if (!toActiveDOMObjectFunction) |
113 return 0; | 113 return 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 return configuration; | 203 return configuration; |
204 } | 204 } |
205 | 205 |
206 template<class ElementType> | 206 template<class ElementType> |
207 class WrapperTypeTraits { | 207 class WrapperTypeTraits { |
208 // specialized classes have thier own functions, which are generated by
binding generator. | 208 // specialized classes have thier own functions, which are generated by
binding generator. |
209 }; | 209 }; |
210 } | 210 } |
211 | 211 |
212 #endif // WrapperTypeInfo_h | 212 #endif // WrapperTypeInfo_h |
OLD | NEW |