| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 v8::FunctionCallback getterForMainWorld; | 65 v8::FunctionCallback getterForMainWorld; |
| 66 v8::FunctionCallback setterForMainWorld; | 66 v8::FunctionCallback setterForMainWorld; |
| 67 const WrapperTypeInfo* data; | 67 const WrapperTypeInfo* data; |
| 68 v8::AccessControl settings; | 68 v8::AccessControl settings; |
| 69 v8::PropertyAttribute attribute; | 69 v8::PropertyAttribute attribute; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 static void installAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8:
:ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount, v8::Isol
ate*, WrapperWorldType currentWorldType); | 72 static void installAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8:
:ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount, v8::Isol
ate*, WrapperWorldType currentWorldType); |
| 73 | 73 |
| 74 template<class ObjectOrTemplate> | 74 template<class ObjectOrTemplate> |
| 75 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate*) | 75 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate* isolate) |
| 76 { | 76 { |
| 77 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewSymbol(attribute.name), | 77 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewSymbol(attribute.name), |
| 78 attribute.ge
tter, | 78 attribute.ge
tter, |
| 79 attribute.se
tter, | 79 attribute.se
tter, |
| 80 v8::External
::New(const_cast<WrapperTypeInfo*>(attribute.data)), | 80 v8::External
::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)), |
| 81 attribute.se
ttings, | 81 attribute.se
ttings, |
| 82 attribute.at
tribute); | 82 attribute.at
tribute); |
| 83 } | 83 } |
| 84 | 84 |
| 85 template<class ObjectOrTemplate> | 85 template<class ObjectOrTemplate> |
| 86 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate*, WrapperWorldType currentWorldType) | 86 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 87 { | 87 { |
| 88 v8::AccessorGetterCallback getter = attribute.getter; | 88 v8::AccessorGetterCallback getter = attribute.getter; |
| 89 v8::AccessorSetterCallback setter = attribute.setter; | 89 v8::AccessorSetterCallback setter = attribute.setter; |
| 90 if (currentWorldType == MainWorld) { | 90 if (currentWorldType == MainWorld) { |
| 91 if (attribute.getterForMainWorld) | 91 if (attribute.getterForMainWorld) |
| 92 getter = attribute.getterForMainWorld; | 92 getter = attribute.getterForMainWorld; |
| 93 if (attribute.setterForMainWorld) | 93 if (attribute.setterForMainWorld) |
| 94 setter = attribute.setterForMainWorld; | 94 setter = attribute.setterForMainWorld; |
| 95 } | 95 } |
| 96 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewSymbol(attribute.name), | 96 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewSymbol(attribute.name), |
| 97 getter, | 97 getter, |
| 98 setter, | 98 setter, |
| 99 v8::External::New(const_cast<WrapperTypeInfo*>(attribute.data)), | 99 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.da
ta)), |
| 100 attribute.settings, | 100 attribute.settings, |
| 101 attribute.attribute); | 101 attribute.attribute); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // ConstantConfiguration translates into calls to Set() for setting up an | 104 // ConstantConfiguration translates into calls to Set() for setting up an |
| 105 // object's constants. It sets the constant on both the FunctionTemplate and | 105 // object's constants. It sets the constant on both the FunctionTemplate and |
| 106 // the ObjectTemplate. PropertyAttributes is always ReadOnly. | 106 // the ObjectTemplate. PropertyAttributes is always ReadOnly. |
| 107 struct ConstantConfiguration { | 107 struct ConstantConfiguration { |
| 108 const char* const name; | 108 const char* const name; |
| 109 int value; | 109 int value; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 127 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct
ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent
Class, size_t fieldCount, | 127 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct
ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent
Class, size_t fieldCount, |
| 128 const AttributeConfiguration*, size_t attributeCount, | 128 const AttributeConfiguration*, size_t attributeCount, |
| 129 const AccessorConfiguration*, size_t accessorCount, | 129 const AccessorConfiguration*, size_t accessorCount, |
| 130 const MethodConfiguration*, size_t callbackCount, | 130 const MethodConfiguration*, size_t callbackCount, |
| 131 v8::Isolate*, WrapperWorldType); | 131 v8::Isolate*, WrapperWorldType); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace WebCore | 134 } // namespace WebCore |
| 135 | 135 |
| 136 #endif // V8DOMConfiguration_h | 136 #endif // V8DOMConfiguration_h |
| OLD | NEW |