| 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 30 matching lines...) Expand all Loading... |
| 41 /** | 41 /** |
| 42 * The base class of all wrappable objects. | 42 * The base class of all wrappable objects. |
| 43 * | 43 * |
| 44 * This class provides the internal pointer to be stored in the wrapper objects, | 44 * This class provides the internal pointer to be stored in the wrapper objects, |
| 45 * and its conversions from / to the DOM instances. | 45 * and its conversions from / to the DOM instances. |
| 46 * | 46 * |
| 47 * Note that this class must not have vtbl (any virtual function) or any member | 47 * Note that this class must not have vtbl (any virtual function) or any member |
| 48 * variable which increase the size of instances. Some of the classes sensitive | 48 * variable which increase the size of instances. Some of the classes sensitive |
| 49 * to the size inherit from this class. So this class must be zero size. | 49 * to the size inherit from this class. So this class must be zero size. |
| 50 */ | 50 */ |
| 51 #if COMPILER(MSVC) | |
| 52 // VC++ 2013 doesn't support EBCO (Empty Base Class Optimization). It causes | |
| 53 // that not always pointers to an empty base class are aligned to 4 byte | |
| 54 // alignment. For example, | |
| 55 // | |
| 56 // class EmptyBase1 {}; | |
| 57 // class EmptyBase2 {}; | |
| 58 // class Derived : public EmptyBase1, public EmptyBase2 {}; | |
| 59 // Derived d; | |
| 60 // // &d == 0x1000 | |
| 61 // // static_cast<EmptyBase1*>(&d) == 0x1000 | |
| 62 // // static_cast<EmptyBase2*>(&d) == 0x1001 // Not 4 byte alignment! | |
| 63 // | |
| 64 // This doesn't happen with other compilers which support EBCO. All the | |
| 65 // addresses in the above example will be 0x1000 with EBCO supported. | |
| 66 // | |
| 67 // Since v8::Object::SetAlignedPointerInInternalField requires the pointers to | |
| 68 // be aligned, we need a hack to specify at least 4 byte alignment to MSVC. | |
| 69 __declspec(align(4)) | |
| 70 #endif | |
| 71 class ScriptWrappableBase { | 51 class ScriptWrappableBase { |
| 72 public: | 52 public: |
| 73 template<typename T> | 53 template<typename T> |
| 74 T* toImpl() | 54 T* toImpl() |
| 75 { | 55 { |
| 76 // Check if T* is castable to ScriptWrappableBase*, which means T | 56 // Check if T* is castable to ScriptWrappableBase*, which means T |
| 77 // doesn't have two or more ScriptWrappableBase as superclasses. | 57 // doesn't have two or more ScriptWrappableBase as superclasses. |
| 78 // If T has two ScriptWrappableBase as superclasses, conversions | 58 // If T has two ScriptWrappableBase as superclasses, conversions |
| 79 // from T* to ScriptWrappableBase* are ambiguous. | 59 // from T* to ScriptWrappableBase* are ambiguous. |
| 80 ASSERT(static_cast<ScriptWrappableBase*>(static_cast<T*>(this))); | 60 ASSERT(static_cast<ScriptWrappableBase*>(static_cast<T*>(this))); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 virtual const WrapperTypeInfo* wrapperTypeInfo() const override \ | 246 virtual const WrapperTypeInfo* wrapperTypeInfo() const override \ |
| 267 { \ | 247 { \ |
| 268 return &s_wrapperTypeInfo; \ | 248 return &s_wrapperTypeInfo; \ |
| 269 } \ | 249 } \ |
| 270 private: \ | 250 private: \ |
| 271 static const WrapperTypeInfo& s_wrapperTypeInfo | 251 static const WrapperTypeInfo& s_wrapperTypeInfo |
| 272 | 252 |
| 273 } // namespace blink | 253 } // namespace blink |
| 274 | 254 |
| 275 #endif // ScriptWrappable_h | 255 #endif // ScriptWrappable_h |
| OLD | NEW |