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

Side by Side Diff: sky/engine/bindings/core/v8/ScriptWrappable.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
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
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
51 class ScriptWrappableBase { 71 class ScriptWrappableBase {
52 public: 72 public:
53 template<typename T> 73 template<typename T>
54 T* toImpl() 74 T* toImpl()
55 { 75 {
56 // Check if T* is castable to ScriptWrappableBase*, which means T 76 // Check if T* is castable to ScriptWrappableBase*, which means T
57 // doesn't have two or more ScriptWrappableBase as superclasses. 77 // doesn't have two or more ScriptWrappableBase as superclasses.
58 // If T has two ScriptWrappableBase as superclasses, conversions 78 // If T has two ScriptWrappableBase as superclasses, conversions
59 // from T* to ScriptWrappableBase* are ambiguous. 79 // from T* to ScriptWrappableBase* are ambiguous.
60 ASSERT(static_cast<ScriptWrappableBase*>(static_cast<T*>(this))); 80 ASSERT(static_cast<ScriptWrappableBase*>(static_cast<T*>(this)));
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 virtual const WrapperTypeInfo* wrapperTypeInfo() const override \ 266 virtual const WrapperTypeInfo* wrapperTypeInfo() const override \
247 { \ 267 { \
248 return &s_wrapperTypeInfo; \ 268 return &s_wrapperTypeInfo; \
249 } \ 269 } \
250 private: \ 270 private: \
251 static const WrapperTypeInfo& s_wrapperTypeInfo 271 static const WrapperTypeInfo& s_wrapperTypeInfo
252 272
253 } // namespace blink 273 } // namespace blink
254 274
255 #endif // ScriptWrappable_h 275 #endif // ScriptWrappable_h
OLDNEW
« no previous file with comments | « no previous file | sky/engine/bindings/core/v8/ScriptWrappable.cpp » ('j') | sky/engine/wtf/Compiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698