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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 }; | 59 }; |
60 | 60 |
61 enum HolderCheckConfiguration { | 61 enum HolderCheckConfiguration { |
62 CheckHolder, | 62 CheckHolder, |
63 DoNotCheckHolder, | 63 DoNotCheckHolder, |
64 }; | 64 }; |
65 | 65 |
66 // AttributeConfiguration translates into calls to SetAccessor() on either | 66 // AttributeConfiguration translates into calls to SetAccessor() on either |
67 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy
peConfiguration|. | 67 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy
peConfiguration|. |
68 struct AttributeConfiguration { | 68 struct AttributeConfiguration { |
69 WTF_MAKE_NONCOPYABLE(AttributeConfiguration); | 69 AttributeConfiguration& operator=(const AttributeConfiguration&) = delet
e; |
70 DISALLOW_ALLOCATION(); | 70 DISALLOW_ALLOCATION(); |
71 const char* const name; | 71 const char* const name; |
72 v8::AccessorNameGetterCallback getter; | 72 v8::AccessorNameGetterCallback getter; |
73 v8::AccessorNameSetterCallback setter; | 73 v8::AccessorNameSetterCallback setter; |
74 v8::AccessorNameGetterCallback getterForMainWorld; | 74 v8::AccessorNameGetterCallback getterForMainWorld; |
75 v8::AccessorNameSetterCallback setterForMainWorld; | 75 v8::AccessorNameSetterCallback setterForMainWorld; |
76 const WrapperTypeInfo* data; | 76 const WrapperTypeInfo* data; |
77 v8::AccessControl settings; | 77 v8::AccessControl settings; |
78 v8::PropertyAttribute attribute; | 78 v8::PropertyAttribute attribute; |
79 unsigned exposeConfiguration : 1; // ExposeConfiguration | 79 unsigned exposeConfiguration : 1; // ExposeConfiguration |
80 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura
tion | 80 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura
tion |
81 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 81 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration |
82 }; | 82 }; |
83 | 83 |
84 static void installAttributes(v8::Isolate*, v8::Local<v8::ObjectTemplate> in
stanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Attribute
Configuration*, size_t attributeCount); | 84 static void installAttributes(v8::Isolate*, v8::Local<v8::ObjectTemplate> in
stanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Attribute
Configuration*, size_t attributeCount); |
85 | 85 |
86 static void installAttribute(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins
tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeC
onfiguration&); | 86 static void installAttribute(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins
tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeC
onfiguration&); |
87 | 87 |
88 // AccessorConfiguration translates into calls to SetAccessorProperty() | 88 // AccessorConfiguration translates into calls to SetAccessorProperty() |
89 // on prototype ObjectTemplate. | 89 // on prototype ObjectTemplate. |
90 struct AccessorConfiguration { | 90 struct AccessorConfiguration { |
91 WTF_MAKE_NONCOPYABLE(AccessorConfiguration); | 91 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete; |
92 DISALLOW_ALLOCATION(); | 92 DISALLOW_ALLOCATION(); |
93 const char* const name; | 93 const char* const name; |
94 v8::FunctionCallback getter; | 94 v8::FunctionCallback getter; |
95 v8::FunctionCallback setter; | 95 v8::FunctionCallback setter; |
96 v8::FunctionCallback getterForMainWorld; | 96 v8::FunctionCallback getterForMainWorld; |
97 v8::FunctionCallback setterForMainWorld; | 97 v8::FunctionCallback setterForMainWorld; |
98 const WrapperTypeInfo* data; | 98 const WrapperTypeInfo* data; |
99 v8::AccessControl settings; | 99 v8::AccessControl settings; |
100 v8::PropertyAttribute attribute; | 100 v8::PropertyAttribute attribute; |
101 unsigned exposeConfiguration : 1; // ExposeConfiguration | 101 unsigned exposeConfiguration : 1; // ExposeConfiguration |
(...skipping 14 matching lines...) Expand all Loading... |
116 ConstantTypeUnsignedLong, | 116 ConstantTypeUnsignedLong, |
117 ConstantTypeFloat, | 117 ConstantTypeFloat, |
118 ConstantTypeDouble, | 118 ConstantTypeDouble, |
119 ConstantTypeString | 119 ConstantTypeString |
120 }; | 120 }; |
121 | 121 |
122 // ConstantConfiguration translates into calls to Set() for setting up an | 122 // ConstantConfiguration translates into calls to Set() for setting up an |
123 // object's constants. It sets the constant on both the FunctionTemplate and | 123 // object's constants. It sets the constant on both the FunctionTemplate and |
124 // the ObjectTemplate. PropertyAttributes is always ReadOnly. | 124 // the ObjectTemplate. PropertyAttributes is always ReadOnly. |
125 struct ConstantConfiguration { | 125 struct ConstantConfiguration { |
126 WTF_MAKE_NONCOPYABLE(ConstantConfiguration); | 126 ConstantConfiguration& operator=(const ConstantConfiguration&) = delete; |
127 DISALLOW_ALLOCATION(); | 127 DISALLOW_ALLOCATION(); |
128 const char* const name; | 128 const char* const name; |
129 int ivalue; | 129 int ivalue; |
130 double dvalue; | 130 double dvalue; |
131 const char* const svalue; | 131 const char* const svalue; |
132 ConstantType type; | 132 ConstantType type; |
133 }; | 133 }; |
134 | 134 |
135 // Constant installation | 135 // Constant installation |
136 // | 136 // |
137 // installConstants and installConstant are used for simple constants. They | 137 // installConstants and installConstant are used for simple constants. They |
138 // install constants using v8::Template::Set(), which results in a property | 138 // install constants using v8::Template::Set(), which results in a property |
139 // that is much faster to access from scripts. | 139 // that is much faster to access from scripts. |
140 // installConstantWithGetter is used when some C++ code needs to be executed | 140 // installConstantWithGetter is used when some C++ code needs to be executed |
141 // when the constant is accessed, e.g. to handle deprecation or measuring | 141 // when the constant is accessed, e.g. to handle deprecation or measuring |
142 // usage. The property appears the same to scripts, but is slower to access. | 142 // usage. The property appears the same to scripts, but is slower to access. |
143 static void installConstants(v8::Isolate*, v8::Local<v8::FunctionTemplate> f
unctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Consta
ntConfiguration*, size_t constantCount); | 143 static void installConstants(v8::Isolate*, v8::Local<v8::FunctionTemplate> f
unctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Consta
ntConfiguration*, size_t constantCount); |
144 | 144 |
145 static void installConstant(v8::Isolate*, v8::Local<v8::FunctionTemplate> fu
nctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constan
tConfiguration&); | 145 static void installConstant(v8::Isolate*, v8::Local<v8::FunctionTemplate> fu
nctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constan
tConfiguration&); |
146 | 146 |
147 static void installConstantWithGetter(v8::Isolate*, v8::Local<v8::FunctionTe
mplate> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, con
st char* name, v8::AccessorNameGetterCallback); | 147 static void installConstantWithGetter(v8::Isolate*, v8::Local<v8::FunctionTe
mplate> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, con
st char* name, v8::AccessorNameGetterCallback); |
148 | 148 |
149 // MethodConfiguration translates into calls to Set() for setting up an | 149 // MethodConfiguration translates into calls to Set() for setting up an |
150 // object's callbacks. It sets the method on both the FunctionTemplate or | 150 // object's callbacks. It sets the method on both the FunctionTemplate or |
151 // the ObjectTemplate. | 151 // the ObjectTemplate. |
152 struct MethodConfiguration { | 152 struct MethodConfiguration { |
153 WTF_MAKE_NONCOPYABLE(MethodConfiguration); | 153 MethodConfiguration& operator=(const MethodConfiguration&) = delete; |
154 DISALLOW_ALLOCATION(); | 154 DISALLOW_ALLOCATION(); |
155 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At
omicString(isolate, name); } | 155 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At
omicString(isolate, name); } |
156 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons
t | 156 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons
t |
157 { | 157 { |
158 return world.isMainWorld() && callbackForMainWorld ? callbackForMain
World : callback; | 158 return world.isMainWorld() && callbackForMainWorld ? callbackForMain
World : callback; |
159 } | 159 } |
160 | 160 |
161 const char* const name; | 161 const char* const name; |
162 v8::FunctionCallback callback; | 162 v8::FunctionCallback callback; |
163 v8::FunctionCallback callbackForMainWorld; | 163 v8::FunctionCallback callbackForMainWorld; |
164 int length; | 164 int length; |
165 ExposeConfiguration exposeConfiguration; | 165 ExposeConfiguration exposeConfiguration; |
166 }; | 166 }; |
167 | 167 |
168 struct SymbolKeyedMethodConfiguration { | 168 struct SymbolKeyedMethodConfiguration { |
169 WTF_MAKE_NONCOPYABLE(SymbolKeyedMethodConfiguration); | 169 SymbolKeyedMethodConfiguration& operator=(const SymbolKeyedMethodConfigu
ration&) = delete; |
170 DISALLOW_ALLOCATION(); | 170 DISALLOW_ALLOCATION(); |
171 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return getS
ymbol(isolate); } | 171 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return getS
ymbol(isolate); } |
172 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const | 172 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const |
173 { | 173 { |
174 return callback; | 174 return callback; |
175 } | 175 } |
176 | 176 |
177 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); | 177 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); |
178 v8::FunctionCallback callback; | 178 v8::FunctionCallback callback; |
179 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. | 179 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. |
(...skipping 13 matching lines...) Expand all Loading... |
193 const AttributeConfiguration*, size_t attributeCount, | 193 const AttributeConfiguration*, size_t attributeCount, |
194 const AccessorConfiguration*, size_t accessorCount, | 194 const AccessorConfiguration*, size_t accessorCount, |
195 const MethodConfiguration*, size_t callbackCount); | 195 const MethodConfiguration*, size_t callbackCount); |
196 | 196 |
197 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe
rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); | 197 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe
rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); |
198 }; | 198 }; |
199 | 199 |
200 } // namespace blink | 200 } // namespace blink |
201 | 201 |
202 #endif // V8DOMConfiguration_h | 202 #endif // V8DOMConfiguration_h |
OLD | NEW |