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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 Dependent, | 85 Dependent, |
86 Independent, | 86 Independent, |
87 }; | 87 }; |
88 | 88 |
89 enum GCType { | 89 enum GCType { |
90 GarbageCollectedObject, | 90 GarbageCollectedObject, |
91 WillBeGarbageCollectedObject, | 91 WillBeGarbageCollectedObject, |
92 RefCountedObject, | 92 RefCountedObject, |
93 }; | 93 }; |
94 | 94 |
95 static const WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapper) | 95 static const WrapperTypeInfo* unwrap(v8::Local<v8::Value> typeInfoWrapper) |
96 { | 96 { |
97 return reinterpret_cast<const WrapperTypeInfo*>(v8::External::Cast(*type
InfoWrapper)->Value()); | 97 return reinterpret_cast<const WrapperTypeInfo*>(v8::External::Cast(*type
InfoWrapper)->Value()); |
98 } | 98 } |
99 | 99 |
100 bool equals(const WrapperTypeInfo* that) const | 100 bool equals(const WrapperTypeInfo* that) const |
101 { | 101 { |
102 return this == that; | 102 return this == that; |
103 } | 103 } |
104 | 104 |
105 bool isSubclass(const WrapperTypeInfo* that) const | 105 bool isSubclass(const WrapperTypeInfo* that) const |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 installConditionallyEnabledPropertiesFunction(prototypeTemplate, iso
late); | 154 installConditionallyEnabledPropertiesFunction(prototypeTemplate, iso
late); |
155 } | 155 } |
156 | 156 |
157 ActiveDOMObject* toActiveDOMObject(v8::Local<v8::Object> object) const | 157 ActiveDOMObject* toActiveDOMObject(v8::Local<v8::Object> object) const |
158 { | 158 { |
159 if (!toActiveDOMObjectFunction) | 159 if (!toActiveDOMObjectFunction) |
160 return 0; | 160 return 0; |
161 return toActiveDOMObjectFunction(object); | 161 return toActiveDOMObjectFunction(object); |
162 } | 162 } |
163 | 163 |
164 EventTarget* toEventTarget(v8::Handle<v8::Object>) const; | 164 EventTarget* toEventTarget(v8::Local<v8::Object>) const; |
165 | 165 |
166 void visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* scriptWrappable,
const v8::Persistent<v8::Object>& wrapper) const | 166 void visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* scriptWrappable,
const v8::Persistent<v8::Object>& wrapper) const |
167 { | 167 { |
168 if (!visitDOMWrapperFunction) | 168 if (!visitDOMWrapperFunction) |
169 setObjectGroup(isolate, scriptWrappable, wrapper); | 169 setObjectGroup(isolate, scriptWrappable, wrapper); |
170 else | 170 else |
171 visitDOMWrapperFunction(isolate, scriptWrappable, wrapper); | 171 visitDOMWrapperFunction(isolate, scriptWrappable, wrapper); |
172 } | 172 } |
173 | 173 |
174 // This field must be the first member of the struct WrapperTypeInfo. This i
s also checked by a static_assert() below. | 174 // This field must be the first member of the struct WrapperTypeInfo. This i
s also checked by a static_assert() below. |
(...skipping 19 matching lines...) Expand all Loading... |
194 static_assert(offsetof(struct WrapperTypeInfo, ginEmbedder) == offsetof(struct g
in::WrapperInfo, embedder), "offset of WrapperTypeInfo.ginEmbedder must be the s
ame as gin::WrapperInfo.embedder"); | 194 static_assert(offsetof(struct WrapperTypeInfo, ginEmbedder) == offsetof(struct g
in::WrapperInfo, embedder), "offset of WrapperTypeInfo.ginEmbedder must be the s
ame as gin::WrapperInfo.embedder"); |
195 | 195 |
196 template <typename T, int offset> | 196 template <typename T, int offset> |
197 inline T* getInternalField(const v8::PersistentBase<v8::Object>& persistent) | 197 inline T* getInternalField(const v8::PersistentBase<v8::Object>& persistent) |
198 { | 198 { |
199 ASSERT(offset < v8::Object::InternalFieldCount(persistent)); | 199 ASSERT(offset < v8::Object::InternalFieldCount(persistent)); |
200 return static_cast<T*>(v8::Object::GetAlignedPointerFromInternalField(persis
tent, offset)); | 200 return static_cast<T*>(v8::Object::GetAlignedPointerFromInternalField(persis
tent, offset)); |
201 } | 201 } |
202 | 202 |
203 template<typename T, int offset> | 203 template<typename T, int offset> |
204 inline T* getInternalField(v8::Handle<v8::Object> wrapper) | 204 inline T* getInternalField(v8::Local<v8::Object> wrapper) |
205 { | 205 { |
206 ASSERT(offset < wrapper->InternalFieldCount()); | 206 ASSERT(offset < wrapper->InternalFieldCount()); |
207 return static_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offset)); | 207 return static_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offset)); |
208 } | 208 } |
209 | 209 |
210 inline ScriptWrappable* toScriptWrappable(const v8::Persistent<v8::Object>& wrap
per) | 210 inline ScriptWrappable* toScriptWrappable(const v8::Persistent<v8::Object>& wrap
per) |
211 { | 211 { |
212 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | 212 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); |
213 } | 213 } |
214 | 214 |
215 inline ScriptWrappable* toScriptWrappable(const v8::Global<v8::Object>& wrapper) | 215 inline ScriptWrappable* toScriptWrappable(const v8::Global<v8::Object>& wrapper) |
216 { | 216 { |
217 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | 217 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); |
218 } | 218 } |
219 | 219 |
220 inline ScriptWrappable* toScriptWrappable(v8::Handle<v8::Object> wrapper) | 220 inline ScriptWrappable* toScriptWrappable(v8::Local<v8::Object> wrapper) |
221 { | 221 { |
222 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | 222 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); |
223 } | 223 } |
224 | 224 |
225 inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::Persistent<v8::Object>
& wrapper) | 225 inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::Persistent<v8::Object>
& wrapper) |
226 { | 226 { |
227 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); | 227 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); |
228 } | 228 } |
229 | 229 |
230 inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::Global<v8::Object>& wr
apper) | 230 inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::Global<v8::Object>& wr
apper) |
231 { | 231 { |
232 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); | 232 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); |
233 } | 233 } |
234 | 234 |
235 inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Handle<v8::Object> wrapper) | 235 inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Local<v8::Object> wrapper) |
236 { | 236 { |
237 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); | 237 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); |
238 } | 238 } |
239 | 239 |
240 inline void releaseObject(v8::Handle<v8::Object> wrapper) | 240 inline void releaseObject(v8::Local<v8::Object> wrapper) |
241 { | 241 { |
242 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappable(wrapper)); | 242 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappable(wrapper)); |
243 } | 243 } |
244 | 244 |
245 inline void releaseObject(v8::Global<v8::Object>& wrapper) | 245 inline void releaseObject(v8::Global<v8::Object>& wrapper) |
246 { | 246 { |
247 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappable(wrapper)); | 247 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappable(wrapper)); |
248 } | 248 } |
249 | 249 |
250 } // namespace blink | 250 } // namespace blink |
251 | 251 |
252 #endif // WrapperTypeInfo_h | 252 #endif // WrapperTypeInfo_h |
OLD | NEW |