| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 sub ParseInterface | 299 sub ParseInterface |
| 300 { | 300 { |
| 301 my $interfaceName = shift; | 301 my $interfaceName = shift; |
| 302 | 302 |
| 303 if (exists $cachedInterfaces->{$interfaceName}) { | 303 if (exists $cachedInterfaces->{$interfaceName}) { |
| 304 return $cachedInterfaces->{$interfaceName}; | 304 return $cachedInterfaces->{$interfaceName}; |
| 305 } | 305 } |
| 306 | 306 |
| 307 # Step #1: Find the IDL file associated with 'interface' | 307 # Step #1: Find the IDL file associated with 'interface' |
| 308 my $filename = IDLFileForInterface($interfaceName) | 308 my $filename = IDLFileForInterface($interfaceName) |
| 309 or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); | 309 or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); |
| 310 | 310 |
| 311 print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceN
ame\"\n" if $verbose; | 311 print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceN
ame\"\n" if $verbose; |
| 312 | 312 |
| 313 # Step #2: Parse the found IDL file (in quiet mode). | 313 # Step #2: Parse the found IDL file (in quiet mode). |
| 314 my $parser = IDLParser->new(1); | 314 my $parser = IDLParser->new(1); |
| 315 my $document = $parser->Parse($filename, $defines, $preprocessor); | 315 my $document = $parser->Parse($filename, $defines, $preprocessor); |
| 316 | 316 |
| 317 foreach my $interface (@{$document->interfaces}) { | 317 foreach my $interface (@{$document->interfaces}) { |
| 318 if ($interface->name eq $interfaceName or $interface->isPartial) { | 318 if ($interface->name eq $interfaceName or $interface->isPartial) { |
| 319 $cachedInterfaces->{$interfaceName} = $interface; | 319 $cachedInterfaces->{$interfaceName} = $interface; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 return if SkipIncludeHeader($type); | 435 return if SkipIncludeHeader($type); |
| 436 | 436 |
| 437 # Default includes | 437 # Default includes |
| 438 if ($type eq "EventListener") { | 438 if ($type eq "EventListener") { |
| 439 AddToImplIncludes("core/dom/EventListener.h"); | 439 AddToImplIncludes("core/dom/EventListener.h"); |
| 440 } elsif ($type eq "SerializedScriptValue") { | 440 } elsif ($type eq "SerializedScriptValue") { |
| 441 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 441 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| 442 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { | 442 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { |
| 443 AddToImplIncludes("bindings/v8/ScriptValue.h"); | 443 AddToImplIncludes("bindings/v8/ScriptValue.h"); |
| 444 } elsif ($type eq "ArrayBuffer") { | |
| 445 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); | |
| 446 } else { | 444 } else { |
| 447 AddToImplIncludes("V8${type}.h"); | 445 AddToImplIncludes("V8${type}.h"); |
| 448 } | 446 } |
| 449 | 447 |
| 450 # Additional includes | 448 # Additional includes |
| 451 if ($type eq "CSSStyleSheet") { | 449 if ($type eq "CSSStyleSheet") { |
| 452 AddToImplIncludes("core/css/CSSImportRule.h"); | 450 AddToImplIncludes("core/css/CSSImportRule.h"); |
| 453 } | 451 } |
| 454 } | 452 } |
| 455 | 453 |
| 456 sub HeaderFilesForInterface | 454 sub HeaderFilesForInterface |
| 457 { | 455 { |
| 458 my $interfaceName = shift; | 456 my $interfaceName = shift; |
| 459 my $implClassName = shift; | 457 my $implClassName = shift; |
| 460 | 458 |
| 461 my @includes = (); | 459 my @includes = (); |
| 462 if (IsTypedArrayType($interfaceName) or $interfaceName eq "ArrayBuffer") { | 460 if (IsTypedArrayType($interfaceName)) { |
| 463 push(@includes, "wtf/${interfaceName}.h"); | 461 push(@includes, "wtf/${interfaceName}.h"); |
| 464 } elsif ($interfaceName =~ /SVGPathSeg/) { | 462 } elsif ($interfaceName =~ /SVGPathSeg/) { |
| 465 $interfaceName =~ s/Abs|Rel//; | 463 $interfaceName =~ s/Abs|Rel//; |
| 466 push(@includes, "core/svg/${interfaceName}.h"); | 464 push(@includes, "core/svg/${interfaceName}.h"); |
| 467 } elsif (!SkipIncludeHeader($interfaceName)) { | 465 } elsif (!SkipIncludeHeader($interfaceName)) { |
| 468 my $idlFilename = IDLFileForInterface($interfaceName) or die("Could NOT
find IDL file for interface \"$interfaceName\" $!\n"); | 466 my $idlFilename = IDLFileForInterface($interfaceName) or die("Could NOT
find IDL file for interface \"$interfaceName\" $!\n"); |
| 469 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceR
oot); | 467 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceR
oot); |
| 470 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); | 468 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); |
| 471 } | 469 } |
| 472 return @includes; | 470 return @includes; |
| (...skipping 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4757 } | 4755 } |
| 4758 END | 4756 END |
| 4759 } | 4757 } |
| 4760 | 4758 |
| 4761 $code .= <<END; | 4759 $code .= <<END; |
| 4762 | 4760 |
| 4763 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, impl.get(), isolate); | 4761 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, impl.get(), isolate); |
| 4764 if (UNLIKELY(wrapper.IsEmpty())) | 4762 if (UNLIKELY(wrapper.IsEmpty())) |
| 4765 return wrapper; | 4763 return wrapper; |
| 4766 END | 4764 END |
| 4767 if (IsTypedArrayType($interface->name)) { | 4765 if ($interface->name eq "ArrayBuffer") { |
| 4766 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); |
| 4767 $code .= <<END; |
| 4768 if (!impl->hasDeallocationObserver()) { |
| 4769 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->byteLength()); |
| 4770 impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanc
e()); |
| 4771 } |
| 4772 END |
| 4773 } elsif (IsTypedArrayType($interface->name)) { |
| 4768 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); | 4774 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); |
| 4769 $code .= <<END; | 4775 $code .= <<END; |
| 4770 if (!impl->buffer()->hasDeallocationObserver()) { | 4776 if (!impl->buffer()->hasDeallocationObserver()) { |
| 4771 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->buffer()->byteLength
()); | 4777 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->buffer()->byteLength
()); |
| 4772 impl->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserve
r::instance()); | 4778 impl->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserve
r::instance()); |
| 4773 } | 4779 } |
| 4774 END | 4780 END |
| 4775 } | 4781 } |
| 4776 | 4782 |
| 4777 $code .= <<END; | 4783 $code .= <<END; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5026 return "Dictionary" if $type eq "Dictionary"; | 5032 return "Dictionary" if $type eq "Dictionary"; |
| 5027 | 5033 |
| 5028 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; | 5034 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; |
| 5029 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; | 5035 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; |
| 5030 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; | 5036 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; |
| 5031 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; | 5037 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; |
| 5032 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; | 5038 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; |
| 5033 | 5039 |
| 5034 die "UnionType is not supported" if IsUnionType($type); | 5040 die "UnionType is not supported" if IsUnionType($type); |
| 5035 | 5041 |
| 5036 if ($type eq "ArrayBuffer") { | |
| 5037 return $isParameter ? "ArrayBuffer*" : "RefPtr<ArrayBuffer>"; | |
| 5038 } | |
| 5039 | |
| 5040 # We need to check [ImplementedAs] extended attribute for wrapper types. | 5042 # We need to check [ImplementedAs] extended attribute for wrapper types. |
| 5041 if (IsWrapperType($type)) { | 5043 if (IsWrapperType($type)) { |
| 5042 my $interface = ParseInterface($type); | 5044 my $interface = ParseInterface($type); |
| 5043 my $implClassName = GetImplName($interface); | 5045 my $implClassName = GetImplName($interface); |
| 5044 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>"; | 5046 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>"; |
| 5045 } | 5047 } |
| 5046 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; | 5048 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; |
| 5047 | 5049 |
| 5048 my $arrayOrSequenceType = GetArrayOrSequenceType($type); | 5050 my $arrayOrSequenceType = GetArrayOrSequenceType($type); |
| 5049 | 5051 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5123 | 5125 |
| 5124 if ($type eq "MediaQueryListListener") { | 5126 if ($type eq "MediaQueryListListener") { |
| 5125 AddToImplIncludes("core/css/MediaQueryListListener.h"); | 5127 AddToImplIncludes("core/css/MediaQueryListListener.h"); |
| 5126 return "MediaQueryListListener::create(" . $value . ")"; | 5128 return "MediaQueryListListener::create(" . $value . ")"; |
| 5127 } | 5129 } |
| 5128 | 5130 |
| 5129 if ($type eq "EventTarget") { | 5131 if ($type eq "EventTarget") { |
| 5130 return "V8DOMWrapper::isDOMWrapper($value) ? toWrapperTypeInfo(v8::Handl
e<v8::Object>::Cast($value))->toEventTarget(v8::Handle<v8::Object>::Cast($value)
) : 0"; | 5132 return "V8DOMWrapper::isDOMWrapper($value) ? toWrapperTypeInfo(v8::Handl
e<v8::Object>::Cast($value))->toEventTarget(v8::Handle<v8::Object>::Cast($value)
) : 0"; |
| 5131 } | 5133 } |
| 5132 | 5134 |
| 5133 if ($type eq "ArrayBuffer") { | |
| 5134 AddIncludesForType($type); | |
| 5135 return "$value->IsArrayBuffer() ? V8ArrayBuffer::toNative(v8::Handle<v8:
:ArrayBuffer>::Cast($value)) : 0" | |
| 5136 } | |
| 5137 | |
| 5138 if ($type eq "XPathNSResolver") { | 5135 if ($type eq "XPathNSResolver") { |
| 5139 return "toXPathNSResolver($value, $getIsolate)"; | 5136 return "toXPathNSResolver($value, $getIsolate)"; |
| 5140 } | 5137 } |
| 5141 | 5138 |
| 5142 my $arrayOrSequenceType = GetArrayOrSequenceType($type); | 5139 my $arrayOrSequenceType = GetArrayOrSequenceType($type); |
| 5143 | 5140 |
| 5144 if ($arrayOrSequenceType) { | 5141 if ($arrayOrSequenceType) { |
| 5145 if (IsRefPtrType($arrayOrSequenceType)) { | 5142 if (IsRefPtrType($arrayOrSequenceType)) { |
| 5146 AddToImplIncludes("V8${arrayOrSequenceType}.h"); | 5143 AddToImplIncludes("V8${arrayOrSequenceType}.h"); |
| 5147 return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequ
enceType}>($value, $getIsolate))"; | 5144 return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequ
enceType}>($value, $getIsolate))"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5159 { | 5156 { |
| 5160 my $function = shift; | 5157 my $function = shift; |
| 5161 my $count = @{$function->parameters}; | 5158 my $count = @{$function->parameters}; |
| 5162 my $name = $function->name; | 5159 my $name = $function->name; |
| 5163 my $code = " const int ${name}Argc = ${count};\n" . | 5160 my $code = " const int ${name}Argc = ${count};\n" . |
| 5164 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; | 5161 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; |
| 5165 my $first = 1; | 5162 my $first = 1; |
| 5166 foreach my $parameter (@{$function->parameters}) { | 5163 foreach my $parameter (@{$function->parameters}) { |
| 5167 if ($first) { $first = 0; } | 5164 if ($first) { $first = 0; } |
| 5168 else { $code .= ", "; } | 5165 else { $code .= ", "; } |
| 5169 if (IsWrapperType($parameter->type) && $parameter->type ne "ArrayBuffer"
) { | 5166 if (IsWrapperType($parameter->type)) { |
| 5170 if ($parameter->type eq "XPathNSResolver") { | 5167 if ($parameter->type eq "XPathNSResolver") { |
| 5171 # Special case for XPathNSResolver. All other browsers accepts
a callable, | 5168 # Special case for XPathNSResolver. All other browsers accepts
a callable, |
| 5172 # so, even though it's against IDL, accept objects here. | 5169 # so, even though it's against IDL, accept objects here. |
| 5173 $code .= "v8::Handle<v8::FunctionTemplate>()"; | 5170 $code .= "v8::Handle<v8::FunctionTemplate>()"; |
| 5174 } else { | 5171 } else { |
| 5175 my $type = $parameter->type; | 5172 my $type = $parameter->type; |
| 5176 my $arrayOrSequenceType = GetArrayOrSequenceType($type); | 5173 my $arrayOrSequenceType = GetArrayOrSequenceType($type); |
| 5177 | 5174 |
| 5178 if ($arrayOrSequenceType) { | 5175 if ($arrayOrSequenceType) { |
| 5179 if (IsRefPtrType($arrayOrSequenceType)) { | 5176 if (IsRefPtrType($arrayOrSequenceType)) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5248 return 0 if IsEnumType($type); | 5245 return 0 if IsEnumType($type); |
| 5249 return 0 if IsPrimitiveType($type); | 5246 return 0 if IsPrimitiveType($type); |
| 5250 return 0 if $type eq "DOMString"; | 5247 return 0 if $type eq "DOMString"; |
| 5251 return !$nonWrapperTypes{$type}; | 5248 return !$nonWrapperTypes{$type}; |
| 5252 } | 5249 } |
| 5253 | 5250 |
| 5254 sub IsCallbackInterface | 5251 sub IsCallbackInterface |
| 5255 { | 5252 { |
| 5256 my $type = shift; | 5253 my $type = shift; |
| 5257 return 0 unless IsWrapperType($type); | 5254 return 0 unless IsWrapperType($type); |
| 5258 return 0 if $type eq "ArrayBuffer"; | |
| 5259 | 5255 |
| 5260 my $idlFile = IDLFileForInterface($type) | 5256 my $idlFile = IDLFileForInterface($type) |
| 5261 or die("Could NOT find IDL file for interface \"$type\"!\n"); | 5257 or die("Could NOT find IDL file for interface \"$type\"!\n"); |
| 5262 | 5258 |
| 5263 open FILE, "<", $idlFile; | 5259 open FILE, "<", $idlFile; |
| 5264 my @lines = <FILE>; | 5260 my @lines = <FILE>; |
| 5265 close FILE; | 5261 close FILE; |
| 5266 | 5262 |
| 5267 my $fileContents = join('', @lines); | 5263 my $fileContents = join('', @lines); |
| 5268 return ($fileContents =~ /callback\s+interface\s+(\w+)/gs); | 5264 return ($fileContents =~ /callback\s+interface\s+(\w+)/gs); |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6047 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 6043 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 6048 $found = 1; | 6044 $found = 1; |
| 6049 } | 6045 } |
| 6050 return 1 if $found; | 6046 return 1 if $found; |
| 6051 }, 0); | 6047 }, 0); |
| 6052 | 6048 |
| 6053 return $found; | 6049 return $found; |
| 6054 } | 6050 } |
| 6055 | 6051 |
| 6056 1; | 6052 1; |
| OLD | NEW |