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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 $code .= <<END; | 1287 $code .= <<END; |
1288 V8PerContextData* contextData = V8PerContextData::from(args.GetIsolate()->Ge
tCurrentContext()); | 1288 V8PerContextData* contextData = V8PerContextData::from(args.GetIsolate()->Ge
tCurrentContext()); |
1289 if (contextData && contextData->activityLogger()) { | 1289 if (contextData && contextData->activityLogger()) { |
1290 Vector<v8::Handle<v8::Value> > loggerArgs = toVectorOfArguments(args); | 1290 Vector<v8::Handle<v8::Value> > loggerArgs = toVectorOfArguments(args); |
1291 contextData->activityLogger()->log("${interfaceName}.${propertyName}", a
rgs.Length(), loggerArgs.data(), "${accessType}"); | 1291 contextData->activityLogger()->log("${interfaceName}.${propertyName}", a
rgs.Length(), loggerArgs.data(), "${accessType}"); |
1292 } | 1292 } |
1293 END | 1293 END |
1294 } elsif ($accessType eq "Setter") { | 1294 } elsif ($accessType eq "Setter") { |
1295 $code .= <<END; | 1295 $code .= <<END; |
1296 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 1296 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 1297 /* |
1297 if (contextData && contextData->activityLogger()) { | 1298 if (contextData && contextData->activityLogger()) { |
1298 v8::Handle<v8::Value> loggerArg[] = { jsValue }; | 1299 v8::Handle<v8::Value> loggerArg[] = { jsValue }; |
1299 contextData->activityLogger()->log("${interfaceName}.${propertyName}", 1
, &loggerArg[0], "${accessType}"); | 1300 contextData->activityLogger()->log("${interfaceName}.${propertyName}", 1
, &loggerArg[0], "${accessType}"); |
1300 } | 1301 } |
| 1302 */ |
1301 END | 1303 END |
1302 } elsif ($accessType eq "Getter") { | 1304 } elsif ($accessType eq "Getter") { |
1303 $code .= <<END; | 1305 $code .= <<END; |
1304 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 1306 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
1305 if (contextData && contextData->activityLogger()) | 1307 if (contextData && contextData->activityLogger()) |
1306 contextData->activityLogger()->log("${interfaceName}.${propertyName}", 0
, 0, "${accessType}"); | 1308 contextData->activityLogger()->log("${interfaceName}.${propertyName}", 0
, 0, "${accessType}"); |
1307 END | 1309 END |
1308 } else { | 1310 } else { |
1309 die "Unrecognized activity logging access type"; | 1311 die "Unrecognized activity logging access type"; |
1310 } | 1312 } |
1311 | 1313 |
1312 return $code; | 1314 return $code; |
1313 } | 1315 } |
1314 | 1316 |
1315 sub GenerateNormalAttributeGetterCallback | 1317 sub GenerateNormalAttributeGetterCallback |
1316 { | 1318 { |
1317 my $attribute = shift; | 1319 my $attribute = shift; |
1318 my $interface = shift; | 1320 my $interface = shift; |
1319 my $forMainWorldSuffix = shift; | 1321 my $forMainWorldSuffix = shift; |
| 1322 my $isAccessor = shift; |
1320 | 1323 |
1321 my $implClassName = GetImplName($interface); | 1324 my $implClassName = GetImplName($interface); |
1322 my $v8ClassName = GetV8ClassName($interface); | 1325 my $v8ClassName = GetV8ClassName($interface); |
1323 my $attrExt = $attribute->extendedAttributes; | 1326 my $attrExt = $attribute->extendedAttributes; |
1324 my $attrName = $attribute->name; | 1327 my $attrName = $attribute->name; |
1325 | 1328 |
1326 my $conditionalString = GenerateConditionalString($attribute); | 1329 my $conditionalString = GenerateConditionalString($attribute); |
1327 my $code = ""; | 1330 my $code = ""; |
1328 $code .= "#if ${conditionalString}\n" if $conditionalString; | 1331 $code .= "#if ${conditionalString}\n" if $conditionalString; |
1329 | 1332 |
1330 $code .= "static void ${attrName}AttributeGetterCallback${forMainWorldSuffix
}(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n
"; | 1333 if ($isAccessor) { |
| 1334 $code .= "static void ${attrName}AttributeGetterCallback${forMainWorldSu
ffix}(const v8::FunctionCallbackInfo<v8::Value>& info)\n"; |
| 1335 } else { |
| 1336 $code .= "static void ${attrName}AttributeGetterCallback${forMainWorldSu
ffix}(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& inf
o)\n"; |
| 1337 } |
1331 $code .= "{\n"; | 1338 $code .= "{\n"; |
1332 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n"; | 1339 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n"; |
1333 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1340 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
1334 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); | 1341 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); |
1335 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { | 1342 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { |
1336 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); | 1343 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); |
1337 } | 1344 } |
1338 if (HasCustomGetter($attrExt)) { | 1345 if (HasCustomGetter($attrExt)) { |
1339 $code .= " ${v8ClassName}::${attrName}AttributeGetterCustom(name, inf
o);\n"; | 1346 if ($isAccessor) { |
| 1347 $code .= " ${v8ClassName}::${attrName}AttributeGetterCustom(info)
;\n"; |
| 1348 } else { |
| 1349 $code .= " ${v8ClassName}::${attrName}AttributeGetterCustom(name,
info);\n"; |
| 1350 } |
1340 } else { | 1351 } else { |
1341 $code .= " ${implClassName}V8Internal::${attrName}AttributeGetter${fo
rMainWorldSuffix}(name, info);\n"; | 1352 if ($isAccessor) { |
| 1353 $code .= " ${implClassName}V8Internal::${attrName}AttributeGetter
${forMainWorldSuffix}(info);\n"; |
| 1354 } else { |
| 1355 $code .= " ${implClassName}V8Internal::${attrName}AttributeGetter
${forMainWorldSuffix}(name, info);\n"; |
| 1356 } |
1342 } | 1357 } |
1343 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; | 1358 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; |
1344 $code .= "}\n"; | 1359 $code .= "}\n"; |
1345 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 1360 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
1346 $code .= "\n"; | 1361 $code .= "\n"; |
1347 | 1362 |
1348 $implementation{nameSpaceInternal}->add($code); | 1363 $implementation{nameSpaceInternal}->add($code); |
1349 } | 1364 } |
1350 | 1365 |
1351 sub GetCachedAttribute | 1366 sub GetCachedAttribute |
1352 { | 1367 { |
1353 my $attribute = shift; | 1368 my $attribute = shift; |
1354 my $attrExt = $attribute->extendedAttributes; | 1369 my $attrExt = $attribute->extendedAttributes; |
1355 if (($attribute->type eq "any" || $attribute->type eq "SerializedScriptValue
") && $attrExt->{"CachedAttribute"}) { | 1370 if (($attribute->type eq "any" || $attribute->type eq "SerializedScriptValue
") && $attrExt->{"CachedAttribute"}) { |
1356 return $attrExt->{"CachedAttribute"}; | 1371 return $attrExt->{"CachedAttribute"}; |
1357 } | 1372 } |
1358 return ""; | 1373 return ""; |
1359 } | 1374 } |
1360 | 1375 |
1361 sub GenerateNormalAttributeGetter | 1376 sub GenerateNormalAttributeGetter |
1362 { | 1377 { |
1363 my $attribute = shift; | 1378 my $attribute = shift; |
1364 my $interface = shift; | 1379 my $interface = shift; |
1365 my $forMainWorldSuffix = shift; | 1380 my $forMainWorldSuffix = shift; |
| 1381 my $isAccessor = shift; |
1366 | 1382 |
1367 my $interfaceName = $interface->name; | 1383 my $interfaceName = $interface->name; |
1368 my $implClassName = GetImplName($interface); | 1384 my $implClassName = GetImplName($interface); |
1369 my $v8ClassName = GetV8ClassName($interface); | 1385 my $v8ClassName = GetV8ClassName($interface); |
1370 my $attrExt = $attribute->extendedAttributes; | 1386 my $attrExt = $attribute->extendedAttributes; |
1371 my $attrName = $attribute->name; | 1387 my $attrName = $attribute->name; |
1372 my $attrType = $attribute->type; | 1388 my $attrType = $attribute->type; |
1373 my $attrCached = GetCachedAttribute($attribute); | 1389 my $attrCached = GetCachedAttribute($attribute); |
1374 | 1390 |
1375 if (HasCustomGetter($attrExt)) { | 1391 if (HasCustomGetter($attrExt)) { |
1376 return; | 1392 return; |
1377 } | 1393 } |
1378 | 1394 |
1379 AssertNotSequenceType($attrType); | 1395 AssertNotSequenceType($attrType); |
1380 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu
tes, ""); | 1396 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu
tes, ""); |
1381 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1397 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
1382 | 1398 |
1383 my $conditionalString = GenerateConditionalString($attribute); | 1399 my $conditionalString = GenerateConditionalString($attribute); |
1384 my $code = ""; | 1400 my $code = ""; |
1385 $code .= "#if ${conditionalString}\n" if $conditionalString; | 1401 $code .= "#if ${conditionalString}\n" if $conditionalString; |
1386 $code .= <<END; | 1402 if ($isAccessor) { |
1387 static void ${attrName}AttributeGetter${forMainWorldSuffix}(v8::Local<v8::String
> name, const v8::PropertyCallbackInfo<v8::Value>& info) | 1403 $code .= "static void ${attrName}AttributeGetter${forMainWorldSuffix}(co
nst v8::FunctionCallbackInfo<v8::Value>& info)\n"; |
1388 { | 1404 $code .= "{\n"; |
1389 END | 1405 } else { |
| 1406 $code .= "static void ${attrName}AttributeGetter${forMainWorldSuffix}(v8
::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; |
| 1407 $code .= "{\n"; |
| 1408 } |
1390 if ($svgNativeType) { | 1409 if ($svgNativeType) { |
1391 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); | 1410 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); |
1392 if ($svgWrappedNativeType =~ /List/) { | 1411 if ($svgWrappedNativeType =~ /List/) { |
1393 $code .= <<END; | 1412 $code .= <<END; |
1394 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); | 1413 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); |
1395 END | 1414 END |
1396 } else { | 1415 } else { |
1397 $code .= <<END; | 1416 $code .= <<END; |
1398 $svgNativeType* wrapper = ${v8ClassName}::toNative(info.Holder()); | 1417 $svgNativeType* wrapper = ${v8ClassName}::toNative(info.Holder()); |
1399 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); | 1418 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 END | 1766 END |
1748 } | 1767 } |
1749 return $code; | 1768 return $code; |
1750 } | 1769 } |
1751 | 1770 |
1752 sub GenerateNormalAttributeSetterCallback | 1771 sub GenerateNormalAttributeSetterCallback |
1753 { | 1772 { |
1754 my $attribute = shift; | 1773 my $attribute = shift; |
1755 my $interface = shift; | 1774 my $interface = shift; |
1756 my $forMainWorldSuffix = shift; | 1775 my $forMainWorldSuffix = shift; |
| 1776 my $isAccessor = shift; |
1757 | 1777 |
1758 my $implClassName = GetImplName($interface); | 1778 my $implClassName = GetImplName($interface); |
1759 my $v8ClassName = GetV8ClassName($interface); | 1779 my $v8ClassName = GetV8ClassName($interface); |
1760 my $attrExt = $attribute->extendedAttributes; | 1780 my $attrExt = $attribute->extendedAttributes; |
1761 my $attrName = $attribute->name; | 1781 my $attrName = $attribute->name; |
1762 | 1782 |
1763 my $conditionalString = GenerateConditionalString($attribute); | 1783 my $conditionalString = GenerateConditionalString($attribute); |
1764 my $code = ""; | 1784 my $code = ""; |
1765 $code .= "#if ${conditionalString}\n" if $conditionalString; | 1785 $code .= "#if ${conditionalString}\n" if $conditionalString; |
1766 | 1786 |
1767 $code .= "static void ${attrName}AttributeSetterCallback${forMainWorldSuffix
}(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCa
llbackInfo<void>& info)\n"; | 1787 if ($isAccessor) { |
| 1788 $code .= "static void ${attrName}AttributeSetterCallback${forMainWorldSu
ffix}(const v8::FunctionCallbackInfo<v8::Value>& info)\n"; |
| 1789 } else { |
| 1790 $code .= "static void ${attrName}AttributeSetterCallback${forMainWorldSu
ffix}(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::Proper
tyCallbackInfo<void>& info)\n"; |
| 1791 } |
1768 $code .= "{\n"; | 1792 $code .= "{\n"; |
1769 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n"; | 1793 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n"; |
1770 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1794 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
1771 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); | 1795 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); |
1772 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { | 1796 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { |
1773 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); | 1797 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); |
1774 } | 1798 } |
1775 $code .= GenerateCustomElementInvocationScopeIfNeeded($attrExt); | 1799 $code .= GenerateCustomElementInvocationScopeIfNeeded($attrExt); |
1776 if (HasCustomSetter($attribute)) { | 1800 if (HasCustomSetter($attribute)) { |
1777 $code .= " ${v8ClassName}::${attrName}AttributeSetterCustom(name, jsV
alue, info);\n"; | 1801 if ($isAccessor) { |
| 1802 $code .= " ${v8ClassName}::${attrName}AttributeSetterCustom(info)
;\n"; |
| 1803 } else { |
| 1804 $code .= " ${v8ClassName}::${attrName}AttributeSetterCustom(name,
jsValue, info);\n"; |
| 1805 } |
1778 } else { | 1806 } else { |
1779 $code .= " ${implClassName}V8Internal::${attrName}AttributeSetter${fo
rMainWorldSuffix}(name, jsValue, info);\n"; | 1807 if ($isAccessor) { |
| 1808 $code .= " ${implClassName}V8Internal::${attrName}AttributeSetter
${forMainWorldSuffix}(info);\n"; |
| 1809 } else { |
| 1810 $code .= " ${implClassName}V8Internal::${attrName}AttributeSetter
${forMainWorldSuffix}(name, jsValue, info);\n"; |
| 1811 } |
1780 } | 1812 } |
1781 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; | 1813 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; |
1782 $code .= "}\n"; | 1814 $code .= "}\n"; |
1783 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 1815 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
1784 $code .= "\n"; | 1816 $code .= "\n"; |
1785 $implementation{nameSpaceInternal}->add($code); | 1817 $implementation{nameSpaceInternal}->add($code); |
1786 } | 1818 } |
1787 | 1819 |
1788 sub FindAttributeWithName | 1820 sub FindAttributeWithName |
1789 { | 1821 { |
1790 my $interface = shift; | 1822 my $interface = shift; |
1791 my $attrName = shift; | 1823 my $attrName = shift; |
1792 | 1824 |
1793 foreach my $attribute (@{$interface->attributes}) { | 1825 foreach my $attribute (@{$interface->attributes}) { |
1794 if ($attribute->name eq $attrName) { | 1826 if ($attribute->name eq $attrName) { |
1795 return $attribute; | 1827 return $attribute; |
1796 } | 1828 } |
1797 } | 1829 } |
1798 } | 1830 } |
1799 | 1831 |
1800 sub GenerateNormalAttributeSetter | 1832 sub GenerateNormalAttributeSetter |
1801 { | 1833 { |
1802 my $attribute = shift; | 1834 my $attribute = shift; |
1803 my $interface = shift; | 1835 my $interface = shift; |
1804 my $forMainWorldSuffix = shift; | 1836 my $forMainWorldSuffix = shift; |
| 1837 my $isAccessor = shift; |
1805 | 1838 |
1806 my $interfaceName = $interface->name; | 1839 my $interfaceName = $interface->name; |
1807 my $implClassName = GetImplName($interface); | 1840 my $implClassName = GetImplName($interface); |
1808 my $v8ClassName = GetV8ClassName($interface); | 1841 my $v8ClassName = GetV8ClassName($interface); |
1809 my $attrName = $attribute->name; | 1842 my $attrName = $attribute->name; |
1810 my $attrExt = $attribute->extendedAttributes; | 1843 my $attrExt = $attribute->extendedAttributes; |
1811 my $attrType = $attribute->type; | 1844 my $attrType = $attribute->type; |
1812 my $attrCached = GetCachedAttribute($attribute); | 1845 my $attrCached = GetCachedAttribute($attribute); |
1813 | 1846 |
1814 if (HasCustomSetter($attribute)) { | 1847 if (HasCustomSetter($attribute)) { |
1815 return; | 1848 return; |
1816 } | 1849 } |
1817 | 1850 |
1818 my $conditionalString = GenerateConditionalString($attribute); | 1851 my $conditionalString = GenerateConditionalString($attribute); |
1819 my $code = ""; | 1852 my $code = ""; |
1820 $code .= "#if ${conditionalString}\n" if $conditionalString; | 1853 $code .= "#if ${conditionalString}\n" if $conditionalString; |
1821 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8::Lo
cal<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackIn
fo<void>& info)\n"; | 1854 if ($isAccessor) { |
1822 $code .= "{\n"; | 1855 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(co
nst v8::FunctionCallbackInfo<v8::Value>& info)\n"; |
| 1856 $code .= "{\n"; |
| 1857 $code .= " v8::Local<v8::Value> jsValue = info[0];\n"; |
| 1858 } else { |
| 1859 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8
::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallba
ckInfo<void>& info)\n"; |
| 1860 $code .= "{\n"; |
| 1861 } |
1823 | 1862 |
1824 # If the "StrictTypeChecking" extended attribute is present, and the attribu
te's type is an | 1863 # If the "StrictTypeChecking" extended attribute is present, and the attribu
te's type is an |
1825 # interface type, then if the incoming value does not implement that interfa
ce, a TypeError is | 1864 # interface type, then if the incoming value does not implement that interfa
ce, a TypeError is |
1826 # thrown rather than silently passing NULL to the C++ code. | 1865 # thrown rather than silently passing NULL to the C++ code. |
1827 # Per the Web IDL and ECMAScript specifications, incoming values can always
be converted to both | 1866 # Per the Web IDL and ECMAScript specifications, incoming values can always
be converted to both |
1828 # strings and numbers, so do not throw TypeError if the attribute is of thes
e types. | 1867 # strings and numbers, so do not throw TypeError if the attribute is of thes
e types. |
1829 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { | 1868 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { |
1830 my $argType = $attribute->type; | 1869 my $argType = $attribute->type; |
1831 if (IsWrapperType($argType)) { | 1870 if (IsWrapperType($argType)) { |
1832 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${argType}::HasI
nstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 1871 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${argType}::HasI
nstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 } | 3047 } |
3009 | 3048 |
3010 END | 3049 END |
3011 return $content; | 3050 return $content; |
3012 } | 3051 } |
3013 | 3052 |
3014 sub GenerateAttributeConfigurationArray | 3053 sub GenerateAttributeConfigurationArray |
3015 { | 3054 { |
3016 my $interface = shift; | 3055 my $interface = shift; |
3017 my $attributes = shift; | 3056 my $attributes = shift; |
| 3057 my $isAccessor = shift; |
3018 my $code = ""; | 3058 my $code = ""; |
3019 | 3059 |
3020 foreach my $attribute (@$attributes) { | 3060 foreach my $attribute (@$attributes) { |
3021 my $conditionalString = GenerateConditionalString($attribute); | 3061 my $conditionalString = GenerateConditionalString($attribute); |
3022 my $subCode = ""; | 3062 my $subCode = ""; |
3023 $subCode .= "#if ${conditionalString}\n" if $conditionalString; | 3063 $subCode .= "#if ${conditionalString}\n" if $conditionalString; |
3024 $subCode .= GenerateAttributeConfiguration($interface, $attribute, ",",
""); | 3064 $subCode .= GenerateAttributeConfiguration($interface, $attribute, ",",
"", $isAccessor); |
3025 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; | 3065 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; |
3026 $code .= $subCode; | 3066 $code .= $subCode; |
3027 } | 3067 } |
3028 return $code; | 3068 return $code; |
3029 } | 3069 } |
3030 | 3070 |
3031 sub GenerateAttributeConfigurationParameters | 3071 sub GenerateAttributeConfigurationParameters |
3032 { | 3072 { |
3033 my $interface = shift; | 3073 my $interface = shift; |
3034 my $attribute = shift; | 3074 my $attribute = shift; |
| 3075 my $isAccessor = shift; |
3035 my $attrName = $attribute->name; | 3076 my $attrName = $attribute->name; |
3036 my $attrExt = $attribute->extendedAttributes; | 3077 my $attrExt = $attribute->extendedAttributes; |
3037 my $implClassName = GetImplName($interface); | 3078 my $implClassName = GetImplName($interface); |
3038 | 3079 |
3039 my @accessControlList; | 3080 my @accessControlList; |
3040 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { | 3081 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { |
3041 push(@accessControlList, "v8::ALL_CAN_READ"); | 3082 push(@accessControlList, "v8::ALL_CAN_READ"); |
3042 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { | 3083 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { |
3043 push(@accessControlList, "v8::ALL_CAN_WRITE"); | 3084 push(@accessControlList, "v8::ALL_CAN_WRITE"); |
3044 } elsif ($attrExt->{"DoNotCheckSecurity"}) { | 3085 } elsif ($attrExt->{"DoNotCheckSecurity"}) { |
(...skipping 27 matching lines...) Expand all Loading... |
3072 my @propAttributeList; | 3113 my @propAttributeList; |
3073 if ($attrExt->{"NotEnumerable"} || $isConstructor) { | 3114 if ($attrExt->{"NotEnumerable"} || $isConstructor) { |
3074 push(@propAttributeList, "v8::DontEnum"); | 3115 push(@propAttributeList, "v8::DontEnum"); |
3075 } | 3116 } |
3076 if ($attrExt->{"Unforgeable"} && !$isConstructor) { | 3117 if ($attrExt->{"Unforgeable"} && !$isConstructor) { |
3077 push(@propAttributeList, "v8::DontDelete"); | 3118 push(@propAttributeList, "v8::DontDelete"); |
3078 } | 3119 } |
3079 @propAttributeList = ("v8::None") unless @propAttributeList; | 3120 @propAttributeList = ("v8::None") unless @propAttributeList; |
3080 my $propAttribute = join(" | ", @propAttributeList); | 3121 my $propAttribute = join(" | ", @propAttributeList); |
3081 | 3122 |
3082 my $on_proto = "0 /* on instance */"; | 3123 my $onPrototype = "0 /* on instance */"; |
3083 my $data = "0"; # no data | 3124 my $data = "0"; # no data |
3084 | 3125 |
3085 # Constructor | 3126 # Constructor |
3086 if ($isConstructor) { | 3127 if ($isConstructor) { |
3087 my $constructorType = $attribute->type; | 3128 my $constructorType = $attribute->type; |
3088 $constructorType =~ s/Constructor$//; | 3129 $constructorType =~ s/Constructor$//; |
3089 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. | 3130 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. |
3090 # We do not generate the header file for NamedConstructor of class XXXX, | 3131 # We do not generate the header file for NamedConstructor of class XXXX, |
3091 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. | 3132 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. |
3092 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes
->{"CustomConstructor"}) { | 3133 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes
->{"CustomConstructor"}) { |
(...skipping 18 matching lines...) Expand all Loading... |
3111 } | 3152 } |
3112 | 3153 |
3113 # Read only attributes | 3154 # Read only attributes |
3114 if (IsReadonly($attribute)) { | 3155 if (IsReadonly($attribute)) { |
3115 $setter = "0"; | 3156 $setter = "0"; |
3116 $setterForMainWorld = "0"; | 3157 $setterForMainWorld = "0"; |
3117 } | 3158 } |
3118 | 3159 |
3119 # An accessor can be installed on the proto | 3160 # An accessor can be installed on the proto |
3120 if ($attrExt->{"OnProto"}) { | 3161 if ($attrExt->{"OnProto"}) { |
3121 $on_proto = "1 /* on proto */"; | 3162 $onPrototype = "1 /* on proto */"; |
3122 } | 3163 } |
3123 | 3164 |
3124 if (!$attrExt->{"PerWorldBindings"}) { | 3165 if (!$attrExt->{"PerWorldBindings"}) { |
3125 $getterForMainWorld = "0"; | 3166 $getterForMainWorld = "0"; |
3126 $setterForMainWorld = "0"; | 3167 $setterForMainWorld = "0"; |
3127 } | 3168 } |
3128 | 3169 |
3129 return ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorl
d, $data, $accessControl, "static_cast<v8::PropertyAttribute>($propAttribute)",
$on_proto); | 3170 return ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorl
d, $data, $accessControl, "static_cast<v8::PropertyAttribute>($propAttribute)",
$onPrototype); |
3130 } | 3171 } |
3131 | 3172 |
3132 sub GenerateAttributeConfiguration | 3173 sub GenerateAttributeConfiguration |
3133 { | 3174 { |
3134 my $interface = shift; | 3175 my $interface = shift; |
3135 my $attribute = shift; | 3176 my $attribute = shift; |
3136 my $delimiter = shift; | 3177 my $delimiter = shift; |
3137 my $indent = shift; | 3178 my $indent = shift; |
| 3179 my $isAccessor = shift; |
3138 my $code = ""; | 3180 my $code = ""; |
3139 | 3181 |
3140 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $on_proto) = GenerateAttributeConfiguratio
nParameters($interface, $attribute); | 3182 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $onPrototype) = GenerateAttributeConfigura
tionParameters($interface, $attribute, $isAccessor); |
3141 | 3183 |
3142 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorl
d, $setterForMainWorld, $data, $accessControl, $propAttribute, $on_proto}" . $de
limiter . "\n"; | 3184 if ($isAccessor) { |
| 3185 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMain
World, $setterForMainWorld, $data, $accessControl, $propAttribute}" . $delimiter
. "\n"; |
| 3186 } else { |
| 3187 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMain
World, $setterForMainWorld, $data, $accessControl, $propAttribute, $onPrototype}
" . $delimiter . "\n"; |
| 3188 } |
3143 return $code; | 3189 return $code; |
3144 } | 3190 } |
3145 | 3191 |
3146 sub GenerateStaticAttribute | 3192 sub GenerateStaticAttribute |
3147 { | 3193 { |
3148 my $interface = shift; | 3194 my $interface = shift; |
3149 my $attribute = shift; | 3195 my $attribute = shift; |
3150 my $attrExt = $attribute->extendedAttributes; | 3196 my $attrExt = $attribute->extendedAttributes; |
3151 my $code = ""; | 3197 my $code = ""; |
3152 | 3198 |
3153 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $on_proto) = GenerateAttributeConfiguratio
nParameters($interface, $attribute); | 3199 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $onPrototype) = GenerateAttributeConfigura
tionParameters($interface, $attribute); |
3154 | 3200 |
3155 die "Static attributes do not support optimized getters or setters for the m
ain world" if $getterForMainWorld || $setterForMainWorld; | 3201 die "Static attributes do not support optimized getters or setters for the m
ain world" if $getterForMainWorld || $setterForMainWorld; |
3156 | 3202 |
3157 my $conditionalString = GenerateConditionalString($attribute); | 3203 my $conditionalString = GenerateConditionalString($attribute); |
3158 | 3204 |
3159 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3205 $code .= "#if ${conditionalString}\n" if $conditionalString; |
3160 $code .= " desc->SetNativeDataProperty(v8::String::NewSymbol(\"$attrName\
"), $getter, $setter, v8::External::New($data), $propAttribute, v8::Handle<v8::A
ccessorSignature>(), $accessControl);\n"; | 3206 $code .= " desc->SetNativeDataProperty(v8::String::NewSymbol(\"$attrName\
"), $getter, $setter, v8::External::New($data), $propAttribute, v8::Handle<v8::A
ccessorSignature>(), $accessControl);\n"; |
3161 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3207 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
3162 | 3208 |
3163 return $code; | 3209 return $code; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4075 if ($attrType eq "SerializedScriptValue") { | 4121 if ($attrType eq "SerializedScriptValue") { |
4076 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 4122 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
4077 } | 4123 } |
4078 | 4124 |
4079 my $isReplaceable = 0; | 4125 my $isReplaceable = 0; |
4080 if (!HasCustomSetter($attribute) && !$attrExt->{"PutForwards"} && $attrE
xt->{"Replaceable"}) { | 4126 if (!HasCustomSetter($attribute) && !$attrExt->{"PutForwards"} && $attrE
xt->{"Replaceable"}) { |
4081 $isReplaceable = 1; | 4127 $isReplaceable = 1; |
4082 $hasReplaceable = 1; | 4128 $hasReplaceable = 1; |
4083 } | 4129 } |
4084 | 4130 |
| 4131 my $isAccessor = $attrExt->{"ExposeV8GetterAndSetter"}; |
4085 my @worldSuffixes = (""); | 4132 my @worldSuffixes = (""); |
4086 if ($attrExt->{"PerWorldBindings"}) { | 4133 if ($attrExt->{"PerWorldBindings"}) { |
4087 push(@worldSuffixes, "ForMainWorld"); | 4134 push(@worldSuffixes, "ForMainWorld"); |
4088 } | 4135 } |
4089 foreach my $worldSuffix (@worldSuffixes) { | 4136 foreach my $worldSuffix (@worldSuffixes) { |
4090 GenerateNormalAttributeGetter($attribute, $interface, $worldSuffix); | 4137 GenerateNormalAttributeGetter($attribute, $interface, $worldSuffix,
$isAccessor); |
4091 GenerateNormalAttributeGetterCallback($attribute, $interface, $world
Suffix); | 4138 GenerateNormalAttributeGetterCallback($attribute, $interface, $world
Suffix, $isAccessor); |
4092 if (!$isReplaceable && !IsReadonly($attribute)) { | 4139 if (!$isReplaceable && !IsReadonly($attribute)) { |
4093 GenerateNormalAttributeSetter($attribute, $interface, $worldSuff
ix); | 4140 GenerateNormalAttributeSetter($attribute, $interface, $worldSuff
ix, $isAccessor); |
4094 GenerateNormalAttributeSetterCallback($attribute, $interface, $w
orldSuffix); | 4141 GenerateNormalAttributeSetterCallback($attribute, $interface, $w
orldSuffix, $isAccessor); |
4095 } | 4142 } |
4096 } | 4143 } |
4097 } | 4144 } |
4098 | 4145 |
4099 if ($hasConstructors) { | 4146 if ($hasConstructors) { |
4100 GenerateConstructorGetter($interface); | 4147 GenerateConstructorGetter($interface); |
4101 } | 4148 } |
4102 | 4149 |
4103 if ($hasConstructors || $hasReplaceable) { | 4150 if ($hasConstructors || $hasReplaceable) { |
4104 GenerateReplaceableAttributeSetter($interface); | 4151 GenerateReplaceableAttributeSetter($interface); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4178 # Attributes | 4225 # Attributes |
4179 my $attributes = $interface->attributes; | 4226 my $attributes = $interface->attributes; |
4180 | 4227 |
4181 # For the Window interface we partition the attributes into the | 4228 # For the Window interface we partition the attributes into the |
4182 # ones that disallows shadowing and the rest. | 4229 # ones that disallows shadowing and the rest. |
4183 my @disallowsShadowing; | 4230 my @disallowsShadowing; |
4184 # Also separate out attributes that are enabled at runtime so we can process
them specially. | 4231 # Also separate out attributes that are enabled at runtime so we can process
them specially. |
4185 my @runtimeEnabledAttributes; | 4232 my @runtimeEnabledAttributes; |
4186 my @perContextEnabledAttributes; | 4233 my @perContextEnabledAttributes; |
4187 my @normalAttributes; | 4234 my @normalAttributes; |
| 4235 my @normalAccessors; |
4188 my @staticAttributes; | 4236 my @staticAttributes; |
4189 foreach my $attribute (@$attributes) { | 4237 foreach my $attribute (@$attributes) { |
4190 | |
4191 if ($attribute->isStatic) { | 4238 if ($attribute->isStatic) { |
4192 push(@staticAttributes, $attribute); | 4239 push(@staticAttributes, $attribute); |
4193 } elsif ($interfaceName eq "Window" && $attribute->extendedAttributes->{
"Unforgeable"}) { | 4240 } elsif ($interfaceName eq "Window" && $attribute->extendedAttributes->{
"Unforgeable"}) { |
4194 push(@disallowsShadowing, $attribute); | 4241 push(@disallowsShadowing, $attribute); |
4195 } elsif ($attribute->extendedAttributes->{"PerContextEnabled"}) { | 4242 } elsif ($attribute->extendedAttributes->{"RuntimeEnabled"} || $attribut
e->extendedAttributes->{"PerContextEnabled"}) { |
4196 push(@perContextEnabledAttributes, $attribute); | 4243 if ($attribute->extendedAttributes->{"PerContextEnabled"}) { |
4197 } elsif ($attribute->extendedAttributes->{"RuntimeEnabled"}) { | 4244 push(@perContextEnabledAttributes, $attribute); |
4198 push(@runtimeEnabledAttributes, $attribute); | 4245 } |
| 4246 if ($attribute->extendedAttributes->{"RuntimeEnabled"}) { |
| 4247 push(@runtimeEnabledAttributes, $attribute); |
| 4248 } |
| 4249 } elsif ($attribute->extendedAttributes->{"ExposeV8GetterAndSetter"}) { |
| 4250 push(@normalAccessors, $attribute); |
4199 } else { | 4251 } else { |
4200 push(@normalAttributes, $attribute); | 4252 push(@normalAttributes, $attribute); |
4201 } | 4253 } |
4202 } | 4254 } |
4203 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); | 4255 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); |
4204 # Put the attributes that disallow shadowing on the shadow object. | 4256 # Put the attributes that disallow shadowing on the shadow object. |
4205 if (@disallowsShadowing) { | 4257 if (@disallowsShadowing) { |
4206 my $code = ""; | 4258 my $code = ""; |
4207 $code .= "static const V8DOMConfiguration::AttributeConfiguration shadow
Attributes[] = {\n"; | 4259 $code .= "static const V8DOMConfiguration::AttributeConfiguration shadow
Attributes[] = {\n"; |
4208 $code .= GenerateAttributeConfigurationArray($interface, \@disallowsShad
owing); | 4260 $code .= GenerateAttributeConfigurationArray($interface, \@disallowsShad
owing); |
4209 $code .= "};\n\n"; | 4261 $code .= "};\n\n"; |
4210 $implementation{nameSpaceWebCore}->add($code); | 4262 $implementation{nameSpaceWebCore}->add($code); |
4211 } | 4263 } |
4212 | 4264 |
4213 my $has_attributes = 0; | 4265 my $hasAttributes = 0; |
4214 if (@normalAttributes) { | 4266 if (@normalAttributes) { |
4215 $has_attributes = 1; | 4267 $hasAttributes = 1; |
4216 my $code = ""; | 4268 my $code = ""; |
4217 $code .= "static const V8DOMConfiguration::AttributeConfiguration ${v8Cl
assName}Attributes[] = {\n"; | 4269 $code .= "static const V8DOMConfiguration::AttributeConfiguration ${v8Cl
assName}Attributes[] = {\n"; |
4218 $code .= GenerateAttributeConfigurationArray($interface, \@normalAttribu
tes); | 4270 $code .= GenerateAttributeConfigurationArray($interface, \@normalAttribu
tes); |
4219 $code .= "};\n\n"; | 4271 $code .= "};\n\n"; |
4220 $implementation{nameSpaceWebCore}->add($code); | 4272 $implementation{nameSpaceWebCore}->add($code); |
4221 } | 4273 } |
4222 | 4274 |
| 4275 my $hasAccessors = 0; |
| 4276 if (@normalAccessors) { |
| 4277 $hasAccessors = 1; |
| 4278 my $code = ""; |
| 4279 $code .= "static const V8DOMConfiguration::AccessorConfiguration ${v8Cla
ssName}Accessors[] = {\n"; |
| 4280 $code .= GenerateAttributeConfigurationArray($interface, \@normalAccesso
rs, "accessor"); |
| 4281 $code .= "};\n\n"; |
| 4282 $implementation{nameSpaceWebCore}->add($code); |
| 4283 } |
| 4284 |
4223 # Setup table of standard callback functions | 4285 # Setup table of standard callback functions |
4224 my $num_callbacks = 0; | 4286 my $hasMethods = 0; |
4225 my $has_callbacks = 0; | |
4226 $code = ""; | 4287 $code = ""; |
4227 foreach my $function (@normalFunctions) { | 4288 foreach my $function (@normalFunctions) { |
4228 # Only one table entry is needed for overloaded methods: | 4289 # Only one table entry is needed for overloaded methods: |
4229 next if $function->{overloadIndex} > 1; | 4290 next if $function->{overloadIndex} > 1; |
4230 # Don't put any nonstandard functions into this table: | 4291 # Don't put any nonstandard functions into this table: |
4231 next if !IsStandardFunction($interface, $function); | 4292 next if !IsStandardFunction($interface, $function); |
4232 next if $function->name eq ""; | 4293 next if $function->name eq ""; |
4233 if (!$has_callbacks) { | 4294 if (!$hasMethods) { |
4234 $has_callbacks = 1; | 4295 $hasMethods = 1; |
4235 $code .= "static const V8DOMConfiguration::MethodConfiguration ${v8C
lassName}Methods[] = {\n"; | 4296 $code .= "static const V8DOMConfiguration::MethodConfiguration ${v8C
lassName}Methods[] = {\n"; |
4236 } | 4297 } |
4237 my $name = $function->name; | 4298 my $name = $function->name; |
4238 my $methodForMainWorld = "0"; | 4299 my $methodForMainWorld = "0"; |
4239 if ($function->extendedAttributes->{"PerWorldBindings"}) { | 4300 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
4240 $methodForMainWorld = "${implClassName}V8Internal::${name}MethodCall
backForMainWorld"; | 4301 $methodForMainWorld = "${implClassName}V8Internal::${name}MethodCall
backForMainWorld"; |
4241 } | 4302 } |
4242 my $functionLength = GetFunctionLength($function); | 4303 my $functionLength = GetFunctionLength($function); |
4243 my $conditionalString = GenerateConditionalString($function); | 4304 my $conditionalString = GenerateConditionalString($function); |
4244 $code .= "#if ${conditionalString}\n" if $conditionalString; | 4305 $code .= "#if ${conditionalString}\n" if $conditionalString; |
4245 $code .= <<END; | 4306 $code .= <<END; |
4246 {"$name", ${implClassName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${functionLength}}, | 4307 {"$name", ${implClassName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${functionLength}}, |
4247 END | 4308 END |
4248 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 4309 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
4249 $num_callbacks++; | |
4250 } | 4310 } |
4251 $code .= "};\n\n" if $has_callbacks; | 4311 $code .= "};\n\n" if $hasMethods; |
4252 $implementation{nameSpaceWebCore}->add($code); | 4312 $implementation{nameSpaceWebCore}->add($code); |
4253 | 4313 |
4254 my $has_constants = 0; | 4314 my $hasConstants = 0; |
4255 if (@{$interface->constants}) { | 4315 if (@{$interface->constants}) { |
4256 $has_constants = 1; | 4316 $hasConstants = 1; |
4257 } | 4317 } |
4258 | 4318 |
4259 if (!HasCustomConstructor($interface)) { | 4319 if (!HasCustomConstructor($interface)) { |
4260 if ($interface->extendedAttributes->{"NamedConstructor"}) { | 4320 if ($interface->extendedAttributes->{"NamedConstructor"}) { |
4261 GenerateNamedConstructor(@{$interface->constructors}[0], $interface)
; | 4321 GenerateNamedConstructor(@{$interface->constructors}[0], $interface)
; |
4262 } elsif ($interface->extendedAttributes->{"Constructor"}) { | 4322 } elsif ($interface->extendedAttributes->{"Constructor"}) { |
4263 GenerateConstructor($interface); | 4323 GenerateConstructor($interface); |
4264 } elsif (IsConstructorTemplate($interface, "Event")) { | 4324 } elsif (IsConstructorTemplate($interface, "Event")) { |
4265 GenerateEventConstructor($interface); | 4325 GenerateEventConstructor($interface); |
4266 } | 4326 } |
4267 } | 4327 } |
4268 if (IsConstructable($interface)) { | 4328 if (IsConstructable($interface)) { |
4269 GenerateConstructorCallback($interface); | 4329 GenerateConstructorCallback($interface); |
4270 } | 4330 } |
4271 | 4331 |
4272 my $access_check = ""; | 4332 my $accessCheck = ""; |
4273 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
Window") { | 4333 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
Window") { |
4274 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int
ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8:
:External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));
"; | 4334 $accessCheck = "instance->SetAccessCheckCallbacks(${implClassName}V8Inte
rnal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8::
External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));"
; |
4275 } | 4335 } |
4276 | 4336 |
4277 # For the Window interface, generate the shadow object template | 4337 # For the Window interface, generate the shadow object template |
4278 # configuration method. | 4338 # configuration method. |
4279 if ($interfaceName eq "Window") { | 4339 if ($interfaceName eq "Window") { |
4280 $implementation{nameSpaceWebCore}->add(<<END); | 4340 $implementation{nameSpaceWebCore}->add(<<END); |
4281 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) | 4341 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) |
4282 { | 4342 { |
4283 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); | 4343 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); |
4284 | 4344 |
4285 // Install a security handler with V8. | 4345 // Install a security handler with V8. |
4286 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(const_cast<WrapperTypeInfo*>(&V8W
indow::wrapperTypeInfo))); | 4346 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(const_cast<WrapperTypeInfo*>(&V8W
indow::wrapperTypeInfo))); |
4287 templ->SetInternalFieldCount(V8Window::internalFieldCount); | 4347 templ->SetInternalFieldCount(V8Window::internalFieldCount); |
4288 } | 4348 } |
4289 END | 4349 END |
4290 } | 4350 } |
4291 | 4351 |
4292 if (!$parentClassTemplate) { | 4352 if (!$parentClassTemplate) { |
4293 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; | 4353 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; |
4294 } | 4354 } |
4295 | 4355 |
4296 # Generate the template configuration method | 4356 # Generate the template configuration method |
4297 $code = <<END; | 4357 $code = <<END; |
4298 static v8::Handle<v8::FunctionTemplate> Configure${v8ClassName}Template(v8::Hand
le<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWor
ldType) | 4358 static v8::Handle<v8::FunctionTemplate> Configure${v8ClassName}Template(v8::Hand
le<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWor
ldType) |
4299 { | 4359 { |
4300 desc->ReadOnlyPrototype(); | 4360 desc->ReadOnlyPrototype(); |
4301 | 4361 |
4302 v8::Local<v8::Signature> defaultSignature; | 4362 v8::Local<v8::Signature> defaultSignature; |
4303 END | 4363 END |
| 4364 |
| 4365 # Define constants, attributes, accessors and methods. |
4304 if ($interface->extendedAttributes->{"RuntimeEnabled"}) { | 4366 if ($interface->extendedAttributes->{"RuntimeEnabled"}) { |
4305 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($interface); | 4367 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($interface); |
4306 $code .= <<END; | 4368 $code .= <<END; |
4307 if (!${runtimeEnabledFunction}()) | 4369 if (!${runtimeEnabledFunction}()) |
4308 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"\
", $parentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate
, currentWorldType); | 4370 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"\
", $parentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, 0, 0, i
solate, currentWorldType); |
4309 else | 4371 else |
4310 END | 4372 END |
4311 } | 4373 } |
4312 $code .= <<END; | 4374 $code .= " defaultSignature = V8DOMConfiguration::installDOMClassTemplat
e(desc, \"${interfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFiel
dCount, "; |
4313 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"${int
erfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, | |
4314 END | |
4315 # Set up our attributes if we have them | |
4316 if ($has_attributes) { | |
4317 $code .= <<END; | |
4318 ${v8ClassName}Attributes, WTF_ARRAY_LENGTH(${v8ClassName}Attributes), | |
4319 END | |
4320 } else { | |
4321 $code .= <<END; | |
4322 0, 0, | |
4323 END | |
4324 } | |
4325 | 4375 |
4326 if ($has_callbacks) { | 4376 $code .= $hasAttributes ? "${v8ClassName}Attributes, WTF_ARRAY_LENGTH(${v8Cl
assName}Attributes), " : "0, 0, "; |
4327 $code .= <<END; | 4377 $code .= $hasAccessors ? "${v8ClassName}Accessors, WTF_ARRAY_LENGTH(${v8Clas
sName}Accessors), " : "0, 0, "; |
4328 ${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassName}Methods), isolate,
currentWorldType); | 4378 $code .= $hasMethods ? "${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassNam
e}Methods), " : "0, 0, "; |
4329 END | 4379 $code .= "isolate, currentWorldType);\n"; |
4330 } else { | |
4331 $code .= <<END; | |
4332 0, 0, isolate, currentWorldType); | |
4333 END | |
4334 } | |
4335 | 4380 |
4336 AddToImplIncludes("wtf/UnusedParam.h"); | 4381 AddToImplIncludes("wtf/UnusedParam.h"); |
4337 $code .= <<END; | 4382 $code .= <<END; |
4338 UNUSED_PARAM(defaultSignature); | 4383 UNUSED_PARAM(defaultSignature); |
4339 END | 4384 END |
4340 | 4385 |
4341 if (IsConstructable($interface)) { | 4386 if (IsConstructable($interface)) { |
4342 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback);
\n"; | 4387 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback);
\n"; |
4343 my $interfaceLength = GetInterfaceLength($interface); | 4388 my $interfaceLength = GetInterfaceLength($interface); |
4344 $code .= " desc->SetLength(${interfaceLength});\n"; | 4389 $code .= " desc->SetLength(${interfaceLength});\n"; |
4345 } | 4390 } |
4346 | 4391 |
4347 if ($access_check or @runtimeEnabledAttributes or @normalFunctions or $has_c
onstants) { | 4392 if ($accessCheck or @runtimeEnabledAttributes or @normalFunctions or $hasCon
stants) { |
4348 $code .= <<END; | 4393 $code .= <<END; |
4349 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 4394 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
4350 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 4395 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
4351 UNUSED_PARAM(instance); | 4396 UNUSED_PARAM(instance); |
4352 UNUSED_PARAM(proto); | 4397 UNUSED_PARAM(proto); |
4353 END | 4398 END |
4354 } | 4399 } |
4355 | 4400 |
4356 if ($access_check) { | 4401 if ($accessCheck) { |
4357 $code .= " $access_check\n"; | 4402 $code .= " $accessCheck\n"; |
4358 } | 4403 } |
4359 | 4404 |
4360 # Setup the enable-at-runtime attributes if we have them | 4405 # Define enable-at-runtime attributes. |
4361 foreach my $runtime_attr (@runtimeEnabledAttributes) { | 4406 foreach my $runtimeAttribute (@runtimeEnabledAttributes) { |
4362 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_attr
); | 4407 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtimeAttri
bute); |
4363 my $conditionalString = GenerateConditionalString($runtime_attr); | 4408 my $conditionalString = GenerateConditionalString($runtimeAttribute); |
4364 $code .= "#if ${conditionalString}\n" if $conditionalString; | 4409 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
4365 $code .= " if (${runtimeEnabledFunction}()) {\n"; | 4410 $code .= " if (${runtimeEnabledFunction}()) {\n"; |
4366 $code .= " static const V8DOMConfiguration::AttributeConfiguratio
n attributeConfiguration =\\\n"; | 4411 $code .= " static const V8DOMConfiguration::AttributeConfiguratio
n attributeConfiguration =\\\n"; |
4367 $code .= GenerateAttributeConfiguration($interface, $runtime_attr, ";",
" "); | 4412 $code .= GenerateAttributeConfiguration($interface, $runtimeAttribute, "
;", " "); |
4368 $code .= <<END; | 4413 $code .= <<END; |
4369 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate, currentWorldType); | 4414 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate, currentWorldType); |
4370 } | 4415 } |
4371 END | 4416 END |
4372 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 4417 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
4373 } | 4418 } |
4374 | 4419 |
4375 my @constantsEnabledAtRuntime; | 4420 my @constantsEnabledAtRuntime; |
4376 if ($has_constants) { | 4421 if ($hasConstants) { |
| 4422 # Define constants. |
4377 $code .= " static const V8DOMConfiguration::ConstantConfiguration ${v
8ClassName}Constants[] = {\n"; | 4423 $code .= " static const V8DOMConfiguration::ConstantConfiguration ${v
8ClassName}Constants[] = {\n"; |
4378 foreach my $constant (@{$interface->constants}) { | 4424 foreach my $constant (@{$interface->constants}) { |
4379 my $name = $constant->name; | 4425 my $name = $constant->name; |
4380 my $value = $constant->value; | 4426 my $value = $constant->value; |
4381 my $attrExt = $constant->extendedAttributes; | 4427 my $attrExt = $constant->extendedAttributes; |
4382 my $implementedBy = $attrExt->{"ImplementedBy"}; | 4428 my $implementedBy = $attrExt->{"ImplementedBy"}; |
4383 if ($implementedBy) { | 4429 if ($implementedBy) { |
4384 my $implementedByImplName = GetImplNameFromImplementedBy($implem
entedBy); | 4430 my $implementedByImplName = GetImplNameFromImplementedBy($implem
entedBy); |
4385 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple
mentedByImplName)); | 4431 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple
mentedByImplName)); |
4386 } | 4432 } |
4387 if ($attrExt->{"RuntimeEnabled"}) { | 4433 if ($attrExt->{"RuntimeEnabled"}) { |
4388 push(@constantsEnabledAtRuntime, $constant); | 4434 push(@constantsEnabledAtRuntime, $constant); |
4389 } else { | 4435 } else { |
4390 $code .= <<END; | 4436 $code .= <<END; |
4391 {"${name}", $value}, | 4437 {"${name}", $value}, |
4392 END | 4438 END |
4393 } | 4439 } |
4394 } | 4440 } |
4395 $code .= " };\n"; | 4441 $code .= " };\n"; |
4396 $code .= <<END; | 4442 $code .= <<END; |
4397 V8DOMConfiguration::installConstants(desc, proto, ${v8ClassName}Constants, W
TF_ARRAY_LENGTH(${v8ClassName}Constants), isolate); | 4443 V8DOMConfiguration::installConstants(desc, proto, ${v8ClassName}Constants, W
TF_ARRAY_LENGTH(${v8ClassName}Constants), isolate); |
4398 END | 4444 END |
4399 # Setup the enable-at-runtime constants if we have them | 4445 # Define enable-at-runtime constants. |
4400 foreach my $runtime_const (@constantsEnabledAtRuntime) { | 4446 foreach my $runtimeConstant (@constantsEnabledAtRuntime) { |
4401 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_
const); | 4447 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtimeC
onstant); |
4402 my $name = $runtime_const->name; | 4448 my $name = $runtimeConstant->name; |
4403 my $value = $runtime_const->value; | 4449 my $value = $runtimeConstant->value; |
4404 $code .= " if (${runtimeEnabledFunction}()) {\n"; | 4450 $code .= " if (${runtimeEnabledFunction}()) {\n"; |
4405 $code .= <<END; | 4451 $code .= <<END; |
4406 static const V8DOMConfiguration::ConstantConfiguration constantConfigura
tion = {"${name}", static_cast<signed int>(${value})}; | 4452 static const V8DOMConfiguration::ConstantConfiguration constantConfigura
tion = {"${name}", static_cast<signed int>(${value})}; |
4407 V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration
, 1, isolate); | 4453 V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration
, 1, isolate); |
4408 END | 4454 END |
4409 $code .= " }\n"; | 4455 $code .= " }\n"; |
4410 } | 4456 } |
4411 $code .= join "", GenerateCompileTimeCheckForEnumsIfNeeded($interface); | 4457 $code .= join "", GenerateCompileTimeCheckForEnumsIfNeeded($interface); |
4412 } | 4458 } |
4413 | 4459 |
4414 $code .= GenerateImplementationIndexedPropertyAccessors($interface); | 4460 $code .= GenerateImplementationIndexedPropertyAccessors($interface); |
4415 $code .= GenerateImplementationNamedPropertyAccessors($interface); | 4461 $code .= GenerateImplementationNamedPropertyAccessors($interface); |
4416 $code .= GenerateImplementationLegacyCall($interface); | 4462 $code .= GenerateImplementationLegacyCall($interface); |
4417 $code .= GenerateImplementationMasqueradesAsUndefined($interface); | 4463 $code .= GenerateImplementationMasqueradesAsUndefined($interface); |
4418 | 4464 |
4419 # Define our functions with Set() or SetAccessor() | 4465 # Define methods. |
4420 my $total_functions = 0; | |
4421 foreach my $function (@normalFunctions) { | 4466 foreach my $function (@normalFunctions) { |
4422 # Only one accessor is needed for overloaded methods: | 4467 # Only one accessor is needed for overloaded methods: |
4423 next if $function->{overloadIndex} > 1; | 4468 next if $function->{overloadIndex} > 1; |
4424 next if $function->name eq ""; | 4469 next if $function->name eq ""; |
4425 | 4470 |
4426 $total_functions++; | |
4427 next if IsStandardFunction($interface, $function); | 4471 next if IsStandardFunction($interface, $function); |
4428 $code .= GenerateNonStandardFunction($interface, $function); | 4472 $code .= GenerateNonStandardFunction($interface, $function); |
4429 $num_callbacks++; | |
4430 } | 4473 } |
4431 | 4474 |
4432 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks,
should be $total_functions)" if $num_callbacks != $total_functions; | |
4433 | |
4434 # Define static attributes. | 4475 # Define static attributes. |
4435 foreach my $attribute (@staticAttributes) { | 4476 foreach my $attribute (@staticAttributes) { |
4436 $code .= GenerateStaticAttribute($interface, $attribute); | 4477 $code .= GenerateStaticAttribute($interface, $attribute); |
4437 } | 4478 } |
4438 | 4479 |
4439 # Special cases | 4480 # Special cases |
4440 if ($interfaceName eq "Window") { | 4481 if ($interfaceName eq "Window") { |
4441 $code .= <<END; | 4482 $code .= <<END; |
4442 | 4483 |
4443 proto->SetInternalFieldCount(V8Window::internalFieldCount); | 4484 proto->SetInternalFieldCount(V8Window::internalFieldCount); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4500 END | 4541 END |
4501 | 4542 |
4502 if (@perContextEnabledAttributes) { | 4543 if (@perContextEnabledAttributes) { |
4503 my $code = ""; | 4544 my $code = ""; |
4504 $code .= <<END; | 4545 $code .= <<END; |
4505 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
nstance, ${nativeType}* impl, v8::Isolate* isolate) | 4546 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
nstance, ${nativeType}* impl, v8::Isolate* isolate) |
4506 { | 4547 { |
4507 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); | 4548 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); |
4508 END | 4549 END |
4509 | 4550 |
4510 # Setup the enable-by-settings attributes if we have them | 4551 # Define the enable-per-context attributes. |
4511 foreach my $perContextEnabledAttribute (@perContextEnabledAttributes) { | 4552 foreach my $perContextEnabledAttribute (@perContextEnabledAttributes) { |
4512 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledAttribute); | 4553 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledAttribute); |
4513 $code .= " if (${contextEnabledFunction}(impl->document())) {\n"; | 4554 $code .= " if (${contextEnabledFunction}(impl->document())) {\n"; |
4514 | 4555 |
4515 $code .= " static const V8DOMConfiguration::AttributeConfigur
ation attributeConfiguration =\\\n"; | 4556 $code .= " static const V8DOMConfiguration::AttributeConfigur
ation attributeConfiguration =\\\n"; |
4516 $code .= GenerateAttributeConfiguration($interface, $perContextEnabl
edAttribute, ";", " "); | 4557 $code .= GenerateAttributeConfiguration($interface, $perContextEnabl
edAttribute, ";", " "); |
4517 $code .= <<END; | 4558 $code .= <<END; |
4518 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate); | 4559 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate); |
4519 END | 4560 END |
4520 $code .= " }\n"; | 4561 $code .= " }\n"; |
4521 } | 4562 } |
4522 $code .= <<END; | 4563 $code .= <<END; |
4523 } | 4564 } |
4524 | 4565 |
4525 END | 4566 END |
4526 $implementation{nameSpaceWebCore}->add($code); | 4567 $implementation{nameSpaceWebCore}->add($code); |
4527 } | 4568 } |
4528 | 4569 |
4529 if (@perContextEnabledFunctions) { | 4570 if (@perContextEnabledFunctions) { |
4530 my $code = ""; | 4571 my $code = ""; |
4531 $code .= <<END; | 4572 $code .= <<END; |
4532 void ${v8ClassName}::installPerContextEnabledPrototypeProperties(v8::Handle<v8::
Object> proto, v8::Isolate* isolate) | 4573 void ${v8ClassName}::installPerContextEnabledPrototypeProperties(v8::Handle<v8::
Object> proto, v8::Isolate* isolate) |
4533 { | 4574 { |
4534 UNUSED_PARAM(proto); | 4575 UNUSED_PARAM(proto); |
4535 END | 4576 END |
4536 # Setup the enable-by-settings functions if we have them | 4577 # Define enable-per-context methods. |
4537 $code .= <<END; | 4578 $code .= <<END; |
4538 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); | 4579 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); |
4539 UNUSED_PARAM(defaultSignature); | 4580 UNUSED_PARAM(defaultSignature); |
4540 | 4581 |
4541 ExecutionContext* context = toExecutionContext(proto->CreationContext()); | 4582 ExecutionContext* context = toExecutionContext(proto->CreationContext()); |
4542 END | 4583 END |
4543 | 4584 |
4544 foreach my $runtimeFunc (@perContextEnabledFunctions) { | 4585 foreach my $runtimeFunc (@perContextEnabledFunctions) { |
4545 my $contextEnabledFunction = GetContextEnabledFunctionName($runtimeF
unc); | 4586 my $contextEnabledFunction = GetContextEnabledFunctionName($runtimeF
unc); |
4546 my $functionLength = GetFunctionLength($runtimeFunc); | 4587 my $functionLength = GetFunctionLength($runtimeFunc); |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6197 my $interface = shift; | 6238 my $interface = shift; |
6198 | 6239 |
6199 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6240 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6200 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6241 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6201 return 1 if InheritsInterface($interface, "Document"); | 6242 return 1 if InheritsInterface($interface, "Document"); |
6202 | 6243 |
6203 return 0; | 6244 return 0; |
6204 } | 6245 } |
6205 | 6246 |
6206 1; | 6247 1; |
OLD | NEW |