Chromium Code Reviews| 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 | |
|
vivekg
2015/10/15 11:23:22
nit: Shall we put a FIXME here to remove the code
| |
| 252 // as ScriptWrappable. | |
| 253 ASSERT(toWrapperTypeInfo(wrapper) != npObjectTypeInfo()); | |
| 254 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | |
| 255 } | |
| 256 | |
| 257 inline ScriptWrappable* toScriptWrappable(v8::Local<v8::Object> wrapper) | |
| 258 { | |
| 259 // NPObject is not ScriptWrappable. We must not retrieve the pointer | |
| 260 // as ScriptWrappable. | |
| 261 ASSERT(toWrapperTypeInfo(wrapper) != npObjectTypeInfo()); | |
| 262 return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper); | |
| 263 } | |
| 264 | |
| 257 } // namespace blink | 265 } // namespace blink |
| 258 | 266 |
| 259 #endif // WrapperTypeInfo_h | 267 #endif // WrapperTypeInfo_h |
| OLD | NEW |