Chromium Code Reviews| Index: Source/bindings/core/v8/ScriptWrappable.h |
| diff --git a/Source/bindings/core/v8/ScriptWrappable.h b/Source/bindings/core/v8/ScriptWrappable.h |
| index b0e176c1f05a95e8a3b42cbfc1207c60a1992462..e4c24de6bfbd7f5599a0ff217ddd8348e17e8e70 100644 |
| --- a/Source/bindings/core/v8/ScriptWrappable.h |
| +++ b/Source/bindings/core/v8/ScriptWrappable.h |
| @@ -46,6 +46,25 @@ template <class C> inline void initializeScriptWrappableHelper(C* object) |
| namespace blink { |
| /** |
| + * The base class of all wrappable objects. |
| + * |
| + * This class provides the internal pointer to be stored in the wrapper objects, |
| + * and its conversions from / to the DOM instances. |
| + * |
| + * Note that this class must not have vtbl (any virtual function) or any member |
| + * variable which increase the size of instances. Some of the classes sensitive |
| + * to the size inherit from this class. So this class must be zero size. |
| + */ |
| +class ScriptWrappableBase { |
| +public: |
| + template <class T> static T* fromInternalPointer(void* internalPointer) |
| + { |
| + return static_cast<T*>(static_cast<ScriptWrappableBase*>(internalPointer)); |
|
kouhei (in TOK)
2014/07/28 13:40:05
As previously discussed, woudl it be possible to a
Yuki
2014/07/28 15:26:03
Done.
|
| + } |
| + void* toInternalPointer() { return this; } |
| +}; |
| + |
| +/** |
| * ScriptWrappable wraps a V8 object and its WrapperTypeInfo. |
| * |
| * ScriptWrappable acts much like a v8::Persistent<> in that it keeps a |
| @@ -74,7 +93,7 @@ namespace blink { |
| * - disposeWrapper (via setWeakCallback, triggered by V8 garbage collecter): |
| * remove v8::Persistent and install a TypeInfo of the previous value. |
| */ |
| -class ScriptWrappable { |
| +class ScriptWrappable : public ScriptWrappableBase { |
| public: |
| ScriptWrappable() : m_wrapperOrTypeInfo(0) { } |