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

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

Issue 16924018: [Binding] Remove signature from domAttribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rebased 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 | « no previous file | Source/bindings/scripts/IDLParser.pm » ('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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 if (IsConstructable($interface)) { 719 if (IsConstructable($interface)) {
720 $header{classPublic}->add(" static void constructorCallback(const v8: :FunctionCallbackInfo<v8::Value>&);\n"); 720 $header{classPublic}->add(" static void constructorCallback(const v8: :FunctionCallbackInfo<v8::Value>&);\n");
721 END 721 END
722 } 722 }
723 if (HasCustomConstructor($interface)) { 723 if (HasCustomConstructor($interface)) {
724 $header{classPublic}->add(" static void constructorCustom(const v8::F unctionCallbackInfo<v8::Value>&);\n"); 724 $header{classPublic}->add(" static void constructorCustom(const v8::F unctionCallbackInfo<v8::Value>&);\n");
725 } 725 }
726 726
727 my @enabledPerContextAttributes; 727 my @enabledPerContextAttributes;
728 foreach my $attribute (@{$interface->attributes}) { 728 foreach my $attribute (@{$interface->attributes}) {
729 my $name = $attribute->signature->name; 729 my $name = $attribute->name;
730 my $attrExt = $attribute->signature->extendedAttributes; 730 my $attrExt = $attribute->extendedAttributes;
731 my $conditionalString = GenerateConditionalString($attribute->signature) ; 731 my $conditionalString = GenerateConditionalString($attribute);
732 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { 732 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
733 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; 733 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString;
734 $header{classPublic}->add(<<END); 734 $header{classPublic}->add(<<END);
735 static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::Pr opertyCallbackInfo<v8::Value>&); 735 static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::Pr opertyCallbackInfo<v8::Value>&);
736 END 736 END
737 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString; 737 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString;
738 } 738 }
739 if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) { 739 if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
740 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; 740 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString;
741 $header{classPublic}->add(<<END); 741 $header{classPublic}->add(<<END);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1096
1097 sub HasCustomMethod 1097 sub HasCustomMethod
1098 { 1098 {
1099 my $attrExt = shift; 1099 my $attrExt = shift;
1100 return $attrExt->{"Custom"}; 1100 return $attrExt->{"Custom"};
1101 } 1101 }
1102 1102
1103 sub IsReadonly 1103 sub IsReadonly
1104 { 1104 {
1105 my $attribute = shift; 1105 my $attribute = shift;
1106 my $attrExt = $attribute->signature->extendedAttributes; 1106 my $attrExt = $attribute->extendedAttributes;
1107 return $attribute->isReadOnly && !$attrExt->{"Replaceable"}; 1107 return $attribute->isReadOnly && !$attrExt->{"Replaceable"};
1108 } 1108 }
1109 1109
1110 sub GetV8ClassName 1110 sub GetV8ClassName
1111 { 1111 {
1112 my $interface = shift; 1112 my $interface = shift;
1113 return "V8" . $interface->name; 1113 return "V8" . $interface->name;
1114 } 1114 }
1115 1115
1116 sub GetImplName 1116 sub GetImplName
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 } 1297 }
1298 1298
1299 sub GenerateNormalAttrGetterCallback 1299 sub GenerateNormalAttrGetterCallback
1300 { 1300 {
1301 my $attribute = shift; 1301 my $attribute = shift;
1302 my $interface = shift; 1302 my $interface = shift;
1303 my $forMainWorldSuffix = shift; 1303 my $forMainWorldSuffix = shift;
1304 1304
1305 my $implClassName = GetImplName($interface); 1305 my $implClassName = GetImplName($interface);
1306 my $v8ClassName = GetV8ClassName($interface); 1306 my $v8ClassName = GetV8ClassName($interface);
1307 my $attrExt = $attribute->signature->extendedAttributes; 1307 my $attrExt = $attribute->extendedAttributes;
1308 my $attrName = $attribute->signature->name; 1308 my $attrName = $attribute->name;
1309 1309
1310 my $conditionalString = GenerateConditionalString($attribute->signature); 1310 my $conditionalString = GenerateConditionalString($attribute);
1311 my $code = ""; 1311 my $code = "";
1312 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1312 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1313 1313
1314 $code .= "static void ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 1314 $code .= "static void ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
1315 $code .= "{\n"; 1315 $code .= "{\n";
1316 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); 1316 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
1317 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); 1317 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"});
1318 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { 1318 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) {
1319 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); 1319 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}");
1320 } 1320 }
(...skipping 10 matching lines...) Expand all
1331 1331
1332 sub GenerateNormalAttrGetter 1332 sub GenerateNormalAttrGetter
1333 { 1333 {
1334 my $attribute = shift; 1334 my $attribute = shift;
1335 my $interface = shift; 1335 my $interface = shift;
1336 my $forMainWorldSuffix = shift; 1336 my $forMainWorldSuffix = shift;
1337 1337
1338 my $interfaceName = $interface->name; 1338 my $interfaceName = $interface->name;
1339 my $implClassName = GetImplName($interface); 1339 my $implClassName = GetImplName($interface);
1340 my $v8ClassName = GetV8ClassName($interface); 1340 my $v8ClassName = GetV8ClassName($interface);
1341 my $attrExt = $attribute->signature->extendedAttributes; 1341 my $attrExt = $attribute->extendedAttributes;
1342 my $attrName = $attribute->signature->name; 1342 my $attrName = $attribute->name;
1343 my $attrType = $attribute->signature->type; 1343 my $attrType = $attribute->type;
1344 1344
1345 if (HasCustomGetter($attrExt)) { 1345 if (HasCustomGetter($attrExt)) {
1346 return; 1346 return;
1347 } 1347 }
1348 1348
1349 AssertNotSequenceType($attrType); 1349 AssertNotSequenceType($attrType);
1350 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; 1350 my $getterStringUsesImp = $interfaceName ne "SVGNumber";
1351 my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); 1351 my $nativeType = GetNativeTypeFromSignature($attribute, -1);
1352 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1352 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1353 1353
1354 my $conditionalString = GenerateConditionalString($attribute->signature); 1354 my $conditionalString = GenerateConditionalString($attribute);
1355 my $code = ""; 1355 my $code = "";
1356 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1356 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1357 $code .= <<END; 1357 $code .= <<END;
1358 static void ${attrName}AttrGetter${forMainWorldSuffix}(v8::Local<v8::String> nam e, const v8::PropertyCallbackInfo<v8::Value>& info) 1358 static void ${attrName}AttrGetter${forMainWorldSuffix}(v8::Local<v8::String> nam e, const v8::PropertyCallbackInfo<v8::Value>& info)
1359 { 1359 {
1360 END 1360 END
1361 if ($svgNativeType) { 1361 if ($svgNativeType) {
1362 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e); 1362 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e);
1363 if ($svgWrappedNativeType =~ /List/) { 1363 if ($svgWrappedNativeType =~ /List/) {
1364 $code .= <<END; 1364 $code .= <<END;
(...skipping 20 matching lines...) Expand all
1385 $code .= <<END; 1385 $code .= <<END;
1386 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 1386 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
1387 if (holder.IsEmpty()) 1387 if (holder.IsEmpty())
1388 return; 1388 return;
1389 END 1389 END
1390 } 1390 }
1391 $code .= <<END; 1391 $code .= <<END;
1392 ${implClassName}* imp = ${v8ClassName}::toNative(holder); 1392 ${implClassName}* imp = ${v8ClassName}::toNative(holder);
1393 END 1393 END
1394 } else { 1394 } else {
1395 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; 1395 my $reflect = $attribute->extendedAttributes->{"Reflect"};
1396 my $url = $attribute->signature->extendedAttributes->{"URL"}; 1396 my $url = $attribute->extendedAttributes->{"URL"};
1397 if ($getterStringUsesImp && $reflect && !$url && InheritsInterface($inte rface, "Node") && $attrType eq "DOMString") { 1397 if ($getterStringUsesImp && $reflect && !$url && InheritsInterface($inte rface, "Node") && $attrType eq "DOMString") {
1398 # Generate super-compact call for regular attribute getter: 1398 # Generate super-compact call for regular attribute getter:
1399 my ($functionName, @arguments) = GetterExpression($interfaceName, $a ttribute); 1399 my ($functionName, @arguments) = GetterExpression($interfaceName, $a ttribute);
1400 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; 1400 $code .= " Element* imp = V8Element::toNative(info.Holder());\n";
1401 $code .= " v8SetReturnValue(info, v8String(imp->${functionName}(" . join(", ", @arguments) . "), info.GetIsolate(), ReturnUnsafeHandle));\n"; 1401 $code .= " v8SetReturnValue(info, v8String(imp->${functionName}(" . join(", ", @arguments) . "), info.GetIsolate(), ReturnUnsafeHandle));\n";
1402 $code .= " return;\n"; 1402 $code .= " return;\n";
1403 $code .= "}\n\n"; 1403 $code .= "}\n\n";
1404 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1404 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1405 $implementation{nameSpaceInternal}->add($code); 1405 $implementation{nameSpaceInternal}->add($code);
1406 return; 1406 return;
1407 # Skip the rest of the function! 1407 # Skip the rest of the function!
1408 } 1408 }
1409 if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt-> {"CachedAttribute"}) { 1409 if ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAtt ribute"}) {
1410 $code .= <<END; 1410 $code .= <<END;
1411 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); 1411 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}");
1412 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); 1412 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName);
1413 if (!value.IsEmpty()) { 1413 if (!value.IsEmpty()) {
1414 v8SetReturnValue(info, value); 1414 v8SetReturnValue(info, value);
1415 return; 1415 return;
1416 } 1416 }
1417 END 1417 END
1418 } 1418 }
1419 if (!$attribute->isStatic) { 1419 if (!$attribute->isStatic) {
1420 $code .= <<END; 1420 $code .= <<END;
1421 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1421 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1422 END 1422 END
1423 } 1423 }
1424 } 1424 }
1425 1425
1426 # Generate security checks if necessary 1426 # Generate security checks if necessary
1427 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { 1427 if ($attribute->extendedAttributes->{"CheckSecurityForNode"}) {
1428 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1428 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1429 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute->signature) . "())) {\n"; 1429 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n";
1430 $code .= " v8SetReturnValueNull(info);\n"; 1430 $code .= " v8SetReturnValueNull(info);\n";
1431 $code .= " return;\n"; 1431 $code .= " return;\n";
1432 $code .= " }\n"; 1432 $code .= " }\n";
1433 } 1433 }
1434 1434
1435 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Getter RaisesException"} || $attribute->signature->extendedAttributes->{"RaisesExcepti on"}; 1435 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1436 my $isNullable = $attribute->signature->isNullable; 1436 my $isNullable = $attribute->isNullable;
1437 if ($useExceptions) { 1437 if ($useExceptions) {
1438 AddToImplIncludes("core/dom/ExceptionCode.h"); 1438 AddToImplIncludes("core/dom/ExceptionCode.h");
1439 $code .= " ExceptionCode ec = 0;\n"; 1439 $code .= " ExceptionCode ec = 0;\n";
1440 } 1440 }
1441 1441
1442 if ($isNullable) { 1442 if ($isNullable) {
1443 $code .= " bool isNull = false;\n"; 1443 $code .= " bool isNull = false;\n";
1444 } 1444 }
1445 1445
1446 my $returnType = $attribute->signature->type; 1446 my $returnType = $attribute->type;
1447 my $getterString; 1447 my $getterString;
1448 1448
1449 if ($getterStringUsesImp) { 1449 if ($getterStringUsesImp) {
1450 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute); 1450 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute);
1451 push(@arguments, "isNull") if $isNullable; 1451 push(@arguments, "isNull") if $isNullable;
1452 push(@arguments, "ec") if $useExceptions; 1452 push(@arguments, "ec") if $useExceptions;
1453 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { 1453 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1454 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"}; 1454 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" };
1455 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 1455 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
1456 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 1456 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
1457 unshift(@arguments, "imp") if !$attribute->isStatic; 1457 unshift(@arguments, "imp") if !$attribute->isStatic;
1458 $functionName = "${implementedByImplName}::${functionName}"; 1458 $functionName = "${implementedByImplName}::${functionName}";
1459 } elsif ($attribute->isStatic) { 1459 } elsif ($attribute->isStatic) {
1460 $functionName = "${implClassName}::${functionName}"; 1460 $functionName = "${implClassName}::${functionName}";
1461 } else { 1461 } else {
1462 $functionName = "imp->${functionName}"; 1462 $functionName = "imp->${functionName}";
1463 } 1463 }
1464 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt tributes->{"CallWith"}, " ", 0); 1464 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{ "CallWith"}, " ", 0);
1465 $code .= $subCode; 1465 $code .= $subCode;
1466 unshift(@arguments, @$arg); 1466 unshift(@arguments, @$arg);
1467 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; 1467 $getterString = "${functionName}(" . join(", ", @arguments) . ")";
1468 } else { 1468 } else {
1469 $getterString = "impInstance"; 1469 $getterString = "impInstance";
1470 } 1470 }
1471 1471
1472 my $expression; 1472 my $expression;
1473 if ($attribute->signature->type eq "EventListener" && $interface->name eq "W indow") { 1473 if ($attribute->type eq "EventListener" && $interface->name eq "Window") {
1474 $code .= " if (!imp->document())\n"; 1474 $code .= " if (!imp->document())\n";
1475 $code .= " return;\n"; 1475 $code .= " return;\n";
1476 } 1476 }
1477 1477
1478 if ($useExceptions || $isNullable) { 1478 if ($useExceptions || $isNullable) {
1479 if ($nativeType =~ /^V8StringResource/) { 1479 if ($nativeType =~ /^V8StringResource/) {
1480 $code .= " " . ConvertToV8StringResource($attribute->signature, $ nativeType, "v", $getterString) . ";\n"; 1480 $code .= " " . ConvertToV8StringResource($attribute, $nativeType, "v", $getterString) . ";\n";
1481 } else { 1481 } else {
1482 $code .= " $nativeType v = $getterString;\n"; 1482 $code .= " $nativeType v = $getterString;\n";
1483 } 1483 }
1484 1484
1485 if ($isNullable) { 1485 if ($isNullable) {
1486 $code .= " if (isNull) {\n"; 1486 $code .= " if (isNull) {\n";
1487 $code .= " v8SetReturnValueNull(info);\n"; 1487 $code .= " v8SetReturnValueNull(info);\n";
1488 $code .= " return;\n"; 1488 $code .= " return;\n";
1489 $code .= " }\n"; 1489 $code .= " }\n";
1490 } 1490 }
1491 1491
1492 if ($useExceptions) { 1492 if ($useExceptions) {
1493 $code .= " if (UNLIKELY(ec)) {\n"; 1493 $code .= " if (UNLIKELY(ec)) {\n";
1494 $code .= " setDOMException(ec, info.GetIsolate());\n"; 1494 $code .= " setDOMException(ec, info.GetIsolate());\n";
1495 $code .= " return;\n"; 1495 $code .= " return;\n";
1496 $code .= " };\n"; 1496 $code .= " };\n";
1497 1497
1498 if (ExtendedAttributeContains($attribute->signature->extendedAttribu tes->{"CallWith"}, "ScriptState")) { 1498 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) {
1499 $code .= " if (state.hadException()) {\n"; 1499 $code .= " if (state.hadException()) {\n";
1500 $code .= " throwError(state.exception(), info.GetIsolate( ));\n"; 1500 $code .= " throwError(state.exception(), info.GetIsolate( ));\n";
1501 $code .= " return;\n"; 1501 $code .= " return;\n";
1502 $code .= " }\n"; 1502 $code .= " }\n";
1503 } 1503 }
1504 } 1504 }
1505 1505
1506 $expression = "v"; 1506 $expression = "v";
1507 $expression .= ".release()" if (IsRefPtrType($returnType)); 1507 $expression .= ".release()" if (IsRefPtrType($returnType));
1508 } else { 1508 } else {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 AddToImplIncludes("V8$attrType.h"); 1551 AddToImplIncludes("V8$attrType.h");
1552 my $svgNativeType = GetSVGTypeNeedingTearOff($attrType); 1552 my $svgNativeType = GetSVGTypeNeedingTearOff($attrType);
1553 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked. 1553 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked.
1554 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix(static_ cast<$svgNativeType*>($expression), info, imp));\n"; 1554 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix(static_ cast<$svgNativeType*>($expression), info, imp));\n";
1555 $code .= " return;\n"; 1555 $code .= " return;\n";
1556 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$ /) { 1556 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$ /) {
1557 AddToImplIncludes("V8$attrType.h"); 1557 AddToImplIncludes("V8$attrType.h");
1558 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); 1558 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h");
1559 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); 1559 my $tearOffType = GetSVGTypeNeedingTearOff($attrType);
1560 my $wrappedValue; 1560 my $wrappedValue;
1561 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def ined $attribute->signature->extendedAttributes->{"Immutable"}) { 1561 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def ined $attribute->extendedAttributes->{"Immutable"}) {
1562 my $getter = $expression; 1562 my $getter = $expression;
1563 $getter =~ s/imp->//; 1563 $getter =~ s/imp->//;
1564 $getter =~ s/\(\)//; 1564 $getter =~ s/\(\)//;
1565 1565
1566 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC ase($getter); 1566 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC ase($getter);
1567 1567
1568 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName); 1568 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName);
1569 if ($selfIsTearOffType) { 1569 if ($selfIsTearOffType) {
1570 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare ntTearOff.h"); 1570 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare ntTearOff.h");
1571 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen tTearOff<$implClassName, /; 1571 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen tTearOff<$implClassName, /;
(...skipping 13 matching lines...) Expand all
1585 } 1585 }
1586 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { 1586 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) {
1587 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres sion))"; 1587 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres sion))";
1588 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { 1588 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) {
1589 $wrappedValue = "WTF::getPtr($expression)"; 1589 $wrappedValue = "WTF::getPtr($expression)";
1590 } else { 1590 } else {
1591 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression) )"; 1591 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression) )";
1592 } 1592 }
1593 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix($wrappe dValue, info, imp));\n"; 1593 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix($wrappe dValue, info, imp));\n";
1594 $code .= " return;\n"; 1594 $code .= " return;\n";
1595 } elsif ($attribute->signature->type eq "SerializedScriptValue" && $attrExt- >{"CachedAttribute"}) { 1595 } elsif ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAt tribute"}) {
1596 my $getterFunc = ToMethodName($attribute->signature->name); 1596 my $getterFunc = ToMethodName($attribute->name);
1597 $code .= <<END; 1597 $code .= <<END;
1598 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); 1598 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}();
1599 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Nul l(info.GetIsolate())); 1599 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Nul l(info.GetIsolate()));
1600 info.Holder()->SetHiddenValue(propertyName, value); 1600 info.Holder()->SetHiddenValue(propertyName, value);
1601 v8SetReturnValue(info, value); 1601 v8SetReturnValue(info, value);
1602 return; 1602 return;
1603 END 1603 END
1604 } elsif ($attribute->signature->type eq "EventListener") { 1604 } elsif ($attribute->type eq "EventListener") {
1605 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1605 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1606 my $getterFunc = ToMethodName($attribute->signature->name); 1606 my $getterFunc = ToMethodName($attribute->name);
1607 # FIXME: Pass the main world ID for main-world-only getters. 1607 # FIXME: Pass the main world ID for main-world-only getters.
1608 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld ForIsolate(info.GetIsolate()));\n"; 1608 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld ForIsolate(info.GetIsolate()));\n";
1609 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8 AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon text())) : v8::Handle<v8::Value>(v8Null(info.GetIsolate())));\n"; 1609 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8 AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon text())) : v8::Handle<v8::Value>(v8Null(info.GetIsolate())));\n";
1610 $code .= " return;\n"; 1610 $code .= " return;\n";
1611 } else { 1611 } else {
1612 my $nativeValue = NativeToJSValue($attribute->signature->type, $attribut e->signature->extendedAttributes, $expression, " ", "", "info.Holder()", "inf o.GetIsolate()", "info", "imp", "ReturnUnsafeHandle", $forMainWorldSuffix, "retu rn"); 1612 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", "ReturnUnsafeHandle", $forMainWorldSuffix, "return");
1613 $code .= "${nativeValue}\n"; 1613 $code .= "${nativeValue}\n";
1614 $code .= " return;\n"; 1614 $code .= " return;\n";
1615 } 1615 }
1616 1616
1617 $code .= "}\n\n"; # end of getter 1617 $code .= "}\n\n"; # end of getter
1618 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1618 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1619 $implementation{nameSpaceInternal}->add($code); 1619 $implementation{nameSpaceInternal}->add($code);
1620 } 1620 }
1621 1621
1622 sub ShouldKeepAttributeAlive 1622 sub ShouldKeepAttributeAlive
1623 { 1623 {
1624 my ($interface, $attribute, $returnType) = @_; 1624 my ($interface, $attribute, $returnType) = @_;
1625 my $attrName = $attribute->signature->name; 1625 my $attrName = $attribute->name;
1626 1626
1627 return 1 if $attribute->signature->extendedAttributes->{"KeepAttributeAliveF orGC"}; 1627 return 1 if $attribute->extendedAttributes->{"KeepAttributeAliveForGC"};
1628 1628
1629 # Basically, for readonly or replaceable attributes, we have to guarantee 1629 # Basically, for readonly or replaceable attributes, we have to guarantee
1630 # that JS wrappers don't get garbage-collected prematually when their 1630 # that JS wrappers don't get garbage-collected prematually when their
1631 # lifetime is strongly tied to their owner. 1631 # lifetime is strongly tied to their owner.
1632 return 0 if !IsWrapperType($returnType); 1632 return 0 if !IsWrapperType($returnType);
1633 return 0 if !IsReadonly($attribute) && !$attribute->signature->extendedAttri butes->{"Replaceable"}; 1633 return 0 if !IsReadonly($attribute) && !$attribute->extendedAttributes->{"Re placeable"};
1634 1634
1635 # However, there are a couple of exceptions. 1635 # However, there are a couple of exceptions.
1636 1636
1637 # Node lifetime is managed by object grouping. 1637 # Node lifetime is managed by object grouping.
1638 return 0 if InheritsInterface($interface, "Node"); 1638 return 0 if InheritsInterface($interface, "Node");
1639 return 0 if IsDOMNodeType($returnType); 1639 return 0 if IsDOMNodeType($returnType);
1640 1640
1641 # To avoid adding a reference to itself. 1641 # To avoid adding a reference to itself.
1642 # FIXME: Introduce [DoNotKeepAttributeAliveForGC] and remove this hack 1642 # FIXME: Introduce [DoNotKeepAttributeAliveForGC] and remove this hack
1643 # depending on the attribute name. 1643 # depending on the attribute name.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 } 1720 }
1721 1721
1722 sub GenerateNormalAttrSetterCallback 1722 sub GenerateNormalAttrSetterCallback
1723 { 1723 {
1724 my $attribute = shift; 1724 my $attribute = shift;
1725 my $interface = shift; 1725 my $interface = shift;
1726 my $forMainWorldSuffix = shift; 1726 my $forMainWorldSuffix = shift;
1727 1727
1728 my $implClassName = GetImplName($interface); 1728 my $implClassName = GetImplName($interface);
1729 my $v8ClassName = GetV8ClassName($interface); 1729 my $v8ClassName = GetV8ClassName($interface);
1730 my $attrExt = $attribute->signature->extendedAttributes; 1730 my $attrExt = $attribute->extendedAttributes;
1731 my $attrName = $attribute->signature->name; 1731 my $attrName = $attribute->name;
1732 1732
1733 my $conditionalString = GenerateConditionalString($attribute->signature); 1733 my $conditionalString = GenerateConditionalString($attribute);
1734 my $code = ""; 1734 my $code = "";
1735 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1735 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1736 1736
1737 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackI nfo<void>& info)\n"; 1737 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackI nfo<void>& info)\n";
1738 $code .= "{\n"; 1738 $code .= "{\n";
1739 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); 1739 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
1740 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); 1740 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"});
1741 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { 1741 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) {
1742 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); 1742 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}");
1743 } 1743 }
1744 if (HasCustomSetter($attrExt)) { 1744 if (HasCustomSetter($attrExt)) {
1745 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i nfo);\n"; 1745 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i nfo);\n";
1746 } else { 1746 } else {
1747 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain WorldSuffix}(name, value, info);\n"; 1747 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain WorldSuffix}(name, value, info);\n";
1748 } 1748 }
1749 $code .= "}\n\n"; 1749 $code .= "}\n\n";
1750 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1750 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1751 $implementation{nameSpaceInternal}->add($code); 1751 $implementation{nameSpaceInternal}->add($code);
1752 } 1752 }
1753 1753
1754 sub GenerateNormalAttrSetter 1754 sub GenerateNormalAttrSetter
1755 { 1755 {
1756 my $attribute = shift; 1756 my $attribute = shift;
1757 my $interface = shift; 1757 my $interface = shift;
1758 my $forMainWorldSuffix = shift; 1758 my $forMainWorldSuffix = shift;
1759 1759
1760 my $interfaceName = $interface->name; 1760 my $interfaceName = $interface->name;
1761 my $implClassName = GetImplName($interface); 1761 my $implClassName = GetImplName($interface);
1762 my $v8ClassName = GetV8ClassName($interface); 1762 my $v8ClassName = GetV8ClassName($interface);
1763 my $attrName = $attribute->signature->name; 1763 my $attrName = $attribute->name;
1764 my $attrExt = $attribute->signature->extendedAttributes; 1764 my $attrExt = $attribute->extendedAttributes;
1765 my $attrType = $attribute->signature->type; 1765 my $attrType = $attribute->type;
1766 1766
1767 if (HasCustomSetter($attrExt)) { 1767 if (HasCustomSetter($attrExt)) {
1768 return; 1768 return;
1769 } 1769 }
1770 1770
1771 my $conditionalString = GenerateConditionalString($attribute->signature); 1771 my $conditionalString = GenerateConditionalString($attribute);
1772 my $code = ""; 1772 my $code = "";
1773 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1773 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1774 $code .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v 8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void >& info)\n"; 1774 $code .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v 8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void >& info)\n";
1775 $code .= "{\n"; 1775 $code .= "{\n";
1776 1776
1777 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an 1777 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an
1778 # interface type, then if the incoming value does not implement that interfa ce, a TypeError is 1778 # interface type, then if the incoming value does not implement that interfa ce, a TypeError is
1779 # thrown rather than silently passing NULL to the C++ code. 1779 # thrown rather than silently passing NULL to the C++ code.
1780 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both 1780 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both
1781 # strings and numbers, so do not throw TypeError if the attribute is of thes e types. 1781 # strings and numbers, so do not throw TypeError if the attribute is of thes e types.
1782 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { 1782 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) {
1783 my $argType = $attribute->signature->type; 1783 my $argType = $attribute->type;
1784 if (IsWrapperType($argType)) { 1784 if (IsWrapperType($argType)) {
1785 $code .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; 1785 $code .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n";
1786 $code .= " throwTypeError(0, info.GetIsolate());\n"; 1786 $code .= " throwTypeError(0, info.GetIsolate());\n";
1787 $code .= " return;\n"; 1787 $code .= " return;\n";
1788 $code .= " }\n"; 1788 $code .= " }\n";
1789 } 1789 }
1790 } 1790 }
1791 1791
1792 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1792 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1793 if ($svgNativeType) { 1793 if ($svgNativeType) {
(...skipping 10 matching lines...) Expand all
1804 $code .= " return;\n"; 1804 $code .= " return;\n";
1805 $code .= " }\n"; 1805 $code .= " }\n";
1806 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 1806 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
1807 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 1807 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
1808 } 1808 }
1809 } elsif ($attrExt->{"OnProto"}) { 1809 } elsif ($attrExt->{"OnProto"}) {
1810 $code .= <<END; 1810 $code .= <<END;
1811 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1811 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1812 END 1812 END
1813 } else { 1813 } else {
1814 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; 1814 my $reflect = $attribute->extendedAttributes->{"Reflect"};
1815 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D OMString") { 1815 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D OMString") {
1816 # Generate super-compact call for regular attribute setter: 1816 # Generate super-compact call for regular attribute setter:
1817 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr Name : $reflect; 1817 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr Name : $reflect;
1818 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt tributeName); 1818 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt tributeName);
1819 AddToImplIncludes("${namespace}.h"); 1819 AddToImplIncludes("${namespace}.h");
1820 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; 1820 $code .= " Element* imp = V8Element::toNative(info.Holder());\n";
1821 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource< WithNullCheck>, stringResource, value);\n"; 1821 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource< WithNullCheck>, stringResource, value);\n";
1822 $code .= " imp->setAttribute(${namespace}::${contentAttributeName }Attr, stringResource);\n"; 1822 $code .= " imp->setAttribute(${namespace}::${contentAttributeName }Attr, stringResource);\n";
1823 $code .= "}\n\n"; 1823 $code .= "}\n\n";
1824 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1824 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1825 $implementation{nameSpaceInternal}->add($code); 1825 $implementation{nameSpaceInternal}->add($code);
1826 return; 1826 return;
1827 # Skip the rest of the function! 1827 # Skip the rest of the function!
1828 } 1828 }
1829 1829
1830 if (!$attribute->isStatic) { 1830 if (!$attribute->isStatic) {
1831 $code .= <<END; 1831 $code .= <<END;
1832 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1832 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1833 END 1833 END
1834 } 1834 }
1835 } 1835 }
1836 1836
1837 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); 1837 my $nativeType = GetNativeTypeFromSignature($attribute, 0);
1838 if ($attribute->signature->type eq "EventListener") { 1838 if ($attribute->type eq "EventListener") {
1839 if ($interface->name eq "Window") { 1839 if ($interface->name eq "Window") {
1840 $code .= " if (!imp->document())\n"; 1840 $code .= " if (!imp->document())\n";
1841 $code .= " return;\n"; 1841 $code .= " return;\n";
1842 } 1842 }
1843 } else { 1843 } else {
1844 my $value = JSValueToNative($attribute->signature->type, $attribute->sig nature->extendedAttributes, "value", "info.GetIsolate()"); 1844 my $value = JSValueToNative($attribute->type, $attribute->extendedAttrib utes, "value", "info.GetIsolate()");
1845 my $arrayType = GetArrayType($nativeType); 1845 my $arrayType = GetArrayType($nativeType);
1846 1846
1847 if ($nativeType =~ /^V8StringResource/) { 1847 if ($nativeType =~ /^V8StringResource/) {
1848 $code .= " " . ConvertToV8StringResource($attribute->signature, $ nativeType, "v", $value) . "\n"; 1848 $code .= " " . ConvertToV8StringResource($attribute, $nativeType, "v", $value) . "\n";
1849 } elsif ($arrayType) { 1849 } elsif ($arrayType) {
1850 $code .= " Vector<$arrayType> v = $value;\n"; 1850 $code .= " Vector<$arrayType> v = $value;\n";
1851 } elsif ($attribute->signature->extendedAttributes->{"EnforceRange"}) { 1851 } elsif ($attribute->extendedAttributes->{"EnforceRange"}) {
1852 $code .= " V8TRYCATCH_WITH_TYPECHECK_VOID($nativeType, v, $value, info.GetIsolate());\n"; 1852 $code .= " V8TRYCATCH_WITH_TYPECHECK_VOID($nativeType, v, $value, info.GetIsolate());\n";
1853 } else { 1853 } else {
1854 $code .= " V8TRYCATCH_VOID($nativeType, v, $value);\n"; 1854 $code .= " V8TRYCATCH_VOID($nativeType, v, $value);\n";
1855 } 1855 }
1856 } 1856 }
1857 1857
1858 if (IsEnumType($attrType)) { 1858 if (IsEnumType($attrType)) {
1859 # setter ignores invalid enumeration values 1859 # setter ignores invalid enumeration values
1860 my @enumValues = ValidEnumValues($attrType); 1860 my @enumValues = ValidEnumValues($attrType);
1861 my @validEqualities = (); 1861 my @validEqualities = ();
1862 foreach my $enumValue (@enumValues) { 1862 foreach my $enumValue (@enumValues) {
1863 push(@validEqualities, "string == \"$enumValue\""); 1863 push(@validEqualities, "string == \"$enumValue\"");
1864 } 1864 }
1865 my $enumValidationExpression = join(" || ", @validEqualities); 1865 my $enumValidationExpression = join(" || ", @validEqualities);
1866 $code .= <<END; 1866 $code .= <<END;
1867 String string = v; 1867 String string = v;
1868 if (!($enumValidationExpression)) 1868 if (!($enumValidationExpression))
1869 return; 1869 return;
1870 END 1870 END
1871 } 1871 }
1872 1872
1873 my $expression = "v"; 1873 my $expression = "v";
1874 my $returnType = $attribute->signature->type; 1874 my $returnType = $attribute->type;
1875 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { 1875 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) {
1876 $expression = "WTF::getPtr(" . $expression . ")"; 1876 $expression = "WTF::getPtr(" . $expression . ")";
1877 } 1877 }
1878 1878
1879 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->signature- >extendedAttributes); 1879 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes);
1880 1880
1881 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Setter RaisesException"} || $attribute->signature->extendedAttributes->{"RaisesExcepti on"}; 1881 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1882 1882
1883 if ($useExceptions) { 1883 if ($useExceptions) {
1884 AddToImplIncludes("core/dom/ExceptionCode.h"); 1884 AddToImplIncludes("core/dom/ExceptionCode.h");
1885 $code .= " ExceptionCode ec = 0;\n"; 1885 $code .= " ExceptionCode ec = 0;\n";
1886 } 1886 }
1887 1887
1888 if ($interfaceName eq "SVGNumber") { 1888 if ($interfaceName eq "SVGNumber") {
1889 $code .= " *imp = $expression;\n"; 1889 $code .= " *imp = $expression;\n";
1890 } else { 1890 } else {
1891 if ($attribute->signature->type eq "EventListener") { 1891 if ($attribute->type eq "EventListener") {
1892 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); 1892 my $implSetterFunctionName = FirstLetterToUpperCase($attrName);
1893 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1893 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1894 if (!InheritsInterface($interface, "Node")) { 1894 if (!InheritsInterface($interface, "Node")) {
1895 my $attrImplName = GetImplName($attribute->signature); 1895 my $attrImplName = GetImplName($attribute);
1896 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e ventListenerCacheIndex, info.GetIsolate());\n"; 1896 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e ventListenerCacheIndex, info.GetIsolate());\n";
1897 } 1897 }
1898 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 1898 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
1899 if (($interfaceName eq "Window" or $interfaceName eq "WorkerContext" ) and $attribute->signature->name eq "onerror") { 1899 if (($interfaceName eq "Window" or $interfaceName eq "WorkerContext" ) and $attribute->name eq "onerror") {
1900 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); 1900 AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
1901 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf o.GetIsolate()));\n"; 1901 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf o.GetIsolate()));\n";
1902 } else { 1902 } else {
1903 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate( info.GetIsolate()));\n"; 1903 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate( info.GetIsolate()));\n";
1904 } 1904 }
1905 } else { 1905 } else {
1906 my ($functionName, @arguments) = SetterExpression($interfaceName, $a ttribute); 1906 my ($functionName, @arguments) = SetterExpression($interfaceName, $a ttribute);
1907 push(@arguments, $expression); 1907 push(@arguments, $expression);
1908 push(@arguments, "ec") if $useExceptions; 1908 push(@arguments, "ec") if $useExceptions;
1909 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { 1909 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1910 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"}; 1910 my $implementedBy = $attribute->extendedAttributes->{"Implemente dBy"};
1911 my $implementedByImplName = GetImplNameFromImplementedBy($implem entedBy); 1911 my $implementedByImplName = GetImplNameFromImplementedBy($implem entedBy);
1912 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple mentedByImplName)); 1912 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple mentedByImplName));
1913 unshift(@arguments, "imp") if !$attribute->isStatic; 1913 unshift(@arguments, "imp") if !$attribute->isStatic;
1914 $functionName = "${implementedByImplName}::${functionName}"; 1914 $functionName = "${implementedByImplName}::${functionName}";
1915 } elsif ($attribute->isStatic) { 1915 } elsif ($attribute->isStatic) {
1916 $functionName = "${implClassName}::${functionName}"; 1916 $functionName = "${implClassName}::${functionName}";
1917 } else { 1917 } else {
1918 $functionName = "imp->${functionName}"; 1918 $functionName = "imp->${functionName}";
1919 } 1919 }
1920 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend edAttributes->{"SetterCallWith"} || $attribute->signature->extendedAttributes->{ "CallWith"}, " ", 1); 1920 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttribute s->{"SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1 );
1921 $code .= $subCode; 1921 $code .= $subCode;
1922 unshift(@arguments, @$arg); 1922 unshift(@arguments, @$arg);
1923 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 1923 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
1924 } 1924 }
1925 } 1925 }
1926 1926
1927 if ($useExceptions) { 1927 if ($useExceptions) {
1928 $code .= " if (UNLIKELY(ec))\n"; 1928 $code .= " if (UNLIKELY(ec))\n";
1929 $code .= " setDOMException(ec, info.GetIsolate());\n"; 1929 $code .= " setDOMException(ec, info.GetIsolate());\n";
1930 } 1930 }
1931 1931
1932 if (ExtendedAttributeContains($attribute->signature->extendedAttributes->{"C allWith"}, "ScriptState")) { 1932 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) {
1933 $code .= " if (state.hadException())\n"; 1933 $code .= " if (state.hadException())\n";
1934 $code .= " throwError(state.exception(), info.GetIsolate());\n"; 1934 $code .= " throwError(state.exception(), info.GetIsolate());\n";
1935 } 1935 }
1936 1936
1937 if ($svgNativeType) { 1937 if ($svgNativeType) {
1938 if ($useExceptions) { 1938 if ($useExceptions) {
1939 $code .= " if (!ec)\n"; 1939 $code .= " if (!ec)\n";
1940 $code .= " wrapper->commitChange();\n"; 1940 $code .= " wrapper->commitChange();\n";
1941 } else { 1941 } else {
1942 $code .= " wrapper->commitChange();\n"; 1942 $code .= " wrapper->commitChange();\n";
1943 } 1943 }
1944 } 1944 }
1945 1945
1946 if ($attribute->signature->type eq "SerializedScriptValue" && $attribute->si gnature->extendedAttributes->{"CachedAttribute"}) { 1946 if ($attribute->type eq "SerializedScriptValue" && $attribute->extendedAttri butes->{"CachedAttribute"}) {
1947 $code .= <<END; 1947 $code .= <<END;
1948 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value. 1948 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value.
1949 END 1949 END
1950 } 1950 }
1951 1951
1952 $code .= " return;\n"; 1952 $code .= " return;\n";
1953 $code .= "}\n\n"; # end of setter 1953 $code .= "}\n\n"; # end of setter
1954 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1954 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1955 $implementation{nameSpaceInternal}->add($code); 1955 $implementation{nameSpaceInternal}->add($code);
1956 } 1956 }
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2695 foreach my $interfaceBase (@{$interface->parents}) { 2695 foreach my $interfaceBase (@{$interface->parents}) {
2696 $code .= <<END; 2696 $code .= <<END;
2697 if (!fill${interfaceBase}Init(eventInit, options)) 2697 if (!fill${interfaceBase}Init(eventInit, options))
2698 return false; 2698 return false;
2699 2699
2700 END 2700 END
2701 } 2701 }
2702 2702
2703 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 2703 for (my $index = 0; $index < @{$interface->attributes}; $index++) {
2704 my $attribute = @{$interface->attributes}[$index]; 2704 my $attribute = @{$interface->attributes}[$index];
2705 if ($attribute->signature->extendedAttributes->{"InitializedByEventConst ructor"}) { 2705 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) {
2706 my $attributeName = $attribute->signature->name; 2706 my $attributeName = $attribute->name;
2707 $code .= " options.get(\"$attributeName\", eventInit.$attributeNa me);\n"; 2707 $code .= " options.get(\"$attributeName\", eventInit.$attributeNa me);\n";
2708 } 2708 }
2709 } 2709 }
2710 2710
2711 $code .= <<END; 2711 $code .= <<END;
2712 return true; 2712 return true;
2713 } 2713 }
2714 2714
2715 END 2715 END
2716 $implementation{nameSpaceWebCore}->add($code); 2716 $implementation{nameSpaceWebCore}->add($code);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2883 return $content; 2883 return $content;
2884 } 2884 }
2885 2885
2886 sub GenerateBatchedAttributeData 2886 sub GenerateBatchedAttributeData
2887 { 2887 {
2888 my $interface = shift; 2888 my $interface = shift;
2889 my $attributes = shift; 2889 my $attributes = shift;
2890 my $code = ""; 2890 my $code = "";
2891 2891
2892 foreach my $attribute (@$attributes) { 2892 foreach my $attribute (@$attributes) {
2893 my $conditionalString = GenerateConditionalString($attribute->signature) ; 2893 my $conditionalString = GenerateConditionalString($attribute);
2894 my $subCode = ""; 2894 my $subCode = "";
2895 $subCode .= "#if ${conditionalString}\n" if $conditionalString; 2895 $subCode .= "#if ${conditionalString}\n" if $conditionalString;
2896 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",", ""); 2896 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",", "");
2897 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; 2897 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString;
2898 $code .= $subCode; 2898 $code .= $subCode;
2899 } 2899 }
2900 return $code; 2900 return $code;
2901 } 2901 }
2902 2902
2903 sub GenerateSingleBatchedAttribute 2903 sub GenerateSingleBatchedAttribute
2904 { 2904 {
2905 my $interface = shift; 2905 my $interface = shift;
2906 my $attribute = shift; 2906 my $attribute = shift;
2907 my $delimiter = shift; 2907 my $delimiter = shift;
2908 my $indent = shift; 2908 my $indent = shift;
2909 my $code = ""; 2909 my $code = "";
2910 my $attrName = $attribute->signature->name; 2910 my $attrName = $attribute->name;
2911 my $attrExt = $attribute->signature->extendedAttributes; 2911 my $attrExt = $attribute->extendedAttributes;
2912 my $implClassName = GetImplName($interface); 2912 my $implClassName = GetImplName($interface);
2913 2913
2914 my $accessControl = "v8::DEFAULT"; 2914 my $accessControl = "v8::DEFAULT";
2915 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { 2915 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) {
2916 $accessControl = "v8::ALL_CAN_READ"; 2916 $accessControl = "v8::ALL_CAN_READ";
2917 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { 2917 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) {
2918 $accessControl = "v8::ALL_CAN_WRITE"; 2918 $accessControl = "v8::ALL_CAN_WRITE";
2919 } elsif ($attrExt->{"DoNotCheckSecurity"}) { 2919 } elsif ($attrExt->{"DoNotCheckSecurity"}) {
2920 $accessControl = "v8::ALL_CAN_READ"; 2920 $accessControl = "v8::ALL_CAN_READ";
2921 if (!IsReadonly($attribute)) { 2921 if (!IsReadonly($attribute)) {
(...skipping 10 matching lines...) Expand all
2932 # use the naming convension, interface + (capitalize) attr name 2932 # use the naming convension, interface + (capitalize) attr name
2933 $customAccessor = $implClassName . "::" . $attrName; 2933 $customAccessor = $implClassName . "::" . $attrName;
2934 } 2934 }
2935 2935
2936 my $getter; 2936 my $getter;
2937 my $setter; 2937 my $setter;
2938 my $getterForMainWorld; 2938 my $getterForMainWorld;
2939 my $setterForMainWorld; 2939 my $setterForMainWorld;
2940 my $propAttr = "v8::None"; 2940 my $propAttr = "v8::None";
2941 2941
2942 my $isConstructor = ($attribute->signature->type =~ /Constructor$/); 2942 my $isConstructor = ($attribute->type =~ /Constructor$/);
2943 2943
2944 # Check attributes. 2944 # Check attributes.
2945 # As per Web IDL specification, constructor properties on the ECMAScript glo bal object should be 2945 # As per Web IDL specification, constructor properties on the ECMAScript glo bal object should be
2946 # configurable and should not be enumerable. 2946 # configurable and should not be enumerable.
2947 if ($attrExt->{"NotEnumerable"} || $isConstructor) { 2947 if ($attrExt->{"NotEnumerable"} || $isConstructor) {
2948 $propAttr .= " | v8::DontEnum"; 2948 $propAttr .= " | v8::DontEnum";
2949 } 2949 }
2950 if ($attrExt->{"Unforgeable"} && !$isConstructor) { 2950 if ($attrExt->{"Unforgeable"} && !$isConstructor) {
2951 $propAttr .= " | v8::DontDelete"; 2951 $propAttr .= " | v8::DontDelete";
2952 } 2952 }
2953 2953
2954 my $on_proto = "0 /* on instance */"; 2954 my $on_proto = "0 /* on instance */";
2955 my $data = "0 /* no data */"; 2955 my $data = "0 /* no data */";
2956 2956
2957 # Constructor 2957 # Constructor
2958 if ($isConstructor) { 2958 if ($isConstructor) {
2959 my $constructorType = $attribute->signature->type; 2959 my $constructorType = $attribute->type;
2960 $constructorType =~ s/Constructor$//; 2960 $constructorType =~ s/Constructor$//;
2961 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct or. 2961 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct or.
2962 # We do not generate the header file for NamedConstructor of class XXXX, 2962 # We do not generate the header file for NamedConstructor of class XXXX,
2963 # since we generate the NamedConstructor declaration into the header fil e of class XXXX. 2963 # since we generate the NamedConstructor declaration into the header fil e of class XXXX.
2964 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende dAttributes->{"CustomConstructor"}) { 2964 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes ->{"CustomConstructor"}) {
2965 AddToImplIncludes("V8${constructorType}.h"); 2965 AddToImplIncludes("V8${constructorType}.h");
2966 } 2966 }
2967 $data = "&V8${constructorType}::info"; 2967 $data = "&V8${constructorType}::info";
2968 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter "; 2968 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter ";
2969 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrSe tterCallback"; 2969 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrSe tterCallback";
2970 $getterForMainWorld = "0"; 2970 $getterForMainWorld = "0";
2971 $setterForMainWorld = "0"; 2971 $setterForMainWorld = "0";
2972 } else { 2972 } else {
2973 # Default Getter and Setter 2973 # Default Getter and Setter
2974 $getter = "${implClassName}V8Internal::${attrName}AttrGetterCallback"; 2974 $getter = "${implClassName}V8Internal::${attrName}AttrGetterCallback";
(...skipping 16 matching lines...) Expand all
2991 # An accessor can be installed on the proto 2991 # An accessor can be installed on the proto
2992 if ($attrExt->{"OnProto"}) { 2992 if ($attrExt->{"OnProto"}) {
2993 $on_proto = "1 /* on proto */"; 2993 $on_proto = "1 /* on proto */";
2994 } 2994 }
2995 2995
2996 if (!$attrExt->{"PerWorldBindings"}) { 2996 if (!$attrExt->{"PerWorldBindings"}) {
2997 $getterForMainWorld = "0"; 2997 $getterForMainWorld = "0";
2998 $setterForMainWorld = "0"; 2998 $setterForMainWorld = "0";
2999 } 2999 }
3000 3000
3001 my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . 3001 my $commentInfo = "Attribute '$attrName'";
3002 "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')";
3003 3002
3004 $code .= $indent . " \/\/ $commentInfo\n"; 3003 $code .= $indent . " \/\/ $commentInfo\n";
3005 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorl d, $setterForMainWorld, $data, $accessControl, static_cast<v8::PropertyAttribute >($propAttr), $on_proto}" . $delimiter . "\n"; 3004 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorl d, $setterForMainWorld, $data, $accessControl, static_cast<v8::PropertyAttribute >($propAttr), $on_proto}" . $delimiter . "\n";
3006 return $code; 3005 return $code;
3007 } 3006 }
3008 3007
3009 sub IsStandardFunction 3008 sub IsStandardFunction
3010 { 3009 {
3011 my $interface = shift; 3010 my $interface = shift;
3012 my $function = shift; 3011 my $function = shift;
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
3743 $implementation{nameSpaceWebCore}->addHeader($code); 3742 $implementation{nameSpaceWebCore}->addHeader($code);
3744 3743
3745 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); 3744 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n");
3746 3745
3747 my $hasConstructors = 0; 3746 my $hasConstructors = 0;
3748 my $hasReplaceable = 0; 3747 my $hasReplaceable = 0;
3749 3748
3750 # Generate property accessors for attributes. 3749 # Generate property accessors for attributes.
3751 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 3750 for (my $index = 0; $index < @{$interface->attributes}; $index++) {
3752 my $attribute = @{$interface->attributes}[$index]; 3751 my $attribute = @{$interface->attributes}[$index];
3753 my $attrType = $attribute->signature->type; 3752 my $attrType = $attribute->type;
3754 my $attrExt = $attribute->signature->extendedAttributes; 3753 my $attrExt = $attribute->extendedAttributes;
3755 3754
3756 # Generate special code for the constructor attributes. 3755 # Generate special code for the constructor attributes.
3757 if ($attrType =~ /Constructor$/) { 3756 if ($attrType =~ /Constructor$/) {
3758 if (!HasCustomGetter($attrExt)) { 3757 if (!HasCustomGetter($attrExt)) {
3759 $hasConstructors = 1; 3758 $hasConstructors = 1;
3760 } 3759 }
3761 next; 3760 next;
3762 } 3761 }
3763 3762
3764 if ($attrType eq "EventListener" && $interfaceName eq "Window") { 3763 if ($attrType eq "EventListener" && $interfaceName eq "Window") {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3871 3870
3872 # For the Window interface we partition the attributes into the 3871 # For the Window interface we partition the attributes into the
3873 # ones that disallows shadowing and the rest. 3872 # ones that disallows shadowing and the rest.
3874 my @disallowsShadowing; 3873 my @disallowsShadowing;
3875 # Also separate out attributes that are enabled at runtime so we can process them specially. 3874 # Also separate out attributes that are enabled at runtime so we can process them specially.
3876 my @enabledAtRuntimeAttributes; 3875 my @enabledAtRuntimeAttributes;
3877 my @enabledPerContextAttributes; 3876 my @enabledPerContextAttributes;
3878 my @normalAttributes; 3877 my @normalAttributes;
3879 foreach my $attribute (@$attributes) { 3878 foreach my $attribute (@$attributes) {
3880 3879
3881 if ($interfaceName eq "Window" && $attribute->signature->extendedAttribu tes->{"Unforgeable"}) { 3880 if ($interfaceName eq "Window" && $attribute->extendedAttributes->{"Unfo rgeable"}) {
3882 push(@disallowsShadowing, $attribute); 3881 push(@disallowsShadowing, $attribute);
3883 } elsif ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"} || $attribute->signature->extendedAttributes->{"EnabledPerContext"}) { 3882 } elsif ($attribute->extendedAttributes->{"EnabledAtRuntime"} || $attrib ute->extendedAttributes->{"EnabledPerContext"}) {
3884 if ($attribute->signature->extendedAttributes->{"EnabledPerContext"} ) { 3883 if ($attribute->extendedAttributes->{"EnabledPerContext"}) {
3885 push(@enabledPerContextAttributes, $attribute); 3884 push(@enabledPerContextAttributes, $attribute);
3886 } 3885 }
3887 if ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) { 3886 if ($attribute->extendedAttributes->{"EnabledAtRuntime"}) {
3888 push(@enabledAtRuntimeAttributes, $attribute); 3887 push(@enabledAtRuntimeAttributes, $attribute);
3889 } 3888 }
3890 } else { 3889 } else {
3891 push(@normalAttributes, $attribute); 3890 push(@normalAttributes, $attribute);
3892 } 3891 }
3893 } 3892 }
3894 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); 3893 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h");
3895 $attributes = \@normalAttributes; 3894 $attributes = \@normalAttributes;
3896 # Put the attributes that disallow shadowing on the shadow object. 3895 # Put the attributes that disallow shadowing on the shadow object.
3897 if (@disallowsShadowing) { 3896 if (@disallowsShadowing) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
4081 END 4080 END
4082 } 4081 }
4083 4082
4084 if ($access_check) { 4083 if ($access_check) {
4085 $code .= " $access_check\n"; 4084 $code .= " $access_check\n";
4086 } 4085 }
4087 4086
4088 # Setup the enable-at-runtime attrs if we have them 4087 # Setup the enable-at-runtime attrs if we have them
4089 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { 4088 foreach my $runtime_attr (@enabledAtRuntimeAttributes) {
4090 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes; 4089 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes;
4091 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signat ure); 4090 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr);
4092 my $conditionalString = GenerateConditionalString($runtime_attr->signatu re); 4091 my $conditionalString = GenerateConditionalString($runtime_attr);
4093 $code .= "\n#if ${conditionalString}\n" if $conditionalString; 4092 $code .= "\n#if ${conditionalString}\n" if $conditionalString;
4094 $code .= " if (${enable_function}()) {\n"; 4093 $code .= " if (${enable_function}()) {\n";
4095 $code .= " static const V8DOMConfiguration::BatchedAttribute attr Data =\\\n"; 4094 $code .= " static const V8DOMConfiguration::BatchedAttribute attr Data =\\\n";
4096 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";", " "); 4095 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";", " ");
4097 $code .= <<END; 4096 $code .= <<END;
4098 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e, currentWorldType); 4097 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e, currentWorldType);
4099 } 4098 }
4100 END 4099 END
4101 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; 4100 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString;
4102 } 4101 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 if (@enabledPerContextAttributes) { 4207 if (@enabledPerContextAttributes) {
4209 my $code = ""; 4208 my $code = "";
4210 $code .= <<END; 4209 $code .= <<END;
4211 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance , ${nativeType}* impl, v8::Isolate* isolate) 4210 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance , ${nativeType}* impl, v8::Isolate* isolate)
4212 { 4211 {
4213 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); 4212 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type());
4214 END 4213 END
4215 4214
4216 # Setup the enable-by-settings attrs if we have them 4215 # Setup the enable-by-settings attrs if we have them
4217 foreach my $runtimeAttr (@enabledPerContextAttributes) { 4216 foreach my $runtimeAttr (@enabledPerContextAttributes) {
4218 my $enableFunction = GetContextEnableFunction($runtimeAttr->signatur e); 4217 my $enableFunction = GetContextEnableFunction($runtimeAttr);
4219 my $conditionalString = GenerateConditionalString($runtimeAttr->sign ature); 4218 my $conditionalString = GenerateConditionalString($runtimeAttr);
4220 $code .= "\n#if ${conditionalString}\n" if $conditionalString; 4219 $code .= "\n#if ${conditionalString}\n" if $conditionalString;
4221 if (grep { $_ eq $runtimeAttr } @enabledAtRuntimeAttributes) { 4220 if (grep { $_ eq $runtimeAttr } @enabledAtRuntimeAttributes) {
4222 my $runtimeEnableFunction = GetRuntimeEnableFunctionName($runtim eAttr->signature); 4221 my $runtimeEnableFunction = GetRuntimeEnableFunctionName($runtim eAttr);
4223 $code .= " if (${enableFunction}(impl->document()) && ${runti meEnableFunction}()) {\n"; 4222 $code .= " if (${enableFunction}(impl->document()) && ${runti meEnableFunction}()) {\n";
4224 } else { 4223 } else {
4225 $code .= " if (${enableFunction}(impl->document())) {\n"; 4224 $code .= " if (${enableFunction}(impl->document())) {\n";
4226 } 4225 }
4227 4226
4228 $code .= " static const V8DOMConfiguration::BatchedAttribute attrData =\\\n"; 4227 $code .= " static const V8DOMConfiguration::BatchedAttribute attrData =\\\n";
4229 $code .= GenerateSingleBatchedAttribute($interface, $runtimeAttr, "; ", " "); 4228 $code .= GenerateSingleBatchedAttribute($interface, $runtimeAttr, "; ", " ");
4230 $code .= <<END; 4229 $code .= <<END;
4231 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e); 4230 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e);
4232 END 4231 END
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
5658 push(@{$nameToFunctionsMap{$name}}, $function); 5657 push(@{$nameToFunctionsMap{$name}}, $function);
5659 $function->{overloads} = $nameToFunctionsMap{$name}; 5658 $function->{overloads} = $nameToFunctionsMap{$name};
5660 $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; 5659 $function->{overloadIndex} = @{$nameToFunctionsMap{$name}};
5661 } 5660 }
5662 } 5661 }
5663 5662
5664 sub AttributeNameForGetterAndSetter 5663 sub AttributeNameForGetterAndSetter
5665 { 5664 {
5666 my $attribute = shift; 5665 my $attribute = shift;
5667 5666
5668 my $attributeName = GetImplName($attribute->signature); 5667 my $attributeName = GetImplName($attribute);
5669 if ($attribute->signature->extendedAttributes->{"ImplementedAs"}) { 5668 if ($attribute->extendedAttributes->{"ImplementedAs"}) {
5670 $attributeName = $attribute->signature->extendedAttributes->{"Implemente dAs"}; 5669 $attributeName = $attribute->extendedAttributes->{"ImplementedAs"};
5671 } 5670 }
5672 my $attributeType = $attribute->signature->type; 5671 my $attributeType = $attribute->type;
5673 5672
5674 # Avoid clash with C++ keyword. 5673 # Avoid clash with C++ keyword.
5675 $attributeName = "_operator" if $attributeName eq "operator"; 5674 $attributeName = "_operator" if $attributeName eq "operator";
5676 5675
5677 # SVGAElement defines a non-virtual "String& target() const" method which cl ashes with "virtual String target() const" in Element. 5676 # SVGAElement defines a non-virtual "String& target() const" method which cl ashes with "virtual String target() const" in Element.
5678 # To solve this issue the SVGAElement method was renamed to "svgTarget", tak e care of that when calling this method. 5677 # To solve this issue the SVGAElement method was renamed to "svgTarget", tak e care of that when calling this method.
5679 $attributeName = "svgTarget" if $attributeName eq "target" and $attributeTyp e eq "SVGAnimatedString"; 5678 $attributeName = "svgTarget" if $attributeName eq "target" and $attributeTyp e eq "SVGAnimatedString";
5680 5679
5681 # SVG animated types need to use a special attribute name. 5680 # SVG animated types need to use a special attribute name.
5682 # The rest of the special casing for SVG animated types is handled in the la nguage-specific code generators. 5681 # The rest of the special casing for SVG animated types is handled in the la nguage-specific code generators.
5683 $attributeName .= "Animated" if IsSVGAnimatedType($attributeType); 5682 $attributeName .= "Animated" if IsSVGAnimatedType($attributeType);
5684 5683
5685 return $attributeName; 5684 return $attributeName;
5686 } 5685 }
5687 5686
5688 sub ContentAttributeName 5687 sub ContentAttributeName
5689 { 5688 {
5690 my ($interfaceName, $attribute) = @_; 5689 my ($interfaceName, $attribute) = @_;
5691 5690
5692 my $contentAttributeName = $attribute->signature->extendedAttributes->{"Refl ect"}; 5691 my $contentAttributeName = $attribute->extendedAttributes->{"Reflect"};
5693 return undef if !$contentAttributeName; 5692 return undef if !$contentAttributeName;
5694 5693
5695 $contentAttributeName = lc AttributeNameForGetterAndSetter($attribute) if $c ontentAttributeName eq "VALUE_IS_MISSING"; 5694 $contentAttributeName = lc AttributeNameForGetterAndSetter($attribute) if $c ontentAttributeName eq "VALUE_IS_MISSING";
5696 5695
5697 my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeN ame); 5696 my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeN ame);
5698 5697
5699 AddToImplIncludes("${namespace}.h"); 5698 AddToImplIncludes("${namespace}.h");
5700 return "WebCore::${namespace}::${contentAttributeName}Attr"; 5699 return "WebCore::${namespace}::${contentAttributeName}Attr";
5701 } 5700 }
5702 5701
5703 sub CanUseFastAttribute 5702 sub CanUseFastAttribute
5704 { 5703 {
5705 my $attribute = shift; 5704 my $attribute = shift;
5706 return !IsSVGAnimatedType($attribute->signature->type); 5705 return !IsSVGAnimatedType($attribute->type);
5707 } 5706 }
5708 5707
5709 sub GetterExpression 5708 sub GetterExpression
5710 { 5709 {
5711 my ($interfaceName, $attribute) = @_; 5710 my ($interfaceName, $attribute) = @_;
5712 5711
5713 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); 5712 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute);
5714 5713
5715 if (!$contentAttributeName) { 5714 if (!$contentAttributeName) {
5716 return (ToMethodName(AttributeNameForGetterAndSetter($attribute))); 5715 return (ToMethodName(AttributeNameForGetterAndSetter($attribute)));
5717 } 5716 }
5718 5717
5719 my $functionName; 5718 my $functionName;
5720 if ($attribute->signature->extendedAttributes->{"URL"}) { 5719 if ($attribute->extendedAttributes->{"URL"}) {
5721 $functionName = "getURLAttribute"; 5720 $functionName = "getURLAttribute";
5722 } elsif ($attribute->signature->type eq "boolean") { 5721 } elsif ($attribute->type eq "boolean") {
5723 if (CanUseFastAttribute($attribute)) { 5722 if (CanUseFastAttribute($attribute)) {
5724 $functionName = "fastHasAttribute"; 5723 $functionName = "fastHasAttribute";
5725 } else { 5724 } else {
5726 $functionName = "hasAttribute"; 5725 $functionName = "hasAttribute";
5727 } 5726 }
5728 } elsif ($attribute->signature->type eq "long") { 5727 } elsif ($attribute->type eq "long") {
5729 $functionName = "getIntegralAttribute"; 5728 $functionName = "getIntegralAttribute";
5730 } elsif ($attribute->signature->type eq "unsigned long") { 5729 } elsif ($attribute->type eq "unsigned long") {
5731 $functionName = "getUnsignedIntegralAttribute"; 5730 $functionName = "getUnsignedIntegralAttribute";
5732 } else { 5731 } else {
5733 if ($contentAttributeName eq "WebCore::HTMLNames::idAttr") { 5732 if ($contentAttributeName eq "WebCore::HTMLNames::idAttr") {
5734 $functionName = "getIdAttribute"; 5733 $functionName = "getIdAttribute";
5735 $contentAttributeName = ""; 5734 $contentAttributeName = "";
5736 } elsif ($contentAttributeName eq "WebCore::HTMLNames::nameAttr") { 5735 } elsif ($contentAttributeName eq "WebCore::HTMLNames::nameAttr") {
5737 $functionName = "getNameAttribute"; 5736 $functionName = "getNameAttribute";
5738 $contentAttributeName = ""; 5737 $contentAttributeName = "";
5739 } elsif ($contentAttributeName eq "WebCore::HTMLNames::classAttr") { 5738 } elsif ($contentAttributeName eq "WebCore::HTMLNames::classAttr") {
5740 $functionName = "getClassAttribute"; 5739 $functionName = "getClassAttribute";
(...skipping 12 matching lines...) Expand all
5753 { 5752 {
5754 my ($interfaceName, $attribute) = @_; 5753 my ($interfaceName, $attribute) = @_;
5755 5754
5756 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); 5755 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute);
5757 5756
5758 if (!$contentAttributeName) { 5757 if (!$contentAttributeName) {
5759 return ("set" . FirstLetterToUpperCase(AttributeNameForGetterAndSetter($ attribute))); 5758 return ("set" . FirstLetterToUpperCase(AttributeNameForGetterAndSetter($ attribute)));
5760 } 5759 }
5761 5760
5762 my $functionName; 5761 my $functionName;
5763 if ($attribute->signature->type eq "boolean") { 5762 if ($attribute->type eq "boolean") {
5764 $functionName = "setBooleanAttribute"; 5763 $functionName = "setBooleanAttribute";
5765 } elsif ($attribute->signature->type eq "long") { 5764 } elsif ($attribute->type eq "long") {
5766 $functionName = "setIntegralAttribute"; 5765 $functionName = "setIntegralAttribute";
5767 } elsif ($attribute->signature->type eq "unsigned long") { 5766 } elsif ($attribute->type eq "unsigned long") {
5768 $functionName = "setUnsignedIntegralAttribute"; 5767 $functionName = "setUnsignedIntegralAttribute";
5769 } else { 5768 } else {
5770 $functionName = "setAttribute"; 5769 $functionName = "setAttribute";
5771 } 5770 }
5772 5771
5773 return ($functionName, $contentAttributeName); 5772 return ($functionName, $contentAttributeName);
5774 } 5773 }
5775 5774
5776 sub GenerateConditionalString 5775 sub GenerateConditionalString
5777 { 5776 {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5878 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 5877 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
5879 $found = 1; 5878 $found = 1;
5880 } 5879 }
5881 return 1 if $found; 5880 return 1 if $found;
5882 }, 0); 5881 }, 0);
5883 5882
5884 return $found; 5883 return $found;
5885 } 5884 }
5886 5885
5887 1; 5886 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/IDLParser.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698