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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 if ($interface->extendedAttributes->{"CustomCall"}) { | 791 if ($interface->extendedAttributes->{"CustomCall"}) { |
792 AddToHeader(" static v8::Handle<v8::Value> callAsFunctionCallback(con
st v8::Arguments&);\n"); | 792 AddToHeader(" static v8::Handle<v8::Value> callAsFunctionCallback(con
st v8::Arguments&);\n"); |
793 } | 793 } |
794 if ($interface->name eq "Location") { | 794 if ($interface->name eq "Location") { |
795 AddToHeader(" static v8::Handle<v8::Value> assignAttrGetterCustom(v8:
:Local<v8::String> name, const v8::AccessorInfo&);\n"); | 795 AddToHeader(" static v8::Handle<v8::Value> assignAttrGetterCustom(v8:
:Local<v8::String> name, const v8::AccessorInfo&);\n"); |
796 AddToHeader(" static v8::Handle<v8::Value> reloadAttrGetterCustom(v8:
:Local<v8::String> name, const v8::AccessorInfo&);\n"); | 796 AddToHeader(" static v8::Handle<v8::Value> reloadAttrGetterCustom(v8:
:Local<v8::String> name, const v8::AccessorInfo&);\n"); |
797 AddToHeader(" static v8::Handle<v8::Value> replaceAttrGetterCustom(v8
::Local<v8::String> name, const v8::AccessorInfo&);\n"); | 797 AddToHeader(" static v8::Handle<v8::Value> replaceAttrGetterCustom(v8
::Local<v8::String> name, const v8::AccessorInfo&);\n"); |
798 } | 798 } |
799 } | 799 } |
800 | 800 |
| 801 sub HasActivityLogging |
| 802 { |
| 803 my $forMainWorldSuffix = shift; |
| 804 my $attrExt = shift; |
| 805 my $access = shift; |
| 806 |
| 807 if (!$attrExt->{"ActivityLog"}) { |
| 808 return 0; |
| 809 } |
| 810 my $logAllAccess = ($attrExt->{"ActivityLog"} =~ /^Access/); |
| 811 my $logGetter = ($attrExt->{"ActivityLog"} =~ /^Getter/); |
| 812 my $logSetter = ($attrExt->{"ActivityLog"} =~ /^Setter/); |
| 813 my $logOnlyIsolatedWorlds = ($attrExt->{"ActivityLog"} =~ /ForIsolatedWorlds
$/); |
| 814 |
| 815 if ($logOnlyIsolatedWorlds && $forMainWorldSuffix eq "ForMainWorld") { |
| 816 return 0; |
| 817 } |
| 818 return $logAllAccess || ($logGetter && $access eq "Getter") || ($logSetter &
& $access eq "Setter"); |
| 819 } |
| 820 |
801 sub IsConstructable | 821 sub IsConstructable |
802 { | 822 { |
803 my $interface = shift; | 823 my $interface = shift; |
804 | 824 |
805 return $interface->extendedAttributes->{"CustomConstructor"} || $interface->
extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"Constru
ctorTemplate"}; | 825 return $interface->extendedAttributes->{"CustomConstructor"} || $interface->
extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"Constru
ctorTemplate"}; |
806 } | 826 } |
807 | 827 |
808 sub HasCustomConstructor | 828 sub HasCustomConstructor |
809 { | 829 { |
810 my $interface = shift; | 830 my $interface = shift; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 my $measureAs = shift; | 956 my $measureAs = shift; |
937 | 957 |
938 if ($measureAs) { | 958 if ($measureAs) { |
939 AddToImplIncludes("UseCounter.h"); | 959 AddToImplIncludes("UseCounter.h"); |
940 return " UseCounter::observe(activeDOMWindow(BindingState::instance()
), UseCounter::${measureAs});\n"; | 960 return " UseCounter::observe(activeDOMWindow(BindingState::instance()
), UseCounter::${measureAs});\n"; |
941 } | 961 } |
942 | 962 |
943 return ""; | 963 return ""; |
944 } | 964 } |
945 | 965 |
| 966 sub GenerateActivityLogging |
| 967 { |
| 968 my $accessType = shift; |
| 969 my $interface = shift; |
| 970 my $propertyName = shift; |
| 971 |
| 972 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac
e); |
| 973 |
| 974 AddToImplIncludes("V8Binding.h"); |
| 975 AddToImplIncludes("V8DOMActivityLogger.h"); |
| 976 AddToImplIncludes("wtf/Vector.h"); |
| 977 |
| 978 my $code = ""; |
| 979 if ($accessType eq "Method") { |
| 980 $code .= <<END; |
| 981 V8PerContextData* contextData = V8PerContextData::from(args.GetIsolate()->Ge
tCurrentContext()); |
| 982 if (contextData && contextData->activityLogger()) { |
| 983 Vector<v8::Handle<v8::Value> > loggerArgs = toVectorOfArguments(args); |
| 984 contextData->activityLogger()->log("${visibleInterfaceName}.${propertyNa
me}", args.Length(), loggerArgs.data(), "${accessType}"); |
| 985 } |
| 986 END |
| 987 } elsif ($accessType eq "Setter") { |
| 988 $code .= <<END; |
| 989 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 990 if (contextData && contextData->activityLogger()) { |
| 991 v8::Handle<v8::Value> loggerArg[] = { value }; |
| 992 contextData->activityLogger()->log("${visibleInterfaceName}.${propertyNa
me}", 1, &loggerArg[0], "${accessType}"); |
| 993 } |
| 994 END |
| 995 } elsif ($accessType eq "Getter") { |
| 996 $code .= <<END; |
| 997 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 998 if (contextData && contextData->activityLogger()) |
| 999 contextData->activityLogger()->log("${visibleInterfaceName}.${propertyNa
me}", 0, 0, "${accessType}"); |
| 1000 END |
| 1001 } else { |
| 1002 die "Unrecognized activity logging access type"; |
| 1003 } |
| 1004 |
| 1005 return $code; |
| 1006 } |
| 1007 |
946 sub GenerateNormalAttrGetterCallback | 1008 sub GenerateNormalAttrGetterCallback |
947 { | 1009 { |
948 my $attribute = shift; | 1010 my $attribute = shift; |
949 my $interface = shift; | 1011 my $interface = shift; |
950 my $forMainWorldSuffix = shift; | 1012 my $forMainWorldSuffix = shift; |
951 | 1013 |
952 my $interfaceName = $interface->name; | 1014 my $interfaceName = $interface->name; |
953 my $v8InterfaceName = "V8$interfaceName"; | 1015 my $v8InterfaceName = "V8$interfaceName"; |
954 my $attrExt = $attribute->signature->extendedAttributes; | 1016 my $attrExt = $attribute->signature->extendedAttributes; |
955 my $attrName = $attribute->signature->name; | 1017 my $attrName = $attribute->signature->name; |
956 | 1018 |
957 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute
->signature); | 1019 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute
->signature); |
958 my $code = ""; | 1020 my $code = ""; |
959 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1021 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
960 | 1022 |
961 $code .= "static v8::Handle<v8::Value> ${attrName}AttrGetterCallback${forMai
nWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n"; | 1023 $code .= "static v8::Handle<v8::Value> ${attrName}AttrGetterCallback${forMai
nWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n"; |
962 $code .= "{\n"; | 1024 $code .= "{\n"; |
963 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1025 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
| 1026 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { |
| 1027 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); |
| 1028 } |
964 if (HasCustomGetter($attrExt)) { | 1029 if (HasCustomGetter($attrExt)) { |
965 $code .= " return ${v8InterfaceName}::${attrName}AttrGetterCustom(nam
e, info);\n"; | 1030 $code .= " return ${v8InterfaceName}::${attrName}AttrGetterCustom(nam
e, info);\n"; |
966 } else { | 1031 } else { |
967 $code .= " return ${interfaceName}V8Internal::${attrName}AttrGetter${
forMainWorldSuffix}(name, info);\n"; | 1032 $code .= " return ${interfaceName}V8Internal::${attrName}AttrGetter${
forMainWorldSuffix}(name, info);\n"; |
968 } | 1033 } |
969 $code .= "}\n\n"; | 1034 $code .= "}\n\n"; |
970 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1035 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
971 | 1036 |
972 AddToImplContentInternals($code); | 1037 AddToImplContentInternals($code); |
973 } | 1038 } |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 | 1323 |
1259 sub GenerateReplaceableAttrSetterCallback | 1324 sub GenerateReplaceableAttrSetterCallback |
1260 { | 1325 { |
1261 my $interface = shift; | 1326 my $interface = shift; |
1262 my $interfaceName = $interface->name; | 1327 my $interfaceName = $interface->name; |
1263 | 1328 |
1264 my $code = ""; | 1329 my $code = ""; |
1265 $code .= "static void ${interfaceName}ReplaceableAttrSetterCallback(v8::Loca
l<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"
; | 1330 $code .= "static void ${interfaceName}ReplaceableAttrSetterCallback(v8::Loca
l<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"
; |
1266 $code .= "{\n"; | 1331 $code .= "{\n"; |
1267 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); | 1332 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); |
| 1333 if (HasActivityLogging("", $interface->extendedAttributes, "Setter")) { |
| 1334 die "IDL error: ActivityLog attribute cannot exist on a ReplacableAttrS
etterCallback"; |
| 1335 } |
1268 $code .= " return ${interfaceName}V8Internal::${interfaceName}Replaceable
AttrSetter(name, value, info);\n"; | 1336 $code .= " return ${interfaceName}V8Internal::${interfaceName}Replaceable
AttrSetter(name, value, info);\n"; |
1269 $code .= "}\n\n"; | 1337 $code .= "}\n\n"; |
1270 AddToImplContentInternals($code); | 1338 AddToImplContentInternals($code); |
1271 } | 1339 } |
1272 | 1340 |
1273 sub GenerateReplaceableAttrSetter | 1341 sub GenerateReplaceableAttrSetter |
1274 { | 1342 { |
1275 my $interface = shift; | 1343 my $interface = shift; |
1276 my $interfaceName = $interface->name; | 1344 my $interfaceName = $interface->name; |
1277 | 1345 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 my $attrExt = $attribute->signature->extendedAttributes; | 1396 my $attrExt = $attribute->signature->extendedAttributes; |
1329 my $attrName = $attribute->signature->name; | 1397 my $attrName = $attribute->signature->name; |
1330 | 1398 |
1331 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute
->signature); | 1399 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute
->signature); |
1332 my $code = ""; | 1400 my $code = ""; |
1333 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1401 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
1334 | 1402 |
1335 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& inf
o)\n"; | 1403 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& inf
o)\n"; |
1336 $code .= "{\n"; | 1404 $code .= "{\n"; |
1337 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1405 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
| 1406 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { |
| 1407 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); |
| 1408 } |
1338 if (HasCustomSetter($attrExt)) { | 1409 if (HasCustomSetter($attrExt)) { |
1339 $code .= " ${v8InterfaceName}::${attrName}AttrSetterCustom(name, valu
e, info);\n"; | 1410 $code .= " ${v8InterfaceName}::${attrName}AttrSetterCustom(name, valu
e, info);\n"; |
1340 } else { | 1411 } else { |
1341 $code .= " ${interfaceName}V8Internal::${attrName}AttrSetter${forMain
WorldSuffix}(name, value, info);\n"; | 1412 $code .= " ${interfaceName}V8Internal::${attrName}AttrSetter${forMain
WorldSuffix}(name, value, info);\n"; |
1342 } | 1413 } |
1343 $code .= "}\n\n"; | 1414 $code .= "}\n\n"; |
1344 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1415 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1345 AddToImplContentInternals($code); | 1416 AddToImplContentInternals($code); |
1346 } | 1417 } |
1347 | 1418 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 my $name = $function->signature->name; | 1748 my $name = $function->signature->name; |
1678 | 1749 |
1679 my $conditionalString = $codeGenerator->GenerateConditionalString($function-
>signature); | 1750 my $conditionalString = $codeGenerator->GenerateConditionalString($function-
>signature); |
1680 my $code = ""; | 1751 my $code = ""; |
1681 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1752 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
1682 $code .= <<END; | 1753 $code .= <<END; |
1683 static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8
::Arguments& args) | 1754 static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8
::Arguments& args) |
1684 { | 1755 { |
1685 END | 1756 END |
1686 $code .= GenerateFeatureObservation($function->signature->extendedAttributes
->{"MeasureAs"}); | 1757 $code .= GenerateFeatureObservation($function->signature->extendedAttributes
->{"MeasureAs"}); |
| 1758 if (HasActivityLogging($forMainWorldSuffix, $function->signature->extendedAt
tributes, "Access")) { |
| 1759 $code .= GenerateActivityLogging("Method", $interface, "${name}"); |
| 1760 } |
1687 if (HasCustomMethod($function->signature->extendedAttributes)) { | 1761 if (HasCustomMethod($function->signature->extendedAttributes)) { |
1688 $code .= " return ${v8InterfaceName}::${name}MethodCustom(args);\n"; | 1762 $code .= " return ${v8InterfaceName}::${name}MethodCustom(args);\n"; |
1689 } else { | 1763 } else { |
1690 $code .= " return ${interfaceName}V8Internal::${name}Method${forMainW
orldSuffix}(args);\n"; | 1764 $code .= " return ${interfaceName}V8Internal::${name}Method${forMainW
orldSuffix}(args);\n"; |
1691 } | 1765 } |
1692 $code .= "}\n\n"; | 1766 $code .= "}\n\n"; |
1693 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1767 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1694 AddToImplContentInternals($code); | 1768 AddToImplContentInternals($code); |
1695 } | 1769 } |
1696 | 1770 |
(...skipping 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4760 | 4834 |
4761 sub GetPassRefPtrType | 4835 sub GetPassRefPtrType |
4762 { | 4836 { |
4763 my $v8InterfaceName = shift; | 4837 my $v8InterfaceName = shift; |
4764 | 4838 |
4765 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4839 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
4766 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4840 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
4767 } | 4841 } |
4768 | 4842 |
4769 1; | 4843 1; |
OLD | NEW |