| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 | 109 |
| 110 package CodeGeneratorV8; | 110 package CodeGeneratorV8; |
| 111 | 111 |
| 112 use strict; | 112 use strict; |
| 113 use Cwd; | 113 use Cwd; |
| 114 use File::Basename; | 114 use File::Basename; |
| 115 use File::Find; | 115 use File::Find; |
| 116 use File::Spec; | 116 use File::Spec; |
| 117 | 117 |
| 118 use idltopath; |
| 119 |
| 118 my $codeGenerator; | 120 my $codeGenerator; |
| 119 my $idlDocument; | 121 my $idlDocument; |
| 120 my $useDirectories; | 122 my $useDirectories; |
| 121 my $preprocessor; | 123 my $preprocessor; |
| 122 my $defines; | 124 my $defines; |
| 123 my $verbose; | 125 my $verbose; |
| 124 my $dependentIdlFiles; | 126 my $dependentIdlFiles; |
| 125 my $sourceRoot; | 127 my $sourceRoot; |
| 126 | 128 |
| 127 # Cache of IDL file pathnames. | 129 # Cache of IDL file pathnames. |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 $expression = $getterString; | 1555 $expression = $getterString; |
| 1554 # Fix amigious conversion problem, by casting to the base type first ($g
etterString returns a type that inherits from SVGAnimatedEnumeration, not the ba
se class directly). | 1556 # Fix amigious conversion problem, by casting to the base type first ($g
etterString returns a type that inherits from SVGAnimatedEnumeration, not the ba
se class directly). |
| 1555 $expression = "static_pointer_cast<SVGAnimatedEnumeration>($expression)"
if $returnType eq "SVGAnimatedEnumeration"; | 1557 $expression = "static_pointer_cast<SVGAnimatedEnumeration>($expression)"
if $returnType eq "SVGAnimatedEnumeration"; |
| 1556 } | 1558 } |
| 1557 | 1559 |
| 1558 if (ShouldKeepAttributeAlive($interface, $attribute, $returnType)) { | 1560 if (ShouldKeepAttributeAlive($interface, $attribute, $returnType)) { |
| 1559 my $arrayType = GetArrayType($returnType); | 1561 my $arrayType = GetArrayType($returnType); |
| 1560 if ($arrayType) { | 1562 if ($arrayType) { |
| 1561 if (!SkipIncludeHeader($arrayType)) { | 1563 if (!SkipIncludeHeader($arrayType)) { |
| 1562 AddToImplIncludes("V8$arrayType.h"); | 1564 AddToImplIncludes("V8$arrayType.h"); |
| 1563 AddToImplIncludes("$arrayType.h"); | 1565 # Since $arrayType is always ScriptProfile here, and |
| 1566 # that ScriptProfile.h is in core/inspector. Or I could |
| 1567 # use idlToPath. |
| 1568 die unless $arrayType eq "ScriptProfile"; |
| 1569 AddToImplIncludes("core/inspector/$arrayType.h"); |
| 1564 } | 1570 } |
| 1565 $code .= " return v8Array(${getterString}, info.GetIsolate());\n"
; | 1571 $code .= " return v8Array(${getterString}, info.GetIsolate());\n"
; |
| 1566 $code .= "}\n\n"; | 1572 $code .= "}\n\n"; |
| 1567 AddToImplContentInternals($code); | 1573 AddToImplContentInternals($code); |
| 1568 return; | 1574 return; |
| 1569 } | 1575 } |
| 1570 | 1576 |
| 1571 AddIncludesForType($returnType); | 1577 AddIncludesForType($returnType); |
| 1572 # Check for a wrapper in the wrapper cache. If there is one, we know tha
t a hidden reference has already | 1578 # Check for a wrapper in the wrapper cache. If there is one, we know tha
t a hidden reference has already |
| 1573 # been created. If we don't find a wrapper, we create both a wrapper and
a hidden reference. | 1579 # been created. If we don't find a wrapper, we create both a wrapper and
a hidden reference. |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2991 my $data = "0 /* no data */"; | 2997 my $data = "0 /* no data */"; |
| 2992 | 2998 |
| 2993 # Constructor | 2999 # Constructor |
| 2994 if ($isConstructor) { | 3000 if ($isConstructor) { |
| 2995 my $constructorType = $attribute->signature->type; | 3001 my $constructorType = $attribute->signature->type; |
| 2996 $constructorType =~ s/Constructor$//; | 3002 $constructorType =~ s/Constructor$//; |
| 2997 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. | 3003 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. |
| 2998 # We do not generate the header file for NamedConstructor of class XXXX, | 3004 # We do not generate the header file for NamedConstructor of class XXXX, |
| 2999 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. | 3005 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. |
| 3000 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende
dAttributes->{"CustomConstructor"}) { | 3006 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende
dAttributes->{"CustomConstructor"}) { |
| 3001 AddToImplIncludes("V8${constructorType}.h", $attribute->signature->e
xtendedAttributes->{"Conditional"}); | 3007 my $includepath = ""; |
| 3008 if ($constructorType eq "HTMLImageElementConstructor") { |
| 3009 $includepath = "bindings/v8/custom/"; |
| 3010 } |
| 3011 AddToImplIncludes("${includepath}V8${constructorType}.h", $attribute
->signature->extendedAttributes->{"Conditional"}); |
| 3002 } | 3012 } |
| 3003 $data = "&V8${constructorType}::info"; | 3013 $data = "&V8${constructorType}::info"; |
| 3004 $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter
"; | 3014 $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter
"; |
| 3005 $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSe
tterCallback"; | 3015 $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSe
tterCallback"; |
| 3006 $getterForMainWorld = "0"; | 3016 $getterForMainWorld = "0"; |
| 3007 $setterForMainWorld = "0"; | 3017 $setterForMainWorld = "0"; |
| 3008 } else { | 3018 } else { |
| 3009 # Default Getter and Setter | 3019 # Default Getter and Setter |
| 3010 $getter = "${interfaceName}V8Internal::${attrName}AttrGetterCallback"; | 3020 $getter = "${interfaceName}V8Internal::${attrName}AttrGetterCallback"; |
| 3011 $setter = "${interfaceName}V8Internal::${attrName}AttrSetterCallback"; | 3021 $setter = "${interfaceName}V8Internal::${attrName}AttrSetterCallback"; |
| (...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4813 return "V8${type}::HasInstance($value, $getIsolate, worldType($getIsolate))
? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; | 4823 return "V8${type}::HasInstance($value, $getIsolate, worldType($getIsolate))
? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; |
| 4814 } | 4824 } |
| 4815 | 4825 |
| 4816 sub GetV8HeaderName | 4826 sub GetV8HeaderName |
| 4817 { | 4827 { |
| 4818 my $type = shift; | 4828 my $type = shift; |
| 4819 return "V8Event.h" if $type eq "DOMTimeStamp"; | 4829 return "V8Event.h" if $type eq "DOMTimeStamp"; |
| 4820 return "core/dom/EventListener.h" if $type eq "EventListener"; | 4830 return "core/dom/EventListener.h" if $type eq "EventListener"; |
| 4821 return "bindings/v8/SerializedScriptValue.h" if $type eq "SerializedScriptVa
lue"; | 4831 return "bindings/v8/SerializedScriptValue.h" if $type eq "SerializedScriptVa
lue"; |
| 4822 return "bindings/v8/ScriptValue.h" if $type eq "any"; | 4832 return "bindings/v8/ScriptValue.h" if $type eq "any"; |
| 4833 return "bindings/v8/V8GCController.h" if $type eq "GCController"; |
| 4823 return "V8${type}.h"; | 4834 return "V8${type}.h"; |
| 4824 } | 4835 } |
| 4825 | 4836 |
| 4826 sub CreateCustomSignature | 4837 sub CreateCustomSignature |
| 4827 { | 4838 { |
| 4828 my $function = shift; | 4839 my $function = shift; |
| 4829 my $count = @{$function->parameters}; | 4840 my $count = @{$function->parameters}; |
| 4830 my $name = $function->signature->name; | 4841 my $name = $function->signature->name; |
| 4831 my $code = " const int ${name}Argc = ${count};\n" . | 4842 my $code = " const int ${name}Argc = ${count};\n" . |
| 4832 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; | 4843 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5068 my $sequenceType = GetSequenceType($type); | 5079 my $sequenceType = GetSequenceType($type); |
| 5069 my $arrayOrSequenceType = $arrayType || $sequenceType; | 5080 my $arrayOrSequenceType = $arrayType || $sequenceType; |
| 5070 | 5081 |
| 5071 if ($arrayOrSequenceType) { | 5082 if ($arrayOrSequenceType) { |
| 5072 if ($arrayType eq "DOMString") { | 5083 if ($arrayType eq "DOMString") { |
| 5073 AddToImplIncludes("V8DOMStringList.h"); | 5084 AddToImplIncludes("V8DOMStringList.h"); |
| 5074 AddToImplIncludes("core/dom/DOMStringList.h"); | 5085 AddToImplIncludes("core/dom/DOMStringList.h"); |
| 5075 | 5086 |
| 5076 } elsif (IsRefPtrType($arrayOrSequenceType)) { | 5087 } elsif (IsRefPtrType($arrayOrSequenceType)) { |
| 5077 AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)); | 5088 AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)); |
| 5078 AddToImplIncludes("${arrayOrSequenceType}.h"); | 5089 my $includepath = idlToPath($arrayOrSequenceType); # This is not an
arraytype (always?). It's things like ScriptProfileNode, MediaStreamTream, Media
StreamTream, MediaStream. |
| 5090 AddToImplIncludes("${includepath}${arrayOrSequenceType}.h"); |
| 5079 } | 5091 } |
| 5080 return "v8Array($value, $getIsolate)"; | 5092 return "v8Array($value, $getIsolate)"; |
| 5081 } | 5093 } |
| 5082 | 5094 |
| 5083 AddIncludesForType($type); | 5095 AddIncludesForType($type); |
| 5084 | 5096 |
| 5085 if (IsDOMNodeType($type) || $type eq "EventTarget") { | 5097 if (IsDOMNodeType($type) || $type eq "EventTarget") { |
| 5086 if ($getScriptWrappable) { | 5098 if ($getScriptWrappable) { |
| 5087 return "toV8Fast${forMainWorldSuffix}($value$getHolderContainerArg$get
ScriptWrappableArg)"; | 5099 return "toV8Fast${forMainWorldSuffix}($value$getHolderContainerArg$get
ScriptWrappableArg)"; |
| 5088 } | 5100 } |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5739 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5751 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 5740 $found = 1; | 5752 $found = 1; |
| 5741 } | 5753 } |
| 5742 return 1 if $found; | 5754 return 1 if $found; |
| 5743 }, 0); | 5755 }, 0); |
| 5744 | 5756 |
| 5745 return $found; | 5757 return $found; |
| 5746 } | 5758 } |
| 5747 | 5759 |
| 5748 1; | 5760 1; |
| OLD | NEW |