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

Side by Side Diff: Source/bindings/scripts/CodeGeneratorV8.pm

Issue 17225003: Support named query generation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: remove int returnValue and hard code v8::None Created 7 years, 6 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
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 3186
3187 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); 3187 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface);
3188 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct ion->extendedAttributes->{"Custom"} : 0; 3188 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct ion->extendedAttributes->{"Custom"} : 0;
3189 if ($indexedDeleterFunction && !$hasCustomIndexedDeleter) { 3189 if ($indexedDeleterFunction && !$hasCustomIndexedDeleter) {
3190 GenerateImplementationIndexedPropertyDeleter($interface, $indexedDeleter Function); 3190 GenerateImplementationIndexedPropertyDeleter($interface, $indexedDeleter Function);
3191 } 3191 }
3192 3192
3193 my $indexedEnumeratorFunction = $indexedGetterFunction; 3193 my $indexedEnumeratorFunction = $indexedGetterFunction;
3194 $indexedEnumeratorFunction = 0 if $indexedGetterFunction && $indexedGetterFu nction->extendedAttributes->{"NotEnumerable"}; 3194 $indexedEnumeratorFunction = 0 if $indexedGetterFunction && $indexedGetterFu nction->extendedAttributes->{"NotEnumerable"};
3195 3195
3196 # FIXME: Support generated named query bindings.
3197 my $indexedQueryFunction = 0; 3196 my $indexedQueryFunction = 0;
3198 # If there is an enumerator, there MUST be a query method to properly commun icate property attributes. 3197 # If there is an enumerator, there MUST be a query method to properly commun icate property attributes.
3199 my $hasQuery = $indexedQueryFunction || $indexedEnumeratorFunction; 3198 my $hasQuery = $indexedQueryFunction || $indexedEnumeratorFunction;
3200 3199
3201 my $setOn = "Instance"; 3200 my $setOn = "Instance";
3202 3201
3203 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on Window 3202 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on Window
3204 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to 3203 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to
3205 # get implementation straight out of the Window prototype regardless of what prototype is actually set 3204 # get implementation straight out of the Window prototype regardless of what prototype is actually set
3206 # on the object. 3205 # on the object.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3344 } 3343 }
3345 my $hasDeleter = $namedDeleterFunction; 3344 my $hasDeleter = $namedDeleterFunction;
3346 3345
3347 my $namedEnumeratorFunction = $namedGetterFunction; 3346 my $namedEnumeratorFunction = $namedGetterFunction;
3348 $namedEnumeratorFunction = 0 if $namedGetterFunction && $namedGetterFunction ->extendedAttributes->{"NotEnumerable"}; 3347 $namedEnumeratorFunction = 0 if $namedGetterFunction && $namedGetterFunction ->extendedAttributes->{"NotEnumerable"};
3349 my $hasCustomNamedEnumerator = 1 if $namedGetterFunction && $namedGetterFunc tion->extendedAttributes->{"CustomEnumerateProperty"}; 3348 my $hasCustomNamedEnumerator = 1 if $namedGetterFunction && $namedGetterFunc tion->extendedAttributes->{"CustomEnumerateProperty"};
3350 if ($namedEnumeratorFunction && !$hasCustomNamedEnumerator) { 3349 if ($namedEnumeratorFunction && !$hasCustomNamedEnumerator) {
3351 GenerateImplementationNamedPropertyEnumerator($interface); 3350 GenerateImplementationNamedPropertyEnumerator($interface);
3352 } 3351 }
3353 3352
3354 # FIXME: Support generated named query bindings.
3355 my $namedQueryFunction = 0;
3356 # If there is an enumerator, there MUST be a query method to properly commun icate property attributes. 3353 # If there is an enumerator, there MUST be a query method to properly commun icate property attributes.
3357 my $hasQuery = $namedQueryFunction || $namedEnumeratorFunction; 3354 my $hasQuery = $namedEnumeratorFunction;
3355 my $hasCustomNamedQuery = $hasCustomNamedEnumerator;
3356 if ($hasQuery && !$hasCustomNamedQuery) {
3357 GenerateImplementationNamedPropertyQuery($interface);
3358 }
3358 3359
3359 my $subCode = ""; 3360 my $subCode = "";
3360 if ($namedGetterFunction || $namedSetterFunction || $namedDeleterFunction || $namedEnumeratorFunction || $hasQuery) { 3361 if ($namedGetterFunction || $namedSetterFunction || $namedDeleterFunction || $namedEnumeratorFunction || $hasQuery) {
3361 my $setOn = "Instance"; 3362 my $setOn = "Instance";
3362 3363
3363 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCa llbacks) and it's used on Window 3364 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCa llbacks) and it's used on Window
3364 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to 3365 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to
3365 # get implementation straight out of the Window prototype regardless of what prototype is actually set 3366 # get implementation straight out of the Window prototype regardless of what prototype is actually set
3366 # on the object. 3367 # on the object.
3367 if ($interfaceName eq "Window") { 3368 if ($interfaceName eq "Window") {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3636 } 3637 }
3637 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 3638 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
3638 for (size_t i = 0; i < names.size(); ++i) 3639 for (size_t i = 0; i < names.size(); ++i)
3639 v8names->Set(v8Integer(i, info.GetIsolate()), v8String(names[i], info.Ge tIsolate())); 3640 v8names->Set(v8Integer(i, info.GetIsolate()), v8String(names[i], info.Ge tIsolate()));
3640 v8SetReturnValue(info, v8names); 3641 v8SetReturnValue(info, v8names);
3641 } 3642 }
3642 3643
3643 END 3644 END
3644 } 3645 }
3645 3646
3647 sub GenerateImplementationNamedPropertyQuery
3648 {
3649 my $interface = shift;
3650 my $implClassName = GetImplName($interface);
3651 my $v8ClassName = GetV8ClassName($interface);
3652
3653 $implementation{nameSpaceWebCore}->add(<<END);
3654 void ${v8ClassName}::namedPropertyQuery(v8::Local<v8::String> name, const v8::Pr opertyCallbackInfo<v8::Integer>& info)
3655 {
3656 ${implClassName}* collection = toNative(info.Holder());
3657 AtomicString propertyName = toWebCoreAtomicString(name);
3658 ExceptionCode ec = 0;
3659 bool result = collection->namedPropertyQuery(propertyName, ec);
3660 if (ec) {
3661 setDOMException(ec, info.GetIsolate());
3662 return;
3663 }
3664 if (!result)
3665 return;
3666 v8SetReturnValueInt(info, v8::None);
3667 }
3668
3669 END
3670 }
3671
3646 sub GenerateImplementationLegacyCall 3672 sub GenerateImplementationLegacyCall
3647 { 3673 {
3648 my $interface = shift; 3674 my $interface = shift;
3649 my $code = ""; 3675 my $code = "";
3650 3676
3651 my $v8ClassName = GetV8ClassName($interface); 3677 my $v8ClassName = GetV8ClassName($interface);
3652 3678
3653 if ($interface->extendedAttributes->{"CustomLegacyCall"}) { 3679 if ($interface->extendedAttributes->{"CustomLegacyCall"}) {
3654 $code .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(${v8Cla ssName}::legacyCallCustom);\n"; 3680 $code .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(${v8Cla ssName}::legacyCallCustom);\n";
3655 } 3681 }
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after
5878 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 5904 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
5879 $found = 1; 5905 $found = 1;
5880 } 5906 }
5881 return 1 if $found; 5907 return 1 if $found;
5882 }, 0); 5908 }, 0);
5883 5909
5884 return $found; 5910 return $found;
5885 } 5911 }
5886 5912
5887 1; 5913 1;
OLDNEW
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698