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

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

Issue 153883003: [SVG] SVGAnimatedTransform{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 "SVGLength" => 1, 238 "SVGLength" => 1,
239 "SVGLengthList" => 1, 239 "SVGLengthList" => 1,
240 "SVGNumber" => 1, 240 "SVGNumber" => 1,
241 "SVGNumberList" => 1, 241 "SVGNumberList" => 1,
242 "SVGPoint" => 1, 242 "SVGPoint" => 1,
243 "SVGPointList" => 1, 243 "SVGPointList" => 1,
244 "SVGPreserveAspectRatio" => 1, 244 "SVGPreserveAspectRatio" => 1,
245 "SVGRect" => 1, 245 "SVGRect" => 1,
246 "SVGString" => 1, 246 "SVGString" => 1,
247 "SVGStringList" => 1, 247 "SVGStringList" => 1,
248 "SVGTransform" => 1,
249 "SVGTransformList" => 1,
248 ); 250 );
249 251
250 my %svgTypeNeedingTearOff = ( 252 my %svgTypeNeedingTearOff = (
251 "SVGAngle" => "SVGPropertyTearOff<SVGAngle>", 253 "SVGAngle" => "SVGPropertyTearOff<SVGAngle>",
252 "SVGMatrix" => "SVGMatrixTearOff",
253 "SVGPathSegList" => "SVGPathSegListPropertyTearOff", 254 "SVGPathSegList" => "SVGPathSegListPropertyTearOff",
254 "SVGTransform" => "SVGPropertyTearOff<SVGTransform>",
255 "SVGTransformList" => "SVGTransformListPropertyTearOff"
256 );
257
258 my %svgTypeWithWritablePropertiesNeedingTearOff = (
259 "SVGMatrix" => 1
260 ); 255 );
261 256
262 # Default license header 257 # Default license header
263 my $licenseHeader = <<EOF; 258 my $licenseHeader = <<EOF;
264 /* 259 /*
265 * Copyright (C) 2013 Google Inc. All rights reserved. 260 * Copyright (C) 2013 Google Inc. All rights reserved.
266 * 261 *
267 * Redistribution and use in source and binary forms, with or without 262 * Redistribution and use in source and binary forms, with or without
268 * modification, are permitted provided that the following conditions are 263 * modification, are permitted provided that the following conditions are
269 * met: 264 * met:
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 END 547 END
553 } 548 }
554 for my $setReference (@{$interface->extendedAttributes->{"SetWrapperReferenc eTo"}}) { 549 for my $setReference (@{$interface->extendedAttributes->{"SetWrapperReferenc eTo"}}) {
555 my $setReferenceType = $setReference->type; 550 my $setReferenceType = $setReference->type;
556 my $setReferenceV8Type = "V8".$setReferenceType; 551 my $setReferenceV8Type = "V8".$setReferenceType;
557 552
558 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProp ertyTypes($setReferenceType); 553 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProp ertyTypes($setReferenceType);
559 if ($svgPropertyType) { 554 if ($svgPropertyType) {
560 $setReferenceType = $svgNativeType; 555 $setReferenceType = $svgNativeType;
561 } 556 }
557 my $setReferenceImplType = GetImplNameFromImplementedBy($setReferenceTyp e);
562 558
563 my $setReferenceName = $setReference->name; 559 my $setReferenceName = $setReference->name;
564 560
565 AddIncludesForType($setReferenceType); 561 AddIncludesForType($setReferenceType);
566 $code .= <<END; 562 $code .= <<END;
567 ${setReferenceType}* ${setReferenceName} = impl->${setReferenceName}(); 563 ${setReferenceImplType}* ${setReferenceName} = impl->${setReferenceName}();
568 if (${setReferenceName}) { 564 if (${setReferenceName}) {
569 if (!DOMDataStore::containsWrapper<${setReferenceV8Type}>(${setReference Name}, isolate)) 565 if (!DOMDataStore::containsWrapper<${setReferenceV8Type}>(${setReference Name}, isolate))
570 wrap(${setReferenceName}, creationContext, isolate); 566 wrap(${setReferenceName}, creationContext, isolate);
571 DOMDataStore::setWrapperReference<${setReferenceV8Type}>(wrapper, ${setR eferenceName}, isolate); 567 DOMDataStore::setWrapperReference<${setReferenceV8Type}>(wrapper, ${setR eferenceName}, isolate);
572 } 568 }
573 END 569 END
574 } 570 }
575 571
576 my $isReachableMethod = $interface->extendedAttributes->{"SetWrapperReferenc eFrom"}; 572 my $isReachableMethod = $interface->extendedAttributes->{"SetWrapperReferenc eFrom"};
577 if ($isReachableMethod) { 573 if ($isReachableMethod) {
(...skipping 29 matching lines...) Expand all
607 $svgNativeType = GetSVGTypeNeedingTearOff($implType); 603 $svgNativeType = GetSVGTypeNeedingTearOff($implType);
608 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgN ativeType; 604 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgN ativeType;
609 605
610 # Append space to avoid compilation errors when using PassRefPtr<$svgNative Type> 606 # Append space to avoid compilation errors when using PassRefPtr<$svgNative Type>
611 $svgNativeType = "$svgNativeType "; 607 $svgNativeType = "$svgNativeType ";
612 608
613 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($implType); 609 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($implType);
614 if ($svgNativeType =~ /SVGPropertyTearOff/) { 610 if ($svgNativeType =~ /SVGPropertyTearOff/) {
615 $svgPropertyType = $svgWrappedNativeType; 611 $svgPropertyType = $svgWrappedNativeType;
616 AddToHeaderIncludes("core/svg/properties/SVGAnimatedPropertyTearOff.h"); 612 AddToHeaderIncludes("core/svg/properties/SVGAnimatedPropertyTearOff.h");
617 } elsif ($svgNativeType =~ /SVGMatrixTearOff/) {
618 $svgPropertyType = $svgWrappedNativeType;
619 AddToHeaderIncludes("core/svg/properties/SVGMatrixTearOff.h");
620 AddToHeaderIncludes("core/svg/properties/SVGAnimatedPropertyTearOff.h");
621 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SV GStaticListPropertyTearOff/ or $svgNativeType =~ /SVGTransformListPropertyTearOf f/) { 613 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SV GStaticListPropertyTearOff/ or $svgNativeType =~ /SVGTransformListPropertyTearOf f/) {
622 $svgListPropertyType = $svgWrappedNativeType; 614 $svgListPropertyType = $svgWrappedNativeType;
623 AddToHeaderIncludes("core/svg/properties/SVGAnimatedListPropertyTearOff. h"); 615 AddToHeaderIncludes("core/svg/properties/SVGAnimatedListPropertyTearOff. h");
624 } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) { 616 } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) {
625 $svgListPropertyType = $svgWrappedNativeType; 617 $svgListPropertyType = $svgWrappedNativeType;
626 AddToHeaderIncludes("core/svg/properties/SVGPathSegListPropertyTearOff.h "); 618 AddToHeaderIncludes("core/svg/properties/SVGPathSegListPropertyTearOff.h ");
627 } 619 }
628 620
629 return ($svgPropertyType, $svgListPropertyType, $svgNativeType); 621 return ($svgPropertyType, $svgListPropertyType, $svgNativeType);
630 } 622 }
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 if ($forMainWorldSuffix eq "ForMainWorld") { 1706 if ($forMainWorldSuffix eq "ForMainWorld") {
1715 $code .= " v8SetReturnValueForMainWorld(info, static_cast<$svgNat iveType*>($expression));\n"; 1707 $code .= " v8SetReturnValueForMainWorld(info, static_cast<$svgNat iveType*>($expression));\n";
1716 } else { 1708 } else {
1717 $code .= " v8SetReturnValueFast(info, static_cast<$svgNativeType* >($expression), imp);\n"; 1709 $code .= " v8SetReturnValueFast(info, static_cast<$svgNativeType* >($expression), imp);\n";
1718 } 1710 }
1719 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$ /) { 1711 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$ /) {
1720 AddToImplIncludes("V8$attrType.h"); 1712 AddToImplIncludes("V8$attrType.h");
1721 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); 1713 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h");
1722 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); 1714 my $tearOffType = GetSVGTypeNeedingTearOff($attrType);
1723 my $wrappedValue; 1715 my $wrappedValue;
1724 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def ined $attribute->extendedAttributes->{"Immutable"}) { 1716 if ($tearOffType =~ /SVGStaticListPropertyTearOff/) {
1725 my $getter = $expression;
1726 $getter =~ s/imp->//;
1727 $getter =~ s/\(\)//;
1728
1729 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC ase($getter);
1730
1731 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName);
1732 if ($selfIsTearOffType) {
1733 AddToImplIncludes("core/svg/properties/SVGMatrixTearOff.h");
1734 # FIXME: Don't create a new one everytime we access the matrix p roperty. This means, e.g, === won't work.
1735 $wrappedValue = "WTF::getPtr(SVGMatrixTearOff::create(wrapper, $ expression))";
1736 } else {
1737 AddToImplIncludes("core/svg/properties/SVGStaticPropertyTearOff. h");
1738 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$ implClassName, /;
1739
1740 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres sion, $updateMethod))";
1741 }
1742 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) {
1743 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres sion))"; 1717 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres sion))";
1744 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { 1718 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) {
1745 $wrappedValue = "WTF::getPtr($expression)"; 1719 $wrappedValue = "WTF::getPtr($expression)";
1746 } else { 1720 } else {
1747 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression) )"; 1721 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression) )";
1748 } 1722 }
1749 if ($forMainWorldSuffix eq "ForMainWorld") { 1723 if ($forMainWorldSuffix eq "ForMainWorld") {
1750 $code .= " v8SetReturnValueForMainWorld(info, $wrappedValue);\n"; 1724 $code .= " v8SetReturnValueForMainWorld(info, $wrappedValue);\n";
1751 } else { 1725 } else {
1752 $code .= " v8SetReturnValueFast(info, $wrappedValue, imp);\n"; 1726 $code .= " v8SetReturnValueFast(info, $wrappedValue, imp);\n";
(...skipping 3572 matching lines...) Expand 10 before | Expand all | Expand 10 after
5325 } 5299 }
5326 END 5300 END
5327 } else { 5301 } else {
5328 $code .= <<END; 5302 $code .= <<END;
5329 if (!$paramName) { 5303 if (!$paramName) {
5330 throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfac eName\", \"parameter $humanFriendlyIndex is not of type '${ \$parameter->type }' .\"), info.GetIsolate()); 5304 throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfac eName\", \"parameter $humanFriendlyIndex is not of type '${ \$parameter->type }' .\"), info.GetIsolate());
5331 return; 5305 return;
5332 } 5306 }
5333 END 5307 END
5334 } 5308 }
5335 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") {
5336 push @arguments, "$paramName.get()";
5337 } elsif (IsNullableParameter($parameter)) { 5309 } elsif (IsNullableParameter($parameter)) {
5338 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; 5310 push @arguments, "${paramName}IsNull ? 0 : &$paramName";
5339 } elsif (IsCallbackInterface($paramType) or $paramType eq "NodeFilter" o r $paramType eq "XPathNSResolver") { 5311 } elsif (IsCallbackInterface($paramType) or $paramType eq "NodeFilter" o r $paramType eq "XPathNSResolver") {
5340 push @arguments, "$paramName.release()"; 5312 push @arguments, "$paramName.release()";
5341 } else { 5313 } else {
5342 push @arguments, $paramName; 5314 push @arguments, $paramName;
5343 } 5315 }
5344 $index++; 5316 $index++;
5345 $humanFriendlyIndex = $index + 1; 5317 $humanFriendlyIndex = $index + 1;
5346 } 5318 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
6025 } 5997 }
6026 5998
6027 sub IsSVGTypeNeedingTearOff 5999 sub IsSVGTypeNeedingTearOff
6028 { 6000 {
6029 my $type = shift; 6001 my $type = shift;
6030 6002
6031 return 1 if $svgTypeNeedingTearOff{$type}; 6003 return 1 if $svgTypeNeedingTearOff{$type};
6032 return 0; 6004 return 0;
6033 } 6005 }
6034 6006
6035 sub IsSVGTypeWithWritablePropertiesNeedingTearOff
6036 {
6037 my $type = shift;
6038
6039 return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type};
6040 return 0;
6041 }
6042
6043 sub IsTypedArrayType 6007 sub IsTypedArrayType
6044 { 6008 {
6045 my $type = shift; 6009 my $type = shift;
6046 return 1 if $typedArrayHash{$type}; 6010 return 1 if $typedArrayHash{$type};
6047 return 0; 6011 return 0;
6048 } 6012 }
6049 6013
6050 sub IsWillBeGarbageCollectedType 6014 sub IsWillBeGarbageCollectedType
6051 { 6015 {
6052 my $interfaceName = shift; 6016 my $interfaceName = shift;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6095 return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff; 6059 return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff;
6096 6060
6097 if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) { 6061 if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) {
6098 $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//; 6062 $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//;
6099 } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) { 6063 } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) {
6100 $svgTypeNeedingTearOff =~ s/SVGListPropertyTearOff<//; 6064 $svgTypeNeedingTearOff =~ s/SVGListPropertyTearOff<//;
6101 } elsif ($svgTypeNeedingTearOff =~ /SVGStaticListPropertyTearOff/) { 6065 } elsif ($svgTypeNeedingTearOff =~ /SVGStaticListPropertyTearOff/) {
6102 $svgTypeNeedingTearOff =~ s/SVGStaticListPropertyTearOff<//; 6066 $svgTypeNeedingTearOff =~ s/SVGStaticListPropertyTearOff<//;
6103 } elsif ($svgTypeNeedingTearOff =~ /SVGTransformListPropertyTearOff/) { 6067 } elsif ($svgTypeNeedingTearOff =~ /SVGTransformListPropertyTearOff/) {
6104 $svgTypeNeedingTearOff =~ s/SVGTransformListPropertyTearOff<//; 6068 $svgTypeNeedingTearOff =~ s/SVGTransformListPropertyTearOff<//;
6105 } elsif ($svgTypeNeedingTearOff =~ /SVGMatrixTearOff/) {
6106 $svgTypeNeedingTearOff = 'SVGMatrix';
6107 } 6069 }
6108 6070
6109 $svgTypeNeedingTearOff =~ s/>//; 6071 $svgTypeNeedingTearOff =~ s/>//;
6110 return $svgTypeNeedingTearOff; 6072 return $svgTypeNeedingTearOff;
6111 } 6073 }
6112 6074
6113 sub IsSVGAnimatedType 6075 sub IsSVGAnimatedType
6114 { 6076 {
6115 my $type = shift; 6077 my $type = shift;
6116 6078
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
6483 if ($parameter->type eq "SerializedScriptValue") { 6445 if ($parameter->type eq "SerializedScriptValue") {
6484 return 1; 6446 return 1;
6485 } elsif (IsIntegerType($parameter->type)) { 6447 } elsif (IsIntegerType($parameter->type)) {
6486 return 1; 6448 return 1;
6487 } 6449 }
6488 } 6450 }
6489 return 0; 6451 return 0;
6490 } 6452 }
6491 6453
6492 1; 6454 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698