| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return reinterpret_cast<T*>(v8::Object::GetAlignedPointerFromInternalField(p
ersistent, offset)); | 227 return reinterpret_cast<T*>(v8::Object::GetAlignedPointerFromInternalField(p
ersistent, offset)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 template<typename T, int offset> | 230 template<typename T, int offset> |
| 231 inline T* getInternalField(v8::Local<v8::Object> wrapper) | 231 inline T* getInternalField(v8::Local<v8::Object> wrapper) |
| 232 { | 232 { |
| 233 ASSERT(offset < wrapper->InternalFieldCount()); | 233 ASSERT(offset < wrapper->InternalFieldCount()); |
| 234 return reinterpret_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offs
et)); | 234 return reinterpret_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offs
et)); |
| 235 } | 235 } |
| 236 | 236 |
| 237 inline ScriptWrappable* toScriptWrappable(const v8::PersistentBase<v8::Object>&
wrapper) | |
| 238 { | |
| 239 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | |
| 240 } | |
| 241 | |
| 242 inline ScriptWrappable* toScriptWrappable(v8::Local<v8::Object> wrapper) | |
| 243 { | |
| 244 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | |
| 245 } | |
| 246 | |
| 247 inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::PersistentBase<v8::Obj
ect>& wrapper) | 237 inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::PersistentBase<v8::Obj
ect>& wrapper) |
| 248 { | 238 { |
| 249 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); | 239 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); |
| 250 } | 240 } |
| 251 | 241 |
| 252 inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Local<v8::Object> wrapper) | 242 inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Local<v8::Object> wrapper) |
| 253 { | 243 { |
| 254 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); | 244 return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper); |
| 255 } | 245 } |
| 256 | 246 |
| 247 const WrapperTypeInfo* npObjectTypeInfo(); |
| 248 |
| 249 inline ScriptWrappable* toScriptWrappable(const v8::PersistentBase<v8::Object>&
wrapper) |
| 250 { |
| 251 // NPObject is not ScriptWrappable. We must not retrieve the pointer |
| 252 // as ScriptWrappable. |
| 253 // TODO: Remove this ASSERT when we deprecate NPAPI. |
| 254 ASSERT(toWrapperTypeInfo(wrapper) != npObjectTypeInfo()); |
| 255 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); |
| 256 } |
| 257 |
| 258 inline ScriptWrappable* toScriptWrappable(v8::Local<v8::Object> wrapper) |
| 259 { |
| 260 // NPObject is not ScriptWrappable. We must not retrieve the pointer |
| 261 // as ScriptWrappable. |
| 262 // TODO: Remove this ASSERT when we deprecate NPAPI. |
| 263 ASSERT(toWrapperTypeInfo(wrapper) != npObjectTypeInfo()); |
| 264 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); |
| 265 } |
| 266 |
| 257 } // namespace blink | 267 } // namespace blink |
| 258 | 268 |
| 259 #endif // WrapperTypeInfo_h | 269 #endif // WrapperTypeInfo_h |
| OLD | NEW |