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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp

Issue 2768393004: [Bindings] Rename CachedAccessorCallback method in generated code (Closed)
Patch Set: . Created 3 years, 9 months 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) 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 static_cast<v8::PropertyAttribute>(attribute.attribute)); 152 static_cast<v8::PropertyAttribute>(attribute.attribute));
153 } 153 }
154 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) 154 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface)
155 NOTREACHED(); 155 NOTREACHED();
156 } 156 }
157 157
158 template <class FunctionOrTemplate> 158 template <class FunctionOrTemplate>
159 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate( 159 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(
160 v8::Isolate*, 160 v8::Isolate*,
161 v8::FunctionCallback, 161 v8::FunctionCallback,
162 V8DOMConfiguration::CachedAccessorCallback, 162 V8DOMConfiguration::CachedPropertyKey,
163 v8::Local<v8::Value> data, 163 v8::Local<v8::Value> data,
164 v8::Local<v8::Signature>, 164 v8::Local<v8::Signature>,
165 int length); 165 int length);
166 166
167 template <> 167 template <>
168 v8::Local<v8::FunctionTemplate> 168 v8::Local<v8::FunctionTemplate>
169 createAccessorFunctionOrTemplate<v8::FunctionTemplate>( 169 createAccessorFunctionOrTemplate<v8::FunctionTemplate>(
170 v8::Isolate* isolate, 170 v8::Isolate* isolate,
171 v8::FunctionCallback callback, 171 v8::FunctionCallback callback,
172 V8DOMConfiguration::CachedAccessorCallback cachedAccessorCallback, 172 V8DOMConfiguration::CachedPropertyKey cachedPropertyKey,
173 v8::Local<v8::Value> data, 173 v8::Local<v8::Value> data,
174 v8::Local<v8::Signature> signature, 174 v8::Local<v8::Signature> signature,
175 int length) { 175 int length) {
176 v8::Local<v8::FunctionTemplate> functionTemplate; 176 v8::Local<v8::FunctionTemplate> functionTemplate;
177 if (callback) { 177 if (callback) {
178 if (cachedAccessorCallback) { 178 if (cachedPropertyKey) {
179 functionTemplate = v8::FunctionTemplate::NewWithCache( 179 functionTemplate = v8::FunctionTemplate::NewWithCache(
180 isolate, callback, cachedAccessorCallback(isolate), data, signature, 180 isolate, callback, cachedPropertyKey(isolate), data, signature,
181 length); 181 length);
182 } else { 182 } else {
183 functionTemplate = 183 functionTemplate =
184 v8::FunctionTemplate::New(isolate, callback, data, signature, length); 184 v8::FunctionTemplate::New(isolate, callback, data, signature, length);
185 } 185 }
186 186
187 if (!functionTemplate.IsEmpty()) { 187 if (!functionTemplate.IsEmpty()) {
188 functionTemplate->RemovePrototype(); 188 functionTemplate->RemovePrototype();
189 functionTemplate->SetAcceptAnyReceiver(false); 189 functionTemplate->SetAcceptAnyReceiver(false);
190 } 190 }
191 } 191 }
192 return functionTemplate; 192 return functionTemplate;
193 } 193 }
194 194
195 template <> 195 template <>
196 v8::Local<v8::Function> createAccessorFunctionOrTemplate<v8::Function>( 196 v8::Local<v8::Function> createAccessorFunctionOrTemplate<v8::Function>(
197 v8::Isolate* isolate, 197 v8::Isolate* isolate,
198 v8::FunctionCallback callback, 198 v8::FunctionCallback callback,
199 V8DOMConfiguration::CachedAccessorCallback, 199 V8DOMConfiguration::CachedPropertyKey,
200 v8::Local<v8::Value> data, 200 v8::Local<v8::Value> data,
201 v8::Local<v8::Signature> signature, 201 v8::Local<v8::Signature> signature,
202 int length) { 202 int length) {
203 if (!callback) 203 if (!callback)
204 return v8::Local<v8::Function>(); 204 return v8::Local<v8::Function>();
205 205
206 v8::Local<v8::FunctionTemplate> functionTemplate = 206 v8::Local<v8::FunctionTemplate> functionTemplate =
207 createAccessorFunctionOrTemplate<v8::FunctionTemplate>( 207 createAccessorFunctionOrTemplate<v8::FunctionTemplate>(
208 isolate, callback, nullptr, data, signature, length); 208 isolate, callback, nullptr, data, signature, length);
209 if (functionTemplate.IsEmpty()) 209 if (functionTemplate.IsEmpty())
(...skipping 13 matching lines...) Expand all
223 v8::Local<ObjectOrTemplate> prototypeOrTemplate, 223 v8::Local<ObjectOrTemplate> prototypeOrTemplate,
224 v8::Local<FunctionOrTemplate> interfaceOrTemplate, 224 v8::Local<FunctionOrTemplate> interfaceOrTemplate,
225 v8::Local<v8::Signature> signature, 225 v8::Local<v8::Signature> signature,
226 const V8DOMConfiguration::AccessorConfiguration& accessor, 226 const V8DOMConfiguration::AccessorConfiguration& accessor,
227 const DOMWrapperWorld& world) { 227 const DOMWrapperWorld& world) {
228 if (!worldConfigurationApplies(accessor, world)) 228 if (!worldConfigurationApplies(accessor, world))
229 return; 229 return;
230 v8::Local<v8::Name> name = v8AtomicString(isolate, accessor.name); 230 v8::Local<v8::Name> name = v8AtomicString(isolate, accessor.name);
231 v8::FunctionCallback getterCallback = accessor.getter; 231 v8::FunctionCallback getterCallback = accessor.getter;
232 v8::FunctionCallback setterCallback = accessor.setter; 232 v8::FunctionCallback setterCallback = accessor.setter;
233 V8DOMConfiguration::CachedAccessorCallback cachedAccessorCallback = nullptr; 233 V8DOMConfiguration::CachedPropertyKey cachedPropertyKey = nullptr;
234 if (world.isMainWorld()) { 234 if (world.isMainWorld()) {
235 cachedAccessorCallback = accessor.cachedAccessorCallback; 235 cachedPropertyKey = accessor.cachedPropertyKey;
236 } 236 }
237 237
238 // Support [LenientThis] by not specifying the signature. V8 does not do 238 // Support [LenientThis] by not specifying the signature. V8 does not do
239 // the type checking against holder if no signature is specified. Note that 239 // the type checking against holder if no signature is specified. Note that
240 // info.Holder() passed to callbacks will be *unsafe*. 240 // info.Holder() passed to callbacks will be *unsafe*.
241 if (accessor.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) 241 if (accessor.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder)
242 signature = v8::Local<v8::Signature>(); 242 signature = v8::Local<v8::Signature>();
243 v8::Local<v8::Value> data = 243 v8::Local<v8::Value> data =
244 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(accessor.data)); 244 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(accessor.data));
245 245
246 DCHECK(accessor.propertyLocationConfiguration); 246 DCHECK(accessor.propertyLocationConfiguration);
247 if (accessor.propertyLocationConfiguration & 247 if (accessor.propertyLocationConfiguration &
248 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { 248 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) {
249 v8::Local<FunctionOrTemplate> getter = 249 v8::Local<FunctionOrTemplate> getter =
250 createAccessorFunctionOrTemplate<FunctionOrTemplate>( 250 createAccessorFunctionOrTemplate<FunctionOrTemplate>(
251 isolate, getterCallback, cachedAccessorCallback, data, signature, 251 isolate, getterCallback, cachedPropertyKey, data, signature, 0);
252 0);
253 v8::Local<FunctionOrTemplate> setter = 252 v8::Local<FunctionOrTemplate> setter =
254 createAccessorFunctionOrTemplate<FunctionOrTemplate>( 253 createAccessorFunctionOrTemplate<FunctionOrTemplate>(
255 isolate, setterCallback, nullptr, data, signature, 1); 254 isolate, setterCallback, nullptr, data, signature, 1);
256 if (accessor.propertyLocationConfiguration & 255 if (accessor.propertyLocationConfiguration &
257 V8DOMConfiguration::OnInstance) { 256 V8DOMConfiguration::OnInstance) {
258 instanceOrTemplate->SetAccessorProperty( 257 instanceOrTemplate->SetAccessorProperty(
259 name, getter, setter, 258 name, getter, setter,
260 static_cast<v8::PropertyAttribute>(accessor.attribute), v8::DEFAULT); 259 static_cast<v8::PropertyAttribute>(accessor.attribute), v8::DEFAULT);
261 } 260 }
262 if (accessor.propertyLocationConfiguration & 261 if (accessor.propertyLocationConfiguration &
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 void V8DOMConfiguration::setClassString( 687 void V8DOMConfiguration::setClassString(
689 v8::Isolate* isolate, 688 v8::Isolate* isolate,
690 v8::Local<v8::ObjectTemplate> objectTemplate, 689 v8::Local<v8::ObjectTemplate> objectTemplate,
691 const char* classString) { 690 const char* classString) {
692 objectTemplate->Set( 691 objectTemplate->Set(
693 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), 692 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString),
694 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); 693 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum));
695 } 694 }
696 695
697 } // namespace blink 696 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698