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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 const WrapperTypeInfo* parent_class; | 180 const WrapperTypeInfo* parent_class; |
181 const unsigned wrapper_type_prototype : 1; // WrapperTypePrototype | 181 const unsigned wrapper_type_prototype : 1; // WrapperTypePrototype |
182 const unsigned wrapper_class_id : 2; // WrapperClassId | 182 const unsigned wrapper_class_id : 2; // WrapperClassId |
183 const unsigned | 183 const unsigned |
184 active_script_wrappable_inheritance : 1; // ActiveScriptWrappableInherita
nce | 184 active_script_wrappable_inheritance : 1; // ActiveScriptWrappableInherita
nce |
185 const unsigned lifetime : 1; // Lifetime | 185 const unsigned lifetime : 1; // Lifetime |
186 }; | 186 }; |
187 | 187 |
188 template <typename T, int offset> | 188 template <typename T, int offset> |
189 inline T* GetInternalField(const v8::PersistentBase<v8::Object>& persistent) { | 189 inline T* GetInternalField(const v8::PersistentBase<v8::Object>& persistent) { |
190 ASSERT(offset < v8::Object::InternalFieldCount(persistent)); | 190 DCHECK_LT(offset, v8::Object::InternalFieldCount(persistent)); |
191 return reinterpret_cast<T*>( | 191 return reinterpret_cast<T*>( |
192 v8::Object::GetAlignedPointerFromInternalField(persistent, offset)); | 192 v8::Object::GetAlignedPointerFromInternalField(persistent, offset)); |
193 } | 193 } |
194 | 194 |
195 template <typename T, int offset> | 195 template <typename T, int offset> |
196 inline T* GetInternalField(v8::Local<v8::Object> wrapper) { | 196 inline T* GetInternalField(v8::Local<v8::Object> wrapper) { |
197 ASSERT(offset < wrapper->InternalFieldCount()); | 197 DCHECK_LT(offset, wrapper->InternalFieldCount()); |
198 return reinterpret_cast<T*>( | 198 return reinterpret_cast<T*>( |
199 wrapper->GetAlignedPointerFromInternalField(offset)); | 199 wrapper->GetAlignedPointerFromInternalField(offset)); |
200 } | 200 } |
201 | 201 |
202 inline ScriptWrappable* ToScriptWrappable( | 202 inline ScriptWrappable* ToScriptWrappable( |
203 const v8::PersistentBase<v8::Object>& wrapper) { | 203 const v8::PersistentBase<v8::Object>& wrapper) { |
204 return GetInternalField<ScriptWrappable, kV8DOMWrapperObjectIndex>(wrapper); | 204 return GetInternalField<ScriptWrappable, kV8DOMWrapperObjectIndex>(wrapper); |
205 } | 205 } |
206 | 206 |
207 inline ScriptWrappable* ToScriptWrappable(v8::Local<v8::Object> wrapper) { | 207 inline ScriptWrappable* ToScriptWrappable(v8::Local<v8::Object> wrapper) { |
208 return GetInternalField<ScriptWrappable, kV8DOMWrapperObjectIndex>(wrapper); | 208 return GetInternalField<ScriptWrappable, kV8DOMWrapperObjectIndex>(wrapper); |
209 } | 209 } |
210 | 210 |
211 inline const WrapperTypeInfo* ToWrapperTypeInfo( | 211 inline const WrapperTypeInfo* ToWrapperTypeInfo( |
212 const v8::PersistentBase<v8::Object>& wrapper) { | 212 const v8::PersistentBase<v8::Object>& wrapper) { |
213 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper); | 213 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper); |
214 } | 214 } |
215 | 215 |
216 inline const WrapperTypeInfo* ToWrapperTypeInfo(v8::Local<v8::Object> wrapper) { | 216 inline const WrapperTypeInfo* ToWrapperTypeInfo(v8::Local<v8::Object> wrapper) { |
217 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper); | 217 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper); |
218 } | 218 } |
219 | 219 |
220 } // namespace blink | 220 } // namespace blink |
221 | 221 |
222 #endif // WrapperTypeInfo_h | 222 #endif // WrapperTypeInfo_h |
OLD | NEW |