| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 } | 1289 } |
| 1290 | 1290 |
| 1291 sub GenerateNormalAttrGetterCallback | 1291 sub GenerateNormalAttrGetterCallback |
| 1292 { | 1292 { |
| 1293 my $attribute = shift; | 1293 my $attribute = shift; |
| 1294 my $interface = shift; | 1294 my $interface = shift; |
| 1295 my $forMainWorldSuffix = shift; | 1295 my $forMainWorldSuffix = shift; |
| 1296 | 1296 |
| 1297 my $implClassName = GetImplName($interface); | 1297 my $implClassName = GetImplName($interface); |
| 1298 my $v8ClassName = GetV8ClassName($interface); | 1298 my $v8ClassName = GetV8ClassName($interface); |
| 1299 my $attrExt = $attribute->signature->extendedAttributes; | 1299 my $attrExt = $attribute->extendedAttributes; |
| 1300 my $attrName = $attribute->signature->name; | 1300 my $attrName = $attribute->name; |
| 1301 | 1301 |
| 1302 my $conditionalString = GenerateConditionalString($attribute->signature); | 1302 my $conditionalString = GenerateConditionalString($attribute); |
| 1303 my $code = ""; | 1303 my $code = ""; |
| 1304 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1304 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1305 | 1305 |
| 1306 $code .= "static void ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; | 1306 $code .= "static void ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; |
| 1307 $code .= "{\n"; | 1307 $code .= "{\n"; |
| 1308 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1308 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
| 1309 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); | 1309 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); |
| 1310 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { | 1310 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { |
| 1311 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); | 1311 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); |
| 1312 } | 1312 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1323 | 1323 |
| 1324 sub GenerateNormalAttrGetter | 1324 sub GenerateNormalAttrGetter |
| 1325 { | 1325 { |
| 1326 my $attribute = shift; | 1326 my $attribute = shift; |
| 1327 my $interface = shift; | 1327 my $interface = shift; |
| 1328 my $forMainWorldSuffix = shift; | 1328 my $forMainWorldSuffix = shift; |
| 1329 | 1329 |
| 1330 my $interfaceName = $interface->name; | 1330 my $interfaceName = $interface->name; |
| 1331 my $implClassName = GetImplName($interface); | 1331 my $implClassName = GetImplName($interface); |
| 1332 my $v8ClassName = GetV8ClassName($interface); | 1332 my $v8ClassName = GetV8ClassName($interface); |
| 1333 my $attrExt = $attribute->signature->extendedAttributes; | 1333 my $attrExt = $attribute->extendedAttributes; |
| 1334 my $attrName = $attribute->signature->name; | 1334 my $attrName = $attribute->name; |
| 1335 my $attrType = $attribute->signature->type; | 1335 my $attrType = $attribute->type; |
| 1336 | 1336 |
| 1337 if (HasCustomGetter($attrExt)) { | 1337 if (HasCustomGetter($attrExt)) { |
| 1338 return; | 1338 return; |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 AssertNotSequenceType($attrType); | 1341 AssertNotSequenceType($attrType); |
| 1342 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; | 1342 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; |
| 1343 my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); | 1343 my $nativeType = GetNativeTypeFromSignature($attribute, -1); |
| 1344 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1344 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
| 1345 | 1345 |
| 1346 my $conditionalString = GenerateConditionalString($attribute->signature); | 1346 my $conditionalString = GenerateConditionalString($attribute); |
| 1347 my $code = ""; | 1347 my $code = ""; |
| 1348 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1348 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1349 $code .= <<END; | 1349 $code .= <<END; |
| 1350 static void ${attrName}AttrGetter${forMainWorldSuffix}(v8::Local<v8::String> nam
e, const v8::PropertyCallbackInfo<v8::Value>& info) | 1350 static void ${attrName}AttrGetter${forMainWorldSuffix}(v8::Local<v8::String> nam
e, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 1351 { | 1351 { |
| 1352 END | 1352 END |
| 1353 if ($svgNativeType) { | 1353 if ($svgNativeType) { |
| 1354 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); | 1354 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); |
| 1355 if ($svgWrappedNativeType =~ /List/) { | 1355 if ($svgWrappedNativeType =~ /List/) { |
| 1356 $code .= <<END; | 1356 $code .= <<END; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1377 $code .= <<END; | 1377 $code .= <<END; |
| 1378 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 1378 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
| 1379 if (holder.IsEmpty()) | 1379 if (holder.IsEmpty()) |
| 1380 return; | 1380 return; |
| 1381 END | 1381 END |
| 1382 } | 1382 } |
| 1383 $code .= <<END; | 1383 $code .= <<END; |
| 1384 ${implClassName}* imp = ${v8ClassName}::toNative(holder); | 1384 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
| 1385 END | 1385 END |
| 1386 } else { | 1386 } else { |
| 1387 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; | 1387 my $reflect = $attribute->extendedAttributes->{"Reflect"}; |
| 1388 my $url = $attribute->signature->extendedAttributes->{"URL"}; | 1388 my $url = $attribute->extendedAttributes->{"URL"}; |
| 1389 if ($getterStringUsesImp && $reflect && !$url && InheritsInterface($inte
rface, "Node") && $attrType eq "DOMString") { | 1389 if ($getterStringUsesImp && $reflect && !$url && InheritsInterface($inte
rface, "Node") && $attrType eq "DOMString") { |
| 1390 # Generate super-compact call for regular attribute getter: | 1390 # Generate super-compact call for regular attribute getter: |
| 1391 my ($functionName, @arguments) = GetterExpression($interfaceName, $a
ttribute); | 1391 my ($functionName, @arguments) = GetterExpression($interfaceName, $a
ttribute); |
| 1392 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; | 1392 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
| 1393 $code .= " v8SetReturnValue(info, v8String(imp->${functionName}("
. join(", ", @arguments) . "), info.GetIsolate(), ReturnUnsafeHandle));\n"; | 1393 $code .= " v8SetReturnValue(info, v8String(imp->${functionName}("
. join(", ", @arguments) . "), info.GetIsolate(), ReturnUnsafeHandle));\n"; |
| 1394 $code .= " return;\n"; | 1394 $code .= " return;\n"; |
| 1395 $code .= "}\n\n"; | 1395 $code .= "}\n\n"; |
| 1396 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1396 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1397 $implementation{nameSpaceInternal}->add($code); | 1397 $implementation{nameSpaceInternal}->add($code); |
| 1398 return; | 1398 return; |
| 1399 # Skip the rest of the function! | 1399 # Skip the rest of the function! |
| 1400 } | 1400 } |
| 1401 if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->
{"CachedAttribute"}) { | 1401 if ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAtt
ribute"}) { |
| 1402 $code .= <<END; | 1402 $code .= <<END; |
| 1403 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); | 1403 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); |
| 1404 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); | 1404 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); |
| 1405 if (!value.IsEmpty()) { | 1405 if (!value.IsEmpty()) { |
| 1406 v8SetReturnValue(info, value); | 1406 v8SetReturnValue(info, value); |
| 1407 return; | 1407 return; |
| 1408 } | 1408 } |
| 1409 END | 1409 END |
| 1410 } | 1410 } |
| 1411 if (!$attribute->isStatic) { | 1411 if (!$attribute->isStatic) { |
| 1412 $code .= <<END; | 1412 $code .= <<END; |
| 1413 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1413 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1414 END | 1414 END |
| 1415 } | 1415 } |
| 1416 } | 1416 } |
| 1417 | 1417 |
| 1418 # Generate security checks if necessary | 1418 # Generate security checks if necessary |
| 1419 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 1419 if ($attribute->extendedAttributes->{"CheckSecurityForNode"}) { |
| 1420 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1420 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 1421 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($attribute->signature) . "())) {\n"; | 1421 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($attribute) . "())) {\n"; |
| 1422 $code .= " v8SetReturnValueNull(info);\n"; | 1422 $code .= " v8SetReturnValueNull(info);\n"; |
| 1423 $code .= " return;\n"; | 1423 $code .= " return;\n"; |
| 1424 $code .= " }\n"; | 1424 $code .= " }\n"; |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Getter
RaisesException"} || $attribute->signature->extendedAttributes->{"RaisesExcepti
on"}; | 1427 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep
tion"} || $attribute->extendedAttributes->{"RaisesException"}; |
| 1428 my $isNullable = $attribute->signature->isNullable; | 1428 my $isNullable = $attribute->isNullable; |
| 1429 if ($useExceptions) { | 1429 if ($useExceptions) { |
| 1430 AddToImplIncludes("core/dom/ExceptionCode.h"); | 1430 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 1431 $code .= " ExceptionCode ec = 0;\n"; | 1431 $code .= " ExceptionCode ec = 0;\n"; |
| 1432 } | 1432 } |
| 1433 | 1433 |
| 1434 if ($isNullable) { | 1434 if ($isNullable) { |
| 1435 $code .= " bool isNull = false;\n"; | 1435 $code .= " bool isNull = false;\n"; |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 my $returnType = $attribute->signature->type; | 1438 my $returnType = $attribute->type; |
| 1439 my $getterString; | 1439 my $getterString; |
| 1440 | 1440 |
| 1441 if ($getterStringUsesImp) { | 1441 if ($getterStringUsesImp) { |
| 1442 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri
bute); | 1442 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri
bute); |
| 1443 push(@arguments, "isNull") if $isNullable; | 1443 push(@arguments, "isNull") if $isNullable; |
| 1444 push(@arguments, "ec") if $useExceptions; | 1444 push(@arguments, "ec") if $useExceptions; |
| 1445 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1445 if ($attribute->extendedAttributes->{"ImplementedBy"}) { |
| 1446 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp
lementedBy"}; | 1446 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"
}; |
| 1447 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement
edBy)); | 1447 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement
edBy)); |
| 1448 unshift(@arguments, "imp") if !$attribute->isStatic; | 1448 unshift(@arguments, "imp") if !$attribute->isStatic; |
| 1449 $functionName = "${implementedBy}::${functionName}"; | 1449 $functionName = "${implementedBy}::${functionName}"; |
| 1450 } elsif ($attribute->isStatic) { | 1450 } elsif ($attribute->isStatic) { |
| 1451 $functionName = "${implClassName}::${functionName}"; | 1451 $functionName = "${implClassName}::${functionName}"; |
| 1452 } else { | 1452 } else { |
| 1453 $functionName = "imp->${functionName}"; | 1453 $functionName = "imp->${functionName}"; |
| 1454 } | 1454 } |
| 1455 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt
tributes->{"CallWith"}, " ", 0); | 1455 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{
"CallWith"}, " ", 0); |
| 1456 $code .= $subCode; | 1456 $code .= $subCode; |
| 1457 unshift(@arguments, @$arg); | 1457 unshift(@arguments, @$arg); |
| 1458 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; | 1458 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; |
| 1459 } else { | 1459 } else { |
| 1460 $getterString = "impInstance"; | 1460 $getterString = "impInstance"; |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 my $expression; | 1463 my $expression; |
| 1464 if ($attribute->signature->type eq "EventListener" && $interface->name eq "D
OMWindow") { | 1464 if ($attribute->type eq "EventListener" && $interface->name eq "DOMWindow")
{ |
| 1465 $code .= " if (!imp->document())\n"; | 1465 $code .= " if (!imp->document())\n"; |
| 1466 $code .= " return;\n"; | 1466 $code .= " return;\n"; |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 if ($useExceptions || $isNullable) { | 1469 if ($useExceptions || $isNullable) { |
| 1470 if ($nativeType =~ /^V8StringResource/) { | 1470 if ($nativeType =~ /^V8StringResource/) { |
| 1471 $code .= " " . ConvertToV8StringResource($attribute->signature, $
nativeType, "v", $getterString) . ";\n"; | 1471 $code .= " " . ConvertToV8StringResource($attribute, $nativeType,
"v", $getterString) . ";\n"; |
| 1472 } else { | 1472 } else { |
| 1473 $code .= " $nativeType v = $getterString;\n"; | 1473 $code .= " $nativeType v = $getterString;\n"; |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 if ($isNullable) { | 1476 if ($isNullable) { |
| 1477 $code .= " if (isNull) {\n"; | 1477 $code .= " if (isNull) {\n"; |
| 1478 $code .= " v8SetReturnValueNull(info);\n"; | 1478 $code .= " v8SetReturnValueNull(info);\n"; |
| 1479 $code .= " return;\n"; | 1479 $code .= " return;\n"; |
| 1480 $code .= " }\n"; | 1480 $code .= " }\n"; |
| 1481 } | 1481 } |
| 1482 | 1482 |
| 1483 if ($useExceptions) { | 1483 if ($useExceptions) { |
| 1484 $code .= " if (UNLIKELY(ec)) {\n"; | 1484 $code .= " if (UNLIKELY(ec)) {\n"; |
| 1485 $code .= " setDOMException(ec, info.GetIsolate());\n"; | 1485 $code .= " setDOMException(ec, info.GetIsolate());\n"; |
| 1486 $code .= " return;\n"; | 1486 $code .= " return;\n"; |
| 1487 $code .= " };\n"; | 1487 $code .= " };\n"; |
| 1488 | 1488 |
| 1489 if (ExtendedAttributeContains($attribute->signature->extendedAttribu
tes->{"CallWith"}, "ScriptState")) { | 1489 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call
With"}, "ScriptState")) { |
| 1490 $code .= " if (state.hadException()) {\n"; | 1490 $code .= " if (state.hadException()) {\n"; |
| 1491 $code .= " throwError(state.exception(), info.GetIsolate(
));\n"; | 1491 $code .= " throwError(state.exception(), info.GetIsolate(
));\n"; |
| 1492 $code .= " return;\n"; | 1492 $code .= " return;\n"; |
| 1493 $code .= " }\n"; | 1493 $code .= " }\n"; |
| 1494 } | 1494 } |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 $expression = "v"; | 1497 $expression = "v"; |
| 1498 $expression .= ".release()" if (IsRefPtrType($returnType)); | 1498 $expression .= ".release()" if (IsRefPtrType($returnType)); |
| 1499 } else { | 1499 } else { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 AddToImplIncludes("V8$attrType.h"); | 1542 AddToImplIncludes("V8$attrType.h"); |
| 1543 my $svgNativeType = GetSVGTypeNeedingTearOff($attrType); | 1543 my $svgNativeType = GetSVGTypeNeedingTearOff($attrType); |
| 1544 # Convert from abstract SVGProperty to real type, so the right toJS() me
thod can be invoked. | 1544 # Convert from abstract SVGProperty to real type, so the right toJS() me
thod can be invoked. |
| 1545 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix(static_
cast<$svgNativeType*>($expression), info, imp));\n"; | 1545 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix(static_
cast<$svgNativeType*>($expression), info, imp));\n"; |
| 1546 $code .= " return;\n"; | 1546 $code .= " return;\n"; |
| 1547 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$
/) { | 1547 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$
/) { |
| 1548 AddToImplIncludes("V8$attrType.h"); | 1548 AddToImplIncludes("V8$attrType.h"); |
| 1549 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); | 1549 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); |
| 1550 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); | 1550 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); |
| 1551 my $wrappedValue; | 1551 my $wrappedValue; |
| 1552 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def
ined $attribute->signature->extendedAttributes->{"Immutable"}) { | 1552 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def
ined $attribute->extendedAttributes->{"Immutable"}) { |
| 1553 my $getter = $expression; | 1553 my $getter = $expression; |
| 1554 $getter =~ s/imp->//; | 1554 $getter =~ s/imp->//; |
| 1555 $getter =~ s/\(\)//; | 1555 $getter =~ s/\(\)//; |
| 1556 | 1556 |
| 1557 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC
ase($getter); | 1557 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC
ase($getter); |
| 1558 | 1558 |
| 1559 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName); | 1559 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName); |
| 1560 if ($selfIsTearOffType) { | 1560 if ($selfIsTearOffType) { |
| 1561 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare
ntTearOff.h"); | 1561 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare
ntTearOff.h"); |
| 1562 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen
tTearOff<$implClassName, /; | 1562 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen
tTearOff<$implClassName, /; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1576 } | 1576 } |
| 1577 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { | 1577 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { |
| 1578 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres
sion))"; | 1578 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres
sion))"; |
| 1579 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { | 1579 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { |
| 1580 $wrappedValue = "WTF::getPtr($expression)"; | 1580 $wrappedValue = "WTF::getPtr($expression)"; |
| 1581 } else { | 1581 } else { |
| 1582 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression)
)"; | 1582 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression)
)"; |
| 1583 } | 1583 } |
| 1584 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix($wrappe
dValue, info, imp));\n"; | 1584 $code .= " v8SetReturnValue(info, toV8Fast$forMainWorldSuffix($wrappe
dValue, info, imp));\n"; |
| 1585 $code .= " return;\n"; | 1585 $code .= " return;\n"; |
| 1586 } elsif ($attribute->signature->type eq "SerializedScriptValue" && $attrExt-
>{"CachedAttribute"}) { | 1586 } elsif ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAt
tribute"}) { |
| 1587 my $getterFunc = ToMethodName($attribute->signature->name); | 1587 my $getterFunc = ToMethodName($attribute->name); |
| 1588 $code .= <<END; | 1588 $code .= <<END; |
| 1589 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); | 1589 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); |
| 1590 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Nul
l(info.GetIsolate())); | 1590 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Nul
l(info.GetIsolate())); |
| 1591 info.Holder()->SetHiddenValue(propertyName, value); | 1591 info.Holder()->SetHiddenValue(propertyName, value); |
| 1592 v8SetReturnValue(info, value); | 1592 v8SetReturnValue(info, value); |
| 1593 return; | 1593 return; |
| 1594 END | 1594 END |
| 1595 } elsif ($attribute->signature->type eq "EventListener") { | 1595 } elsif ($attribute->type eq "EventListener") { |
| 1596 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1596 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
| 1597 my $getterFunc = ToMethodName($attribute->signature->name); | 1597 my $getterFunc = ToMethodName($attribute->name); |
| 1598 # FIXME: Pass the main world ID for main-world-only getters. | 1598 # FIXME: Pass the main world ID for main-world-only getters. |
| 1599 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld
ForIsolate(info.GetIsolate()));\n"; | 1599 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld
ForIsolate(info.GetIsolate()));\n"; |
| 1600 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8
AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon
text())) : v8::Handle<v8::Value>(v8Null(info.GetIsolate())));\n"; | 1600 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8
AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon
text())) : v8::Handle<v8::Value>(v8Null(info.GetIsolate())));\n"; |
| 1601 $code .= " return;\n"; | 1601 $code .= " return;\n"; |
| 1602 } else { | 1602 } else { |
| 1603 my $nativeValue = NativeToJSValue($attribute->signature->type, $attribut
e->signature->extendedAttributes, $expression, " ", "", "info.Holder()", "inf
o.GetIsolate()", "info", "imp", "ReturnUnsafeHandle", $forMainWorldSuffix, "retu
rn"); | 1603 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended
Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info
", "imp", "ReturnUnsafeHandle", $forMainWorldSuffix, "return"); |
| 1604 $code .= "${nativeValue}\n"; | 1604 $code .= "${nativeValue}\n"; |
| 1605 $code .= " return;\n"; | 1605 $code .= " return;\n"; |
| 1606 } | 1606 } |
| 1607 | 1607 |
| 1608 $code .= "}\n\n"; # end of getter | 1608 $code .= "}\n\n"; # end of getter |
| 1609 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1609 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1610 $implementation{nameSpaceInternal}->add($code); | 1610 $implementation{nameSpaceInternal}->add($code); |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 sub ShouldKeepAttributeAlive | 1613 sub ShouldKeepAttributeAlive |
| 1614 { | 1614 { |
| 1615 my ($interface, $attribute, $returnType) = @_; | 1615 my ($interface, $attribute, $returnType) = @_; |
| 1616 my $attrName = $attribute->signature->name; | 1616 my $attrName = $attribute->name; |
| 1617 | 1617 |
| 1618 return 1 if $attribute->signature->extendedAttributes->{"KeepAttributeAliveF
orGC"}; | 1618 return 1 if $attribute->extendedAttributes->{"KeepAttributeAliveForGC"}; |
| 1619 | 1619 |
| 1620 # Basically, for readonly or replaceable attributes, we have to guarantee | 1620 # Basically, for readonly or replaceable attributes, we have to guarantee |
| 1621 # that JS wrappers don't get garbage-collected prematually when their | 1621 # that JS wrappers don't get garbage-collected prematually when their |
| 1622 # lifetime is strongly tied to their owner. | 1622 # lifetime is strongly tied to their owner. |
| 1623 return 0 if !IsWrapperType($returnType); | 1623 return 0 if !IsWrapperType($returnType); |
| 1624 return 0 if !IsReadonly($attribute) && !$attribute->signature->extendedAttri
butes->{"Replaceable"}; | 1624 return 0 if !IsReadonly($attribute) && !$attribute->extendedAttributes->{"Re
placeable"}; |
| 1625 | 1625 |
| 1626 # However, there are a couple of exceptions. | 1626 # However, there are a couple of exceptions. |
| 1627 | 1627 |
| 1628 # Node lifetime is managed by object grouping. | 1628 # Node lifetime is managed by object grouping. |
| 1629 return 0 if InheritsInterface($interface, "Node"); | 1629 return 0 if InheritsInterface($interface, "Node"); |
| 1630 return 0 if IsDOMNodeType($returnType); | 1630 return 0 if IsDOMNodeType($returnType); |
| 1631 | 1631 |
| 1632 # To avoid adding a reference to itself. | 1632 # To avoid adding a reference to itself. |
| 1633 # FIXME: Introduce [DoNotKeepAttributeAliveForGC] and remove this hack | 1633 # FIXME: Introduce [DoNotKeepAttributeAliveForGC] and remove this hack |
| 1634 # depending on the attribute name. | 1634 # depending on the attribute name. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 sub GenerateNormalAttrSetterCallback | 1713 sub GenerateNormalAttrSetterCallback |
| 1714 { | 1714 { |
| 1715 my $attribute = shift; | 1715 my $attribute = shift; |
| 1716 my $interface = shift; | 1716 my $interface = shift; |
| 1717 my $forMainWorldSuffix = shift; | 1717 my $forMainWorldSuffix = shift; |
| 1718 | 1718 |
| 1719 my $implClassName = GetImplName($interface); | 1719 my $implClassName = GetImplName($interface); |
| 1720 my $v8ClassName = GetV8ClassName($interface); | 1720 my $v8ClassName = GetV8ClassName($interface); |
| 1721 my $attrExt = $attribute->signature->extendedAttributes; | 1721 my $attrExt = $attribute->extendedAttributes; |
| 1722 my $attrName = $attribute->signature->name; | 1722 my $attrName = $attribute->name; |
| 1723 | 1723 |
| 1724 my $conditionalString = GenerateConditionalString($attribute->signature); | 1724 my $conditionalString = GenerateConditionalString($attribute); |
| 1725 my $code = ""; | 1725 my $code = ""; |
| 1726 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1726 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1727 | 1727 |
| 1728 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackI
nfo<void>& info)\n"; | 1728 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackI
nfo<void>& info)\n"; |
| 1729 $code .= "{\n"; | 1729 $code .= "{\n"; |
| 1730 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1730 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
| 1731 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); | 1731 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); |
| 1732 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { | 1732 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { |
| 1733 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); | 1733 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); |
| 1734 } | 1734 } |
| 1735 if (HasCustomSetter($attrExt)) { | 1735 if (HasCustomSetter($attrExt)) { |
| 1736 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i
nfo);\n"; | 1736 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i
nfo);\n"; |
| 1737 } else { | 1737 } else { |
| 1738 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain
WorldSuffix}(name, value, info);\n"; | 1738 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain
WorldSuffix}(name, value, info);\n"; |
| 1739 } | 1739 } |
| 1740 $code .= "}\n\n"; | 1740 $code .= "}\n\n"; |
| 1741 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1741 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1742 $implementation{nameSpaceInternal}->add($code); | 1742 $implementation{nameSpaceInternal}->add($code); |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 sub GenerateNormalAttrSetter | 1745 sub GenerateNormalAttrSetter |
| 1746 { | 1746 { |
| 1747 my $attribute = shift; | 1747 my $attribute = shift; |
| 1748 my $interface = shift; | 1748 my $interface = shift; |
| 1749 my $forMainWorldSuffix = shift; | 1749 my $forMainWorldSuffix = shift; |
| 1750 | 1750 |
| 1751 my $interfaceName = $interface->name; | 1751 my $interfaceName = $interface->name; |
| 1752 my $implClassName = GetImplName($interface); | 1752 my $implClassName = GetImplName($interface); |
| 1753 my $v8ClassName = GetV8ClassName($interface); | 1753 my $v8ClassName = GetV8ClassName($interface); |
| 1754 my $attrName = $attribute->signature->name; | 1754 my $attrName = $attribute->name; |
| 1755 my $attrExt = $attribute->signature->extendedAttributes; | 1755 my $attrExt = $attribute->extendedAttributes; |
| 1756 my $attrType = $attribute->signature->type; | 1756 my $attrType = $attribute->type; |
| 1757 | 1757 |
| 1758 if (HasCustomSetter($attrExt)) { | 1758 if (HasCustomSetter($attrExt)) { |
| 1759 return; | 1759 return; |
| 1760 } | 1760 } |
| 1761 | 1761 |
| 1762 my $conditionalString = GenerateConditionalString($attribute->signature); | 1762 my $conditionalString = GenerateConditionalString($attribute); |
| 1763 my $code = ""; | 1763 my $code = ""; |
| 1764 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1764 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1765 $code .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v
8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void
>& info)\n"; | 1765 $code .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v
8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void
>& info)\n"; |
| 1766 $code .= "{\n"; | 1766 $code .= "{\n"; |
| 1767 | 1767 |
| 1768 # If the "StrictTypeChecking" extended attribute is present, and the attribu
te's type is an | 1768 # If the "StrictTypeChecking" extended attribute is present, and the attribu
te's type is an |
| 1769 # interface type, then if the incoming value does not implement that interfa
ce, a TypeError is | 1769 # interface type, then if the incoming value does not implement that interfa
ce, a TypeError is |
| 1770 # thrown rather than silently passing NULL to the C++ code. | 1770 # thrown rather than silently passing NULL to the C++ code. |
| 1771 # Per the Web IDL and ECMAScript specifications, incoming values can always
be converted to both | 1771 # Per the Web IDL and ECMAScript specifications, incoming values can always
be converted to both |
| 1772 # strings and numbers, so do not throw TypeError if the attribute is of thes
e types. | 1772 # strings and numbers, so do not throw TypeError if the attribute is of thes
e types. |
| 1773 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { | 1773 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { |
| 1774 my $argType = $attribute->signature->type; | 1774 my $argType = $attribute->type; |
| 1775 if (IsWrapperType($argType)) { | 1775 if (IsWrapperType($argType)) { |
| 1776 $code .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns
tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 1776 $code .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns
tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
| 1777 $code .= " throwTypeError(0, info.GetIsolate());\n"; | 1777 $code .= " throwTypeError(0, info.GetIsolate());\n"; |
| 1778 $code .= " return;\n"; | 1778 $code .= " return;\n"; |
| 1779 $code .= " }\n"; | 1779 $code .= " }\n"; |
| 1780 } | 1780 } |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1783 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
| 1784 if ($svgNativeType) { | 1784 if ($svgNativeType) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1795 $code .= " return;\n"; | 1795 $code .= " return;\n"; |
| 1796 $code .= " }\n"; | 1796 $code .= " }\n"; |
| 1797 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; | 1797 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; |
| 1798 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 1798 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
| 1799 } | 1799 } |
| 1800 } elsif ($attrExt->{"OnProto"}) { | 1800 } elsif ($attrExt->{"OnProto"}) { |
| 1801 $code .= <<END; | 1801 $code .= <<END; |
| 1802 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1802 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1803 END | 1803 END |
| 1804 } else { | 1804 } else { |
| 1805 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; | 1805 my $reflect = $attribute->extendedAttributes->{"Reflect"}; |
| 1806 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D
OMString") { | 1806 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D
OMString") { |
| 1807 # Generate super-compact call for regular attribute setter: | 1807 # Generate super-compact call for regular attribute setter: |
| 1808 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr
Name : $reflect; | 1808 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr
Name : $reflect; |
| 1809 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt
tributeName); | 1809 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt
tributeName); |
| 1810 AddToImplIncludes("${namespace}.h"); | 1810 AddToImplIncludes("${namespace}.h"); |
| 1811 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; | 1811 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
| 1812 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<
WithNullCheck>, stringResource, value);\n"; | 1812 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<
WithNullCheck>, stringResource, value);\n"; |
| 1813 $code .= " imp->setAttribute(${namespace}::${contentAttributeName
}Attr, stringResource);\n"; | 1813 $code .= " imp->setAttribute(${namespace}::${contentAttributeName
}Attr, stringResource);\n"; |
| 1814 $code .= "}\n\n"; | 1814 $code .= "}\n\n"; |
| 1815 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1815 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1816 $implementation{nameSpaceInternal}->add($code); | 1816 $implementation{nameSpaceInternal}->add($code); |
| 1817 return; | 1817 return; |
| 1818 # Skip the rest of the function! | 1818 # Skip the rest of the function! |
| 1819 } | 1819 } |
| 1820 | 1820 |
| 1821 if (!$attribute->isStatic) { | 1821 if (!$attribute->isStatic) { |
| 1822 $code .= <<END; | 1822 $code .= <<END; |
| 1823 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1823 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1824 END | 1824 END |
| 1825 } | 1825 } |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 1828 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); | 1828 my $nativeType = GetNativeTypeFromSignature($attribute, 0); |
| 1829 if ($attribute->signature->type eq "EventListener") { | 1829 if ($attribute->type eq "EventListener") { |
| 1830 if ($interface->name eq "DOMWindow") { | 1830 if ($interface->name eq "DOMWindow") { |
| 1831 $code .= " if (!imp->document())\n"; | 1831 $code .= " if (!imp->document())\n"; |
| 1832 $code .= " return;\n"; | 1832 $code .= " return;\n"; |
| 1833 } | 1833 } |
| 1834 } else { | 1834 } else { |
| 1835 my $value = JSValueToNative($attribute->signature->type, $attribute->sig
nature->extendedAttributes, "value", "info.GetIsolate()"); | 1835 my $value = JSValueToNative($attribute->type, $attribute->extendedAttrib
utes, "value", "info.GetIsolate()"); |
| 1836 my $arrayType = GetArrayType($nativeType); | 1836 my $arrayType = GetArrayType($nativeType); |
| 1837 | 1837 |
| 1838 if ($nativeType =~ /^V8StringResource/) { | 1838 if ($nativeType =~ /^V8StringResource/) { |
| 1839 $code .= " " . ConvertToV8StringResource($attribute->signature, $
nativeType, "v", $value) . "\n"; | 1839 $code .= " " . ConvertToV8StringResource($attribute, $nativeType,
"v", $value) . "\n"; |
| 1840 } elsif ($arrayType) { | 1840 } elsif ($arrayType) { |
| 1841 $code .= " Vector<$arrayType> v = $value;\n"; | 1841 $code .= " Vector<$arrayType> v = $value;\n"; |
| 1842 } elsif ($attribute->signature->extendedAttributes->{"EnforceRange"}) { | 1842 } elsif ($attribute->extendedAttributes->{"EnforceRange"}) { |
| 1843 $code .= " V8TRYCATCH_WITH_TYPECHECK_VOID($nativeType, v, $value,
info.GetIsolate());\n"; | 1843 $code .= " V8TRYCATCH_WITH_TYPECHECK_VOID($nativeType, v, $value,
info.GetIsolate());\n"; |
| 1844 } else { | 1844 } else { |
| 1845 $code .= " V8TRYCATCH_VOID($nativeType, v, $value);\n"; | 1845 $code .= " V8TRYCATCH_VOID($nativeType, v, $value);\n"; |
| 1846 } | 1846 } |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 if (IsEnumType($attrType)) { | 1849 if (IsEnumType($attrType)) { |
| 1850 # setter ignores invalid enumeration values | 1850 # setter ignores invalid enumeration values |
| 1851 my @enumValues = ValidEnumValues($attrType); | 1851 my @enumValues = ValidEnumValues($attrType); |
| 1852 my @validEqualities = (); | 1852 my @validEqualities = (); |
| 1853 foreach my $enumValue (@enumValues) { | 1853 foreach my $enumValue (@enumValues) { |
| 1854 push(@validEqualities, "string == \"$enumValue\""); | 1854 push(@validEqualities, "string == \"$enumValue\""); |
| 1855 } | 1855 } |
| 1856 my $enumValidationExpression = join(" || ", @validEqualities); | 1856 my $enumValidationExpression = join(" || ", @validEqualities); |
| 1857 $code .= <<END; | 1857 $code .= <<END; |
| 1858 String string = v; | 1858 String string = v; |
| 1859 if (!($enumValidationExpression)) | 1859 if (!($enumValidationExpression)) |
| 1860 return; | 1860 return; |
| 1861 END | 1861 END |
| 1862 } | 1862 } |
| 1863 | 1863 |
| 1864 my $expression = "v"; | 1864 my $expression = "v"; |
| 1865 my $returnType = $attribute->signature->type; | 1865 my $returnType = $attribute->type; |
| 1866 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { | 1866 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { |
| 1867 $expression = "WTF::getPtr(" . $expression . ")"; | 1867 $expression = "WTF::getPtr(" . $expression . ")"; |
| 1868 } | 1868 } |
| 1869 | 1869 |
| 1870 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->signature-
>extendedAttributes); | 1870 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt
tributes); |
| 1871 | 1871 |
| 1872 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Setter
RaisesException"} || $attribute->signature->extendedAttributes->{"RaisesExcepti
on"}; | 1872 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep
tion"} || $attribute->extendedAttributes->{"RaisesException"}; |
| 1873 | 1873 |
| 1874 if ($useExceptions) { | 1874 if ($useExceptions) { |
| 1875 AddToImplIncludes("core/dom/ExceptionCode.h"); | 1875 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 1876 $code .= " ExceptionCode ec = 0;\n"; | 1876 $code .= " ExceptionCode ec = 0;\n"; |
| 1877 } | 1877 } |
| 1878 | 1878 |
| 1879 if ($interfaceName eq "SVGNumber") { | 1879 if ($interfaceName eq "SVGNumber") { |
| 1880 $code .= " *imp = $expression;\n"; | 1880 $code .= " *imp = $expression;\n"; |
| 1881 } else { | 1881 } else { |
| 1882 if ($attribute->signature->type eq "EventListener") { | 1882 if ($attribute->type eq "EventListener") { |
| 1883 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); | 1883 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); |
| 1884 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1884 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
| 1885 if (!InheritsInterface($interface, "Node")) { | 1885 if (!InheritsInterface($interface, "Node")) { |
| 1886 my $attrImplName = GetImplName($attribute->signature); | 1886 my $attrImplName = GetImplName($attribute); |
| 1887 $code .= " transferHiddenDependency(info.Holder(), imp->${att
rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e
ventListenerCacheIndex, info.GetIsolate());\n"; | 1887 $code .= " transferHiddenDependency(info.Holder(), imp->${att
rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e
ventListenerCacheIndex, info.GetIsolate());\n"; |
| 1888 } | 1888 } |
| 1889 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 1889 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
| 1890 if (($interfaceName eq "DOMWindow" or $interfaceName eq "WorkerConte
xt") and $attribute->signature->name eq "onerror") { | 1890 if (($interfaceName eq "DOMWindow" or $interfaceName eq "WorkerConte
xt") and $attribute->name eq "onerror") { |
| 1891 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); | 1891 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); |
| 1892 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf
o.GetIsolate()));\n"; | 1892 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf
o.GetIsolate()));\n"; |
| 1893 } else { | 1893 } else { |
| 1894 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate(
info.GetIsolate()));\n"; | 1894 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate(
info.GetIsolate()));\n"; |
| 1895 } | 1895 } |
| 1896 } else { | 1896 } else { |
| 1897 my ($functionName, @arguments) = SetterExpression($interfaceName, $a
ttribute); | 1897 my ($functionName, @arguments) = SetterExpression($interfaceName, $a
ttribute); |
| 1898 push(@arguments, $expression); | 1898 push(@arguments, $expression); |
| 1899 push(@arguments, "ec") if $useExceptions; | 1899 push(@arguments, "ec") if $useExceptions; |
| 1900 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1900 if ($attribute->extendedAttributes->{"ImplementedBy"}) { |
| 1901 my $implementedBy = $attribute->signature->extendedAttributes->{
"ImplementedBy"}; | 1901 my $implementedBy = $attribute->extendedAttributes->{"Implemente
dBy"}; |
| 1902 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple
mentedBy)); | 1902 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple
mentedBy)); |
| 1903 unshift(@arguments, "imp") if !$attribute->isStatic; | 1903 unshift(@arguments, "imp") if !$attribute->isStatic; |
| 1904 $functionName = "${implementedBy}::${functionName}"; | 1904 $functionName = "${implementedBy}::${functionName}"; |
| 1905 } elsif ($attribute->isStatic) { | 1905 } elsif ($attribute->isStatic) { |
| 1906 $functionName = "${implClassName}::${functionName}"; | 1906 $functionName = "${implClassName}::${functionName}"; |
| 1907 } else { | 1907 } else { |
| 1908 $functionName = "imp->${functionName}"; | 1908 $functionName = "imp->${functionName}"; |
| 1909 } | 1909 } |
| 1910 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend
edAttributes->{"SetterCallWith"} || $attribute->signature->extendedAttributes->{
"CallWith"}, " ", 1); | 1910 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttribute
s->{"SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1
); |
| 1911 $code .= $subCode; | 1911 $code .= $subCode; |
| 1912 unshift(@arguments, @$arg); | 1912 unshift(@arguments, @$arg); |
| 1913 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; | 1913 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; |
| 1914 } | 1914 } |
| 1915 } | 1915 } |
| 1916 | 1916 |
| 1917 if ($useExceptions) { | 1917 if ($useExceptions) { |
| 1918 $code .= " if (UNLIKELY(ec))\n"; | 1918 $code .= " if (UNLIKELY(ec))\n"; |
| 1919 $code .= " setDOMException(ec, info.GetIsolate());\n"; | 1919 $code .= " setDOMException(ec, info.GetIsolate());\n"; |
| 1920 } | 1920 } |
| 1921 | 1921 |
| 1922 if (ExtendedAttributeContains($attribute->signature->extendedAttributes->{"C
allWith"}, "ScriptState")) { | 1922 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"},
"ScriptState")) { |
| 1923 $code .= " if (state.hadException())\n"; | 1923 $code .= " if (state.hadException())\n"; |
| 1924 $code .= " throwError(state.exception(), info.GetIsolate());\n"; | 1924 $code .= " throwError(state.exception(), info.GetIsolate());\n"; |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 if ($svgNativeType) { | 1927 if ($svgNativeType) { |
| 1928 if ($useExceptions) { | 1928 if ($useExceptions) { |
| 1929 $code .= " if (!ec)\n"; | 1929 $code .= " if (!ec)\n"; |
| 1930 $code .= " wrapper->commitChange();\n"; | 1930 $code .= " wrapper->commitChange();\n"; |
| 1931 } else { | 1931 } else { |
| 1932 $code .= " wrapper->commitChange();\n"; | 1932 $code .= " wrapper->commitChange();\n"; |
| 1933 } | 1933 } |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 if ($attribute->signature->type eq "SerializedScriptValue" && $attribute->si
gnature->extendedAttributes->{"CachedAttribute"}) { | 1936 if ($attribute->type eq "SerializedScriptValue" && $attribute->extendedAttri
butes->{"CachedAttribute"}) { |
| 1937 $code .= <<END; | 1937 $code .= <<END; |
| 1938 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I
nvalidate the cached value. | 1938 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I
nvalidate the cached value. |
| 1939 END | 1939 END |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 $code .= " return;\n"; | 1942 $code .= " return;\n"; |
| 1943 $code .= "}\n\n"; # end of setter | 1943 $code .= "}\n\n"; # end of setter |
| 1944 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1944 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1945 $implementation{nameSpaceInternal}->add($code); | 1945 $implementation{nameSpaceInternal}->add($code); |
| 1946 } | 1946 } |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2685 foreach my $interfaceBase (@{$interface->parents}) { | 2685 foreach my $interfaceBase (@{$interface->parents}) { |
| 2686 $code .= <<END; | 2686 $code .= <<END; |
| 2687 if (!fill${interfaceBase}Init(eventInit, options)) | 2687 if (!fill${interfaceBase}Init(eventInit, options)) |
| 2688 return false; | 2688 return false; |
| 2689 | 2689 |
| 2690 END | 2690 END |
| 2691 } | 2691 } |
| 2692 | 2692 |
| 2693 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 2693 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
| 2694 my $attribute = @{$interface->attributes}[$index]; | 2694 my $attribute = @{$interface->attributes}[$index]; |
| 2695 if ($attribute->signature->extendedAttributes->{"InitializedByEventConst
ructor"}) { | 2695 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { |
| 2696 my $attributeName = $attribute->signature->name; | 2696 my $attributeName = $attribute->name; |
| 2697 $code .= " options.get(\"$attributeName\", eventInit.$attributeNa
me);\n"; | 2697 $code .= " options.get(\"$attributeName\", eventInit.$attributeNa
me);\n"; |
| 2698 } | 2698 } |
| 2699 } | 2699 } |
| 2700 | 2700 |
| 2701 $code .= <<END; | 2701 $code .= <<END; |
| 2702 return true; | 2702 return true; |
| 2703 } | 2703 } |
| 2704 | 2704 |
| 2705 END | 2705 END |
| 2706 $implementation{nameSpaceWebCore}->add($code); | 2706 $implementation{nameSpaceWebCore}->add($code); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 return $content; | 2873 return $content; |
| 2874 } | 2874 } |
| 2875 | 2875 |
| 2876 sub GenerateBatchedAttributeData | 2876 sub GenerateBatchedAttributeData |
| 2877 { | 2877 { |
| 2878 my $interface = shift; | 2878 my $interface = shift; |
| 2879 my $attributes = shift; | 2879 my $attributes = shift; |
| 2880 my $code = ""; | 2880 my $code = ""; |
| 2881 | 2881 |
| 2882 foreach my $attribute (@$attributes) { | 2882 foreach my $attribute (@$attributes) { |
| 2883 my $conditionalString = GenerateConditionalString($attribute->signature)
; | 2883 my $conditionalString = GenerateConditionalString($attribute); |
| 2884 my $subCode = ""; | 2884 my $subCode = ""; |
| 2885 $subCode .= "#if ${conditionalString}\n" if $conditionalString; | 2885 $subCode .= "#if ${conditionalString}\n" if $conditionalString; |
| 2886 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",",
""); | 2886 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",",
""); |
| 2887 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; | 2887 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 2888 $code .= $subCode; | 2888 $code .= $subCode; |
| 2889 } | 2889 } |
| 2890 return $code; | 2890 return $code; |
| 2891 } | 2891 } |
| 2892 | 2892 |
| 2893 sub GenerateSingleBatchedAttribute | 2893 sub GenerateSingleBatchedAttribute |
| 2894 { | 2894 { |
| 2895 my $interface = shift; | 2895 my $interface = shift; |
| 2896 my $attribute = shift; | 2896 my $attribute = shift; |
| 2897 my $delimiter = shift; | 2897 my $delimiter = shift; |
| 2898 my $indent = shift; | 2898 my $indent = shift; |
| 2899 my $code = ""; | 2899 my $code = ""; |
| 2900 my $attrName = $attribute->signature->name; | 2900 my $attrName = $attribute->name; |
| 2901 my $attrExt = $attribute->signature->extendedAttributes; | 2901 my $attrExt = $attribute->extendedAttributes; |
| 2902 my $implClassName = GetImplName($interface); | 2902 my $implClassName = GetImplName($interface); |
| 2903 | 2903 |
| 2904 my $accessControl = "v8::DEFAULT"; | 2904 my $accessControl = "v8::DEFAULT"; |
| 2905 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { | 2905 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { |
| 2906 $accessControl = "v8::ALL_CAN_READ"; | 2906 $accessControl = "v8::ALL_CAN_READ"; |
| 2907 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { | 2907 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { |
| 2908 $accessControl = "v8::ALL_CAN_WRITE"; | 2908 $accessControl = "v8::ALL_CAN_WRITE"; |
| 2909 } elsif ($attrExt->{"DoNotCheckSecurity"}) { | 2909 } elsif ($attrExt->{"DoNotCheckSecurity"}) { |
| 2910 $accessControl = "v8::ALL_CAN_READ"; | 2910 $accessControl = "v8::ALL_CAN_READ"; |
| 2911 if (!IsReadonly($attribute)) { | 2911 if (!IsReadonly($attribute)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2922 # use the naming convension, interface + (capitalize) attr name | 2922 # use the naming convension, interface + (capitalize) attr name |
| 2923 $customAccessor = $implClassName . "::" . $attrName; | 2923 $customAccessor = $implClassName . "::" . $attrName; |
| 2924 } | 2924 } |
| 2925 | 2925 |
| 2926 my $getter; | 2926 my $getter; |
| 2927 my $setter; | 2927 my $setter; |
| 2928 my $getterForMainWorld; | 2928 my $getterForMainWorld; |
| 2929 my $setterForMainWorld; | 2929 my $setterForMainWorld; |
| 2930 my $propAttr = "v8::None"; | 2930 my $propAttr = "v8::None"; |
| 2931 | 2931 |
| 2932 my $isConstructor = ($attribute->signature->type =~ /Constructor$/); | 2932 my $isConstructor = ($attribute->type =~ /Constructor$/); |
| 2933 | 2933 |
| 2934 # Check attributes. | 2934 # Check attributes. |
| 2935 # As per Web IDL specification, constructor properties on the ECMAScript glo
bal object should be | 2935 # As per Web IDL specification, constructor properties on the ECMAScript glo
bal object should be |
| 2936 # configurable and should not be enumerable. | 2936 # configurable and should not be enumerable. |
| 2937 if ($attrExt->{"NotEnumerable"} || $isConstructor) { | 2937 if ($attrExt->{"NotEnumerable"} || $isConstructor) { |
| 2938 $propAttr .= " | v8::DontEnum"; | 2938 $propAttr .= " | v8::DontEnum"; |
| 2939 } | 2939 } |
| 2940 if ($attrExt->{"Unforgeable"} && !$isConstructor) { | 2940 if ($attrExt->{"Unforgeable"} && !$isConstructor) { |
| 2941 $propAttr .= " | v8::DontDelete"; | 2941 $propAttr .= " | v8::DontDelete"; |
| 2942 } | 2942 } |
| 2943 | 2943 |
| 2944 my $on_proto = "0 /* on instance */"; | 2944 my $on_proto = "0 /* on instance */"; |
| 2945 my $data = "0 /* no data */"; | 2945 my $data = "0 /* no data */"; |
| 2946 | 2946 |
| 2947 # Constructor | 2947 # Constructor |
| 2948 if ($isConstructor) { | 2948 if ($isConstructor) { |
| 2949 my $constructorType = $attribute->signature->type; | 2949 my $constructorType = $attribute->type; |
| 2950 $constructorType =~ s/Constructor$//; | 2950 $constructorType =~ s/Constructor$//; |
| 2951 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. | 2951 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. |
| 2952 # We do not generate the header file for NamedConstructor of class XXXX, | 2952 # We do not generate the header file for NamedConstructor of class XXXX, |
| 2953 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. | 2953 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. |
| 2954 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende
dAttributes->{"CustomConstructor"}) { | 2954 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes
->{"CustomConstructor"}) { |
| 2955 AddToImplIncludes("V8${constructorType}.h"); | 2955 AddToImplIncludes("V8${constructorType}.h"); |
| 2956 } | 2956 } |
| 2957 $data = "&V8${constructorType}::info"; | 2957 $data = "&V8${constructorType}::info"; |
| 2958 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter
"; | 2958 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter
"; |
| 2959 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrSe
tterCallback"; | 2959 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrSe
tterCallback"; |
| 2960 $getterForMainWorld = "0"; | 2960 $getterForMainWorld = "0"; |
| 2961 $setterForMainWorld = "0"; | 2961 $setterForMainWorld = "0"; |
| 2962 } else { | 2962 } else { |
| 2963 # Default Getter and Setter | 2963 # Default Getter and Setter |
| 2964 $getter = "${implClassName}V8Internal::${attrName}AttrGetterCallback"; | 2964 $getter = "${implClassName}V8Internal::${attrName}AttrGetterCallback"; |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3733 $implementation{nameSpaceWebCore}->addHeader($code); | 3733 $implementation{nameSpaceWebCore}->addHeader($code); |
| 3734 | 3734 |
| 3735 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); | 3735 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); |
| 3736 | 3736 |
| 3737 my $hasConstructors = 0; | 3737 my $hasConstructors = 0; |
| 3738 my $hasReplaceable = 0; | 3738 my $hasReplaceable = 0; |
| 3739 | 3739 |
| 3740 # Generate property accessors for attributes. | 3740 # Generate property accessors for attributes. |
| 3741 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 3741 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
| 3742 my $attribute = @{$interface->attributes}[$index]; | 3742 my $attribute = @{$interface->attributes}[$index]; |
| 3743 my $attrType = $attribute->signature->type; | 3743 my $attrType = $attribute->type; |
| 3744 my $attrExt = $attribute->signature->extendedAttributes; | 3744 my $attrExt = $attribute->extendedAttributes; |
| 3745 | 3745 |
| 3746 # Generate special code for the constructor attributes. | 3746 # Generate special code for the constructor attributes. |
| 3747 if ($attrType =~ /Constructor$/) { | 3747 if ($attrType =~ /Constructor$/) { |
| 3748 if (!HasCustomGetter($attrExt)) { | 3748 if (!HasCustomGetter($attrExt)) { |
| 3749 $hasConstructors = 1; | 3749 $hasConstructors = 1; |
| 3750 } | 3750 } |
| 3751 next; | 3751 next; |
| 3752 } | 3752 } |
| 3753 | 3753 |
| 3754 if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") { | 3754 if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3861 | 3861 |
| 3862 # For the DOMWindow interface we partition the attributes into the | 3862 # For the DOMWindow interface we partition the attributes into the |
| 3863 # ones that disallows shadowing and the rest. | 3863 # ones that disallows shadowing and the rest. |
| 3864 my @disallowsShadowing; | 3864 my @disallowsShadowing; |
| 3865 # Also separate out attributes that are enabled at runtime so we can process
them specially. | 3865 # Also separate out attributes that are enabled at runtime so we can process
them specially. |
| 3866 my @enabledAtRuntimeAttributes; | 3866 my @enabledAtRuntimeAttributes; |
| 3867 my @enabledPerContextAttributes; | 3867 my @enabledPerContextAttributes; |
| 3868 my @normalAttributes; | 3868 my @normalAttributes; |
| 3869 foreach my $attribute (@$attributes) { | 3869 foreach my $attribute (@$attributes) { |
| 3870 | 3870 |
| 3871 if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttr
ibutes->{"Unforgeable"}) { | 3871 if ($interfaceName eq "DOMWindow" && $attribute->extendedAttributes->{"U
nforgeable"}) { |
| 3872 push(@disallowsShadowing, $attribute); | 3872 push(@disallowsShadowing, $attribute); |
| 3873 } elsif ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"}
|| $attribute->signature->extendedAttributes->{"EnabledPerContext"}) { | 3873 } elsif ($attribute->extendedAttributes->{"EnabledAtRuntime"} || $attrib
ute->extendedAttributes->{"EnabledPerContext"}) { |
| 3874 if ($attribute->signature->extendedAttributes->{"EnabledPerContext"}
) { | 3874 if ($attribute->extendedAttributes->{"EnabledPerContext"}) { |
| 3875 push(@enabledPerContextAttributes, $attribute); | 3875 push(@enabledPerContextAttributes, $attribute); |
| 3876 } | 3876 } |
| 3877 if ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"})
{ | 3877 if ($attribute->extendedAttributes->{"EnabledAtRuntime"}) { |
| 3878 push(@enabledAtRuntimeAttributes, $attribute); | 3878 push(@enabledAtRuntimeAttributes, $attribute); |
| 3879 } | 3879 } |
| 3880 } else { | 3880 } else { |
| 3881 push(@normalAttributes, $attribute); | 3881 push(@normalAttributes, $attribute); |
| 3882 } | 3882 } |
| 3883 } | 3883 } |
| 3884 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); | 3884 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); |
| 3885 $attributes = \@normalAttributes; | 3885 $attributes = \@normalAttributes; |
| 3886 # Put the attributes that disallow shadowing on the shadow object. | 3886 # Put the attributes that disallow shadowing on the shadow object. |
| 3887 if (@disallowsShadowing) { | 3887 if (@disallowsShadowing) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4070 END | 4070 END |
| 4071 } | 4071 } |
| 4072 | 4072 |
| 4073 if ($access_check) { | 4073 if ($access_check) { |
| 4074 $code .= " $access_check\n"; | 4074 $code .= " $access_check\n"; |
| 4075 } | 4075 } |
| 4076 | 4076 |
| 4077 # Setup the enable-at-runtime attrs if we have them | 4077 # Setup the enable-at-runtime attrs if we have them |
| 4078 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { | 4078 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { |
| 4079 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes; | 4079 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes; |
| 4080 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signat
ure); | 4080 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr); |
| 4081 my $conditionalString = GenerateConditionalString($runtime_attr->signatu
re); | 4081 my $conditionalString = GenerateConditionalString($runtime_attr); |
| 4082 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 4082 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 4083 $code .= " if (${enable_function}()) {\n"; | 4083 $code .= " if (${enable_function}()) {\n"; |
| 4084 $code .= " static const V8DOMConfiguration::BatchedAttribute attr
Data =\\\n"; | 4084 $code .= " static const V8DOMConfiguration::BatchedAttribute attr
Data =\\\n"; |
| 4085 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";",
" "); | 4085 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";",
" "); |
| 4086 $code .= <<END; | 4086 $code .= <<END; |
| 4087 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e, currentWorldType); | 4087 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e, currentWorldType); |
| 4088 } | 4088 } |
| 4089 END | 4089 END |
| 4090 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; | 4090 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; |
| 4091 } | 4091 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4197 if (@enabledPerContextAttributes) { | 4197 if (@enabledPerContextAttributes) { |
| 4198 my $code = ""; | 4198 my $code = ""; |
| 4199 $code .= <<END; | 4199 $code .= <<END; |
| 4200 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance
, ${nativeType}* impl, v8::Isolate* isolate) | 4200 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance
, ${nativeType}* impl, v8::Isolate* isolate) |
| 4201 { | 4201 { |
| 4202 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); | 4202 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); |
| 4203 END | 4203 END |
| 4204 | 4204 |
| 4205 # Setup the enable-by-settings attrs if we have them | 4205 # Setup the enable-by-settings attrs if we have them |
| 4206 foreach my $runtimeAttr (@enabledPerContextAttributes) { | 4206 foreach my $runtimeAttr (@enabledPerContextAttributes) { |
| 4207 my $enableFunction = GetContextEnableFunction($runtimeAttr->signatur
e); | 4207 my $enableFunction = GetContextEnableFunction($runtimeAttr); |
| 4208 my $conditionalString = GenerateConditionalString($runtimeAttr->sign
ature); | 4208 my $conditionalString = GenerateConditionalString($runtimeAttr); |
| 4209 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 4209 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 4210 if (grep { $_ eq $runtimeAttr } @enabledAtRuntimeAttributes) { | 4210 if (grep { $_ eq $runtimeAttr } @enabledAtRuntimeAttributes) { |
| 4211 my $runtimeEnableFunction = GetRuntimeEnableFunctionName($runtim
eAttr->signature); | 4211 my $runtimeEnableFunction = GetRuntimeEnableFunctionName($runtim
eAttr); |
| 4212 $code .= " if (${enableFunction}(impl->document()) && ${runti
meEnableFunction}()) {\n"; | 4212 $code .= " if (${enableFunction}(impl->document()) && ${runti
meEnableFunction}()) {\n"; |
| 4213 } else { | 4213 } else { |
| 4214 $code .= " if (${enableFunction}(impl->document())) {\n"; | 4214 $code .= " if (${enableFunction}(impl->document())) {\n"; |
| 4215 } | 4215 } |
| 4216 | 4216 |
| 4217 $code .= " static const V8DOMConfiguration::BatchedAttribute
attrData =\\\n"; | 4217 $code .= " static const V8DOMConfiguration::BatchedAttribute
attrData =\\\n"; |
| 4218 $code .= GenerateSingleBatchedAttribute($interface, $runtimeAttr, ";
", " "); | 4218 $code .= GenerateSingleBatchedAttribute($interface, $runtimeAttr, ";
", " "); |
| 4219 $code .= <<END; | 4219 $code .= <<END; |
| 4220 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e); | 4220 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e); |
| 4221 END | 4221 END |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5646 push(@{$nameToFunctionsMap{$name}}, $function); | 5646 push(@{$nameToFunctionsMap{$name}}, $function); |
| 5647 $function->{overloads} = $nameToFunctionsMap{$name}; | 5647 $function->{overloads} = $nameToFunctionsMap{$name}; |
| 5648 $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; | 5648 $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; |
| 5649 } | 5649 } |
| 5650 } | 5650 } |
| 5651 | 5651 |
| 5652 sub AttributeNameForGetterAndSetter | 5652 sub AttributeNameForGetterAndSetter |
| 5653 { | 5653 { |
| 5654 my $attribute = shift; | 5654 my $attribute = shift; |
| 5655 | 5655 |
| 5656 my $attributeName = GetImplName($attribute->signature); | 5656 my $attributeName = GetImplName($attribute); |
| 5657 if ($attribute->signature->extendedAttributes->{"ImplementedAs"}) { | 5657 if ($attribute->extendedAttributes->{"ImplementedAs"}) { |
| 5658 $attributeName = $attribute->signature->extendedAttributes->{"Implemente
dAs"}; | 5658 $attributeName = $attribute->extendedAttributes->{"ImplementedAs"}; |
| 5659 } | 5659 } |
| 5660 my $attributeType = $attribute->signature->type; | 5660 my $attributeType = $attribute->type; |
| 5661 | 5661 |
| 5662 # Avoid clash with C++ keyword. | 5662 # Avoid clash with C++ keyword. |
| 5663 $attributeName = "_operator" if $attributeName eq "operator"; | 5663 $attributeName = "_operator" if $attributeName eq "operator"; |
| 5664 | 5664 |
| 5665 # SVGAElement defines a non-virtual "String& target() const" method which cl
ashes with "virtual String target() const" in Element. | 5665 # SVGAElement defines a non-virtual "String& target() const" method which cl
ashes with "virtual String target() const" in Element. |
| 5666 # To solve this issue the SVGAElement method was renamed to "svgTarget", tak
e care of that when calling this method. | 5666 # To solve this issue the SVGAElement method was renamed to "svgTarget", tak
e care of that when calling this method. |
| 5667 $attributeName = "svgTarget" if $attributeName eq "target" and $attributeTyp
e eq "SVGAnimatedString"; | 5667 $attributeName = "svgTarget" if $attributeName eq "target" and $attributeTyp
e eq "SVGAnimatedString"; |
| 5668 | 5668 |
| 5669 # SVG animated types need to use a special attribute name. | 5669 # SVG animated types need to use a special attribute name. |
| 5670 # The rest of the special casing for SVG animated types is handled in the la
nguage-specific code generators. | 5670 # The rest of the special casing for SVG animated types is handled in the la
nguage-specific code generators. |
| 5671 $attributeName .= "Animated" if IsSVGAnimatedType($attributeType); | 5671 $attributeName .= "Animated" if IsSVGAnimatedType($attributeType); |
| 5672 | 5672 |
| 5673 return $attributeName; | 5673 return $attributeName; |
| 5674 } | 5674 } |
| 5675 | 5675 |
| 5676 sub ContentAttributeName | 5676 sub ContentAttributeName |
| 5677 { | 5677 { |
| 5678 my ($interfaceName, $attribute) = @_; | 5678 my ($interfaceName, $attribute) = @_; |
| 5679 | 5679 |
| 5680 my $contentAttributeName = $attribute->signature->extendedAttributes->{"Refl
ect"}; | 5680 my $contentAttributeName = $attribute->extendedAttributes->{"Reflect"}; |
| 5681 return undef if !$contentAttributeName; | 5681 return undef if !$contentAttributeName; |
| 5682 | 5682 |
| 5683 $contentAttributeName = lc AttributeNameForGetterAndSetter($attribute) if $c
ontentAttributeName eq "VALUE_IS_MISSING"; | 5683 $contentAttributeName = lc AttributeNameForGetterAndSetter($attribute) if $c
ontentAttributeName eq "VALUE_IS_MISSING"; |
| 5684 | 5684 |
| 5685 my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeN
ame); | 5685 my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeN
ame); |
| 5686 | 5686 |
| 5687 AddToImplIncludes("${namespace}.h"); | 5687 AddToImplIncludes("${namespace}.h"); |
| 5688 return "WebCore::${namespace}::${contentAttributeName}Attr"; | 5688 return "WebCore::${namespace}::${contentAttributeName}Attr"; |
| 5689 } | 5689 } |
| 5690 | 5690 |
| 5691 sub CanUseFastAttribute | 5691 sub CanUseFastAttribute |
| 5692 { | 5692 { |
| 5693 my $attribute = shift; | 5693 my $attribute = shift; |
| 5694 return !IsSVGAnimatedType($attribute->signature->type); | 5694 return !IsSVGAnimatedType($attribute->type); |
| 5695 } | 5695 } |
| 5696 | 5696 |
| 5697 sub GetterExpression | 5697 sub GetterExpression |
| 5698 { | 5698 { |
| 5699 my ($interfaceName, $attribute) = @_; | 5699 my ($interfaceName, $attribute) = @_; |
| 5700 | 5700 |
| 5701 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); | 5701 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); |
| 5702 | 5702 |
| 5703 if (!$contentAttributeName) { | 5703 if (!$contentAttributeName) { |
| 5704 return (ToMethodName(AttributeNameForGetterAndSetter($attribute))); | 5704 return (ToMethodName(AttributeNameForGetterAndSetter($attribute))); |
| 5705 } | 5705 } |
| 5706 | 5706 |
| 5707 my $functionName; | 5707 my $functionName; |
| 5708 if ($attribute->signature->extendedAttributes->{"URL"}) { | 5708 if ($attribute->extendedAttributes->{"URL"}) { |
| 5709 $functionName = "getURLAttribute"; | 5709 $functionName = "getURLAttribute"; |
| 5710 } elsif ($attribute->signature->type eq "boolean") { | 5710 } elsif ($attribute->type eq "boolean") { |
| 5711 if (CanUseFastAttribute($attribute)) { | 5711 if (CanUseFastAttribute($attribute)) { |
| 5712 $functionName = "fastHasAttribute"; | 5712 $functionName = "fastHasAttribute"; |
| 5713 } else { | 5713 } else { |
| 5714 $functionName = "hasAttribute"; | 5714 $functionName = "hasAttribute"; |
| 5715 } | 5715 } |
| 5716 } elsif ($attribute->signature->type eq "long") { | 5716 } elsif ($attribute->type eq "long") { |
| 5717 $functionName = "getIntegralAttribute"; | 5717 $functionName = "getIntegralAttribute"; |
| 5718 } elsif ($attribute->signature->type eq "unsigned long") { | 5718 } elsif ($attribute->type eq "unsigned long") { |
| 5719 $functionName = "getUnsignedIntegralAttribute"; | 5719 $functionName = "getUnsignedIntegralAttribute"; |
| 5720 } else { | 5720 } else { |
| 5721 if ($contentAttributeName eq "WebCore::HTMLNames::idAttr") { | 5721 if ($contentAttributeName eq "WebCore::HTMLNames::idAttr") { |
| 5722 $functionName = "getIdAttribute"; | 5722 $functionName = "getIdAttribute"; |
| 5723 $contentAttributeName = ""; | 5723 $contentAttributeName = ""; |
| 5724 } elsif ($contentAttributeName eq "WebCore::HTMLNames::nameAttr") { | 5724 } elsif ($contentAttributeName eq "WebCore::HTMLNames::nameAttr") { |
| 5725 $functionName = "getNameAttribute"; | 5725 $functionName = "getNameAttribute"; |
| 5726 $contentAttributeName = ""; | 5726 $contentAttributeName = ""; |
| 5727 } elsif ($contentAttributeName eq "WebCore::HTMLNames::classAttr") { | 5727 } elsif ($contentAttributeName eq "WebCore::HTMLNames::classAttr") { |
| 5728 $functionName = "getClassAttribute"; | 5728 $functionName = "getClassAttribute"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5741 { | 5741 { |
| 5742 my ($interfaceName, $attribute) = @_; | 5742 my ($interfaceName, $attribute) = @_; |
| 5743 | 5743 |
| 5744 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); | 5744 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); |
| 5745 | 5745 |
| 5746 if (!$contentAttributeName) { | 5746 if (!$contentAttributeName) { |
| 5747 return ("set" . FirstLetterToUpperCase(AttributeNameForGetterAndSetter($
attribute))); | 5747 return ("set" . FirstLetterToUpperCase(AttributeNameForGetterAndSetter($
attribute))); |
| 5748 } | 5748 } |
| 5749 | 5749 |
| 5750 my $functionName; | 5750 my $functionName; |
| 5751 if ($attribute->signature->type eq "boolean") { | 5751 if ($attribute->type eq "boolean") { |
| 5752 $functionName = "setBooleanAttribute"; | 5752 $functionName = "setBooleanAttribute"; |
| 5753 } elsif ($attribute->signature->type eq "long") { | 5753 } elsif ($attribute->type eq "long") { |
| 5754 $functionName = "setIntegralAttribute"; | 5754 $functionName = "setIntegralAttribute"; |
| 5755 } elsif ($attribute->signature->type eq "unsigned long") { | 5755 } elsif ($attribute->type eq "unsigned long") { |
| 5756 $functionName = "setUnsignedIntegralAttribute"; | 5756 $functionName = "setUnsignedIntegralAttribute"; |
| 5757 } else { | 5757 } else { |
| 5758 $functionName = "setAttribute"; | 5758 $functionName = "setAttribute"; |
| 5759 } | 5759 } |
| 5760 | 5760 |
| 5761 return ($functionName, $contentAttributeName); | 5761 return ($functionName, $contentAttributeName); |
| 5762 } | 5762 } |
| 5763 | 5763 |
| 5764 sub GenerateConditionalString | 5764 sub GenerateConditionalString |
| 5765 { | 5765 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5865 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5865 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 5866 $found = 1; | 5866 $found = 1; |
| 5867 } | 5867 } |
| 5868 return 1 if $found; | 5868 return 1 if $found; |
| 5869 }, 0); | 5869 }, 0); |
| 5870 | 5870 |
| 5871 return $found; | 5871 return $found; |
| 5872 } | 5872 } |
| 5873 | 5873 |
| 5874 1; | 5874 1; |
| OLD | NEW |