| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 STATIC_ONLY(V8DOMConfiguration); | 42 STATIC_ONLY(V8DOMConfiguration); |
| 43 | 43 |
| 44 public: | 44 public: |
| 45 // The following Configuration structs and install methods are used for | 45 // The following Configuration structs and install methods are used for |
| 46 // setting multiple properties on ObjectTemplate / FunctionTemplate, used | 46 // setting multiple properties on ObjectTemplate / FunctionTemplate, used |
| 47 // from the generated bindings initialization (ConfigureXXXTemplate). | 47 // from the generated bindings initialization (ConfigureXXXTemplate). |
| 48 // This greatly reduces the binary size by moving from code driven setup to | 48 // This greatly reduces the binary size by moving from code driven setup to |
| 49 // data table driven setup. | 49 // data table driven setup. |
| 50 | 50 |
| 51 // Bitflags to show where the member will be defined. | 51 // Bitflags to show where the member will be defined. |
| 52 enum PropertyLocationConfiguration { | 52 enum PropertyLocationConfiguration : unsigned { |
| 53 OnInstance = 1 << 0, | 53 OnInstance = 1 << 0, |
| 54 OnPrototype = 1 << 1, | 54 OnPrototype = 1 << 1, |
| 55 OnInterface = 1 << 2, | 55 OnInterface = 1 << 2, |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 enum HolderCheckConfiguration { | 58 // TODO(dcheng): Make these enum classes. |
| 59 enum HolderCheckConfiguration : unsigned { |
| 59 CheckHolder, | 60 CheckHolder, |
| 60 DoNotCheckHolder, | 61 DoNotCheckHolder, |
| 61 }; | 62 }; |
| 62 | 63 |
| 64 enum AccessCheckConfiguration : unsigned { |
| 65 CheckAccess, |
| 66 DoNotCheckAccess, |
| 67 }; |
| 68 |
| 63 typedef v8::Local<v8::Private> (*CachedAccessorCallback)(v8::Isolate*); | 69 typedef v8::Local<v8::Private> (*CachedAccessorCallback)(v8::Isolate*); |
| 64 | 70 |
| 65 // AttributeConfiguration translates into calls to SetNativeDataProperty() on | 71 // AttributeConfiguration translates into calls to SetNativeDataProperty() on |
| 66 // either the instance or the prototype ObjectTemplate, based on | 72 // either the instance or the prototype ObjectTemplate, based on |
| 67 // |propertyLocationConfiguration|. | 73 // |propertyLocationConfiguration|. |
| 68 struct AttributeConfiguration { | 74 struct AttributeConfiguration { |
| 69 AttributeConfiguration& operator=(const AttributeConfiguration&) = delete; | 75 AttributeConfiguration& operator=(const AttributeConfiguration&) = delete; |
| 70 DISALLOW_NEW(); | 76 DISALLOW_NEW(); |
| 71 const char* const name; | 77 const char* const name; |
| 72 v8::AccessorNameGetterCallback getter; | 78 v8::AccessorNameGetterCallback getter; |
| 73 v8::AccessorNameSetterCallback setter; | 79 v8::AccessorNameSetterCallback setter; |
| 74 v8::AccessorNameGetterCallback getterForMainWorld; | 80 v8::AccessorNameGetterCallback getterForMainWorld; |
| 75 v8::AccessorNameSetterCallback setterForMainWorld; | 81 v8::AccessorNameSetterCallback setterForMainWorld; |
| 76 // TODO(vogelheim): This has to be removed too since it's only used in | 82 // TODO(vogelheim): This has to be removed too since it's only used in |
| 77 // accessors. | 83 // accessors. |
| 78 // The accessor's 'result' is stored in a private property. | 84 // The accessor's 'result' is stored in a private property. |
| 79 CachedAccessorCallback cachedAccessorCallback; | 85 CachedAccessorCallback cachedAccessorCallback; |
| 80 const WrapperTypeInfo* data; | 86 const WrapperTypeInfo* data; |
| 81 unsigned attribute : 8; // v8::PropertyAttribute | 87 // v8::PropertyAttribute |
| 82 unsigned | 88 unsigned attribute : 8; |
| 83 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 89 // PropertyLocationConfiguration |
| 84 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 90 unsigned propertyLocationConfiguration : 3; |
| 91 // HolderCheckConfiguration |
| 92 unsigned holderCheckConfiguration : 1; |
| 85 }; | 93 }; |
| 86 | 94 |
| 87 static void installAttributes(v8::Isolate*, | 95 static void installAttributes(v8::Isolate*, |
| 88 const DOMWrapperWorld&, | 96 const DOMWrapperWorld&, |
| 89 v8::Local<v8::ObjectTemplate> instanceTemplate, | 97 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 90 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 98 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 91 const AttributeConfiguration*, | 99 const AttributeConfiguration*, |
| 92 size_t attributeCount); | 100 size_t attributeCount); |
| 93 | 101 |
| 94 static void installAttribute(v8::Isolate*, | 102 static void installAttribute(v8::Isolate*, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 123 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete; | 131 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete; |
| 124 DISALLOW_NEW(); | 132 DISALLOW_NEW(); |
| 125 const char* const name; | 133 const char* const name; |
| 126 v8::FunctionCallback getter; | 134 v8::FunctionCallback getter; |
| 127 v8::FunctionCallback setter; | 135 v8::FunctionCallback setter; |
| 128 v8::FunctionCallback getterForMainWorld; | 136 v8::FunctionCallback getterForMainWorld; |
| 129 v8::FunctionCallback setterForMainWorld; | 137 v8::FunctionCallback setterForMainWorld; |
| 130 // The accessor's 'result' is stored in a private property. | 138 // The accessor's 'result' is stored in a private property. |
| 131 CachedAccessorCallback cachedAccessorCallback; | 139 CachedAccessorCallback cachedAccessorCallback; |
| 132 const WrapperTypeInfo* data; | 140 const WrapperTypeInfo* data; |
| 133 unsigned attribute : 8; // v8::PropertyAttribute | 141 // v8::PropertyAttribute |
| 134 unsigned | 142 unsigned attribute : 8; |
| 135 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 143 // PropertyLocationConfiguration |
| 136 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 144 unsigned propertyLocationConfiguration : 3; |
| 145 // HolderCheckConfiguration |
| 146 unsigned holderCheckConfiguration : 1; |
| 137 }; | 147 }; |
| 138 | 148 |
| 139 static void installAccessors( | 149 static void installAccessors( |
| 140 v8::Isolate*, | 150 v8::Isolate*, |
| 141 const DOMWrapperWorld&, | 151 const DOMWrapperWorld&, |
| 142 v8::Local<v8::ObjectTemplate> instanceTemplate, | 152 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 143 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 153 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 144 v8::Local<v8::FunctionTemplate> interfaceTemplate, | 154 v8::Local<v8::FunctionTemplate> interfaceTemplate, |
| 145 v8::Local<v8::Signature>, | 155 v8::Local<v8::Signature>, |
| 146 const AccessorConfiguration*, | 156 const AccessorConfiguration*, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 236 } |
| 227 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) const { | 237 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) const { |
| 228 return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld | 238 return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld |
| 229 : callback; | 239 : callback; |
| 230 } | 240 } |
| 231 | 241 |
| 232 const char* const name; | 242 const char* const name; |
| 233 v8::FunctionCallback callback; | 243 v8::FunctionCallback callback; |
| 234 v8::FunctionCallback callbackForMainWorld; | 244 v8::FunctionCallback callbackForMainWorld; |
| 235 int length; | 245 int length; |
| 236 unsigned attribute : 8; // v8::PropertyAttribute | 246 // v8::PropertyAttribute |
| 237 unsigned | 247 unsigned attribute : 8; |
| 238 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 248 // PropertyLocationConfiguration |
| 239 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 249 unsigned propertyLocationConfiguration : 3; |
| 250 // HolderCheckConfiguration |
| 251 unsigned holderCheckConfiguration : 1; |
| 252 // AccessCheckConfiguration |
| 253 unsigned accessCheckConfiguration : 1; |
| 240 }; | 254 }; |
| 241 | 255 |
| 242 struct SymbolKeyedMethodConfiguration { | 256 struct SymbolKeyedMethodConfiguration { |
| 243 SymbolKeyedMethodConfiguration& operator=( | 257 SymbolKeyedMethodConfiguration& operator=( |
| 244 const SymbolKeyedMethodConfiguration&) = delete; | 258 const SymbolKeyedMethodConfiguration&) = delete; |
| 245 DISALLOW_NEW(); | 259 DISALLOW_NEW(); |
| 246 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { | 260 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { |
| 247 return getSymbol(isolate); | 261 return getSymbol(isolate); |
| 248 } | 262 } |
| 249 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const { | 263 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const { |
| 250 return callback; | 264 return callback; |
| 251 } | 265 } |
| 252 | 266 |
| 253 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); | 267 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); |
| 254 v8::FunctionCallback callback; | 268 v8::FunctionCallback callback; |
| 255 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. | 269 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. |
| 256 int length; | 270 int length; |
| 257 unsigned attribute : 8; // v8::PropertyAttribute | 271 // v8::PropertyAttribute |
| 258 unsigned | 272 unsigned attribute : 8; |
| 259 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 273 // PropertyLocationConfiguration |
| 260 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 274 unsigned propertyLocationConfiguration : 3; |
| 275 // HolderCheckConfiguration |
| 276 unsigned holderCheckConfiguration : 1; |
| 277 // AccessCheckConfiguration |
| 278 unsigned accessCheckConfiguration : 1; |
| 261 }; | 279 }; |
| 262 | 280 |
| 263 static void installMethods(v8::Isolate*, | 281 static void installMethods(v8::Isolate*, |
| 264 const DOMWrapperWorld&, | 282 const DOMWrapperWorld&, |
| 265 v8::Local<v8::ObjectTemplate> instanceTemplate, | 283 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 266 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 284 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 267 v8::Local<v8::FunctionTemplate> interfaceTemplate, | 285 v8::Local<v8::FunctionTemplate> interfaceTemplate, |
| 268 v8::Local<v8::Signature>, | 286 v8::Local<v8::Signature>, |
| 269 const MethodConfiguration*, | 287 const MethodConfiguration*, |
| 270 size_t methodCount); | 288 size_t methodCount); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // Sets the class string of platform objects, interface prototype objects, | 325 // Sets the class string of platform objects, interface prototype objects, |
| 308 // etc. See also http://heycam.github.io/webidl/#dfn-class-string | 326 // etc. See also http://heycam.github.io/webidl/#dfn-class-string |
| 309 static void setClassString(v8::Isolate*, | 327 static void setClassString(v8::Isolate*, |
| 310 v8::Local<v8::ObjectTemplate>, | 328 v8::Local<v8::ObjectTemplate>, |
| 311 const char* classString); | 329 const char* classString); |
| 312 }; | 330 }; |
| 313 | 331 |
| 314 } // namespace blink | 332 } // namespace blink |
| 315 | 333 |
| 316 #endif // V8DOMConfiguration_h | 334 #endif // V8DOMConfiguration_h |
| OLD | NEW |