OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 public: | 45 public: |
46 static v8::Local<v8::Object> createWrapper(v8::Handle<v8::Object> creati
onContext, const WrapperTypeInfo*, void*, v8::Isolate*); | 46 static v8::Local<v8::Object> createWrapper(v8::Handle<v8::Object> creati
onContext, const WrapperTypeInfo*, void*, v8::Isolate*); |
47 | 47 |
48 template<typename V8T, typename T> | 48 template<typename V8T, typename T> |
49 static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefP
tr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConf
iguration::Lifetime); | 49 static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefP
tr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConf
iguration::Lifetime); |
50 template<typename V8T, typename T> | 50 template<typename V8T, typename T> |
51 static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T
> object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isola
te* isolate, WrapperConfiguration::Lifetime lifetime) { return associateObjectWi
thWrapper<V8T, T>(object.get(), type, wrapper, isolate, lifetime); } | 51 static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T
> object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isola
te* isolate, WrapperConfiguration::Lifetime lifetime) { return associateObjectWi
thWrapper<V8T, T>(object.get(), type, wrapper, isolate, lifetime); } |
52 template<typename V8T, typename T> | 52 template<typename V8T, typename T> |
53 static inline v8::Handle<v8::Object> associateObjectWithWrapper(T*, cons
t WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::
Lifetime); | 53 static inline v8::Handle<v8::Object> associateObjectWithWrapper(T*, cons
t WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::
Lifetime); |
54 static inline void setNativeInfo(v8::Handle<v8::Object>, const WrapperTy
peInfo*, void*); | 54 static inline void setNativeInfo(v8::Handle<v8::Object>, const WrapperTy
peInfo*, void*); |
| 55 static inline void setNativeInfoForHiddenWrapper(v8::Handle<v8::Object>,
const WrapperTypeInfo*, void*); |
55 static inline void setNativeInfoWithPersistentHandle(v8::Handle<v8::Obje
ct>, const WrapperTypeInfo*, void*, PersistentNode*); | 56 static inline void setNativeInfoWithPersistentHandle(v8::Handle<v8::Obje
ct>, const WrapperTypeInfo*, void*, PersistentNode*); |
56 static inline void clearNativeInfo(v8::Handle<v8::Object>, const Wrapper
TypeInfo*); | 57 static inline void clearNativeInfo(v8::Handle<v8::Object>, const Wrapper
TypeInfo*); |
57 | 58 |
58 static bool isDOMWrapper(v8::Handle<v8::Value>); | 59 static bool isDOMWrapper(v8::Handle<v8::Value>); |
59 }; | 60 }; |
60 | 61 |
61 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, cons
t WrapperTypeInfo* type, void* object) | 62 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, cons
t WrapperTypeInfo* type, void* object) |
62 { | 63 { |
63 ASSERT(wrapper->InternalFieldCount() >= 2); | 64 ASSERT(wrapper->InternalFieldCount() >= 2); |
64 ASSERT(object); | 65 ASSERT(object); |
65 ASSERT(type); | 66 ASSERT(type); |
66 #if ENABLE(OILPAN) | 67 #if ENABLE(OILPAN) |
67 ASSERT(!type->isGarbageCollected); | 68 ASSERT(!type->isGarbageCollected); |
68 #endif | 69 #endif |
69 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec
t); | 70 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec
t); |
70 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c
ast<WrapperTypeInfo*>(type)); | 71 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c
ast<WrapperTypeInfo*>(type)); |
71 } | 72 } |
72 | 73 |
| 74 inline void V8DOMWrapper::setNativeInfoForHiddenWrapper(v8::Handle<v8::Objec
t> wrapper, const WrapperTypeInfo* type, void* object) |
| 75 { |
| 76 // see V8WindowShell::installDOMWindow() comment for why this version is
needed and safe. |
| 77 ASSERT(wrapper->InternalFieldCount() >= 2); |
| 78 ASSERT(object); |
| 79 ASSERT(type); |
| 80 #if ENABLE(OILPAN) |
| 81 ASSERT(type->isGarbageCollected); |
| 82 #endif |
| 83 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec
t); |
| 84 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c
ast<WrapperTypeInfo*>(type)); |
| 85 // Clear out the last internal field, which is assumed to contain a vali
d persistent pointer value. |
| 86 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, 0); |
| 87 } |
| 88 |
| 89 |
73 inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::O
bject> wrapper, const WrapperTypeInfo* type, void* object, PersistentNode* handl
e) | 90 inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::O
bject> wrapper, const WrapperTypeInfo* type, void* object, PersistentNode* handl
e) |
74 { | 91 { |
75 ASSERT(wrapper->InternalFieldCount() >= 3); | 92 ASSERT(wrapper->InternalFieldCount() >= 3); |
76 ASSERT(object); | 93 ASSERT(object); |
77 ASSERT(type); | 94 ASSERT(type); |
78 ASSERT(type->isGarbageCollected); | 95 ASSERT(type->isGarbageCollected); |
79 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec
t); | 96 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec
t); |
80 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c
ast<WrapperTypeInfo*>(type)); | 97 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c
ast<WrapperTypeInfo*>(type)); |
81 // Persistent handle is stored in the last internal field. | 98 // Persistent handle is stored in the last internal field. |
82 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, handle); | 99 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, handle); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 v8::Handle<v8::Context> context() const { return m_context; } | 160 v8::Handle<v8::Context> context() const { return m_context; } |
144 | 161 |
145 private: | 162 private: |
146 bool m_didEnterContext; | 163 bool m_didEnterContext; |
147 v8::Handle<v8::Context> m_context; | 164 v8::Handle<v8::Context> m_context; |
148 }; | 165 }; |
149 | 166 |
150 } | 167 } |
151 | 168 |
152 #endif // V8DOMWrapper_h | 169 #endif // V8DOMWrapper_h |
OLD | NEW |