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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 v8::AccessorGetterCallback getter; | 49 v8::AccessorGetterCallback getter; |
50 v8::AccessorSetterCallback setter; | 50 v8::AccessorSetterCallback setter; |
51 v8::AccessorGetterCallback getterForMainWorld; | 51 v8::AccessorGetterCallback getterForMainWorld; |
52 v8::AccessorSetterCallback setterForMainWorld; | 52 v8::AccessorSetterCallback setterForMainWorld; |
53 const WrapperTypeInfo* data; | 53 const WrapperTypeInfo* data; |
54 v8::AccessControl settings; | 54 v8::AccessControl settings; |
55 v8::PropertyAttribute attribute; | 55 v8::PropertyAttribute attribute; |
56 bool onPrototype; | 56 bool onPrototype; |
57 }; | 57 }; |
58 | 58 |
| 59 // AccessorConfiguration translates into calls to SetAccessorProperty() |
| 60 // on prototype ObjectTemplate. |
| 61 struct AccessorConfiguration { |
| 62 const char* const name; |
| 63 v8::FunctionCallback getter; |
| 64 v8::FunctionCallback setter; |
| 65 v8::FunctionCallback getterForMainWorld; |
| 66 v8::FunctionCallback setterForMainWorld; |
| 67 WrapperTypeInfo* data; |
| 68 v8::AccessControl settings; |
| 69 v8::PropertyAttribute attribute; |
| 70 }; |
| 71 |
59 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); |
60 | 73 |
61 template<class ObjectOrTemplate> | 74 template<class ObjectOrTemplate> |
62 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instance, v
8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& attribute,
v8::Isolate*) | 75 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instance, v
8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& attribute,
v8::Isolate*) |
63 { | 76 { |
64 (attribute.onPrototype ? prototype : instance)->SetAccessor(v8::String::
NewSymbol(attribute.name), | 77 (attribute.onPrototype ? prototype : instance)->SetAccessor(v8::String::
NewSymbol(attribute.name), |
65 attribute.ge
tter, | 78 attribute.ge
tter, |
66 attribute.se
tter, | 79 attribute.se
tter, |
67 v8::External
::New(const_cast<WrapperTypeInfo*>(attribute.data)), | 80 v8::External
::New(const_cast<WrapperTypeInfo*>(attribute.data)), |
68 attribute.se
ttings, | 81 attribute.se
ttings, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // ObjectTemplate. | 115 // ObjectTemplate. |
103 struct MethodConfiguration { | 116 struct MethodConfiguration { |
104 const char* const name; | 117 const char* const name; |
105 v8::FunctionCallback callback; | 118 v8::FunctionCallback callback; |
106 v8::FunctionCallback callbackForMainWorld; | 119 v8::FunctionCallback callbackForMainWorld; |
107 int length; | 120 int length; |
108 }; | 121 }; |
109 | 122 |
110 static void installCallbacks(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCo
unt, v8::Isolate*, WrapperWorldType); | 123 static void installCallbacks(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCo
unt, v8::Isolate*, WrapperWorldType); |
111 | 124 |
112 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct
ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent
Class, size_t fieldCount, const AttributeConfiguration*, size_t attributeCount,
const MethodConfiguration*, size_t callbackCount, v8::Isolate*, WrapperWorldType
); | 125 static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*, Wr
apperWorldType); |
| 126 |
| 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, |
| 129 const AccessorConfiguration*, size_t accessorCount, |
| 130 const MethodConfiguration*, size_t callbackCount, |
| 131 v8::Isolate*, WrapperWorldType); |
113 }; | 132 }; |
114 | 133 |
115 } // namespace WebCore | 134 } // namespace WebCore |
116 | 135 |
117 #endif // V8DOMConfiguration_h | 136 #endif // V8DOMConfiguration_h |
OLD | NEW |