Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: Source/bindings/core/v8/ScriptWrappable.h

Issue 422873002: bindings: Introduces ScriptWrappableBase to provide the internal pointer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptWrappable.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) { }
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptWrappable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698