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

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

Issue 109473008: Remove custom signatures from V8 bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestInterfaceImplementedAs.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 3359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 { 3370 {
3371 my $interface = shift; 3371 my $interface = shift;
3372 my $function = shift; 3372 my $function = shift;
3373 3373
3374 my $interfaceName = $interface->name; 3374 my $interfaceName = $interface->name;
3375 my $attrExt = $function->extendedAttributes; 3375 my $attrExt = $function->extendedAttributes;
3376 return 0 if $attrExt->{"Unforgeable"}; 3376 return 0 if $attrExt->{"Unforgeable"};
3377 return 0 if $function->isStatic; 3377 return 0 if $function->isStatic;
3378 return 0 if $attrExt->{"RuntimeEnabled"}; 3378 return 0 if $attrExt->{"RuntimeEnabled"};
3379 return 0 if $attrExt->{"PerContextEnabled"}; 3379 return 0 if $attrExt->{"PerContextEnabled"};
3380 return 0 if RequiresCustomSignature($function);
3381 return 0 if $attrExt->{"DoNotCheckSignature"}; 3380 return 0 if $attrExt->{"DoNotCheckSignature"};
3382 return 0 if ($attrExt->{"DoNotCheckSecurity"} && ($interface->extendedAttrib utes->{"CheckSecurity"} || $interfaceName eq "Window")); 3381 return 0 if ($attrExt->{"DoNotCheckSecurity"} && ($interface->extendedAttrib utes->{"CheckSecurity"} || $interfaceName eq "Window"));
3383 return 0 if $attrExt->{"NotEnumerable"}; 3382 return 0 if $attrExt->{"NotEnumerable"};
3384 return 0 if $attrExt->{"ReadOnly"}; 3383 return 0 if $attrExt->{"ReadOnly"};
3385 return 1; 3384 return 1;
3386 } 3385 }
3387 3386
3388 sub GenerateNonStandardFunction 3387 sub GenerateNonStandardFunction
3389 { 3388 {
3390 my $interface = shift; 3389 my $interface = shift;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 return $code; 3447 return $code;
3449 } 3448 }
3450 3449
3451 my $signature = "defaultSignature"; 3450 my $signature = "defaultSignature";
3452 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { 3451 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) {
3453 $signature = "v8::Local<v8::Signature>()"; 3452 $signature = "v8::Local<v8::Signature>()";
3454 } 3453 }
3455 3454
3456 my $conditionalString = GenerateConditionalString($function); 3455 my $conditionalString = GenerateConditionalString($function);
3457 $code .= "#if ${conditionalString}\n" if $conditionalString; 3456 $code .= "#if ${conditionalString}\n" if $conditionalString;
3458 if (RequiresCustomSignature($function)) {
3459 $signature = "${name}Signature";
3460 $code .= "\n // Custom Signature '$name'\n" . CreateCustomSignature($ function);
3461 }
3462 3457
3463 if ($property_attributes eq "v8::DontDelete") { 3458 if ($property_attributes eq "v8::DontDelete") {
3464 $property_attributes = ""; 3459 $property_attributes = "";
3465 } else { 3460 } else {
3466 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a ttributes)"; 3461 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a ttributes)";
3467 } 3462 }
3468 3463
3469 if ($template eq "prototypeTemplate" && $conditional4 eq "" && $signature eq "defaultSignature" && $property_attributes eq "") { 3464 if ($template eq "prototypeTemplate" && $conditional4 eq "" && $signature eq "defaultSignature" && $property_attributes eq "") {
3470 die "This shouldn't happen: Class '$implClassName' $commentInfo\n"; 3465 die "This shouldn't happen: Class '$implClassName' $commentInfo\n";
3471 } 3466 }
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
5496 5491
5497 if ($type eq "Promise") { 5492 if ($type eq "Promise") {
5498 AddToImplIncludes("bindings/v8/ScriptPromise.h"); 5493 AddToImplIncludes("bindings/v8/ScriptPromise.h");
5499 return "ScriptPromise($value)"; 5494 return "ScriptPromise($value)";
5500 } 5495 }
5501 5496
5502 if ($type eq "NodeFilter") { 5497 if ($type eq "NodeFilter") {
5503 return "toNodeFilter($value, $getIsolate)"; 5498 return "toNodeFilter($value, $getIsolate)";
5504 } 5499 }
5505 5500
5501 if ($type eq "Window") {
5502 return "toNativeDOMWindow($value, $getIsolate)";
5503 }
5504
5506 if ($type eq "MediaQueryListListener") { 5505 if ($type eq "MediaQueryListListener") {
5507 AddToImplIncludes("core/css/MediaQueryListListener.h"); 5506 AddToImplIncludes("core/css/MediaQueryListListener.h");
5508 return "MediaQueryListListener::create(ScriptValue(" . $value . ", $getI solate))"; 5507 return "MediaQueryListListener::create(ScriptValue(" . $value . ", $getI solate))";
5509 } 5508 }
5510 5509
5511 if ($type eq "EventTarget") { 5510 if ($type eq "EventTarget") {
5512 return "V8DOMWrapper::isDOMWrapper($value) ? toWrapperTypeInfo(v8::Handl e<v8::Object>::Cast($value))->toEventTarget(v8::Handle<v8::Object>::Cast($value) ) : 0"; 5511 return "V8DOMWrapper::isDOMWrapper($value) ? toWrapperTypeInfo(v8::Handl e<v8::Object>::Cast($value))->toEventTarget(v8::Handle<v8::Object>::Cast($value) ) : 0";
5513 } 5512 }
5514 5513
5515 if (IsTypedArrayType($type)) { 5514 if (IsTypedArrayType($type)) {
(...skipping 14 matching lines...) Expand all
5530 } 5529 }
5531 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu e, $argIndexOrZero, $getIsolate)"; 5530 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu e, $argIndexOrZero, $getIsolate)";
5532 } 5531 }
5533 5532
5534 AddIncludesForType($type); 5533 AddIncludesForType($type);
5535 5534
5536 AddToImplIncludes("V8${type}.h"); 5535 AddToImplIncludes("V8${type}.h");
5537 return "V8${type}::hasInstance($value, $getIsolate, worldType($getIsolate)) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; 5536 return "V8${type}::hasInstance($value, $getIsolate, worldType($getIsolate)) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0";
5538 } 5537 }
5539 5538
5540 sub CreateCustomSignature
5541 {
5542 my $function = shift;
5543 my $count = @{$function->parameters};
5544 my $name = $function->name;
5545 my $code = " const int ${name}Argc = ${count};\n" .
5546 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { ";
5547 my $first = 1;
5548 foreach my $parameter (@{$function->parameters}) {
5549 if ($first) { $first = 0; }
5550 else { $code .= ", "; }
5551 if (IsWrapperType($parameter->type) && not IsTypedArrayType($parameter-> type)) {
5552 if ($parameter->type eq "XPathNSResolver") {
5553 # Special case for XPathNSResolver. All other browsers accepts a callable,
5554 # so, even though it's against IDL, accept objects here.
5555 $code .= "v8::Handle<v8::FunctionTemplate>()";
5556 } else {
5557 my $type = $parameter->type;
5558 my $arrayOrSequenceType = GetArrayOrSequenceType($type);
5559
5560 if ($arrayOrSequenceType) {
5561 if (IsRefPtrType($arrayOrSequenceType)) {
5562 AddIncludesForType($arrayOrSequenceType);
5563 } else {
5564 $code .= "v8::Handle<v8::FunctionTemplate>()";
5565 next;
5566 }
5567 } else {
5568 AddIncludesForType($type);
5569 }
5570 $code .= "V8PerIsolateData::from(isolate)->rawDOMTemplate(&V8${t ype}::wrapperTypeInfo, currentWorldType)";
5571 }
5572 } else {
5573 $code .= "v8::Handle<v8::FunctionTemplate>()";
5574 }
5575 }
5576 $code .= " };\n";
5577 $code .= " v8::Handle<v8::Signature> ${name}Signature = v8::Signature::Ne w(isolate, functionTemplate, ${name}Argc, ${name}Argv);\n";
5578 return $code;
5579 }
5580
5581
5582 sub RequiresCustomSignature
5583 {
5584 my $function = shift;
5585 # No signature needed for Custom function
5586 if (HasCustomMethod($function->extendedAttributes)) {
5587 return 0;
5588 }
5589 # No signature needed for overloaded function
5590 if (@{$function->{overloads}} > 1) {
5591 return 0;
5592 }
5593 if ($function->isStatic) {
5594 return 0;
5595 }
5596 # Type checking is performed in the generated code
5597 if ($function->extendedAttributes->{"StrictTypeChecking"}) {
5598 return 0;
5599 }
5600 foreach my $parameter (@{$function->parameters}) {
5601 if (($parameter->isOptional && !$parameter->extendedAttributes->{"Defaul t"}) || IsCallbackInterface($parameter->type)) {
5602 return 0;
5603 }
5604 }
5605
5606 foreach my $parameter (@{$function->parameters}) {
5607 if (IsWrapperType($parameter->type)) {
5608 return 1;
5609 }
5610 }
5611 return 0;
5612 }
5613
5614 sub IsUnionType 5539 sub IsUnionType
5615 { 5540 {
5616 my $type = shift; # string or UnionType 5541 my $type = shift; # string or UnionType
5617 if(ref($type) eq "UnionType") { 5542 if(ref($type) eq "UnionType") {
5618 die "Currently only 2 values of non-union type is supported as union typ e.\n" unless @{$type->unionMemberTypes} == 2; 5543 die "Currently only 2 values of non-union type is supported as union typ e.\n" unless @{$type->unionMemberTypes} == 2;
5619 return 1; 5544 return 1;
5620 } 5545 }
5621 return 0; 5546 return 0;
5622 } 5547 }
5623 5548
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
6382 6307
6383 foreach my $parameter (@{$function->parameters}) { 6308 foreach my $parameter (@{$function->parameters}) {
6384 if ($parameter->type eq "SerializedScriptValue") { 6309 if ($parameter->type eq "SerializedScriptValue") {
6385 return 1; 6310 return 1;
6386 } 6311 }
6387 } 6312 }
6388 return 0; 6313 return 0;
6389 } 6314 }
6390 6315
6391 1; 6316 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestInterfaceImplementedAs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698