diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-10-16 18:35:17 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-10-16 18:35:17 (GMT) |
commit | 60c543c1d8c6699cc96829f15b16ecc60ac0b410 (patch) | |
tree | f0087f620d45246acf0268da539cb815796d88c0 /contrib | |
parent | 4d186e24e44fe07f04708c2dc38387534c02c7fd (diff) | |
download | uscxml-60c543c1d8c6699cc96829f15b16ecc60ac0b410.zip uscxml-60c543c1d8c6699cc96829f15b16ecc60ac0b410.tar.gz uscxml-60c543c1d8c6699cc96829f15b16ecc60ac0b410.tar.bz2 |
Added license information and bug fixes
Diffstat (limited to 'contrib')
94 files changed, 64 insertions, 17743 deletions
diff --git a/contrib/cmake/FindLIBICAL.cmake b/contrib/cmake/FindLIBICAL.cmake index a0cfe43..6510f96 100644 --- a/contrib/cmake/FindLIBICAL.cmake +++ b/contrib/cmake/FindLIBICAL.cmake @@ -1,5 +1,6 @@ -FIND_PATH(LIBICAL_INCLUDE_DIR libical/ical.h - PATH_SUFFIXES include src +# we cannot search for ical.h as we might find the wrong one without the libical suffix +FIND_PATH(LIBICAL_INCLUDE_DIR icalcomponent.h + PATH_SUFFIXES include/libical PATHS /usr/local /usr diff --git a/contrib/ctest/hosts/epikur-win7-64.ctest b/contrib/ctest/hosts/epikur-win7-64.ctest index ba58a6b..4f6e711 100644 --- a/contrib/ctest/hosts/epikur-win7-64.ctest +++ b/contrib/ctest/hosts/epikur-win7-64.ctest @@ -11,3 +11,8 @@ set(RETAIN_BUILD_DIR OFF) set(CTEST_BUILD_NAME "win7-x86_64 msvc") include("tests/xpath.ctest") include("common.ctest.inc") + +set(RETAIN_BUILD_DIR OFF) +set(CTEST_BUILD_NAME "win7-x86_64 msvc") +include("tests/plugins.ctest") +include("common.ctest.inc") diff --git a/contrib/ctest/hosts/epikur.local.ctest b/contrib/ctest/hosts/epikur.local.ctest index 7b2a801..f7d728d 100644 --- a/contrib/ctest/hosts/epikur.local.ctest +++ b/contrib/ctest/hosts/epikur.local.ctest @@ -2,18 +2,18 @@ set(CTEST_CMAKE_GENERATOR "Unix Makefiles") set(CTEST_SITE "epikur.local") set(CTEST_BUILD_CONFIGURATION "Debug") -set(RETAIN_BUILD_DIR ON) +set(RETAIN_BUILD_DIR OFF) set(CTEST_BUILD_NAME "darwin-x86_64 llvm") include("tests/plugins.ctest") include("common.ctest.inc") -# set(RETAIN_BUILD_DIR OFF) -# set(CTEST_BUILD_NAME "darwin-x86_64 llvm") -# include("tests/ecma.ctest") -# include("common.ctest.inc") -# -# set(RETAIN_BUILD_DIR OFF) -# set(CTEST_BUILD_NAME "darwin-x86_64 llvm") -# include("tests/xpath.ctest") -# include("common.ctest.inc") -# +set(RETAIN_BUILD_DIR OFF) +set(CTEST_BUILD_NAME "darwin-x86_64 llvm") +include("tests/ecma.ctest") +include("common.ctest.inc") + +set(RETAIN_BUILD_DIR OFF) +set(CTEST_BUILD_NAME "darwin-x86_64 llvm") +include("tests/xpath.ctest") +include("common.ctest.inc") + diff --git a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm index f9a2d25..27ad7a7 100644 --- a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm +++ b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm @@ -45,26 +45,25 @@ my %implIncludes = (); my %headerIncludes = (); # Default .h template -my $headerTemplate = << "EOF"; -/* - This file is part of the Wrapper open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ +my $headerTemplate = << 'EOF'; +/** + * @file + * @author This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ EOF # Default constructor @@ -728,6 +727,7 @@ sub GenerateImplementation $parentClass = "JSC" . $parent; last; } + push(@implContent, "namespace Arabica {\n"); push(@implContent, "namespace DOM {\n\n"); push(@implContent, "JSClassRef JSC${interfaceName}::Tmpl;\n"); @@ -767,7 +767,8 @@ sub WriteData # exit(); # Update a .cpp file if the contents are changed. - my $contents = join "", @implContentHeader; + my $contents = $headerTemplate; + $contents .= join "", @implContentHeader; my @includes = (); my %implIncludeConditions = (); diff --git a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm index 08a5805..0095f6b 100644 --- a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm +++ b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm @@ -45,26 +45,26 @@ my %implIncludes = (); my %headerIncludes = (); # Default .h template -my $headerTemplate = << "EOF"; -/* - This file is part of the Wrapper open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ +my $headerTemplate = << 'EOF'; +/** + * @file + * @author This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + EOF # Default constructor @@ -666,6 +666,7 @@ sub GenerateImplementation $parentClass = "V8" . $parent; last; } + push(@implContent, "namespace Arabica {\n"); push(@implContent, "namespace DOM {\n\n"); push(@implContent, " v8::Persistent<v8::FunctionTemplate> V8${interfaceName}::Tmpl;\n"); @@ -710,7 +711,8 @@ sub WriteData # exit(); # Update a .cpp file if the contents are changed. - my $contents = join "", @implContentHeader; + my $contents = $headerTemplate; + $contents .= join "", @implContentHeader; my @includes = (); my %implIncludeConditions = (); diff --git a/contrib/dom/scripts/CodeGeneratorCPP.pm b/contrib/dom/scripts/CodeGeneratorCPP.pm deleted file mode 100644 index bb9f3ee..0000000 --- a/contrib/dom/scripts/CodeGeneratorCPP.pm +++ /dev/null @@ -1,986 +0,0 @@ - -# Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> -# Copyright (C) 2006 Anders Carlsson <andersca@mac.com> -# Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> -# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> -# Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> -# Copyright (C) Research In Motion Limited 2010. All rights reserved. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# aint with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# - -package CodeGeneratorCPP; - -use constant FileNamePrefix => "WebDOM"; - -# Global Variables - -my @headerContentHeader = (); -my @headerContent = (); -my %headerForwardDeclarations = (); - -my @implContentHeader = (); -my @implContent = (); -my %implIncludes = (); - -# Constants -my $exceptionInit = "WebCore::ExceptionCode ec = 0;"; -my $exceptionRaiseOnError = "webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));"; - -# Default License Templates -my $headerLicenseTemplate = << "EOF"; -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig\@gmail.com> - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -EOF - -my $implementationLicenseTemplate = << "EOF"; -/* - * This file is part of the WebKit open source project. - * This file has been generated by generate-bindings.pl. DO NOT MODIFY! - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -EOF - -# Default constructor -sub new -{ - my $object = shift; - my $reference = { }; - - $codeGenerator = shift; - shift; # $useLayerOnTop - shift; # $preprocessor - shift; # $writeDependencies - - bless($reference, $object); - return $reference; -} - -sub GenerateInterface -{ - my $object = shift; - my $interface = shift; - my $defines = shift; - - my $name = $interface->name; - my $className = GetClassName($name); - my $parentClassName = "WebDOM" . GetParentImplClassName($interface); - - $object->GenerateHeader($interface); - $object->GenerateImplementation($interface); -} - -sub GetClassName -{ - my $name = shift; - - # special cases - return "WebDOMString" if $codeGenerator->IsStringType($name) or $name eq "SerializedScriptValue"; - return "WebDOMObject" if $name eq "DOMObject"; - return "bool" if $name eq "boolean"; - return $name if $codeGenerator->IsPrimitiveType($name); - - return "WebDOM$name"; -} - -sub GetImplClassName -{ - return shift; -} - -sub GetParentImplClassName -{ - my $interface = shift; - - if (@{$interface->parents} eq 0) { - return "EventTarget" if $interface->extendedAttributes->{"EventTarget"}; - return "Object"; - } - - return $interface->parents(0); -} - -sub GetParent -{ - my $interface = shift; - my $numParents = @{$interface->parents}; - - my $parent = ""; - if ($numParents eq 0) { - $parent = "WebDOMObject"; - $parent = "WebDOMEventTarget" if $interface->extendedAttributes->{"EventTarget"}; - } elsif ($numParents eq 1) { - my $parentName = $interface->parents(0); - $parent = "WebDOM" . $parentName; - } else { - my @parents = @{$interface->parents}; - my $firstParent = shift(@parents); - $parent = "WebDOM" . $firstParent; - } - - return $parent; -} - -sub SkipFunction -{ - my $function = shift; - - return 1 if $function->signature->extendedAttributes->{"Custom"}; - - # FIXME: We don't generate bindings for SVG related interfaces yet - return 1 if $function->signature->name =~ /getSVGDocument/; - - if ($codeGenerator->GetArrayType($function->signature->type)) { - return 1; - } - - if ($codeGenerator->GetSequenceType($function->signature->type)) { - return 1; - } - - foreach my $param (@{$function->parameters}) { - return 1 if $codeGenerator->GetSequenceType($param->type); - return 1 if $param->extendedAttributes->{"Clamp"}; - } - - # FIXME: This is typically used to add script execution state arguments to the method. - # These functions will not compile with the C++ bindings as is, so disable them - # to restore compilation until a proper implementation can be developed. - return 1 if $function->signature->extendedAttributes->{"CallWith"}; -} - -sub SkipAttribute -{ - my $attribute = shift; - - return 1 if $attribute->signature->extendedAttributes->{"Custom"} - or $attribute->signature->extendedAttributes->{"CustomGetter"}; - - return 1 if $attribute->signature->type =~ /Constructor$/; - - return 1 if $codeGenerator->IsTypedArrayType($attribute->signature->type); - - if ($codeGenerator->GetArrayType($attribute->signature->type)) { - return 1; - } - - if ($codeGenerator->GetSequenceType($attribute->signature->type)) { - return 1; - } - - $codeGenerator->AssertNotSequenceType($attribute->signature->type); - - # FIXME: This is typically used to add script execution state arguments to the method. - # These functions will not compile with the C++ bindings as is, so disable them - # to restore compilation until a proper implementation can be developed. - return 1 if $attribute->signature->extendedAttributes->{"CallWith"}; - - return 0; -} - -sub GetCPPType -{ - my $type = shift; - my $useConstReference = shift; - my $name = GetClassName($type); - - return "int" if $type eq "long"; - return "unsigned" if $name eq "unsigned long"; - return "unsigned short" if $type eq "CompareHow"; - return "double" if $name eq "Date"; - - if ($codeGenerator->IsStringType($type)) { - if ($useConstReference) { - return "const $name&"; - } - - return $name; - } - - return $name if $codeGenerator->IsPrimitiveType($type) or $type eq "DOMTimeStamp"; - return "const $name&" if $useConstReference; - return $name; -} - -sub ConversionNeeded -{ - my $type = shift; - return !$codeGenerator->IsNonPointerType($type) && !$codeGenerator->IsStringType($type); -} - -sub GetCPPTypeGetter -{ - my $argName = shift; - my $type = shift; - - return $argName if $codeGenerator->IsPrimitiveType($type) or $codeGenerator->IsStringType($type); - return "static_cast<WebCore::Range::CompareHow>($argName)" if $type eq "CompareHow"; - return "WebCore::SerializedScriptValue::create(WTF::String($argName))" if $type eq "SerializedScriptValue"; - return "to" . GetNamespaceForClass($argName) . "($argName)"; -} - -sub AddForwardDeclarationsForType -{ - my $type = shift; - my $public = shift; - - return if $codeGenerator->IsNonPointerType($type) or $codeGenerator->IsStringType($type); - - my $class = GetClassName($type); - $headerForwardDeclarations{$class} = 1 if $public; -} - -sub AddIncludesForType -{ - my $type = shift; - - return if $codeGenerator->GetSequenceType($type); - return if $codeGenerator->GetArrayType($type); - return if $codeGenerator->IsNonPointerType($type); - return if $type =~ /Constructor/; - - if ($codeGenerator->IsStringType($type)) { - $implIncludes{"wtf/text/AtomicString.h"} = 1; - $implIncludes{"KURL.h"} = 1; - $implIncludes{"WebDOMString.h"} = 1; - return; - } - - if ($type eq "DOMObject") { - $implIncludes{"WebDOMObject.h"} = 1; - return; - } - - if ($type eq "EventListener") { - $implIncludes{"WebNativeEventListener.h"} = 1; - return; - } - - if ($type eq "SerializedScriptValue") { - $implIncludes{"SerializedScriptValue.h"} = 1; - return; - } - - # Also include CSSImportRule so that the toWebKit methods for subclasses are found - if ($type eq "CSSRule") { - $implIncludes{"WebDOMCSSImportRule.h"} = 1; - } - - $implIncludes{"Node.h"} = 1 if $type eq "NodeList"; - $implIncludes{"StylePropertySet.h"} = 1 if $type eq "CSSStyleDeclaration"; - - # Default, include the same named file (the implementation) and the same name prefixed with "WebDOM". - $implIncludes{"$type.h"} = 1 unless $type eq "DOMObject"; - $implIncludes{"WebDOM$type.h"} = 1; -} - -sub GetNamespaceForClass -{ - my $type = shift; - return "WTF" if (($type eq "ArrayBuffer") or ($type eq "ArrayBufferView")); - return "WTF" if (($type eq "Uint8Array") or ($type eq "Uint8ClampedArray") or ($type eq "Uint16Array") or ($type eq "Uint32Array")); - return "WTF" if (($type eq "Int8Array") or ($type eq "Int16Array") or ($type eq "Int32Array")); - return "WTF" if (($type eq "Float32Array") or ($type eq "Float64Array")); - return "WebCore"; -} - -sub GenerateHeader -{ - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $className = GetClassName($interfaceName); - my $implClassName = GetImplClassName($interfaceName); - - my $implClassNameWithNamespace = GetNamespaceForClass($implClassName) . "::" . $implClassName; - - my $parentName = ""; - $parentName = GetParent($interface); - - my $numConstants = @{$interface->constants}; - my $numAttributes = @{$interface->attributes}; - my $numFunctions = @{$interface->functions}; - - # - Add default header template - @headerContentHeader = split("\r", $headerLicenseTemplate); - push(@headerContentHeader, "\n#ifndef $className" . "_h"); - push(@headerContentHeader, "\n#define $className" . "_h\n\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; - - # - INCLUDES - - - my %headerIncludes = (); - $headerIncludes{"WebDOMString.h"} = 1; - $headerIncludes{"$parentName.h"} = 1; - foreach my $include (sort keys(%headerIncludes)) { - push(@headerContentHeader, "#include <$include>\n"); - } - - push(@headerContent, "class $className"); - push(@headerContent, " : public $parentName") if $parentName; - push(@headerContent, " {\n"); - push(@headerContent, "public:\n"); - - # Constructor - push(@headerContent, " $className();\n"); - push(@headerContent, " explicit $className($implClassNameWithNamespace*);\n"); - - # Copy constructor and assignment operator on classes which have the d-ptr - if ($parentName eq "WebDOMObject") { - push(@headerContent, " $className(const $className&);\n"); - push(@headerContent, " ${className}& operator=(const $className&);\n"); - } - - # Destructor - if ($parentName eq "WebDOMObject") { - push(@headerContent, " virtual ~$className();\n"); - } else { - push(@headerContent, " virtual ~$className() { }\n"); - } - - push(@headerContent, "\n"); - $headerForwardDeclarations{$implClassNameWithNamespace} = 1; - - # - Add constants. - if ($numConstants > 0) { - my @headerConstants = (); - my @constants = @{$interface->constants}; - my $combinedConstants = ""; - - # FIXME: we need a way to include multiple enums. - foreach my $constant (@constants) { - my $constantName = $constant->name; - my $constantValue = $constant->value; - my $conditional = $constant->extendedAttributes->{"Conditional"}; - my $notLast = $constant ne $constants[-1]; - - if ($conditional) { - my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - $combinedConstants .= "#if ${conditionalString}\n"; - } - $combinedConstants .= " WEBDOM_$constantName = $constantValue"; - $combinedConstants .= "," if $notLast; - if ($conditional) { - $combinedConstants .= "\n#endif\n"; - } elsif ($notLast) { - $combinedConstants .= "\n"; - } - } - - push(@headerContent, " "); - push(@headerContent, "enum {\n"); - push(@headerContent, $combinedConstants); - push(@headerContent, "\n "); - push(@headerContent, "};\n\n"); - } - - my @headerAttributes = (); - - # - Add attribute getters/setters. - if ($numAttributes > 0) { - foreach my $attribute (@{$interface->attributes}) { - next if SkipAttribute($attribute); - - my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - my $attributeName = $attribute->signature->name; - my $attributeType = GetCPPType($attribute->signature->type, 0); - my $attributeIsReadonly = ($attribute->type =~ /^readonly/); - my $property = ""; - - $property .= "#if ${attributeConditionalString}\n" if $attributeConditionalString; - $property .= " " . $attributeType . ($attributeType =~ /\*$/ ? "" : " ") . $attributeName . "() const"; - - my $availabilityMacro = ""; - my $declarationSuffix = ";\n"; - - AddForwardDeclarationsForType($attribute->signature->type, 1); - - $attributeType = GetCPPType($attribute->signature->type, 1); - my $setterName = "set" . ucfirst($attributeName); - - $property .= $declarationSuffix; - push(@headerAttributes, $property); - if (!$attributeIsReadonly and !$attribute->signature->extendedAttributes->{"Replaceable"}) { - $property = " void $setterName($attributeType)"; - $property .= $declarationSuffix; - push(@headerAttributes, $property); - } - - push(@headerAttributes, "#endif\n") if $attributeConditionalString; - } - push(@headerContent, @headerAttributes) if @headerAttributes > 0; - } - - my @headerFunctions = (); - my @deprecatedHeaderFunctions = (); - my @interfaceFunctions = (); - - # - Add functions. - if ($numFunctions > 0) { - foreach my $function (@{$interface->functions}) { - next if SkipFunction($function); - next if ($function->signature->name eq "set" and $interface->extendedAttributes->{"TypedArray"}); - my $functionName = $function->signature->extendedAttributes->{"ImplementedAs"} || $function->signature->name; - - my $returnType = GetCPPType($function->signature->type, 0); - my $numberOfParameters = @{$function->parameters}; - my %typesToForwardDeclare = ($function->signature->type => 1); - - my $parameterIndex = 0; - my $functionSig = "$returnType $functionName("; - my $methodName = $functionName; - foreach my $param (@{$function->parameters}) { - my $paramName = $param->name; - my $paramType = GetCPPType($param->type, 1); - $typesToForwardDeclare{$param->type} = 1; - - $functionSig .= ", " if $parameterIndex >= 1; - $functionSig .= "$paramType $paramName"; - $parameterIndex++; - } - $functionSig .= ")"; - if ($interface->extendedAttributes->{"CPPPureInterface"}) { - push(@interfaceFunctions, " virtual " . $functionSig . " = 0;\n"); - } - my $functionDeclaration = $functionSig; - $functionDeclaration .= ";\n"; - - foreach my $type (keys %typesToForwardDeclare) { - # add any forward declarations to the public header if a deprecated version will be generated - AddForwardDeclarationsForType($type, 1); - } - - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@headerFunctions, "#if ${conditionalString}\n") if $conditionalString; - push(@headerFunctions, " "); - push(@headerFunctions, $functionDeclaration); - push(@headerFunctions, "#endif\n") if $conditionalString; - } - - if (@headerFunctions > 0) { - push(@headerContent, "\n") if @headerAttributes > 0; - push(@headerContent, @headerFunctions); - } - } - - push(@headerContent, "\n"); - push(@headerContent, " $implClassNameWithNamespace* impl() const;\n"); - - if ($parentName eq "WebDOMObject") { - push(@headerContent, "\nprotected:\n"); - push(@headerContent, " struct ${className}Private;\n"); - push(@headerContent, " ${className}Private* m_impl;\n"); - } - - push(@headerContent, "};\n\n"); - - # for CPPPureInterface classes also add the interface that the client code needs to - # implement - if ($interface->extendedAttributes->{"CPPPureInterface"}) { - push(@headerContent, "class WebUser$interfaceName {\n"); - push(@headerContent, "public:\n"); - push(@headerContent, " virtual void ref() = 0;\n"); - push(@headerContent, " virtual void deref() = 0;\n\n"); - push(@headerContent, @interfaceFunctions); - push(@headerContent, "\nprotected:\n"); - push(@headerContent, " virtual ~WebUser$interfaceName() {}\n"); - push(@headerContent, "};\n\n"); - } - - my $namespace = GetNamespaceForClass($implClassName); - push(@headerContent, "$namespace" . "::$implClassName* toWebCore(const $className&);\n"); - push(@headerContent, "$className toWebKit($namespace" . "::$implClassName*);\n"); - if ($interface->extendedAttributes->{"CPPPureInterface"}) { - push(@headerContent, "$className toWebKit(WebUser$interfaceName*);\n"); - } - push(@headerContent, "\n#endif\n"); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; -} - -sub AddEarlyReturnStatement -{ - my $returnType = shift; - - if (!defined($returnType) or $returnType eq "void") { - $returnType = ""; - } elsif ($codeGenerator->IsPrimitiveType($returnType)) { - $returnType = " 0"; - } elsif ($returnType eq "bool") { - $returnType = " false"; - } else { - $returnType = " $returnType()"; - } - - # TODO: We could set exceptions here, if we want that - my $statement = " if (!impl())\n"; - $statement .= " return$returnType;\n\n"; - return $statement; -} - -sub AddReturnStatement -{ - my $typeInfo = shift; - my $returnValue = shift; - - # Used to invoke KURLs "const String&" operator - if ($codeGenerator->IsStringType($typeInfo->signature->type)) { - return " return static_cast<const WTF::String&>($returnValue);\n"; - } - - return " return $returnValue;\n"; -} - -sub GenerateImplementation -{ - my $object = shift; - my $interface = shift; - - my @ancestorInterfaceNames = (); - - if (@{$interface->parents} > 1) { - $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames); - } - - my $interfaceName = $interface->name; - my $className = GetClassName($interfaceName); - my $implClassName = GetImplClassName($interfaceName); - my $parentImplClassName = GetParentImplClassName($interface); - my $implClassNameWithNamespace = GetNamespaceForClass($implClassName) . "::" . $implClassName; - my $baseClass = "WebDOM$parentImplClassName"; - my $conditional = $interface->extendedAttributes->{"Conditional"}; - - my $numAttributes = @{$interface->attributes}; - my $numFunctions = @{$interface->functions}; - - # - Add default header template. - @implContentHeader = split("\r", $implementationLicenseTemplate); - - # - INCLUDES - - push(@implContentHeader, "\n#include \"config.h\"\n"); - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; - push(@implContentHeader, "#include \"$className.h\"\n\n"); - - $implIncludes{"WebExceptionHandler.h"} = 1; - $implIncludes{"$implClassName.h"} = 1; - @implContent = (); - - push(@implContent, "#include <wtf/GetPtr.h>\n"); - push(@implContent, "#include <wtf/RefPtr.h>\n\n"); - - # Private datastructure, encapsulating WebCore types - if ($baseClass eq "WebDOMObject") { - push(@implContent, "struct ${className}::${className}Private {\n"); - push(@implContent, " ${className}Private($implClassNameWithNamespace* object = 0)\n"); - push(@implContent, " : impl(object)\n"); - push(@implContent, " {\n"); - push(@implContent, " }\n\n"); - push(@implContent, " RefPtr<$implClassNameWithNamespace> impl;\n"); - push(@implContent, "};\n\n"); - } - - # Constructor - push(@implContent, "${className}::$className()\n"); - push(@implContent, " : ${baseClass}()\n"); - push(@implContent, " , m_impl(0)\n") if ($baseClass eq "WebDOMObject"); - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "${className}::$className($implClassNameWithNamespace* impl)\n"); - if ($baseClass eq "WebDOMObject") { - push(@implContent, " : ${baseClass}()\n"); - push(@implContent, " , m_impl(new ${className}Private(impl))\n"); - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "${className}::${className}(const ${className}& copy)\n"); - push(@implContent, " : ${baseClass}()\n"); - push(@implContent, "{\n"); - push(@implContent, " m_impl = copy.impl() ? new ${className}Private(copy.impl()) : 0;\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "${className}& ${className}::operator\=(const ${className}& copy)\n"); - push(@implContent, "{\n"); - push(@implContent, " delete m_impl;\n"); - push(@implContent, " m_impl = copy.impl() ? new ${className}Private(copy.impl()) : 0;\n"); - push(@implContent, " return *this;\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "$implClassNameWithNamespace* ${className}::impl() const\n"); - push(@implContent, "{\n"); - push(@implContent, " return m_impl ? WTF::getPtr(m_impl->impl) : 0;\n"); - push(@implContent, "}\n\n"); - - # Destructor - push(@implContent, "${className}::~$className()\n"); - push(@implContent, "{\n"); - push(@implContent, " delete m_impl;\n"); - push(@implContent, " m_impl = 0;\n"); - push(@implContent, "}\n\n"); - } else { - push(@implContent, " : ${baseClass}(impl)\n"); - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "$implClassNameWithNamespace* ${className}::impl() const\n"); - push(@implContent, "{\n"); - push(@implContent, " return static_cast<$implClassNameWithNamespace*>(${baseClass}::impl());\n"); - push(@implContent, "}\n\n"); - } - - # START implementation - %attributeNames = (); - - # - Attributes - if ($numAttributes > 0) { - foreach my $attribute (@{$interface->attributes}) { - next if SkipAttribute($attribute); - AddIncludesForType($attribute->signature->type); - - my $idlType = $attribute->signature->type; - - my $attributeName = $attribute->signature->name; - my $attributeType = GetCPPType($attribute->signature->type, 0); - my $attributeIsReadonly = ($attribute->type =~ /^readonly/); - - $attributeNames{$attributeName} = 1; - - # - GETTER - my $getterSig = "$attributeType $className\:\:$attributeName() const\n"; - my $hasGetterException = @{$attribute->getterExceptions}; - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@arguments, "ec") if $hasGetterException; - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "impl()"); - $functionName = "${implementedBy}::${functionName}"; - } else { - $functionName = "impl()->${functionName}"; - } - - # Special cases - my $getterContentHead = ""; - my $getterContentTail = ""; - my @customGetterContent = (); - if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { - $getterContentHead = "WTF::String::number("; - $getterContentTail = ")"; - } elsif ($attribute->signature->type eq "SerializedScriptValue") { - $getterContentTail = "->toString()"; - } elsif (ConversionNeeded($attribute->signature->type)) { - $getterContentHead = "toWebKit(WTF::getPtr("; - $getterContentTail = "))"; - } - - my $getterContent = "${getterContentHead}${functionName}(" . join(", ", @arguments) . ")${getterContentTail}"; - my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; - - push(@implContent, $getterSig); - push(@implContent, "{\n"); - push(@implContent, AddEarlyReturnStatement($attributeType)); - push(@implContent, @customGetterContent); - if ($hasGetterException) { - # Differentiated between when the return type is a pointer and - # not for white space issue (ie. Foo *result vs. int result). - if ($attributeType =~ /\*$/) { - $getterContent = $attributeType . "result = " . $getterContent; - } else { - $getterContent = $attributeType . " result = " . $getterContent; - } - - push(@implContent, " $exceptionInit\n"); - push(@implContent, " $getterContent;\n"); - push(@implContent, " $exceptionRaiseOnError\n"); - push(@implContent, AddReturnStatement($attribute, "result")); - } else { - push(@implContent, AddReturnStatement($attribute, $getterContent)); - } - push(@implContent, "}\n\n"); - - # - SETTER - if (!$attributeIsReadonly and !$attribute->signature->extendedAttributes->{"Replaceable"}) { - # Exception handling - my $hasSetterException = @{$attribute->setterExceptions}; - - my $coreSetterName = "set" . $codeGenerator->WK_ucfirst($attributeName); - my $setterName = "set" . ucfirst($attributeName); - my $argName = "new" . ucfirst($attributeName); - my $arg = GetCPPTypeGetter($argName, $idlType); - - my $attributeType = GetCPPType($attribute->signature->type, 1); - push(@implContent, "void $className\:\:$setterName($attributeType $argName)\n"); - push(@implContent, "{\n"); - push(@implContent, AddEarlyReturnStatement()); - - push(@implContent, " $exceptionInit\n") if $hasSetterException; - - my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@arguments, $arg); - push(@arguments, "ec") if $hasSetterException; - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "impl()"); - $functionName = "${implementedBy}::${functionName}"; - } else { - $functionName = "impl()->${functionName}"; - } - push(@implContent, " ${functionName}(" . join(", ", @arguments) . ");\n"); - push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException; - push(@implContent, "}\n\n"); - } - - push(@implContent, "#endif\n") if $attributeConditionalString; - } - } - - # - Functions - if ($numFunctions > 0) { - foreach my $function (@{$interface->functions}) { - # Treat CPPPureInterface as Custom as well, since the WebCore versions will take a script context as well - next if SkipFunction($function) || $interface->extendedAttributes->{"CPPPureInterface"}; - next if ($function->signature->name eq "set" and $interface->extendedAttributes->{"TypedArray"}); - AddIncludesForType($function->signature->type); - - my $functionName = $function->signature->name; - my $returnType = GetCPPType($function->signature->type, 0); - my $hasParameters = @{$function->parameters}; - my $raisesExceptions = @{$function->raisesExceptions}; - - my @parameterNames = (); - my @needsAssert = (); - my %needsCustom = (); - - my $parameterIndex = 0; - - my $functionSig = "$returnType $className\:\:$functionName("; - foreach my $param (@{$function->parameters}) { - my $paramName = $param->name; - my $paramType = GetCPPType($param->type, 1); - - # make a new parameter name if the original conflicts with a property name - $paramName = "in" . ucfirst($paramName) if $attributeNames{$paramName}; - - AddIncludesForType($param->type); - - my $idlType = $param->type; - my $implGetter = GetCPPTypeGetter($paramName, $idlType); - - push(@parameterNames, $implGetter); - $needsCustom{"NodeToReturn"} = $paramName if $param->extendedAttributes->{"CustomReturn"}; - - unless ($codeGenerator->IsPrimitiveType($idlType) or $codeGenerator->IsStringType($idlType)) { - push(@needsAssert, " ASSERT($paramName);\n"); - } - - $functionSig .= ", " if $parameterIndex >= 1; - $functionSig .= "$paramType $paramName"; - $parameterIndex++; - } - - $functionSig .= ")"; - - my @functionContent = (); - push(@parameterNames, "ec") if $raisesExceptions; - - my $content; - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@parameterNames, "impl()"); - $content = "WebCore::${implementedBy}::" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; - } else { - $content = "impl()->" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; - } - - if ($returnType eq "void") { - # Special case 'void' return type. - if ($raisesExceptions) { - push(@functionContent, " $exceptionInit\n"); - push(@functionContent, " $content;\n"); - push(@functionContent, " $exceptionRaiseOnError\n"); - } else { - push(@functionContent, " $content;\n"); - } - } elsif (defined $needsCustom{"NodeToReturn"}) { - # TODO: This is important to enable, once we care about custom code! - - # Special case the insertBefore, replaceChild, removeChild - # and appendChild functions from DOMNode - my $toReturn = $needsCustom{"NodeToReturn"}; - if ($raisesExceptions) { - push(@functionContent, " $exceptionInit\n"); - push(@functionContent, " if ($content)\n"); - push(@functionContent, " return $toReturn;\n"); - push(@functionContent, " $exceptionRaiseOnError\n"); - push(@functionContent, " return $className();\n"); - } else { - push(@functionContent, " if ($content)\n"); - push(@functionContent, " return $toReturn;\n"); - push(@functionContent, " return NULL;\n"); - } - } else { - if (ConversionNeeded($function->signature->type)) { - $content = "toWebKit(WTF::getPtr($content))"; - } - - if ($raisesExceptions) { - # Differentiated between when the return type is a pointer and - # not for white space issue (ie. Foo *result vs. int result). - if ($returnType =~ /\*$/) { - $content = $returnType . "result = " . $content; - } else { - $content = $returnType . " result = " . $content; - } - - push(@functionContent, " $exceptionInit\n"); - push(@functionContent, " $content;\n"); - push(@functionContent, " $exceptionRaiseOnError\n"); - push(@functionContent, " return result;\n"); - } else { - push(@functionContent, " return $content;\n"); - } - } - - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - - push(@implContent, "$functionSig\n"); - push(@implContent, "{\n"); - push(@implContent, AddEarlyReturnStatement($returnType)); - push(@implContent, @functionContent); - push(@implContent, "}\n\n"); - - push(@implContent, "#endif\n\n") if $conditionalString; - - # Clear the hash - %needsCustom = (); - } - } - - # END implementation - - # Generate internal interfaces - my $namespace = GetNamespaceForClass($implClassName); - push(@implContent, "$namespace" . "::$implClassName* toWebCore(const $className& wrapper)\n"); - push(@implContent, "{\n"); - push(@implContent, " return wrapper.impl();\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "$className toWebKit($namespace" . "::$implClassName* value)\n"); - push(@implContent, "{\n"); - push(@implContent, " return $className(value);\n"); - push(@implContent, "}\n"); - - # - End the ifdef conditional if necessary - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; -} - -sub WriteData -{ - my $object = shift; - my $dataNode = shift; - my $outputDir = shift; - - # Open files for writing... - my $name = $dataNode->name; - my $prefix = FileNamePrefix; - my $headerFileName = "$outputDir/$prefix$name.h"; - my $implFileName = "$outputDir/$prefix$name.cpp"; - - # Update a .h file if the contents are changed. - my $contents = join "", @headerContentHeader; - $contents .= "\n"; - foreach my $class (sort keys(%headerForwardDeclarations)) { - if ($class =~ /::/) { - my $namespacePart = $class; - $namespacePart =~ s/::.*//; - - my $classPart = $class; - $classPart =~ s/${namespacePart}:://; - - $contents .= "namespace $namespacePart {\nclass $classPart;\n};\n\n"; - } else { - $contents .= "class $class;\n" - } - } - - my $hasForwardDeclarations = keys(%headerForwardDeclarations); - $contents .= "\n" if $hasForwardDeclarations; - $contents .= join "", @headerContent; - $codeGenerator->UpdateFile($headerFileName, $contents); - - @headerContentHeader = (); - @headerContent = (); - %headerForwardDeclarations = (); - - # Update a .cpp file if the contents are changed. - $contents = join "", @implContentHeader; - - foreach my $include (sort keys(%implIncludes)) { - # "className.h" is already included right after config.h, silence check-webkit-style - next if $include eq "$name.h"; - $contents .= "#include \"$include\"\n"; - } - - $contents .= join "", @implContent; - $codeGenerator->UpdateFile($implFileName, $contents); - - @implContentHeader = (); - @implContent = (); - %implIncludes = (); -} - -1; diff --git a/contrib/dom/scripts/CodeGeneratorGObject.pm b/contrib/dom/scripts/CodeGeneratorGObject.pm deleted file mode 100644 index 3d84115..0000000 --- a/contrib/dom/scripts/CodeGeneratorGObject.pm +++ /dev/null @@ -1,1489 +0,0 @@ -# Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> -# Copyright (C) 2008 Martin Soto <soto@freedesktop.org> -# Copyright (C) 2008 Alp Toker <alp@atoker.com> -# Copyright (C) 2009 Adam Dingle <adam@yorba.org> -# Copyright (C) 2009 Jim Nelson <jim@yorba.org> -# Copyright (C) 2009, 2010 Igalia S.L. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -package CodeGeneratorGObject; - -use constant FileNamePrefix => "WebKitDOM"; - -# Global Variables -my %implIncludes = (); -my %hdrIncludes = (); - -my $defineTypeMacro = "G_DEFINE_TYPE"; -my $defineTypeInterfaceImplementation = ")"; -my @txtEventListeners = (); -my @txtInstallProps = (); -my @txtSetProps = (); -my @txtGetProps = (); - -my $className = ""; - -# Default constructor -sub new { - my $object = shift; - my $reference = { }; - - $codeGenerator = shift; - - bless($reference, $object); -} - -my $licenceTemplate = << "EOF"; -/* - This file is part of the WebKit open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -EOF - -sub GetParentClassName { - my $interface = shift; - - return "WebKitDOMObject" if @{$interface->parents} eq 0; - return "WebKitDOM" . $interface->parents(0); -} - -sub GetParentImplClassName { - my $interface = shift; - - return "Object" if @{$interface->parents} eq 0; - return $interface->parents(0); -} - -# From String::CamelCase 0.01 -sub camelize -{ - my $s = shift; - join('', map{ ucfirst $_ } split(/(?<=[A-Za-z])_(?=[A-Za-z])|\b/, $s)); -} - -sub decamelize -{ - my $s = shift; - $s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{ - my $fc = pos($s)==0; - my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4); - my $t = $p0 || $fc ? $p0 : '_'; - $t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2"; - $t; - }ge; - $s; -} - -sub FixUpDecamelizedName { - my $classname = shift; - - # FIXME: try to merge this somehow with the fixes in ClassNameToGobjectType - $classname =~ s/x_path/xpath/; - $classname =~ s/web_kit/webkit/; - $classname =~ s/htmli_frame/html_iframe/; - - return $classname; -} - -sub HumanReadableConditional { - my @conditional = split('_', shift); - my @upperCaseExceptions = ("SQL", "API"); - my @humanReadable; - - for $part (@conditional) { - if (!grep {$_ eq $part} @upperCaseExceptions) { - $part = camelize(lc($part)); - } - push(@humanReadable, $part); - } - - return join(' ', @humanReadable); -} - -sub ClassNameToGObjectType { - my $className = shift; - my $CLASS_NAME = uc(decamelize($className)); - # Fixup: with our prefix being 'WebKitDOM' decamelize can't get - # WebKitDOMCSS and similar names right, so we have to fix it - # manually. - $CLASS_NAME =~ s/DOMCSS/DOM_CSS/; - $CLASS_NAME =~ s/DOMHTML/DOM_HTML/; - $CLASS_NAME =~ s/DOMDOM/DOM_DOM/; - $CLASS_NAME =~ s/DOMCDATA/DOM_CDATA/; - $CLASS_NAME =~ s/DOMX_PATH/DOM_XPATH/; - $CLASS_NAME =~ s/DOM_WEB_KIT/DOM_WEBKIT/; - $CLASS_NAME =~ s/DOMUI/DOM_UI/; - $CLASS_NAME =~ s/HTMLI_FRAME/HTML_IFRAME/; - return $CLASS_NAME; -} - -sub GetParentGObjType { - my $interface = shift; - - return "WEBKIT_TYPE_DOM_OBJECT" if @{$interface->parents} eq 0; - return "WEBKIT_TYPE_DOM_" . ClassNameToGObjectType($interface->parents(0)); -} - -sub GetClassName { - my $name = shift; - - return "WebKitDOM$name"; -} - -sub GetCoreObject { - my ($interfaceName, $name, $parameter) = @_; - - return "WebCore::${interfaceName}* $name = WebKit::core($parameter);"; -} - -sub SkipAttribute { - my $attribute = shift; - - if ($attribute->signature->extendedAttributes->{"Custom"} - || $attribute->signature->extendedAttributes->{"CustomGetter"} - || $attribute->signature->extendedAttributes->{"CustomSetter"}) { - return 1; - } - - my $propType = $attribute->signature->type; - if ($propType =~ /Constructor$/) { - return 1; - } - - return 1 if $codeGenerator->IsTypedArrayType($propType); - - $codeGenerator->AssertNotSequenceType($propType); - - if ($codeGenerator->GetArrayType($propType)) { - return 1; - } - - # This is for DOMWindow.idl location attribute - if ($attribute->signature->name eq "location") { - return 1; - } - - # This is for HTMLInput.idl valueAsDate - if ($attribute->signature->name eq "valueAsDate") { - return 1; - } - - # This is for DOMWindow.idl Crypto attribute - if ($attribute->signature->type eq "Crypto") { - return 1; - } - - # Skip indexed database attributes for now, they aren't yet supported for the GObject generator. - if ($attribute->signature->name =~ /^(?:webkit)?[Ii]ndexedDB/ or $attribute->signature->name =~ /^(?:webkit)?IDB/) { - return 1; - } - - return 0; -} - -sub SkipFunction { - my $function = shift; - my $decamelize = shift; - my $prefix = shift; - - my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name); - my $functionReturnType = $prefix eq "set_" ? "void" : $function->signature->type; - my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"}; - my $callWith = $function->signature->extendedAttributes->{"CallWith"}; - my $isUnsupportedCallWith = $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments") || $codeGenerator->ExtendedAttributeContains($callWith, "CallStack"); - - if (($isCustomFunction || $isUnsupportedCallWith) && - $functionName ne "webkit_dom_node_replace_child" && - $functionName ne "webkit_dom_node_insert_before" && - $functionName ne "webkit_dom_node_remove_child" && - $functionName ne "webkit_dom_node_append_child" && - $functionName ne "webkit_dom_html_collection_item" && - $functionName ne "webkit_dom_html_collection_named_item") { - return 1; - } - - if ($function->signature->name eq "getSVGDocument") { - return 1; - } - - if ($function->signature->name eq "getCSSCanvasContext") { - return 1; - } - - if ($function->signature->name eq "setRangeText" && @{$function->parameters} == 1) { - return 1; - } - - if ($function->signature->name eq "timeEnd") { - return 1; - } - - if ($codeGenerator->GetSequenceType($functionReturnType)) { - return 1; - } - - # Skip functions that have ["Callback"] parameters, because this - # code generator doesn't know how to auto-generate callbacks. - # Skip functions that have "MediaQueryListListener" or sequence<T> parameters, because this - # code generator doesn't know how to auto-generate MediaQueryListListener or sequence<T>. - foreach my $param (@{$function->parameters}) { - if ($param->extendedAttributes->{"Callback"} || - $param->extendedAttributes->{"Clamp"} || - $param->type eq "MediaQueryListListener" || - $codeGenerator->GetSequenceType($param->type)) { - return 1; - } - } - - return 0; -} - -# Name type used in the g_value_{set,get}_* functions -sub GetGValueTypeName { - my $type = shift; - - my %types = ("DOMString", "string", - "DOMTimeStamp", "uint", - "float", "float", - "double", "double", - "boolean", "boolean", - "char", "char", - "long", "long", - "long long", "int64", - "short", "int", - "uchar", "uchar", - "unsigned", "uint", - "int", "int", - "unsigned int", "uint", - "unsigned long long", "uint64", - "unsigned long", "ulong", - "unsigned short", "uint"); - - return $types{$type} ? $types{$type} : "object"; -} - -# Name type used in C declarations -sub GetGlibTypeName { - my $type = shift; - my $name = GetClassName($type); - - my %types = ("DOMString", "gchar*", - "DOMTimeStamp", "guint32", - "CompareHow", "gushort", - "float", "gfloat", - "double", "gdouble", - "boolean", "gboolean", - "char", "gchar", - "long", "glong", - "long long", "gint64", - "short", "gshort", - "uchar", "guchar", - "unsigned", "guint", - "int", "gint", - "unsigned int", "guint", - "unsigned long", "gulong", - "unsigned long long", "guint64", - "unsigned short", "gushort", - "void", "void"); - - return $types{$type} ? $types{$type} : "$name*"; -} - -sub IsGDOMClassType { - my $type = shift; - - return 0 if $codeGenerator->IsNonPointerType($type) || $codeGenerator->IsStringType($type); - return 1; -} - -sub GetReadableProperties { - my $properties = shift; - - my @result = (); - - foreach my $property (@{$properties}) { - if (!SkipAttribute($property)) { - push(@result, $property); - } - } - - return @result; -} - -sub GetWriteableProperties { - my $properties = shift; - my @result = (); - - foreach my $property (@{$properties}) { - my $writeable = $property->type !~ /^readonly/; - my $gtype = GetGValueTypeName($property->signature->type); - my $hasGtypeSignature = ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" || - $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" || - $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" || - $gtype eq "char" || $gtype eq "string"); - # FIXME: We are not generating setters for 'Replaceable' - # attributes now, but we should somehow. - my $replaceable = $property->signature->extendedAttributes->{"Replaceable"}; - if ($writeable && $hasGtypeSignature && !$replaceable) { - push(@result, $property); - } - } - - return @result; -} - -sub GenerateConditionalWarning -{ - my $node = shift; - my $indentSize = shift; - if (!$indentSize) { - $indentSize = 4; - } - - my $conditional = $node->extendedAttributes->{"Conditional"}; - my @warn; - - if ($conditional) { - if ($conditional =~ /&/) { - my @splitConditionals = split(/&/, $conditional); - foreach $condition (@splitConditionals) { - push(@warn, "#if !ENABLE($condition)\n"); - push(@warn, ' ' x $indentSize . "WEBKIT_WARN_FEATURE_NOT_PRESENT(\"" . HumanReadableConditional($condition) . "\")\n"); - push(@warn, "#endif\n"); - } - } elsif ($conditional =~ /\|/) { - foreach $condition (split(/\|/, $conditional)) { - push(@warn, ' ' x $indentSize . "WEBKIT_WARN_FEATURE_NOT_PRESENT(\"" . HumanReadableConditional($condition) . "\")\n"); - } - } else { - push(@warn, ' ' x $indentSize . "WEBKIT_WARN_FEATURE_NOT_PRESENT(\"" . HumanReadableConditional($conditional) . "\")\n"); - } - } - - return @warn; -} - -sub GenerateProperty { - my $attribute = shift; - my $interfaceName = shift; - my @writeableProperties = @{shift @_}; - my $parentNode = shift; - - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - my @conditionalWarn = GenerateConditionalWarning($attribute->signature, 8); - my $parentConditionalString = $codeGenerator->GenerateConditionalString($parentNode); - my @parentConditionalWarn = GenerateConditionalWarning($parentNode, 8); - my $camelPropName = $attribute->signature->name; - my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); - my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); - - my $propName = decamelize($camelPropName); - my $propNameCaps = uc($propName); - $propName =~ s/_/-/g; - my ${propEnum} = "PROP_${propNameCaps}"; - push(@cBodyProperties, " ${propEnum},\n"); - - my $propType = $attribute->signature->type; - my ${propGType} = decamelize($propType); - my ${ucPropGType} = uc($propGType); - - my $gtype = GetGValueTypeName($propType); - my $gparamflag = "WEBKIT_PARAM_READABLE"; - my $writeable = $attribute->type !~ /^readonly/; - my $const = "read-only "; - my $custom = $attribute->signature->extendedAttributes->{"Custom"}; - if ($writeable && $custom) { - $const = "read-only (due to custom functions needed in webkitdom)"; - return; - } - if ($writeable && !$custom) { - $gparamflag = "WEBKIT_PARAM_READWRITE"; - $const = "read-write "; - } - - my $type = GetGlibTypeName($propType); - $nick = decamelize("${interfaceName}_${propName}"); - $long = "${const} ${type} ${interfaceName}.${propName}"; - - my $convertFunction = ""; - if ($gtype eq "string") { - $convertFunction = "WTF::String::fromUTF8"; - } - - my ($getterFunctionName, @getterArguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute); - my ($setterFunctionName, @setterArguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute); - - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - push(@setterArguments, "${convertFunction}(g_value_get_$gtype(value))"); - unshift(@getterArguments, "coreSelf"); - unshift(@setterArguments, "coreSelf"); - $getterFunctionName = "WebCore::${implementedBy}::$getterFunctionName"; - $setterFunctionName = "WebCore::${implementedBy}::$setterFunctionName"; - } else { - push(@setterArguments, "${convertFunction}(g_value_get_$gtype(value))"); - $getterFunctionName = "coreSelf->$getterFunctionName"; - $setterFunctionName = "coreSelf->$setterFunctionName"; - } - push(@getterArguments, "ec") if @{$attribute->getterExceptions}; - push(@setterArguments, "ec") if @{$attribute->setterExceptions}; - - if (grep {$_ eq $attribute} @writeableProperties) { - push(@txtSetProps, " case ${propEnum}: {\n"); - push(@txtSetProps, "#if ${parentConditionalString}\n") if $parentConditionalString; - push(@txtSetProps, "#if ${conditionalString}\n") if $conditionalString; - push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; - push(@txtSetProps, " ${setterFunctionName}(" . join(", ", @setterArguments) . ");\n"); - push(@txtSetProps, "#else\n") if $conditionalString; - push(@txtSetProps, @conditionalWarn) if scalar(@conditionalWarn); - push(@txtSetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; - push(@txtSetProps, "#else\n") if $parentConditionalString; - push(@txtSetProps, @parentConditionalWarn) if scalar(@parentConditionalWarn); - push(@txtSetProps, "#endif /* ${parentConditionalString} */\n") if $parentConditionalString; - push(@txtSetProps, " break;\n }\n"); - } - - push(@txtGetProps, " case ${propEnum}: {\n"); - push(@txtGetProps, "#if ${parentConditionalString}\n") if $parentConditionalString; - push(@txtGetProps, "#if ${conditionalString}\n") if $conditionalString; - push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->getterExceptions}; - - my $postConvertFunction = ""; - my $done = 0; - if ($gtype eq "string") { - push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(${getterFunctionName}(" . join(", ", @getterArguments) . ")));\n"); - $done = 1; - } elsif ($gtype eq "object") { - push(@txtGetProps, " RefPtr<WebCore::${propType}> ptr = ${getterFunctionName}(" . join(", ", @getterArguments) . ");\n"); - push(@txtGetProps, " g_value_set_object(value, WebKit::kit(ptr.get()));\n"); - $done = 1; - } - - # FIXME: get rid of this glitch? - my $_gtype = $gtype; - if ($gtype eq "ushort") { - $_gtype = "uint"; - } - - if (!$done) { - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}${getterFunctionName}(" . join(", ", @getterArguments) . ")${postConvertFunction});\n"); - } else { - push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}${getterFunctionName}(" . join(", ", @getterArguments) . ")${postConvertFunction});\n"); - } - } - - push(@txtGetProps, "#else\n") if $conditionalString; - push(@txtGetProps, @conditionalWarn) if scalar(@conditionalWarn); - push(@txtGetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; - push(@txtGetProps, "#else\n") if $parentConditionalString; - push(@txtGetProps, @parentConditionalWarn) if scalar(@parentConditionalWarn); - push(@txtGetProps, "#endif /* ${parentConditionalString} */\n") if $parentConditionalString; - push(@txtGetProps, " break;\n }\n"); - - my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", - "boolean", "FALSE, /* default */", - "float", "-G_MAXFLOAT, /* min */\nG_MAXFLOAT, /* max */\n0.0, /* default */", - "double", "-G_MAXDOUBLE, /* min */\nG_MAXDOUBLE, /* max */\n0.0, /* default */", - "uint64", "0, /* min */\nG_MAXUINT64, /* min */\n0, /* default */", - "long", "G_MINLONG, /* min */\nG_MAXLONG, /* max */\n0, /* default */", - "int64", "G_MININT64, /* min */\nG_MAXINT64, /* max */\n0, /* default */", - "ulong", "0, /* min */\nG_MAXULONG, /* max */\n0, /* default */", - "uint", "0, /* min */\nG_MAXUINT, /* max */\n0, /* default */", - "ushort", "0, /* min */\nG_MAXUINT16, /* max */\n0, /* default */", - "uchar", "G_MININT8, /* min */\nG_MAXINT8, /* max */\n0, /* default */", - "char", "0, /* min */\nG_MAXUINT8, /* max */\n0, /* default */", - "string", "\"\", /* default */", - "object", "WEBKIT_TYPE_DOM_${ucPropGType}, /* gobject type */"); - - my $txtInstallProp = << "EOF"; - g_object_class_install_property(gobjectClass, - ${propEnum}, - g_param_spec_${_gtype}("${propName}", /* name */ - "$nick", /* short description */ - "$long", /* longer - could do with some extra doc stuff here */ - $param_spec_options{$gtype} - ${gparamflag})); -EOF - push(@txtInstallProps, $txtInstallProp); -} - -sub GenerateProperties { - my ($object, $interfaceName, $interface) = @_; - - my $clsCaps = substr(ClassNameToGObjectType($className), 12); - my $lowerCaseIfaceName = "webkit_dom_" . (FixUpDecamelizedName(decamelize($interfaceName))); - my $parentImplClassName = GetParentImplClassName($interface); - - my $conditionGuardStart = ""; - my $conditionGuardEnd = ""; - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - if ($conditionalString) { - $conditionGuardStart = "#if ${conditionalString}"; - $conditionGuardEnd = "#endif // ${conditionalString}"; - } - - # Properties - my $implContent = ""; - my @readableProperties = GetReadableProperties($interface->attributes); - my @writeableProperties = GetWriteableProperties(\@readableProperties); - my $numProperties = scalar @readableProperties; - - # Properties - my $privFunction = GetCoreObject($interfaceName, "coreSelf", "self"); - if ($numProperties > 0) { - $implContent = << "EOF"; -enum { - PROP_0, -EOF - push(@cBodyProperties, $implContent); - - my $txtGetProp = << "EOF"; -static void ${lowerCaseIfaceName}_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) -{ - WebCore::JSMainThreadNullState state; -EOF - push(@txtGetProps, $txtGetProp); - $txtGetProp = << "EOF"; -$conditionGuardStart - ${className}* self = WEBKIT_DOM_${clsCaps}(object); - $privFunction -$conditionGuardEnd -EOF - push(@txtGetProps, $txtGetProp); - - $txtGetProp = << "EOF"; - switch (propertyId) { -EOF - push(@txtGetProps, $txtGetProp); - - if (scalar @writeableProperties > 0) { - my $txtSetProps = << "EOF"; -static void ${lowerCaseIfaceName}_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) -{ - WebCore::JSMainThreadNullState state; -EOF - push(@txtSetProps, $txtSetProps); - - $txtSetProps = << "EOF"; -$conditionGuardStart - ${className}* self = WEBKIT_DOM_${clsCaps}(object); - $privFunction -$conditionGuardEnd -EOF - push(@txtSetProps, $txtSetProps); - - $txtSetProps = << "EOF"; - switch (propertyId) { -EOF - push(@txtSetProps, $txtSetProps); - } - - foreach my $attribute (@readableProperties) { - if ($attribute->signature->type ne "EventListener" && - $attribute->signature->type ne "MediaQueryListListener") { - GenerateProperty($attribute, $interfaceName, \@writeableProperties, $interface); - } - } - - push(@cBodyProperties, "};\n\n"); - - $txtGetProp = << "EOF"; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); - break; - } -} -EOF - push(@txtGetProps, $txtGetProp); - - if (scalar @writeableProperties > 0) { - $txtSetProps = << "EOF"; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); - break; - } -} -EOF - push(@txtSetProps, $txtSetProps); - } - } - - # Do not insert extra spaces when interpolating array variables - $" = ""; - - if ($parentImplClassName eq "Object") { - $implContent = << "EOF"; -static void ${lowerCaseIfaceName}_finalize(GObject* object) -{ - ${className}Private* priv = WEBKIT_DOM_${clsCaps}_GET_PRIVATE(object); -$conditionGuardStart - WebKit::DOMObjectCache::forget(priv->coreObject.get()); -$conditionGuardEnd - priv->~${className}Private(); - G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->finalize(object); -} - -EOF - push(@cBodyProperties, $implContent); - } - - if ($numProperties > 0) { - if (scalar @writeableProperties > 0) { - push(@cBodyProperties, @txtSetProps); - push(@cBodyProperties, "\n"); - } - push(@cBodyProperties, @txtGetProps); - push(@cBodyProperties, "\n"); - } - - # Add a constructor implementation only for direct subclasses of Object to make sure - # that the WebCore wrapped object is added only once to the DOM cache. The DOM garbage - # collector works because Node is a direct subclass of Object and the version of - # DOMObjectCache::put() that receives a Node (which is the one setting the frame) is - # always called for DOM objects derived from Node. - if ($parentImplClassName eq "Object") { - $implContent = << "EOF"; -static GObject* ${lowerCaseIfaceName}_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties) -{ - GObject* object = G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->constructor(type, constructPropertiesCount, constructProperties); -$conditionGuardStart - ${className}Private* priv = WEBKIT_DOM_${clsCaps}_GET_PRIVATE(object); - priv->coreObject = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(object)->coreObject); - WebKit::DOMObjectCache::put(priv->coreObject.get(), object); -$conditionGuardEnd - return object; -} - -EOF - push(@cBodyProperties, $implContent); - } - - $implContent = << "EOF"; -static void ${lowerCaseIfaceName}_class_init(${className}Class* requestClass) -{ -EOF - push(@cBodyProperties, $implContent); - - if ($parentImplClassName eq "Object" || $numProperties > 0) { - push(@cBodyProperties, " GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);\n"); - - if ($parentImplClassName eq "Object") { - push(@cBodyProperties, " g_type_class_add_private(gobjectClass, sizeof(${className}Private));\n"); - push(@cBodyProperties, " gobjectClass->constructor = ${lowerCaseIfaceName}_constructor;\n"); - push(@cBodyProperties, " gobjectClass->finalize = ${lowerCaseIfaceName}_finalize;\n"); - } - - if ($numProperties > 0) { - if (scalar @writeableProperties > 0) { - push(@cBodyProperties, " gobjectClass->set_property = ${lowerCaseIfaceName}_set_property;\n"); - } - push(@cBodyProperties, " gobjectClass->get_property = ${lowerCaseIfaceName}_get_property;\n"); - push(@cBodyProperties, "\n"); - push(@cBodyProperties, @txtInstallProps); - } - } - $implContent = << "EOF"; -} - -static void ${lowerCaseIfaceName}_init(${className}* request) -{ -EOF - push(@cBodyProperties, $implContent); - - if ($parentImplClassName eq "Object") { - $implContent = << "EOF"; - ${className}Private* priv = WEBKIT_DOM_${clsCaps}_GET_PRIVATE(request); - new (priv) ${className}Private(); -EOF - push(@cBodyProperties, $implContent); - } - $implContent = << "EOF"; -} - -EOF - push(@cBodyProperties, $implContent); -} - -sub GenerateHeader { - my ($object, $interfaceName, $parentClassName) = @_; - - my $implContent = ""; - - # Add the default header template - @hPrefix = split("\r", $licenceTemplate); - push(@hPrefix, "\n"); - - #Header guard - my $guard = $className . "_h"; - - @hPrefixGuard = << "EOF"; -#ifndef $guard -#define $guard - -EOF - - $implContent = << "EOF"; -G_BEGIN_DECLS - -EOF - - push(@hBodyPre, $implContent); - - my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); - my $clsCaps = uc($decamelize); - my $lowerCaseIfaceName = "webkit_dom_" . ($decamelize); - - $implContent = << "EOF"; -#define WEBKIT_TYPE_DOM_${clsCaps} (${lowerCaseIfaceName}_get_type()) -#define WEBKIT_DOM_${clsCaps}(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_${clsCaps}, ${className})) -#define WEBKIT_DOM_${clsCaps}_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_${clsCaps}, ${className}Class) -#define WEBKIT_DOM_IS_${clsCaps}(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_${clsCaps})) -#define WEBKIT_DOM_IS_${clsCaps}_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_${clsCaps})) -#define WEBKIT_DOM_${clsCaps}_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_${clsCaps}, ${className}Class)) - -struct _${className} { - ${parentClassName} parent_instance; -}; - -struct _${className}Class { - ${parentClassName}Class parent_class; -}; - -WEBKIT_API GType -${lowerCaseIfaceName}_get_type (void); - -EOF - - push(@hBody, $implContent); -} - -sub GetGReturnMacro { - my ($paramName, $paramIDLType, $returnType) = @_; - - my $condition; - if ($paramIDLType eq "GError") { - $condition = "!$paramName || !*$paramName"; - } elsif (IsGDOMClassType($paramIDLType)) { - my $paramTypeCaps = uc(FixUpDecamelizedName(decamelize($paramIDLType))); - $condition = "WEBKIT_DOM_IS_${paramTypeCaps}($paramName)"; - } else { - $condition = "$paramName"; - } - - my $macro; - if ($returnType ne "void") { - $defaultReturn = $returnType eq "gboolean" ? "FALSE" : 0; - $macro = " g_return_val_if_fail($condition, $defaultReturn);\n"; - } else { - $macro = " g_return_if_fail($condition);\n"; - } - - return $macro; -} - -sub GenerateFunction { - my ($object, $interfaceName, $function, $prefix, $parentNode) = @_; - - my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); - - if ($object eq "MediaQueryListListener") { - return; - } - - if (SkipFunction($function, $decamelize, $prefix)) { - return; - } - - return if ($function->signature->name eq "set" and $parentNode->extendedAttributes->{"TypedArray"}); - - my $functionSigType = $prefix eq "set_" ? "void" : $function->signature->type; - my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name); - my $returnType = GetGlibTypeName($functionSigType); - my $returnValueIsGDOMType = IsGDOMClassType($functionSigType); - - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - my $parentConditionalString = $codeGenerator->GenerateConditionalString($parentNode); - my @conditionalWarn = GenerateConditionalWarning($function->signature); - my @parentConditionalWarn = GenerateConditionalWarning($parentNode); - - my $functionSig = "${className}* self"; - - my @callImplParams; - - foreach my $param (@{$function->parameters}) { - my $paramIDLType = $param->type; - if ($paramIDLType eq "EventListener" || $paramIDLType eq "MediaQueryListListener") { - # EventListeners are handled elsewhere. - return; - } - - my $paramType = GetGlibTypeName($paramIDLType); - my $const = $paramType eq "gchar*" ? "const " : ""; - my $paramName = $param->name; - - $functionSig .= ", ${const}$paramType $paramName"; - - my $paramIsGDOMType = IsGDOMClassType($paramIDLType); - if ($paramIsGDOMType) { - if ($paramIDLType ne "DOMObject") { - $implIncludes{"WebKitDOM${paramIDLType}Private.h"} = 1; - } - } - if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) { - $paramName = "converted" . $codeGenerator->WK_ucfirst($paramName); - } - push(@callImplParams, $paramName); - } - - if ($returnType ne "void" && $returnValueIsGDOMType && $functionSigType ne "DOMObject") { - if ($functionSigType ne "EventTarget") { - $implIncludes{"WebKitDOM${functionSigType}Private.h"} = 1; - } else { - $implIncludes{"WebKitDOM${functionSigType}.h"} = 1; - } - } - - if (@{$function->raisesExceptions}) { - $functionSig .= ", GError** error"; - } - - # Insert introspection annotations - push(@hBody, "/**\n"); - push(@hBody, " * ${functionName}:\n"); - push(@hBody, " * \@self: A #${className}\n"); - - foreach my $param (@{$function->parameters}) { - my $paramType = GetGlibTypeName($param->type); - # $paramType can have a trailing * in some cases - $paramType =~ s/\*$//; - my $paramName = $param->name; - push(@hBody, " * \@${paramName}: A #${paramType}\n"); - } - if(@{$function->raisesExceptions}) { - push(@hBody, " * \@error: #GError\n"); - } - push(@hBody, " *\n"); - if (IsGDOMClassType($function->signature->type)) { - push(@hBody, " * Returns: (transfer none):\n"); - } else { - push(@hBody, " * Returns:\n"); - } - push(@hBody, " *\n"); - push(@hBody, "**/\n"); - - push(@hBody, "WEBKIT_API $returnType\n$functionName($functionSig);\n"); - push(@hBody, "\n"); - - push(@cBody, "$returnType\n$functionName($functionSig)\n{\n"); - push(@cBody, "#if ${parentConditionalString}\n") if $parentConditionalString; - push(@cBody, "#if ${conditionalString}\n") if $conditionalString; - - push(@cBody, " WebCore::JSMainThreadNullState state;\n"); - - # g_return macros to check parameters of public methods. - $gReturnMacro = GetGReturnMacro("self", $interfaceName, $returnType); - push(@cBody, $gReturnMacro); - - foreach my $param (@{$function->parameters}) { - my $paramName = $param->name; - my $paramIDLType = $param->type; - my $paramTypeIsPrimitive = $codeGenerator->IsPrimitiveType($paramIDLType); - my $paramIsGDOMType = IsGDOMClassType($paramIDLType); - if (!$paramTypeIsPrimitive) { - # FIXME: Temporary hack for generating a proper implementation - # of the webkit_dom_document_evaluate function (Bug-ID: 42115) - if (!(($functionName eq "webkit_dom_document_evaluate") && ($paramIDLType eq "XPathResult"))) { - $gReturnMacro = GetGReturnMacro($paramName, $paramIDLType, $returnType); - push(@cBody, $gReturnMacro); - } - } - } - - if (@{$function->raisesExceptions}) { - $gReturnMacro = GetGReturnMacro("error", "GError", $returnType); - push(@cBody, $gReturnMacro); - } - - # The WebKit::core implementations check for null already; no need to duplicate effort. - push(@cBody, " WebCore::${interfaceName}* item = WebKit::core(self);\n"); - - $returnParamName = ""; - foreach my $param (@{$function->parameters}) { - my $paramIDLType = $param->type; - my $paramName = $param->name; - - my $paramIsGDOMType = IsGDOMClassType($paramIDLType); - $convertedParamName = "converted" . $codeGenerator->WK_ucfirst($paramName); - if ($paramIDLType eq "DOMString") { - push(@cBody, " WTF::String ${convertedParamName} = WTF::String::fromUTF8($paramName);\n"); - } elsif ($paramIDLType eq "CompareHow") { - push(@cBody, " WebCore::Range::CompareHow ${convertedParamName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); - } elsif ($paramIsGDOMType) { - push(@cBody, " WebCore::${paramIDLType}* ${convertedParamName} = WebKit::core($paramName);\n"); - } - $returnParamName = $convertedParamName if $param->extendedAttributes->{"CustomReturn"}; - } - - my $assign = ""; - my $assignPre = ""; - my $assignPost = ""; - - # We need to special-case these Node methods because their C++ - # signature is different from what we'd expect given their IDL - # description; see Node.h. - my $functionHasCustomReturn = $functionName eq "webkit_dom_node_append_child" || - $functionName eq "webkit_dom_node_insert_before" || - $functionName eq "webkit_dom_node_replace_child" || - $functionName eq "webkit_dom_node_remove_child"; - - if ($returnType ne "void" && !$functionHasCustomReturn) { - if ($returnValueIsGDOMType) { - $assign = "RefPtr<WebCore::${functionSigType}> gobjectResult = "; - $assignPre = "WTF::getPtr("; - $assignPost = ")"; - } else { - $assign = "${returnType} result = "; - } - } - - if (@{$function->raisesExceptions}) { - push(@cBody, " WebCore::ExceptionCode ec = 0;\n") ; - push(@callImplParams, "ec"); - } - - my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementedAs"} || $function->signature->name; - - if ($functionHasCustomReturn) { - push(@cBody, " bool ok = item->${functionImplementationName}(" . join(", ", @callImplParams) . ");\n"); - my $customNodeAppendChild = << "EOF"; - if (ok) - return WebKit::kit($returnParamName); -EOF - push(@cBody, $customNodeAppendChild); - - if(@{$function->raisesExceptions}) { - my $exceptionHandling = << "EOF"; - - WebCore::ExceptionCodeDescription ecdesc(ec); - g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); -EOF - push(@cBody, $exceptionHandling); - } - push(@cBody, " return 0;\n"); - push(@cBody, "}\n\n"); - return; - } elsif ($functionSigType eq "DOMString") { - my $getterContentHead; - if ($prefix) { - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $function); - push(@arguments, @callImplParams); - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "item"); - $functionName = "WebCore::${implementedBy}::${functionName}"; - } else { - $functionName = "item->${functionName}"; - } - $getterContentHead = "${assign}convertToUTF8String(${functionName}(" . join(", ", @arguments) . "));\n"; - } else { - my @arguments = @callImplParams; - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "item"); - $getterContentHead = "${assign}convertToUTF8String(WebCore::${implementedBy}::${functionImplementationName}(" . join(", ", @arguments) . "));\n"; - } else { - $getterContentHead = "${assign}convertToUTF8String(item->${functionImplementationName}(" . join(", ", @arguments) . "));\n"; - } - } - push(@cBody, " ${getterContentHead}"); - } else { - my $contentHead; - if ($prefix eq "get_") { - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $function); - push(@arguments, @callImplParams); - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "item"); - $functionName = "WebCore::${implementedBy}::${functionName}"; - } else { - $functionName = "item->${functionName}"; - } - $contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n"; - } elsif ($prefix eq "set_") { - my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $function); - push(@arguments, @callImplParams); - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "item"); - $functionName = "WebCore::${implementedBy}::${functionName}"; - $contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n"; - } else { - $functionName = "item->${functionName}"; - $contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n"; - } - } else { - my @arguments = @callImplParams; - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "item"); - $contentHead = "${assign}${assignPre}WebCore::${implementedBy}::${functionImplementationName}(" . join(", ", @arguments) . "${assignPost});\n"; - } else { - $contentHead = "${assign}${assignPre}item->${functionImplementationName}(" . join(", ", @arguments) . "${assignPost});\n"; - } - } - push(@cBody, " ${contentHead}"); - - if(@{$function->raisesExceptions}) { - my $exceptionHandling = << "EOF"; - if (ec) { - WebCore::ExceptionCodeDescription ecdesc(ec); - g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); - } -EOF - push(@cBody, $exceptionHandling); - } - } - - if ($returnType ne "void" && !$functionHasCustomReturn) { - if ($functionSigType ne "DOMObject") { - if ($returnValueIsGDOMType) { - push(@cBody, " return WebKit::kit(gobjectResult.get());\n"); - } else { - push(@cBody, " return result;\n"); - } - } else { - push(@cBody, " return 0; // TODO: return canvas object\n"); - } - } - - if ($conditionalString) { - push(@cBody, "#else\n"); - push(@cBody, @conditionalWarn) if scalar(@conditionalWarn); - if ($returnType ne "void") { - if ($codeGenerator->IsNonPointerType($functionSigType)) { - push(@cBody, " return static_cast<${returnType}>(0);\n"); - } else { - push(@cBody, " return 0;\n"); - } - } - push(@cBody, "#endif /* ${conditionalString} */\n"); - } - - if ($parentConditionalString) { - push(@cBody, "#else\n"); - push(@cBody, @parentConditionalWarn) if scalar(@parentConditionalWarn); - if ($returnType ne "void") { - if ($codeGenerator->IsNonPointerType($functionSigType)) { - push(@cBody, " return static_cast<${returnType}>(0);\n"); - } else { - push(@cBody, " return 0;\n"); - } - } - push(@cBody, "#endif /* ${parentConditionalString} */\n"); - } - - push(@cBody, "}\n\n"); -} - -sub ClassHasFunction { - my ($class, $name) = @_; - - foreach my $function (@{$class->functions}) { - if ($function->signature->name eq $name) { - return 1; - } - } - - return 0; -} - -sub GenerateFunctions { - my ($object, $interfaceName, $interface) = @_; - - foreach my $function (@{$interface->functions}) { - $object->GenerateFunction($interfaceName, $function, "", $interface); - } - - TOP: - foreach my $attribute (@{$interface->attributes}) { - if (SkipAttribute($attribute) || - $attribute->signature->type eq "EventListener" || - $attribute->signature->type eq "MediaQueryListListener") { - next TOP; - } - - if ($attribute->signature->name eq "type" - # This will conflict with the get_type() function we define to return a GType - # according to GObject conventions. Skip this for now. - || $attribute->signature->name eq "URL" # TODO: handle this - ) { - next TOP; - } - - my $attrNameUpper = $codeGenerator->WK_ucfirst($attribute->signature->name); - my $getname = "get${attrNameUpper}"; - my $setname = "set${attrNameUpper}"; - if (ClassHasFunction($interface, $getname) || ClassHasFunction($interface, $setname)) { - # Very occasionally an IDL file defines getter/setter functions for one of its - # attributes; in this case we don't need to autogenerate the getter/setter. - next TOP; - } - - # Generate an attribute getter. For an attribute "foo", this is a function named - # "get_foo" which calls a DOM class method named foo(). - my $function = new domFunction(); - $function->signature($attribute->signature); - $function->raisesExceptions($attribute->getterExceptions); - $object->GenerateFunction($interfaceName, $function, "get_", $interface); - - # FIXME: We are not generating setters for 'Replaceable' - # attributes now, but we should somehow. - if ($attribute->type =~ /^readonly/ || - $attribute->signature->extendedAttributes->{"Replaceable"}) { - next TOP; - } - - # Generate an attribute setter. For an attribute, "foo", this is a function named - # "set_foo" which calls a DOM class method named setFoo(). - $function = new domFunction(); - - $function->signature(new domSignature()); - $function->signature->name($attribute->signature->name); - $function->signature->type($attribute->signature->type); - $function->signature->extendedAttributes($attribute->signature->extendedAttributes); - - my $param = new domSignature(); - $param->name("value"); - $param->type($attribute->signature->type); - my %attributes = (); - $param->extendedAttributes(\%attributes); - my $arrayRef = $function->parameters; - push(@$arrayRef, $param); - - $function->raisesExceptions($attribute->setterExceptions); - - $object->GenerateFunction($interfaceName, $function, "set_", $interface); - } -} - -sub GenerateCFile { - my ($object, $interfaceName, $parentClassName, $parentGObjType, $interface) = @_; - - if ($interface->extendedAttributes->{"EventTarget"}) { - $object->GenerateEventTargetIface($interface); - } - - my $implContent = ""; - - my $clsCaps = uc(FixUpDecamelizedName(decamelize($interfaceName))); - my $lowerCaseIfaceName = "webkit_dom_" . FixUpDecamelizedName(decamelize($interfaceName)); - my $parentImplClassName = GetParentImplClassName($interface); - - # Add a private struct only for direct subclasses of Object so that we can use RefPtr - # for the WebCore wrapped object and make sure we only increment the reference counter once. - if ($parentImplClassName eq "Object") { - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@cStructPriv, "#define WEBKIT_DOM_${clsCaps}_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_TYPE_DOM_${clsCaps}, ${className}Private)\n\n"); - push(@cStructPriv, "typedef struct _${className}Private {\n"); - push(@cStructPriv, "#if ${conditionalString}\n") if $conditionalString; - push(@cStructPriv, " RefPtr<WebCore::${interfaceName}> coreObject;\n"); - push(@cStructPriv, "#endif // ${conditionalString}\n") if $conditionalString; - push(@cStructPriv, "} ${className}Private;\n\n"); - } - - $implContent = << "EOF"; -${defineTypeMacro}(${className}, ${lowerCaseIfaceName}, ${parentGObjType}${defineTypeInterfaceImplementation} - -EOF - push(@cBodyProperties, $implContent); - - if (!UsesManualKitImplementation($interfaceName)) { - $implContent = << "EOF"; -${className}* kit(WebCore::$interfaceName* obj) -{ - if (!obj) - return 0; - - if (gpointer ret = DOMObjectCache::get(obj)) - return WEBKIT_DOM_${clsCaps}(ret); - - return wrap${interfaceName}(obj); -} - -EOF - push(@cBodyPriv, $implContent); - } - - $implContent = << "EOF"; -WebCore::${interfaceName}* core(${className}* request) -{ - return request ? static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0; -} - -${className}* wrap${interfaceName}(WebCore::${interfaceName}* coreObject) -{ - ASSERT(coreObject); - return WEBKIT_DOM_${clsCaps}(g_object_new(WEBKIT_TYPE_DOM_${clsCaps}, "core-object", coreObject, NULL)); -} - -EOF - push(@cBodyPriv, $implContent); - - $object->GenerateProperties($interfaceName, $interface); - $object->GenerateFunctions($interfaceName, $interface); -} - -sub GenerateEndHeader { - my ($object) = @_; - - #Header guard - my $guard = $className . "_h"; - - push(@hBody, "G_END_DECLS\n\n"); - push(@hPrefixGuardEnd, "#endif /* $guard */\n"); -} - -sub UsesManualKitImplementation { - my $type = shift; - - return 1 if $type eq "Node" or $type eq "Element" or $type eq "Event"; - return 0; -} - -sub GenerateEventTargetIface { - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); - - $implIncludes{"GObjectEventListener.h"} = 1; - $implIncludes{"WebKitDOMEventTarget.h"} = 1; - $implIncludes{"WebKitDOMEventPrivate.h"} = 1; - - my $impl = << "EOF"; -static void webkit_dom_${decamelize}_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error) -{ - WebCore::Event* coreEvent = WebKit::core(event); - WebCore::${interfaceName}* coreTarget = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(target)->coreObject); - - WebCore::ExceptionCode ec = 0; - coreTarget->dispatchEvent(coreEvent, ec); - if (ec) { - WebCore::ExceptionCodeDescription description(ec); - g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name); - } -} - -static gboolean webkit_dom_${decamelize}_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData) -{ - WebCore::${interfaceName}* coreTarget = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(target)->coreObject); - return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble, userData); -} - -static gboolean webkit_dom_${decamelize}_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble) -{ - WebCore::${interfaceName}* coreTarget = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(target)->coreObject); - return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble); -} - -static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface) -{ - iface->dispatch_event = webkit_dom_${decamelize}_dispatch_event; - iface->add_event_listener = webkit_dom_${decamelize}_add_event_listener; - iface->remove_event_listener = webkit_dom_${decamelize}_remove_event_listener; -} - -EOF - - push(@cBodyProperties, $impl); - - $defineTypeMacro = "G_DEFINE_TYPE_WITH_CODE"; - $defineTypeInterfaceImplementation = ", G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_DOM_EVENT_TARGET, webkit_dom_event_target_init))"; -} - -sub Generate { - my ($object, $interface) = @_; - - my $parentClassName = GetParentClassName($interface); - my $parentGObjType = GetParentGObjType($interface); - my $interfaceName = $interface->name; - - # Add the default impl header template - @cPrefix = split("\r", $licenceTemplate); - push(@cPrefix, "\n"); - - $implIncludes{"DOMObjectCache.h"} = 1; - $implIncludes{"WebKitDOMBinding.h"} = 1; - $implIncludes{"gobject/ConvertToUTF8String.h"} = 1; - $implIncludes{"${className}Private.h"} = 1; - $implIncludes{"JSMainThreadExecState.h"} = 1; - $implIncludes{"ExceptionCode.h"} = 1; - - $hdrIncludes{"webkitdom/${parentClassName}.h"} = 1; - - $object->GenerateHeader($interfaceName, $parentClassName); - $object->GenerateCFile($interfaceName, $parentClassName, $parentGObjType, $interface); - $object->GenerateEndHeader(); -} - -sub WriteData { - my $object = shift; - my $interface = shift; - my $outputDir = shift; - mkdir $outputDir; - - # Write a private header. - my $interfaceName = $interface->name; - my $filename = "$outputDir/" . $className . "Private.h"; - my $guard = "${className}Private_h"; - - # Add the guard if the 'Conditional' extended attribute exists - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - - open(PRIVHEADER, ">$filename") or die "Couldn't open file $filename for writing"; - - print PRIVHEADER split("\r", $licenceTemplate); - print PRIVHEADER "\n"; - - my $text = << "EOF"; -#ifndef $guard -#define $guard - -#include "${interfaceName}.h" -#include <webkitdom/${className}.h> -EOF - - print PRIVHEADER $text; - print PRIVHEADER "#if ${conditionalString}\n" if $conditionalString; - print PRIVHEADER map { "#include \"$_\"\n" } sort keys(%hdrPropIncludes); - print PRIVHEADER "\n"; - $text = << "EOF"; -namespace WebKit { -${className}* wrap${interfaceName}(WebCore::${interfaceName}*); -WebCore::${interfaceName}* core(${className}* request); -EOF - - print PRIVHEADER $text; - - if ($className ne "WebKitDOMNode") { - print PRIVHEADER "${className}* kit(WebCore::${interfaceName}* node);\n" - } - - $text = << "EOF"; -} // namespace WebKit - -EOF - - print PRIVHEADER $text; - print PRIVHEADER "#endif /* ${conditionalString} */\n\n" if $conditionalString; - print PRIVHEADER "#endif /* ${guard} */\n"; - - close(PRIVHEADER); - - my $basename = FileNamePrefix . $interfaceName; - $basename =~ s/_//g; - - # Write public header. - my $fullHeaderFilename = "$outputDir/" . $basename . ".h"; - my $installedHeaderFilename = "${basename}.h"; - open(HEADER, ">$fullHeaderFilename") or die "Couldn't open file $fullHeaderFilename"; - - print HEADER @hPrefix; - print HEADER @hPrefixGuard; - print HEADER "#include <glib-object.h>\n"; - print HEADER map { "#include <$_>\n" } sort keys(%hdrIncludes); - print HEADER "#include <webkitdom/webkitdomdefines.h>\n\n"; - print HEADER @hBodyPre; - print HEADER @hBody; - print HEADER @hPrefixGuardEnd; - - close(HEADER); - - # Write the implementation sources - my $implFileName = "$outputDir/" . $basename . ".cpp"; - open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName"; - - print IMPL @cPrefix; - print IMPL "#include \"config.h\"\n"; - print IMPL "#include \"$installedHeaderFilename\"\n\n"; - - # Remove the implementation header from the list of included files. - %includesCopy = %implIncludes; - print IMPL map { "#include \"$_\"\n" } sort keys(%includesCopy); - - print IMPL "#include <wtf/GetPtr.h>\n"; - print IMPL "#include <wtf/RefPtr.h>\n\n"; - print IMPL @cStructPriv; - print IMPL "#if ${conditionalString}\n\n" if $conditionalString; - - print IMPL "namespace WebKit {\n\n"; - print IMPL @cBodyPriv; - print IMPL "} // namespace WebKit\n\n"; - print IMPL "#endif // ${conditionalString}\n\n" if $conditionalString; - - print IMPL @cBodyProperties; - print IMPL @cBody; - - close(IMPL); - - %implIncludes = (); - %hdrIncludes = (); - @hPrefix = (); - @hBody = (); - - @cPrefix = (); - @cBody = (); - @cBodyPriv = (); - @cBodyProperties = (); - @cStructPriv = (); -} - -sub GenerateInterface { - my ($object, $interface, $defines) = @_; - - # Set up some global variables - $className = GetClassName($interface->name); - - $object->Generate($interface); -} - -1; diff --git a/contrib/dom/scripts/CodeGeneratorJS.pm b/contrib/dom/scripts/CodeGeneratorJS.pm deleted file mode 100644 index 6c92d71..0000000 --- a/contrib/dom/scripts/CodeGeneratorJS.pm +++ /dev/null @@ -1,4077 +0,0 @@ -# -# Copyright (C) 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> -# Copyright (C) 2006 Anders Carlsson <andersca@mac.com> -# Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> -# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> -# Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. -# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> -# Copyright (C) Research In Motion Limited 2010. All rights reserved. -# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) -# Copyright (C) 2011 Patrick Gansterer <paroga@webkit.org> -# Copyright (C) 2012 Ericsson AB. All rights reserved. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -package CodeGeneratorJS; - -use strict; - -use constant FileNamePrefix => "JS"; - -my $codeGenerator; - -my $writeDependencies = 0; - -my @headerContentHeader = (); -my @headerContent = (); -my %headerIncludes = (); -my %headerTrailingIncludes = (); - -my @implContentHeader = (); -my @implContent = (); -my %implIncludes = (); -my @depsContent = (); -my $numCachedAttributes = 0; -my $currentCachedAttribute = 0; - -# Default .h template -my $headerTemplate = << "EOF"; -/* - This file is part of the WebKit open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -EOF - -# Default constructor -sub new -{ - my $object = shift; - my $reference = { }; - - $codeGenerator = shift; - shift; # $useLayerOnTop - shift; # $preprocessor - $writeDependencies = shift; - - bless($reference, $object); - return $reference; -} - -sub leftShift($$) { - my ($value, $distance) = @_; - return (($value << $distance) & 0xFFFFFFFF); -} - -sub GenerateInterface -{ - my $object = shift; - my $interface = shift; - my $defines = shift; - - $codeGenerator->LinkOverloadedFunctions($interface); - - # Start actual generation - if ($interface->extendedAttributes->{"Callback"}) { - $object->GenerateCallbackHeader($interface); - $object->GenerateCallbackImplementation($interface); - } else { - $object->GenerateHeader($interface); - $object->GenerateImplementation($interface); - } -} - -sub GenerateAttributeEventListenerCall -{ - my $className = shift; - my $implSetterFunctionName = shift; - my $windowEventListener = shift; - - my $wrapperObject = $windowEventListener ? "globalObject" : "thisObject"; - my @GenerateEventListenerImpl = (); - - if ($className eq "JSSVGElementInstance") { - # SVGElementInstances have to create JSEventListeners with the wrapper equal to the correspondingElement - $wrapperObject = "asObject(correspondingElementWrapper)"; - - push(@GenerateEventListenerImpl, <<END); - JSValue correspondingElementWrapper = toJS(exec, castedThis->globalObject(), impl->correspondingElement()); - if (correspondingElementWrapper.isObject()) -END - - # Add leading whitespace to format the impl->set... line correctly - push(@GenerateEventListenerImpl, " "); - } - - push(@GenerateEventListenerImpl, " impl->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, $wrapperObject));\n"); - return @GenerateEventListenerImpl; -} - -sub GenerateEventListenerCall -{ - my $className = shift; - my $functionName = shift; - my $passRefPtrHandling = ($functionName eq "add") ? "" : ".get()"; - - $implIncludes{"JSEventListener.h"} = 1; - - my @GenerateEventListenerImpl = (); - my $wrapperObject = "castedThis"; - if ($className eq "JSSVGElementInstance") { - # SVGElementInstances have to create JSEventListeners with the wrapper equal to the correspondingElement - $wrapperObject = "asObject(correspondingElementWrapper)"; - - push(@GenerateEventListenerImpl, <<END); - JSValue correspondingElementWrapper = toJS(exec, castedThis->globalObject(), impl->correspondingElement()); - if (!correspondingElementWrapper.isObject()) - return JSValue::encode(jsUndefined()); -END - } - - push(@GenerateEventListenerImpl, <<END); - JSValue listener = exec->argument(1); - if (!listener.isObject()) - return JSValue::encode(jsUndefined()); - impl->${functionName}EventListener(exec->argument(0).toString(exec)->value(exec), JSEventListener::create(asObject(listener), $wrapperObject, false, currentWorld(exec))$passRefPtrHandling, exec->argument(2).toBoolean(exec)); - return JSValue::encode(jsUndefined()); -END - return @GenerateEventListenerImpl; -} - -sub GetParentClassName -{ - my $interface = shift; - - return $interface->extendedAttributes->{"JSLegacyParent"} if $interface->extendedAttributes->{"JSLegacyParent"}; - return "JSDOMWrapper" if (@{$interface->parents} eq 0); - return "JS" . $interface->parents(0); -} - -sub GetCallbackClassName -{ - my $className = shift; - - return "JS$className"; -} - -sub IndexGetterReturnsStrings -{ - my $type = shift; - - return 1 if $type eq "CSSStyleDeclaration" or $type eq "MediaList" or $type eq "DOMStringList" or $type eq "DOMString[]" or $type eq "DOMTokenList" or $type eq "DOMSettableTokenList"; - return 0; -} - -sub AddIncludesForTypeInImpl -{ - my $type = shift; - my $isCallback = @_ ? shift : 0; - - AddIncludesForType($type, $isCallback, \%implIncludes); - - # additional includes (things needed to compile the bindings but not the header) - if ($type eq "CanvasRenderingContext2D") { - $implIncludes{"CanvasGradient.h"} = 1; - $implIncludes{"CanvasPattern.h"} = 1; - $implIncludes{"CanvasStyle.h"} = 1; - } - - if ($type eq "CanvasGradient" or $type eq "XPathNSResolver" or $type eq "MessagePort") { - $implIncludes{"<wtf/text/WTFString.h>"} = 1; - } - - if ($type eq "Document") { - $implIncludes{"NodeFilter.h"} = 1; - } - - if ($type eq "MediaQueryListListener") { - $implIncludes{"MediaQueryListListener.h"} = 1; - } -} - -sub AddIncludesForTypeInHeader -{ - my $type = shift; - my $isCallback = @_ ? shift : 0; - - AddIncludesForType($type, $isCallback, \%headerIncludes); -} - -sub AddIncludesForType -{ - my $type = shift; - my $isCallback = shift; - my $includesRef = shift; - - # When we're finished with the one-file-per-class - # reorganization, we won't need these special cases. - if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->SkipIncludeHeader($type) - or $type eq "DOMString" or $type eq "DOMObject" or $type eq "any" or $type eq "Array" or $type eq "DOMTimeStamp") { - } elsif ($type =~ /SVGPathSeg/) { - my $joinedName = $type; - $joinedName =~ s/Abs|Rel//; - $includesRef->{"${joinedName}.h"} = 1; - } elsif ($type eq "XPathNSResolver") { - $includesRef->{"JSXPathNSResolver.h"} = 1; - $includesRef->{"JSCustomXPathNSResolver.h"} = 1; - } elsif ($type eq "DOMString[]") { - # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>. - $includesRef->{"JSDOMStringList.h"} = 1; - } elsif ($type eq "SerializedScriptValue") { - $includesRef->{"SerializedScriptValue.h"} = 1; - } elsif ($isCallback) { - $includesRef->{"JS${type}.h"} = 1; - } elsif ($codeGenerator->IsTypedArrayType($type)) { - $includesRef->{"<wtf/${type}.h>"} = 1; - } elsif ($codeGenerator->GetSequenceType($type)) { - } else { - # default, include the same named file - $includesRef->{"${type}.h"} = 1; - } -} - -# FIXME: This method will go away once all SVG animated properties are converted to the new scheme. -sub AddIncludesForSVGAnimatedType -{ - my $type = shift; - $type =~ s/SVGAnimated//; - - if ($type eq "Point" or $type eq "Rect") { - $implIncludes{"Float$type.h"} = 1; - } elsif ($type eq "String") { - $implIncludes{"<wtf/text/WTFString.h>"} = 1; - } -} - -sub AddToImplIncludes -{ - my $header = shift; - my $conditional = shift; - - if (not $conditional) { - $implIncludes{$header} = 1; - } elsif (not exists($implIncludes{$header})) { - $implIncludes{$header} = $conditional; - } else { - my $oldValue = $implIncludes{$header}; - if ($oldValue ne 1) { - my %newValue = (); - $newValue{$conditional} = 1; - foreach my $condition (split(/\|/, $oldValue)) { - $newValue{$condition} = 1; - } - $implIncludes{$header} = join("|", sort keys %newValue); - } - } -} - -sub IsScriptProfileType -{ - my $type = shift; - return 1 if ($type eq "ScriptProfileNode"); - return 0; -} - -sub IsReadonly -{ - my $attribute = shift; - return $attribute->type =~ /readonly/ && !$attribute->signature->extendedAttributes->{"Replaceable"}; -} - -sub AddTypedefForScriptProfileType -{ - my $type = shift; - (my $jscType = $type) =~ s/Script//; - - push(@headerContent, "typedef JSC::$jscType $type;\n\n"); -} - -sub AddClassForwardIfNeeded -{ - my $interfaceName = shift; - - # SVGAnimatedLength/Number/etc. are typedefs to SVGAnimatedTemplate, so don't use class forwards for them! - unless ($codeGenerator->IsSVGAnimatedType($interfaceName) or IsScriptProfileType($interfaceName) or $codeGenerator->IsTypedArrayType($interfaceName)) { - push(@headerContent, "class $interfaceName;\n\n"); - # ScriptProfile and ScriptProfileNode are typedefs to JSC::Profile and JSC::ProfileNode. - } elsif (IsScriptProfileType($interfaceName)) { - $headerIncludes{"<profiler/ProfileNode.h>"} = 1; - AddTypedefForScriptProfileType($interfaceName); - } -} - -sub HashValueForClassAndName -{ - my $class = shift; - my $name = shift; - - # SVG Filter enums live in WebCore namespace (platform/graphics/) - if ($class =~ /^SVGFE*/ or $class =~ /^SVGComponentTransferFunctionElement$/) { - return "WebCore::$name"; - } - - return "${class}::$name"; -} - -sub hashTableAccessor -{ - my $noStaticTables = shift; - my $className = shift; - if ($noStaticTables) { - return "get${className}Table(exec)"; - } else { - return "&${className}Table"; - } -} - -sub prototypeHashTableAccessor -{ - my $noStaticTables = shift; - my $className = shift; - if ($noStaticTables) { - return "get${className}PrototypeTable(exec)"; - } else { - return "&${className}PrototypeTable"; - } -} - -sub constructorHashTableAccessor -{ - my $noStaticTables = shift; - my $constructorClassName = shift; - if ($noStaticTables) { - return "get${constructorClassName}Table(exec)"; - } else { - return "&${constructorClassName}Table"; - } -} - -sub GetGenerateIsReachable -{ - my $interface = shift; - return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface->extendedAttributes->{"JSGenerateIsReachable"}; -} - -sub GetCustomIsReachable -{ - my $interface = shift; - return $interface->extendedAttributes->{"CustomIsReachable"} || $interface->extendedAttributes->{"JSCustomIsReachable"}; -} - -sub GenerateGetOwnPropertySlotBody -{ - my ($interface, $interfaceName, $className, $hasAttributes, $inlined) = @_; - - my $namespaceMaybe = ($inlined ? "JSC::" : ""); - - my @getOwnPropertySlotImpl = (); - - if ($interfaceName eq "NamedNodeMap" or $interfaceName =~ /^HTML\w*Collection$/) { - push(@getOwnPropertySlotImpl, " ${namespaceMaybe}JSValue proto = thisObject->prototype();\n"); - push(@getOwnPropertySlotImpl, " if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); - push(@getOwnPropertySlotImpl, " return false;\n\n"); - } - - my $manualLookupGetterGeneration = sub { - my $requiresManualLookup = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NamedGetter"}; - if ($requiresManualLookup) { - push(@getOwnPropertySlotImpl, " const ${namespaceMaybe}HashEntry* entry = ${className}Table.entry(exec, propertyName);\n"); - push(@getOwnPropertySlotImpl, " if (entry) {\n"); - push(@getOwnPropertySlotImpl, " slot.setCustom(thisObject, entry->propertyGetter());\n"); - push(@getOwnPropertySlotImpl, " return true;\n"); - push(@getOwnPropertySlotImpl, " }\n"); - } - }; - - if (!$interface->extendedAttributes->{"CustomNamedGetter"}) { - &$manualLookupGetterGeneration(); - } - - if ($interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@getOwnPropertySlotImpl, " unsigned index = propertyName.asIndex();\n"); - - # If the item function returns a string then we let the TreatReturnedNullStringAs handle the cases - # where the index is out of range. - if (IndexGetterReturnsStrings($interfaceName)) { - push(@getOwnPropertySlotImpl, " if (index != PropertyName::NotAnIndex) {\n"); - } else { - push(@getOwnPropertySlotImpl, " if (index != PropertyName::NotAnIndex && index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n"); - } - if ($interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@getOwnPropertySlotImpl, " slot.setValue(thisObject->getByIndex(exec, index));\n"); - } else { - push(@getOwnPropertySlotImpl, " slot.setCustomIndex(thisObject, index, indexGetter);\n"); - } - push(@getOwnPropertySlotImpl, " return true;\n"); - push(@getOwnPropertySlotImpl, " }\n"); - } - - if ($interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"}) { - push(@getOwnPropertySlotImpl, " if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n"); - push(@getOwnPropertySlotImpl, " slot.setCustom(thisObject, thisObject->nameGetter);\n"); - push(@getOwnPropertySlotImpl, " return true;\n"); - push(@getOwnPropertySlotImpl, " }\n"); - if ($inlined) { - $headerIncludes{"wtf/text/AtomicString.h"} = 1; - } else { - $implIncludes{"wtf/text/AtomicString.h"} = 1; - } - } - - if ($interface->extendedAttributes->{"CustomNamedGetter"}) { - &$manualLookupGetterGeneration(); - } - - if ($interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}) { - push(@getOwnPropertySlotImpl, " if (thisObject->getOwnPropertySlotDelegate(exec, propertyName, slot))\n"); - push(@getOwnPropertySlotImpl, " return true;\n"); - } - - if ($hasAttributes) { - if ($inlined) { - die "Cannot inline if NoStaticTables is set." if ($interface->extendedAttributes->{"JSNoStaticTables"}); - push(@getOwnPropertySlotImpl, " return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, s_info.staticPropHashTable, thisObject, propertyName, slot);\n"); - } else { - push(@getOwnPropertySlotImpl, " return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, " . hashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, slot);\n"); - } - } else { - push(@getOwnPropertySlotImpl, " return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);\n"); - } - - return @getOwnPropertySlotImpl; -} - -sub GenerateGetOwnPropertyDescriptorBody -{ - my ($interface, $interfaceName, $className, $hasAttributes, $inlined) = @_; - - my $namespaceMaybe = ($inlined ? "JSC::" : ""); - - my @getOwnPropertyDescriptorImpl = (); - if ($interface->extendedAttributes->{"CheckSecurity"}) { - if ($interfaceName eq "DOMWindow") { - $implIncludes{"BindingSecurity.h"} = 1; - push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, jsCast<$className*>(thisObject)->impl()))\n"); - } else { - push(@implContent, " if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))\n"); - } - push(@implContent, " return false;\n"); - } - - if ($interfaceName eq "NamedNodeMap" or $interfaceName =~ /^HTML\w*Collection$/) { - push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}JSValue proto = thisObject->prototype();\n"); - push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); - push(@getOwnPropertyDescriptorImpl, " return false;\n\n"); - } - - my $manualLookupGetterGeneration = sub { - my $requiresManualLookup = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NamedGetter"}; - if ($requiresManualLookup) { - push(@getOwnPropertyDescriptorImpl, " const ${namespaceMaybe}HashEntry* entry = ${className}Table.entry(exec, propertyName);\n"); - push(@getOwnPropertyDescriptorImpl, " if (entry) {\n"); - push(@getOwnPropertyDescriptorImpl, " PropertySlot slot;\n"); - push(@getOwnPropertyDescriptorImpl, " slot.setCustom(thisObject, entry->propertyGetter());\n"); - push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());\n"); - push(@getOwnPropertyDescriptorImpl, " return true;\n"); - push(@getOwnPropertyDescriptorImpl, " }\n"); - } - }; - - if (!$interface->extendedAttributes->{"CustomNamedGetter"}) { - &$manualLookupGetterGeneration(); - } - - if ($interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@getOwnPropertyDescriptorImpl, " unsigned index = propertyName.asIndex();\n"); - push(@getOwnPropertyDescriptorImpl, " if (index != PropertyName::NotAnIndex && index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n"); - if ($interface->extendedAttributes->{"NumericIndexedGetter"}) { - # Assume that if there's a setter, the index will be writable - if ($interface->extendedAttributes->{"CustomIndexedSetter"}) { - push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(thisObject->getByIndex(exec, index), ${namespaceMaybe}DontDelete);\n"); - } else { - push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(thisObject->getByIndex(exec, index), ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly);\n"); - } - } else { - push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}PropertySlot slot;\n"); - push(@getOwnPropertyDescriptorImpl, " slot.setCustomIndex(thisObject, index, indexGetter);\n"); - # Assume that if there's a setter, the index will be writable - if ($interface->extendedAttributes->{"CustomIndexedSetter"}) { - push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), ${namespaceMaybe}DontDelete);\n"); - } else { - push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly);\n"); - } - } - push(@getOwnPropertyDescriptorImpl, " return true;\n"); - push(@getOwnPropertyDescriptorImpl, " }\n"); - } - - if ($interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"}) { - push(@getOwnPropertyDescriptorImpl, " if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n"); - push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}PropertySlot slot;\n"); - push(@getOwnPropertyDescriptorImpl, " slot.setCustom(thisObject, nameGetter);\n"); - push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);\n"); - push(@getOwnPropertyDescriptorImpl, " return true;\n"); - push(@getOwnPropertyDescriptorImpl, " }\n"); - if ($inlined) { - $headerIncludes{"wtf/text/AtomicString.h"} = 1; - } else { - $implIncludes{"wtf/text/AtomicString.h"} = 1; - } - } - - if ($interface->extendedAttributes->{"CustomNamedGetter"}) { - &$manualLookupGetterGeneration(); - } - - if ($interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}) { - push(@getOwnPropertyDescriptorImpl, " if (thisObject->getOwnPropertyDescriptorDelegate(exec, propertyName, descriptor))\n"); - push(@getOwnPropertyDescriptorImpl, " return true;\n"); - } - - if ($hasAttributes) { - if ($inlined) { - die "Cannot inline if NoStaticTables is set." if ($interface->extendedAttributes->{"JSNoStaticTables"}); - push(@getOwnPropertyDescriptorImpl, " return ${namespaceMaybe}getStaticValueDescriptor<$className, Base>(exec, s_info.staticPropHashTable, thisObject, propertyName, descriptor);\n"); - } else { - push(@getOwnPropertyDescriptorImpl, " return ${namespaceMaybe}getStaticValueDescriptor<$className, Base>(exec, " . hashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); - } - } else { - push(@getOwnPropertyDescriptorImpl, " return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);\n"); - } - - return @getOwnPropertyDescriptorImpl; -} - -sub GenerateHeaderContentHeader -{ - my $interface = shift; - my $className = "JS" . $interface->name; - - my @headerContentHeader = split("\r", $headerTemplate); - - # - Add header protection - push(@headerContentHeader, "\n#ifndef $className" . "_h"); - push(@headerContentHeader, "\n#define $className" . "_h\n\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; - return @headerContentHeader; -} - -sub GenerateImplementationContentHeader -{ - my $interface = shift; - my $className = "JS" . $interface->name; - - my @implContentHeader = split("\r", $headerTemplate); - - push(@implContentHeader, "\n#include \"config.h\"\n"); - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; - push(@implContentHeader, "#include \"$className.h\"\n\n"); - return @implContentHeader; -} - -my %usesToJSNewlyCreated = ( - "CDATASection" => 1, - "Element" => 1, - "Node" => 1, - "Text" => 1, - "Touch" => 1, - "TouchList" => 1 -); - -sub ShouldGenerateToJSDeclaration -{ - my ($hasParent, $interface) = @_; - return 0 if ($interface->extendedAttributes->{"SuppressToJSObject"}); - return 1 if (!$hasParent or $interface->extendedAttributes->{"JSGenerateToJSObject"} or ($interface->extendedAttributes->{"CustomToJSObject"} or $interface->extendedAttributes->{"JSCustomToJSObject"})); - return 0; -} - -sub ShouldGenerateToJSImplementation -{ - my ($hasParent, $interface) = @_; - return 0 if ($interface->extendedAttributes->{"SuppressToJSObject"}); - return 1 if ((!$hasParent or $interface->extendedAttributes->{"JSGenerateToJSObject"}) and !($interface->extendedAttributes->{"CustomToJSObject"} or $interface->extendedAttributes->{"JSCustomToJSObject"})); - return 0; -} - -sub GetAttributeGetterName -{ - my ($interfaceName, $className, $attribute) = @_; - if ($attribute->isStatic) { - return $codeGenerator->WK_lcfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name); - } - return "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); -} - -sub GetAttributeSetterName -{ - my ($interfaceName, $className, $attribute) = @_; - if ($attribute->isStatic) { - return "set" . $codeGenerator->WK_ucfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name); - } - return "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); -} - -sub GetFunctionName -{ - my ($className, $function) = @_; - my $kind = $function->isStatic ? "Constructor" : "Prototype"; - return $codeGenerator->WK_lcfirst($className) . $kind . "Function" . $codeGenerator->WK_ucfirst($function->signature->name); -} - -sub GenerateHeader -{ - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $className = "JS$interfaceName"; - my @ancestorInterfaceNames = (); - my %structureFlags = (); - - # We only support multiple parents with SVG (for now). - if (@{$interface->parents} > 1) { - die "A class can't have more than one parent" unless $interfaceName =~ /SVG/; - $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames); - } - - my $hasLegacyParent = $interface->extendedAttributes->{"JSLegacyParent"}; - my $hasRealParent = @{$interface->parents} > 0; - my $hasParent = $hasLegacyParent || $hasRealParent; - my $parentClassName = GetParentClassName($interface); - my $needsMarkChildren = $interface->extendedAttributes->{"JSCustomMarkFunction"} || $interface->extendedAttributes->{"EventTarget"} || $interface->name eq "EventTarget"; - - # - Add default header template and header protection - push(@headerContentHeader, GenerateHeaderContentHeader($interface)); - - if ($hasParent) { - $headerIncludes{"$parentClassName.h"} = 1; - } else { - $headerIncludes{"JSDOMBinding.h"} = 1; - $headerIncludes{"<runtime/JSGlobalObject.h>"} = 1; - if ($interface->isException) { - $headerIncludes{"<runtime/ErrorPrototype.h>"} = 1; - } else { - $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1; - } - } - - if ($interface->extendedAttributes->{"CustomCall"}) { - $headerIncludes{"<runtime/CallData.h>"} = 1; - } - - if ($interface->extendedAttributes->{"JSInlineGetOwnPropertySlot"}) { - $headerIncludes{"<runtime/Lookup.h>"} = 1; - $headerIncludes{"<wtf/AlwaysInline.h>"} = 1; - } - - if ($hasParent && $interface->extendedAttributes->{"JSGenerateToNativeObject"}) { - if ($codeGenerator->IsTypedArrayType($interfaceName)) { - $headerIncludes{"<wtf/$interfaceName.h>"} = 1; - } else { - $headerIncludes{"$interfaceName.h"} = 1; - } - } - - $headerIncludes{"<runtime/JSObject.h>"} = 1; - $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/; - - my $implType = $interfaceName; - my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implType); - $implType = $svgNativeType if $svgNativeType; - - my $svgPropertyOrListPropertyType; - $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType; - $svgPropertyOrListPropertyType = $svgListPropertyType if $svgListPropertyType; - - my $numConstants = @{$interface->constants}; - my $numAttributes = @{$interface->attributes}; - my $numFunctions = @{$interface->functions}; - - push(@headerContent, "\nnamespace WebCore {\n\n"); - - if ($codeGenerator->IsSVGAnimatedType($interfaceName)) { - $headerIncludes{"$interfaceName.h"} = 1; - } else { - # Implementation class forward declaration - if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerContext"}) { - AddClassForwardIfNeeded($interfaceName) unless $svgPropertyOrListPropertyType; - } - } - - AddClassForwardIfNeeded("JSDOMWindowShell") if $interfaceName eq "DOMWindow"; - AddClassForwardIfNeeded("JSDictionary") if $codeGenerator->IsConstructorTemplate($interface, "Event"); - - # Class declaration - push(@headerContent, "class $className : public $parentClassName {\n"); - - # Static create methods - push(@headerContent, "public:\n"); - push(@headerContent, " typedef $parentClassName Base;\n"); - if ($interfaceName eq "DOMWindow") { - push(@headerContent, " static $className* create(JSC::JSGlobalData& globalData, JSC::Structure* structure, PassRefPtr<$implType> impl, JSDOMWindowShell* windowShell)\n"); - push(@headerContent, " {\n"); - push(@headerContent, " $className* ptr = new (NotNull, JSC::allocateCell<$className>(globalData.heap)) ${className}(globalData, structure, impl, windowShell);\n"); - push(@headerContent, " ptr->finishCreation(globalData, windowShell);\n"); - push(@headerContent, " globalData.heap.addFinalizer(ptr, destroy);\n"); - push(@headerContent, " return ptr;\n"); - push(@headerContent, " }\n\n"); - } elsif ($interface->extendedAttributes->{"IsWorkerContext"}) { - push(@headerContent, " static $className* create(JSC::JSGlobalData& globalData, JSC::Structure* structure, PassRefPtr<$implType> impl)\n"); - push(@headerContent, " {\n"); - push(@headerContent, " $className* ptr = new (NotNull, JSC::allocateCell<$className>(globalData.heap)) ${className}(globalData, structure, impl);\n"); - push(@headerContent, " ptr->finishCreation(globalData);\n"); - push(@headerContent, " globalData.heap.addFinalizer(ptr, destroy);\n"); - push(@headerContent, " return ptr;\n"); - push(@headerContent, " }\n\n"); - } elsif ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) { - AddIncludesForTypeInHeader($implType) unless $svgPropertyOrListPropertyType; - push(@headerContent, " static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<$implType> impl)\n"); - push(@headerContent, " {\n"); - push(@headerContent, " globalObject->masqueradesAsUndefinedWatchpoint()->notifyWrite();\n"); - push(@headerContent, " $className* ptr = new (NotNull, JSC::allocateCell<$className>(globalObject->globalData().heap)) $className(structure, globalObject, impl);\n"); - push(@headerContent, " ptr->finishCreation(globalObject->globalData());\n"); - push(@headerContent, " return ptr;\n"); - push(@headerContent, " }\n\n"); - } else { - AddIncludesForTypeInHeader($implType) unless $svgPropertyOrListPropertyType; - push(@headerContent, " static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<$implType> impl)\n"); - push(@headerContent, " {\n"); - push(@headerContent, " $className* ptr = new (NotNull, JSC::allocateCell<$className>(globalObject->globalData().heap)) $className(structure, globalObject, impl);\n"); - push(@headerContent, " ptr->finishCreation(globalObject->globalData());\n"); - push(@headerContent, " return ptr;\n"); - push(@headerContent, " }\n\n"); - } - - if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerContext"}) { - push(@headerContent, " static const bool needsDestruction = false;\n\n"); - } - - # Prototype - push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($interface->extendedAttributes->{"ExtendsDOMGlobalObject"}); - - $headerTrailingIncludes{"${className}Custom.h"} = 1 if $interface->extendedAttributes->{"JSCustomHeader"}; - - $implIncludes{"${className}Custom.h"} = 1 if !$interface->extendedAttributes->{"JSCustomHeader"} && ($interface->extendedAttributes->{"CustomPutFunction"} || $interface->extendedAttributes->{"CustomNamedSetter"}); - - my $hasImpureNamedGetter = - $interface->extendedAttributes->{"NamedGetter"} - || $interface->extendedAttributes->{"CustomNamedGetter"} - || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; - - my $hasComplexGetter = - $interface->extendedAttributes->{"IndexedGetter"} - || $interface->extendedAttributes->{"NumericIndexedGetter"} - || $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"} - || $hasImpureNamedGetter; - - my $hasGetter = $numAttributes > 0 || !$interface->extendedAttributes->{"OmitConstructor"} || $hasComplexGetter; - - if ($hasImpureNamedGetter) { - $structureFlags{"JSC::HasImpureGetOwnPropertySlot"} = 1; - } - - # Getters - if ($hasGetter) { - push(@headerContent, " static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);\n"); - push(@headerContent, " static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);\n"); - push(@headerContent, " static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);\n") if ($hasComplexGetter); - push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);\n") if $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}; - push(@headerContent, " bool getOwnPropertyDescriptorDelegate(JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);\n") if $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}; - $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1; - $structureFlags{"JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero"} = 1; - } - - # Check if we have any writable properties - my $hasReadWriteProperties = 0; - foreach (@{$interface->attributes}) { - if (!IsReadonly($_) && !$_->isStatic) { - $hasReadWriteProperties = 1; - } - } - - my $hasComplexSetter = - $interface->extendedAttributes->{"CustomPutFunction"} - || $interface->extendedAttributes->{"CustomNamedSetter"} - || $interface->extendedAttributes->{"CustomIndexedSetter"}; - - my $hasSetter = $hasReadWriteProperties || $hasComplexSetter; - - # Getters - if ($hasSetter) { - push(@headerContent, " static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);\n"); - push(@headerContent, " static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow);\n") if ($hasComplexSetter); - push(@headerContent, " bool putDelegate(JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);\n") if $interface->extendedAttributes->{"CustomNamedSetter"}; - } - - if (!$hasParent) { - push(@headerContent, " static void destroy(JSC::JSCell*);\n"); - push(@headerContent, " ~${className}();\n"); - } - - # Class info - if ($interfaceName eq "Node") { - push(@headerContent, " static WEBKIT_EXPORTDATA const JSC::ClassInfo s_info;\n\n"); - } else { - push(@headerContent, " static const JSC::ClassInfo s_info;\n\n"); - } - # Structure ID - if ($interfaceName eq "DOMWindow") { - $structureFlags{"JSC::ImplementsHasInstance"} = 1; - } - push(@headerContent, " static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n"); - push(@headerContent, " {\n"); - if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerContext"}) { - push(@headerContent, " return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);\n"); - } else { - push(@headerContent, " return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);\n"); - } - push(@headerContent, " }\n\n"); - - # Custom pushEventHandlerScope function - push(@headerContent, " JSC::JSScope* pushEventHandlerScope(JSC::ExecState*, JSC::JSScope*) const;\n\n") if $interface->extendedAttributes->{"JSCustomPushEventHandlerScope"}; - - # Custom call functions - push(@headerContent, " static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&);\n\n") if $interface->extendedAttributes->{"CustomCall"}; - - # Custom deleteProperty function - push(@headerContent, " static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);\n") if $interface->extendedAttributes->{"CustomDeleteProperty"}; - push(@headerContent, " static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, unsigned);\n") if $interface->extendedAttributes->{"CustomDeleteProperty"}; - - # Custom getPropertyNames function exists on DOMWindow - if ($interfaceName eq "DOMWindow") { - push(@headerContent, " static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n"); - $structureFlags{"JSC::OverridesGetPropertyNames"} = 1; - } - - # Custom getOwnPropertyNames function - if ($interface->extendedAttributes->{"CustomEnumerateProperty"} || $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@headerContent, " static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n"); - $structureFlags{"JSC::OverridesGetPropertyNames"} = 1; - } - - # Custom defineOwnProperty function - push(@headerContent, " static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interface->extendedAttributes->{"JSCustomDefineOwnProperty"}; - - # Override toBoolean to return false for objects that want to 'MasqueradesAsUndefined'. - if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) { - $structureFlags{"JSC::MasqueradesAsUndefined"} = 1; - } - - # Constructor object getter - push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if !$interface->extendedAttributes->{"OmitConstructor"}; - - my $numCustomFunctions = 0; - my $numCustomAttributes = 0; - - # Attribute and function enums - if ($numAttributes > 0) { - foreach (@{$interface->attributes}) { - my $attribute = $_; - $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"}; - $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}); - $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}); - if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - push(@headerContent, " JSC::WriteBarrier<JSC::Unknown> m_" . $attribute->signature->name . ";\n"); - $numCachedAttributes++; - $needsMarkChildren = 1; - push(@headerContent, "#endif\n") if $conditionalString; - } - } - } - - # visit function - if ($needsMarkChildren) { - push(@headerContent, " static void visitChildren(JSCell*, JSC::SlotVisitor&);\n\n"); - $structureFlags{"JSC::OverridesVisitChildren"} = 1; - } - - if ($numCustomAttributes > 0) { - push(@headerContent, "\n // Custom attributes\n"); - - foreach my $attribute (@{$interface->attributes}) { - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) { - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - my $methodName = $codeGenerator->WK_lcfirst($attribute->signature->name); - push(@headerContent, " JSC::JSValue " . $methodName . "(JSC::ExecState*) const;\n"); - push(@headerContent, "#endif\n") if $conditionalString; - } - if (($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}) && !IsReadonly($attribute)) { - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n"); - push(@headerContent, "#endif\n") if $conditionalString; - } - } - } - - foreach my $function (@{$interface->functions}) { - $numCustomFunctions++ if $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCustom"}; - } - - if ($numCustomFunctions > 0) { - push(@headerContent, "\n // Custom functions\n"); - foreach my $function (@{$interface->functions}) { - next unless $function->signature->extendedAttributes->{"Custom"} or $function->signature->extendedAttributes->{"JSCustom"}; - next if $function->{overloads} && $function->{overloadIndex} != 1; - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementedAs"} || $codeGenerator->WK_lcfirst($function->signature->name); - push(@headerContent, " " . ($function->isStatic ? "static " : "") . "JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n"); - push(@headerContent, "#endif\n") if $conditionalString; - } - } - - if (!$hasParent) { - push(@headerContent, " $implType* impl() const { return m_impl; }\n"); - push(@headerContent, " void releaseImpl() { m_impl->deref(); m_impl = 0; }\n\n"); - push(@headerContent, " void releaseImplIfNotNull() { if (m_impl) { m_impl->deref(); m_impl = 0; } }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " $implType* m_impl;\n"); - } elsif ($interface->extendedAttributes->{"JSGenerateToNativeObject"}) { - push(@headerContent, " $interfaceName* impl() const\n"); - push(@headerContent, " {\n"); - push(@headerContent, " return static_cast<$interfaceName*>(Base::impl());\n"); - push(@headerContent, " }\n"); - } - - if ($codeGenerator->IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) { - push(@headerContent, " static const JSC::TypedArrayType TypedArrayStorageType = JSC::"); - push(@headerContent, "TypedArrayInt8") if $implType eq "Int8Array"; - push(@headerContent, "TypedArrayInt16") if $implType eq "Int16Array"; - push(@headerContent, "TypedArrayInt32") if $implType eq "Int32Array"; - push(@headerContent, "TypedArrayUint8") if $implType eq "Uint8Array"; - push(@headerContent, "TypedArrayUint8Clamped") if $implType eq "Uint8ClampedArray"; - push(@headerContent, "TypedArrayUint16") if $implType eq "Uint16Array"; - push(@headerContent, "TypedArrayUint32") if $implType eq "Uint32Array"; - push(@headerContent, "TypedArrayFloat32") if $implType eq "Float32Array"; - push(@headerContent, "TypedArrayFloat64") if $implType eq "Float64Array"; - push(@headerContent, ";\n"); - push(@headerContent, " intptr_t m_storageLength;\n"); - push(@headerContent, " void* m_storage;\n"); - } - - push(@headerContent, "protected:\n"); - # Constructor - if ($interfaceName eq "DOMWindow") { - push(@headerContent, " $className(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<$implType>, JSDOMWindowShell*);\n"); - } elsif ($interface->extendedAttributes->{"IsWorkerContext"}) { - push(@headerContent, " $className(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<$implType>);\n"); - } else { - push(@headerContent, " $className(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<$implType>);\n"); - push(@headerContent, " void finishCreation(JSC::JSGlobalData&);\n"); - } - - # structure flags - push(@headerContent, " static const unsigned StructureFlags = "); - foreach my $structureFlag (keys %structureFlags) { - push(@headerContent, $structureFlag . " | "); - } - push(@headerContent, "Base::StructureFlags;\n"); - - # Index getter - if ($interface->extendedAttributes->{"IndexedGetter"}) { - push(@headerContent, " static JSC::JSValue indexGetter(JSC::ExecState*, JSC::JSValue, unsigned);\n"); - } - if ($interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@headerContent, " JSC::JSValue getByIndex(JSC::ExecState*, unsigned index);\n"); - } - - # Index setter - if ($interface->extendedAttributes->{"CustomIndexedSetter"}) { - push(@headerContent, " void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue);\n"); - } - # Name getter - if ($interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"}) { - push(@headerContent, "private:\n"); - push(@headerContent, " static bool canGetItemsForName(JSC::ExecState*, $interfaceName*, JSC::PropertyName);\n"); - push(@headerContent, " static JSC::JSValue nameGetter(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);\n"); - } - - push(@headerContent, "};\n\n"); - - if ($interface->extendedAttributes->{"JSInlineGetOwnPropertySlot"} && !$interface->extendedAttributes->{"CustomGetOwnPropertySlot"}) { - push(@headerContent, "ALWAYS_INLINE bool ${className}::getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertySlot& slot)\n"); - push(@headerContent, "{\n"); - push(@headerContent, " ${className}* thisObject = JSC::jsCast<${className}*>(cell);\n"); - push(@headerContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - push(@headerContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numAttributes > 0, 1)); - push(@headerContent, "}\n\n"); - push(@headerContent, "ALWAYS_INLINE bool ${className}::getOwnPropertyDescriptor(JSC::JSObject* object, JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertyDescriptor& descriptor)\n"); - push(@headerContent, "{\n"); - push(@headerContent, " ${className}* thisObject = JSC::jsCast<${className}*>(object);\n"); - push(@headerContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - push(@headerContent, GenerateGetOwnPropertyDescriptorBody($interface, $interfaceName, $className, $numAttributes > 0, 1)); - push(@headerContent, "}\n\n"); - } - - if (!$hasParent || - GetGenerateIsReachable($interface) || - GetCustomIsReachable($interface) || - $interface->extendedAttributes->{"JSCustomFinalize"} || - $interface->extendedAttributes->{"ActiveDOMObject"}) { - if ($interfaceName ne "Node" && $codeGenerator->IsSubType($interface, "Node")) { - $headerIncludes{"JSNode.h"} = 1; - push(@headerContent, "class JS${interfaceName}Owner : public JSNodeOwner {\n"); - } else { - push(@headerContent, "class JS${interfaceName}Owner : public JSC::WeakHandleOwner {\n"); - } - push(@headerContent, "public:\n"); - push(@headerContent, " virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);\n"); - push(@headerContent, " virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);\n"); - push(@headerContent, "};\n"); - push(@headerContent, "\n"); - push(@headerContent, "inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, $implType*)\n"); - push(@headerContent, "{\n"); - push(@headerContent, " DEFINE_STATIC_LOCAL(JS${interfaceName}Owner, js${interfaceName}Owner, ());\n"); - push(@headerContent, " return &js${interfaceName}Owner;\n"); - push(@headerContent, "}\n"); - push(@headerContent, "\n"); - push(@headerContent, "inline void* wrapperContext(DOMWrapperWorld* world, $implType*)\n"); - push(@headerContent, "{\n"); - push(@headerContent, " return world;\n"); - push(@headerContent, "}\n"); - push(@headerContent, "\n"); - } - if (ShouldGenerateToJSDeclaration($hasParent, $interface)) { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*);\n"); - } - if (!$hasParent || $interface->extendedAttributes->{"JSGenerateToNativeObject"}) { - if ($interfaceName eq "NodeFilter") { - push(@headerContent, "PassRefPtr<NodeFilter> toNodeFilter(JSC::JSGlobalData&, JSC::JSValue);\n"); - } elsif ($interfaceName eq "DOMStringList") { - push(@headerContent, "PassRefPtr<DOMStringList> toDOMStringList(JSC::ExecState*, JSC::JSValue);\n"); - } else { - push(@headerContent, "$implType* to${interfaceName}(JSC::JSValue);\n"); - } - } - if ($usesToJSNewlyCreated{$interfaceName}) { - push(@headerContent, "JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, $interfaceName*);\n"); - } - - push(@headerContent, "\n"); - - # Add prototype declaration. - %structureFlags = (); - push(@headerContent, "class ${className}Prototype : public JSC::JSNonFinalObject {\n"); - push(@headerContent, "public:\n"); - push(@headerContent, " typedef JSC::JSNonFinalObject Base;\n"); - if ($interfaceName ne "DOMWindow" && !$interface->extendedAttributes->{"IsWorkerContext"}) { - push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n"); - } - - push(@headerContent, " static ${className}Prototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)\n"); - push(@headerContent, " {\n"); - push(@headerContent, " ${className}Prototype* ptr = new (NotNull, JSC::allocateCell<${className}Prototype>(globalData.heap)) ${className}Prototype(globalData, globalObject, structure);\n"); - push(@headerContent, " ptr->finishCreation(globalData);\n"); - push(@headerContent, " return ptr;\n"); - push(@headerContent, " }\n\n"); - - push(@headerContent, " static const JSC::ClassInfo s_info;\n"); - if ($numFunctions > 0 || $numConstants > 0) { - push(@headerContent, " static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);\n"); - push(@headerContent, " static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);\n"); - $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1; - } - if ($interface->extendedAttributes->{"JSCustomMarkFunction"} or $needsMarkChildren) { - $structureFlags{"JSC::OverridesVisitChildren"} = 1; - } - push(@headerContent, - " static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n" . - " {\n" . - " return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);\n" . - " }\n"); - if ($interface->extendedAttributes->{"JSCustomNamedGetterOnPrototype"}) { - push(@headerContent, " static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);\n"); - push(@headerContent, " bool putDelegate(JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);\n"); - } - - # Custom defineOwnProperty function - push(@headerContent, " static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interface->extendedAttributes->{"JSCustomDefineOwnPropertyOnPrototype"}; - - push(@headerContent, "\nprivate:\n"); - push(@headerContent, " ${className}Prototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { }\n"); - - # structure flags - push(@headerContent, "protected:\n"); - push(@headerContent, " static const unsigned StructureFlags = "); - foreach my $structureFlag (keys %structureFlags) { - push(@headerContent, $structureFlag . " | "); - } - push(@headerContent, "Base::StructureFlags;\n"); - - push(@headerContent, "};\n\n"); - - if (!$interface->extendedAttributes->{"OmitConstructor"}) { - $headerIncludes{"JSDOMBinding.h"} = 1; - GenerateConstructorDeclaration(\@headerContent, $className, $interface, $interfaceName); - } - - if ($numFunctions > 0) { - push(@headerContent,"// Functions\n\n"); - foreach my $function (@{$interface->functions}) { - next if $function->{overloadIndex} && $function->{overloadIndex} > 1; - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - my $functionName = GetFunctionName($className, $function); - push(@headerContent, "JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState*);\n"); - push(@headerContent, "#endif\n") if $conditionalString; - } - } - - if ($numAttributes > 0 || !$interface->extendedAttributes->{"OmitConstructor"}) { - push(@headerContent,"// Attributes\n\n"); - foreach my $attribute (@{$interface->attributes}) { - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - my $getter = GetAttributeGetterName($interfaceName, $className, $attribute); - push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);\n"); - if (!IsReadonly($attribute)) { - my $setter = GetAttributeSetterName($interfaceName, $className, $attribute); - push(@headerContent, "void ${setter}(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);\n"); - } - push(@headerContent, "#endif\n") if $conditionalString; - } - - if (!$interface->extendedAttributes->{"OmitConstructor"}) { - my $getter = "js" . $interfaceName . "Constructor"; - push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);\n"); - } - - if ($interface->extendedAttributes->{"ReplaceableConstructor"}) { - my $constructorFunctionName = "setJS" . $interfaceName . "Constructor"; - push(@headerContent, "void ${constructorFunctionName}(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);\n"); - } - } - - if ($numConstants > 0) { - push(@headerContent,"// Constants\n\n"); - foreach my $constant (@{$interface->constants}) { - my $conditionalString = $codeGenerator->GenerateConditionalString($constant); - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); - push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);\n"); - push(@headerContent, "#endif\n") if $conditionalString; - } - } - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@headerContent, "\n} // namespace WebCore\n\n"); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; - push(@headerContent, "#endif\n"); - - # - Generate dependencies. - if ($writeDependencies && @ancestorInterfaceNames) { - push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestorInterfaceNames), "\n"); - push(@depsContent, map { "$_.idl :\n" } @ancestorInterfaceNames); - } -} - -sub GenerateAttributesHashTable($$) -{ - my ($object, $interface) = @_; - - # FIXME: These should be functions on $interface. - my $interfaceName = $interface->name; - my $className = "JS$interfaceName"; - - # - Add all attributes in a hashtable definition - my $numAttributes = @{$interface->attributes}; - $numAttributes++ if !$interface->extendedAttributes->{"OmitConstructor"}; - - return 0 if !$numAttributes; - - my $hashSize = $numAttributes; - my $hashName = $className . "Table"; - - my @hashKeys = (); - my @hashSpecials = (); - my @hashValue1 = (); - my @hashValue2 = (); - my %conditionals = (); - - my @entries = (); - - foreach my $attribute (@{$interface->attributes}) { - next if ($attribute->isStatic); - my $name = $attribute->signature->name; - push(@hashKeys, $name); - - my @specials = (); - push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; - push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"NotEnumerable"}; - push(@specials, "ReadOnly") if IsReadonly($attribute); - my $special = (@specials > 0) ? join(" | ", @specials) : "0"; - push(@hashSpecials, $special); - - my $getter = GetAttributeGetterName($interfaceName, $className, $attribute); - push(@hashValue1, $getter); - - if (IsReadonly($attribute)) { - push(@hashValue2, "0"); - } else { - my $setter = GetAttributeSetterName($interfaceName, $className, $attribute); - push(@hashValue2, $setter); - } - - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - if (!$interface->extendedAttributes->{"OmitConstructor"}) { - push(@hashKeys, "constructor"); - my $getter = "js" . $interfaceName . "Constructor"; - push(@hashValue1, $getter); - if ($interface->extendedAttributes->{"ReplaceableConstructor"}) { - my $setter = "setJS" . $interfaceName . "Constructor"; - push(@hashValue2, $setter); - push(@hashSpecials, "DontEnum | DontDelete"); - } else { - push(@hashValue2, "0"); - push(@hashSpecials, "DontEnum | ReadOnly"); - } - } - - $object->GenerateHashTable($hashName, $hashSize, - \@hashKeys, \@hashSpecials, - \@hashValue1, \@hashValue2, - \%conditionals); - return $numAttributes; -} - -sub GenerateParametersCheckExpression -{ - my $numParameters = shift; - my $function = shift; - - my @andExpression = (); - push(@andExpression, "argsCount == $numParameters"); - my $parameterIndex = 0; - my %usedArguments = (); - foreach my $parameter (@{$function->parameters}) { - last if $parameterIndex >= $numParameters; - my $value = "arg$parameterIndex"; - my $type = $parameter->type; - - # Only DOMString or wrapper types are checked. - # For DOMString with StrictTypeChecking only Null, Undefined and Object - # are accepted for compatibility. Otherwise, no restrictions are made to - # match the non-overloaded behavior. - # FIXME: Implement WebIDL overload resolution algorithm. - if ($codeGenerator->IsStringType($type)) { - if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { - push(@andExpression, "(${value}.isUndefinedOrNull() || ${value}.isString() || ${value}.isObject())"); - $usedArguments{$parameterIndex} = 1; - } - } elsif ($parameter->extendedAttributes->{"Callback"}) { - # For Callbacks only checks if the value is null or object. - push(@andExpression, "(${value}.isNull() || ${value}.isFunction())"); - $usedArguments{$parameterIndex} = 1; - } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) { - # FIXME: Add proper support for T[], T[]?, sequence<T> - if ($parameter->isNullable) { - push(@andExpression, "(${value}.isNull() || (${value}.isObject() && isJSArray(${value})))"); - } else { - push(@andExpression, "(${value}.isObject() && isJSArray(${value}))"); - } - $usedArguments{$parameterIndex} = 1; - } elsif (!IsNativeType($type)) { - if ($parameter->isNullable) { - push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(&JS${type}::s_info)))"); - } else { - push(@andExpression, "(${value}.isObject() && asObject(${value})->inherits(&JS${type}::s_info))"); - } - $usedArguments{$parameterIndex} = 1; - } - $parameterIndex++; - } - my $res = join(" && ", @andExpression); - $res = "($res)" if @andExpression > 1; - return ($res, keys %usedArguments); -} - -sub GenerateFunctionParametersCheck -{ - my $function = shift; - - my @orExpression = (); - my $numParameters = 0; - my @neededArguments = (); - my $hasVariadic = 0; - my $numMandatoryParams = @{$function->parameters}; - - foreach my $parameter (@{$function->parameters}) { - if ($parameter->extendedAttributes->{"Optional"}) { - my ($expression, @usedArguments) = GenerateParametersCheckExpression($numParameters, $function); - push(@orExpression, $expression); - push(@neededArguments, @usedArguments); - $numMandatoryParams--; - } - if ($parameter->isVariadic) { - $hasVariadic = 1; - last; - } - $numParameters++; - } - if (!$hasVariadic) { - my ($expression, @usedArguments) = GenerateParametersCheckExpression($numParameters, $function); - push(@orExpression, $expression); - push(@neededArguments, @usedArguments); - } - return ($numMandatoryParams, join(" || ", @orExpression), @neededArguments); -} - -sub GenerateOverloadedFunction -{ - my $function = shift; - my $interface = shift; - my $interfaceName = shift; - - # Generate code for choosing the correct overload to call. Overloads are - # chosen based on the total number of arguments passed and the type of - # values passed in non-primitive argument slots. When more than a single - # overload is applicable, precedence is given according to the order of - # declaration in the IDL. - - my $kind = $function->isStatic ? "Constructor" : "Prototype"; - my $functionName = "js${interfaceName}${kind}Function" . $codeGenerator->WK_ucfirst($function->signature->name); - - push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)\n"); - push(@implContent, <<END); -{ - size_t argsCount = exec->argumentCount(); -END - - my %fetchedArguments = (); - my $leastNumMandatoryParams = 255; - - foreach my $overload (@{$function->{overloads}}) { - my ($numMandatoryParams, $parametersCheck, @neededArguments) = GenerateFunctionParametersCheck($overload); - $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); - - foreach my $parameterIndex (@neededArguments) { - next if exists $fetchedArguments{$parameterIndex}; - push(@implContent, " JSValue arg$parameterIndex(exec->argument($parameterIndex));\n"); - $fetchedArguments{$parameterIndex} = 1; - } - - push(@implContent, " if ($parametersCheck)\n"); - push(@implContent, " return ${functionName}$overload->{overloadIndex}(exec);\n"); - } - if ($leastNumMandatoryParams >= 1) { - push(@implContent, " if (argsCount < $leastNumMandatoryParams)\n"); - push(@implContent, " return throwVMError(exec, createNotEnoughArgumentsError(exec));\n"); - } - push(@implContent, <<END); - return throwVMTypeError(exec); -} - -END -} - -sub GenerateImplementation -{ - my ($object, $interface) = @_; - - my $interfaceName = $interface->name; - my $className = "JS$interfaceName"; - - my $hasLegacyParent = $interface->extendedAttributes->{"JSLegacyParent"}; - my $hasRealParent = @{$interface->parents} > 0; - my $hasParent = $hasLegacyParent || $hasRealParent; - my $parentClassName = GetParentClassName($interface); - my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface); - my $eventTarget = $interface->extendedAttributes->{"EventTarget"} || ($codeGenerator->IsSubType($interface, "EventTarget") && $interface->name ne "EventTarget"); - my $needsMarkChildren = $interface->extendedAttributes->{"JSCustomMarkFunction"} || $interface->extendedAttributes->{"EventTarget"} || $interface->name eq "EventTarget"; - - # - Add default header template - push(@implContentHeader, GenerateImplementationContentHeader($interface)); - - AddIncludesForSVGAnimatedType($interfaceName) if $className =~ /^JSSVGAnimated/; - - $implIncludes{"<wtf/GetPtr.h>"} = 1; - $implIncludes{"<runtime/PropertyNameArray.h>"} = 1 if $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}; - - AddIncludesForTypeInImpl($interfaceName); - - @implContent = (); - - push(@implContent, "\nusing namespace JSC;\n\n"); - push(@implContent, "namespace WebCore {\n\n"); - - my $numAttributes = GenerateAttributesHashTable($object, $interface); - - my $numConstants = @{$interface->constants}; - my $numFunctions = @{$interface->functions}; - - # - Add all constants - if (!$interface->extendedAttributes->{"OmitConstructor"}) { - my $hashSize = $numConstants; - my $hashName = $className . "ConstructorTable"; - - my @hashKeys = (); - my @hashValue1 = (); - my @hashValue2 = (); - my @hashSpecials = (); - my %conditionals = (); - - # FIXME: we should not need a function for every constant. - foreach my $constant (@{$interface->constants}) { - my $name = $constant->name; - push(@hashKeys, $name); - my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($name); - push(@hashValue1, $getter); - push(@hashValue2, "0"); - push(@hashSpecials, "DontDelete | ReadOnly"); - - my $implementedBy = $constant->extendedAttributes->{"ImplementedBy"}; - if ($implementedBy) { - $implIncludes{"${implementedBy}.h"} = 1; - } - my $conditional = $constant->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - foreach my $attribute (@{$interface->attributes}) { - next unless ($attribute->isStatic); - my $name = $attribute->signature->name; - push(@hashKeys, $name); - - my @specials = (); - push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; - push(@specials, "ReadOnly") if IsReadonly($attribute); - my $special = (@specials > 0) ? join(" | ", @specials) : "0"; - push(@hashSpecials, $special); - - my $getter = GetAttributeGetterName($interfaceName, $className, $attribute); - push(@hashValue1, $getter); - - if (IsReadonly($attribute)) { - push(@hashValue2, "0"); - } else { - my $setter = GetAttributeSetterName($interfaceName, $className, $attribute); - push(@hashValue2, $setter); - } - - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - foreach my $function (@{$interface->functions}) { - next unless ($function->isStatic); - next if $function->{overloadIndex} && $function->{overloadIndex} > 1; - my $name = $function->signature->name; - push(@hashKeys, $name); - - my $functionName = GetFunctionName($className, $function); - push(@hashValue1, $functionName); - - my $numParameters = @{$function->parameters}; - push(@hashValue2, $numParameters); - - my @specials = (); - push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"}; - push(@specials, "DontEnum") if $function->signature->extendedAttributes->{"NotEnumerable"}; - push(@specials, "JSC::Function"); - my $special = (@specials > 0) ? join(" | ", @specials) : "0"; - push(@hashSpecials, $special); - - my $conditional = $function->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - $object->GenerateHashTable($hashName, $hashSize, - \@hashKeys, \@hashSpecials, - \@hashValue1, \@hashValue2, - \%conditionals); - - push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNeeded($interface)); - - my $protoClassName = "${className}Prototype"; - GenerateConstructorDefinitions(\@implContent, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface); - if ($interface->extendedAttributes->{"NamedConstructor"}) { - GenerateConstructorDefinitions(\@implContent, $className, $protoClassName, $interfaceName, $interface->extendedAttributes->{"NamedConstructor"}, $interface, "GeneratingNamedConstructor"); - } - } - - # - Add functions and constants to a hashtable definition - my $hashSize = $numFunctions + $numConstants; - my $hashName = $className . "PrototypeTable"; - - my @hashKeys = (); - my @hashValue1 = (); - my @hashValue2 = (); - my @hashSpecials = (); - my %conditionals = (); - - # FIXME: we should not need a function for every constant. - foreach my $constant (@{$interface->constants}) { - my $name = $constant->name; - push(@hashKeys, $name); - my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($name); - push(@hashValue1, $getter); - push(@hashValue2, "0"); - push(@hashSpecials, "DontDelete | ReadOnly"); - - my $conditional = $constant->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - foreach my $function (@{$interface->functions}) { - next if ($function->isStatic); - next if $function->{overloadIndex} && $function->{overloadIndex} > 1; - my $name = $function->signature->name; - push(@hashKeys, $name); - - my $functionName = GetFunctionName($className, $function); - push(@hashValue1, $functionName); - - my $numParameters = @{$function->parameters}; - push(@hashValue2, $numParameters); - - my @specials = (); - push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"}; - push(@specials, "DontEnum") if $function->signature->extendedAttributes->{"NotEnumerable"}; - push(@specials, "JSC::Function"); - my $special = (@specials > 0) ? join(" | ", @specials) : "0"; - push(@hashSpecials, $special); - - my $conditional = $function->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - $object->GenerateHashTable($hashName, $hashSize, - \@hashKeys, \@hashSpecials, - \@hashValue1, \@hashValue2, - \%conditionals); - - if ($interface->extendedAttributes->{"JSNoStaticTables"}) { - push(@implContent, "static const HashTable* get${className}PrototypeTable(ExecState* exec)\n"); - push(@implContent, "{\n"); - push(@implContent, " return getHashTableForGlobalData(exec->globalData(), &${className}PrototypeTable);\n"); - push(@implContent, "}\n\n"); - push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleInterfaceName}Prototype\", &Base::s_info, 0, get${className}PrototypeTable, CREATE_METHOD_TABLE(${className}Prototype) };\n\n"); - } else { - push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleInterfaceName}Prototype\", &Base::s_info, &${className}PrototypeTable, 0, CREATE_METHOD_TABLE(${className}Prototype) };\n\n"); - } - if ($interfaceName ne "DOMWindow" && !$interface->extendedAttributes->{"IsWorkerContext"}) { - push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec, JSGlobalObject* globalObject)\n"); - push(@implContent, "{\n"); - push(@implContent, " return getDOMPrototype<${className}>(exec, globalObject);\n"); - push(@implContent, "}\n\n"); - } - - if ($numConstants > 0 || $numFunctions > 0) { - push(@implContent, "bool ${className}Prototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}Prototype* thisObject = jsCast<${className}Prototype*>(cell);\n"); - - if ($numConstants eq 0 && $numFunctions eq 0) { - push(@implContent, " return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);\n"); - } elsif ($numConstants eq 0) { - push(@implContent, " return getStaticFunctionSlot<JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, slot);\n"); - } elsif ($numFunctions eq 0) { - push(@implContent, " return getStaticValueSlot<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, slot);\n"); - } else { - push(@implContent, " return getStaticPropertySlot<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, slot);\n"); - } - push(@implContent, "}\n\n"); - - push(@implContent, "bool ${className}Prototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}Prototype* thisObject = jsCast<${className}Prototype*>(object);\n"); - - if ($numConstants eq 0 && $numFunctions eq 0) { - push(@implContent, " return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);\n"); - } elsif ($numConstants eq 0) { - push(@implContent, " return getStaticFunctionDescriptor<JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); - } elsif ($numFunctions eq 0) { - push(@implContent, " return getStaticValueDescriptor<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); - } else { - push(@implContent, " return getStaticPropertyDescriptor<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); - } - push(@implContent, "}\n\n"); - } - - if ($interface->extendedAttributes->{"JSCustomNamedGetterOnPrototype"}) { - push(@implContent, "void ${className}Prototype::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}Prototype* thisObject = jsCast<${className}Prototype*>(cell);\n"); - push(@implContent, " if (thisObject->putDelegate(exec, propertyName, value, slot))\n"); - push(@implContent, " return;\n"); - push(@implContent, " Base::put(thisObject, exec, propertyName, value, slot);\n"); - push(@implContent, "}\n\n"); - } - - # - Initialize static ClassInfo object - if ($numAttributes > 0 && $interface->extendedAttributes->{"JSNoStaticTables"}) { - push(@implContent, "static const HashTable* get${className}Table(ExecState* exec)\n"); - push(@implContent, "{\n"); - push(@implContent, " return getHashTableForGlobalData(exec->globalData(), &${className}Table);\n"); - push(@implContent, "}\n\n"); - } - - push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleInterfaceName}\", &Base::s_info, "); - - if ($numAttributes > 0 && !$interface->extendedAttributes->{"JSNoStaticTables"}) { - push(@implContent, "&${className}Table"); - } else { - push(@implContent, "0"); - } - if ($numAttributes > 0 && $interface->extendedAttributes->{"JSNoStaticTables"}) { - push(@implContent, ", get${className}Table "); - } else { - push(@implContent, ", 0 "); - } - push(@implContent, ", CREATE_METHOD_TABLE($className) };\n\n"); - - my $implType = $interfaceName; - my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implType); - $implType = $svgNativeType if $svgNativeType; - - my $svgPropertyOrListPropertyType; - $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType; - $svgPropertyOrListPropertyType = $svgListPropertyType if $svgListPropertyType; - - # Constructor - if ($interfaceName eq "DOMWindow") { - AddIncludesForTypeInImpl("JSDOMWindowShell"); - push(@implContent, "${className}::$className(JSGlobalData& globalData, Structure* structure, PassRefPtr<$implType> impl, JSDOMWindowShell* shell)\n"); - push(@implContent, " : $parentClassName(globalData, structure, impl, shell)\n"); - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - } elsif ($interface->extendedAttributes->{"IsWorkerContext"}) { - AddIncludesForTypeInImpl($interfaceName); - push(@implContent, "${className}::$className(JSGlobalData& globalData, Structure* structure, PassRefPtr<$implType> impl)\n"); - push(@implContent, " : $parentClassName(globalData, structure, impl)\n"); - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - } else { - push(@implContent, "${className}::$className(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<$implType> impl)\n"); - if ($hasParent) { - push(@implContent, " : $parentClassName(structure, globalObject, impl)\n"); - } else { - push(@implContent, " : $parentClassName(structure, globalObject)\n"); - push(@implContent, " , m_impl(impl.leakRef())\n"); - } - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "void ${className}::finishCreation(JSGlobalData& globalData)\n"); - push(@implContent, "{\n"); - push(@implContent, " Base::finishCreation(globalData);\n"); - if ($codeGenerator->IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) { - push(@implContent, " TypedArrayDescriptor descriptor(&${className}::s_info, OBJECT_OFFSETOF(${className}, m_storage), OBJECT_OFFSETOF(${className}, m_storageLength));\n"); - push(@implContent, " globalData.registerTypedArrayDescriptor(impl(), descriptor);\n"); - push(@implContent, " m_storage = impl()->data();\n"); - push(@implContent, " m_storageLength = impl()->length();\n"); - } - push(@implContent, " ASSERT(inherits(&s_info));\n"); - push(@implContent, "}\n\n"); - } - - if (!$interface->extendedAttributes->{"ExtendsDOMGlobalObject"}) { - push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec, JSGlobalObject* globalObject)\n"); - push(@implContent, "{\n"); - if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") { - push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(exec->globalData(), globalObject, ${parentClassName}Prototype::self(exec, globalObject)));\n"); - } else { - my $prototype = $interface->isException ? "errorPrototype" : "objectPrototype"; - push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject, globalObject->${prototype}()));\n"); - } - push(@implContent, "}\n\n"); - } - - if (!$hasParent) { - # FIXME: This destroy function should not be necessary, as - # a finalizer should be called for each DOM object wrapper. - # However, that seems not to be the case, so this has been - # added back to avoid leaking while we figure out why the - # finalizers are not always getting called. The work tracking - # the finalizer issue is being tracked in http://webkit.org/b/75451 - push(@implContent, "void ${className}::destroy(JSC::JSCell* cell)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = static_cast<${className}*>(cell);\n"); - push(@implContent, " thisObject->${className}::~${className}();\n"); - push(@implContent, "}\n\n"); - - # We also need a destructor for the allocateCell to work properly with the destructor-free part of the heap. - # Otherwise, these destroy functions/destructors won't get called. - push(@implContent, "${className}::~${className}()\n"); - push(@implContent, "{\n"); - push(@implContent, " releaseImplIfNotNull();\n"); - push(@implContent, "}\n\n"); - } - - my $hasGetter = $numAttributes > 0 - || !$interface->extendedAttributes->{"OmitConstructor"} - || $interface->extendedAttributes->{"IndexedGetter"} - || $interface->extendedAttributes->{"NumericIndexedGetter"} - || $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"} - || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"} - || $interface->extendedAttributes->{"NamedGetter"} - || $interface->extendedAttributes->{"CustomNamedGetter"}; - - # Attributes - if ($hasGetter) { - if (!$interface->extendedAttributes->{"JSInlineGetOwnPropertySlot"} && !$interface->extendedAttributes->{"CustomGetOwnPropertySlot"}) { - push(@implContent, "bool ${className}::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(cell);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - push(@implContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numAttributes > 0, 0)); - push(@implContent, "}\n\n"); - push(@implContent, "bool ${className}::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(object);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - push(@implContent, GenerateGetOwnPropertyDescriptorBody($interface, $interfaceName, $className, $numAttributes > 0, 0)); - push(@implContent, "}\n\n"); - } - - if ($interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"} - || $interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"} - || $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}) { - push(@implContent, "bool ${className}::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned index, PropertySlot& slot)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(cell);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - - # Sink the int-to-string conversion that happens when we create a PropertyName - # to the point where we actually need it. - my $generatedPropertyName = 0; - my $propertyNameGeneration = sub { - if ($generatedPropertyName) { - return; - } - push(@implContent, " PropertyName propertyName = Identifier::from(exec, index);\n"); - $generatedPropertyName = 1; - }; - - if ($interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}) { - if (IndexGetterReturnsStrings($interfaceName)) { - push(@implContent, " if (index <= MAX_ARRAY_INDEX) {\n"); - } else { - push(@implContent, " if (index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n"); - } - if ($interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@implContent, " slot.setValue(thisObject->getByIndex(exec, index));\n"); - } else { - push(@implContent, " slot.setCustomIndex(thisObject, index, thisObject->indexGetter);\n"); - } - push(@implContent, " return true;\n"); - push(@implContent, " }\n"); - } - - if ($interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"}) { - &$propertyNameGeneration(); - push(@implContent, " if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n"); - push(@implContent, " slot.setCustom(thisObject, thisObject->nameGetter);\n"); - push(@implContent, " return true;\n"); - push(@implContent, " }\n"); - $implIncludes{"wtf/text/AtomicString.h"} = 1; - } - - if ($interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}) { - &$propertyNameGeneration(); - push(@implContent, " if (thisObject->getOwnPropertySlotDelegate(exec, propertyName, slot))\n"); - push(@implContent, " return true;\n"); - } - - push(@implContent, " return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);\n"); - push(@implContent, "}\n\n"); - } - - if ($numAttributes > 0) { - foreach my $attribute (@{$interface->attributes}) { - my $name = $attribute->signature->name; - my $type = $attribute->signature->type; - $codeGenerator->AssertNotSequenceType($type); - my $getFunctionName = GetAttributeGetterName($interfaceName, $className, $attribute); - my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name); - - my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; - - push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, PropertyName)\n"); - push(@implContent, "{\n"); - - if (!$attribute->isStatic || $attribute->signature->type =~ /Constructor$/) { - push(@implContent, " ${className}* castedThis = jsCast<$className*>(asObject(slotBase));\n"); - } else { - push(@implContent, " UNUSED_PARAM(slotBase);\n"); - } - - if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { - $needsMarkChildren = 1; - } - - if ($interface->extendedAttributes->{"CheckSecurity"} && - !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"} && - !$attribute->signature->extendedAttributes->{"DoNotCheckSecurityOnGetter"}) { - $implIncludes{"BindingSecurity.h"} = 1; - push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))\n"); - push(@implContent, " return jsUndefined();\n"); - } - - if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) { - push(@implContent, " return castedThis->$implGetterFunctionName(exec);\n"); - } elsif ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { - $implIncludes{"JSDOMBinding.h"} = 1; - push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n"); - push(@implContent, " return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl->$implGetterFunctionName()", "castedThis") . " : jsNull();\n"); - } elsif ($type eq "EventListener") { - $implIncludes{"EventListener.h"} = 1; - push(@implContent, " UNUSED_PARAM(exec);\n"); - push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n"); - push(@implContent, " if (EventListener* listener = impl->$implGetterFunctionName()) {\n"); - push(@implContent, " if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n"); - if ($interfaceName eq "Document" || $interfaceName eq "WorkerContext" || $interfaceName eq "SharedWorkerContext" || $interfaceName eq "DedicatedWorkerContext") { - push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(impl))\n"); - } else { - push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(impl->scriptExecutionContext()))\n"); - } - push(@implContent, " return jsFunction;\n"); - push(@implContent, " }\n"); - push(@implContent, " }\n"); - push(@implContent, " return jsNull();\n"); - } elsif ($attribute->signature->type =~ /Constructor$/) { - my $constructorType = $attribute->signature->type; - $constructorType =~ s/Constructor$//; - # When Constructor attribute is used by DOMWindow.idl, it's correct to pass castedThis as the global object - # When JSDOMWrappers have a back-pointer to the globalObject we can pass castedThis->globalObject() - if ($interfaceName eq "DOMWindow") { - push(@implContent, " return JS" . $constructorType . "::getConstructor(exec, castedThis);\n"); - } else { - AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"}); - push(@implContent, " return JS" . $constructorType . "::getConstructor(exec, castedThis->globalObject());\n"); - } - } elsif (!@{$attribute->getterExceptions}) { - push(@implContent, " UNUSED_PARAM(exec);\n") if !$attribute->signature->extendedAttributes->{"CallWith"}; - - my $cacheIndex = 0; - if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { - $cacheIndex = $currentCachedAttribute; - $currentCachedAttribute++; - push(@implContent, " if (JSValue cachedValue = castedThis->m_" . $attribute->signature->name . ".get())\n"); - push(@implContent, " return cachedValue;\n"); - } - - my @callWithArgs = GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()"); - - if ($svgListPropertyType) { - push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "castedThis->impl()->$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n"); - } elsif ($svgPropertyOrListPropertyType) { - push(@implContent, " $svgPropertyOrListPropertyType& impl = castedThis->impl()->propertyReference();\n"); - if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber - push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl", "castedThis") . ";\n"); - } else { - push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl.$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n"); - - } - } else { - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute); - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - $functionName = "${implementedBy}::${functionName}"; - unshift(@arguments, "impl") if !$attribute->isStatic; - } elsif ($attribute->isStatic) { - $functionName = "${interfaceName}::${functionName}"; - } else { - $functionName = "impl->${functionName}"; - } - - unshift(@arguments, @callWithArgs); - - my $jsType = NativeToJSValue($attribute->signature, 0, $interfaceName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis"); - push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n") if !$attribute->isStatic; - if ($codeGenerator->IsSVGAnimatedType($type)) { - push(@implContent, " RefPtr<$type> obj = $jsType;\n"); - push(@implContent, " JSValue result = toJS(exec, castedThis->globalObject(), obj.get());\n"); - } else { - push(@implContent, " JSValue result = $jsType;\n"); - } - } - - push(@implContent, " castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"}); - push(@implContent, " return result;\n"); - - } else { - my @arguments = ("ec"); - push(@implContent, " ExceptionCode ec = 0;\n"); - - unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()")); - - if ($svgPropertyOrListPropertyType) { - push(@implContent, " $svgPropertyOrListPropertyType impl(*castedThis->impl());\n"); - push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n"); - } else { - push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n"); - push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n"); - } - - push(@implContent, " setDOMException(exec, ec);\n"); - push(@implContent, " return result;\n"); - } - - push(@implContent, "}\n\n"); - - push(@implContent, "#endif\n") if $attributeConditionalString; - - push(@implContent, "\n"); - } - - if (!$interface->extendedAttributes->{"OmitConstructor"}) { - my $constructorFunctionName = "js" . $interfaceName . "Constructor"; - - push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, JSValue slotBase, PropertyName)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* domObject = jsCast<$className*>(asObject(slotBase));\n"); - - if ($interface->extendedAttributes->{"CheckSecurity"}) { - $implIncludes{"BindingSecurity.h"} = 1; - push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, domObject->impl()))\n"); - push(@implContent, " return jsUndefined();\n"); - } - - push(@implContent, " return ${className}::getConstructor(exec, domObject->globalObject());\n"); - push(@implContent, "}\n\n"); - } - } - - # Check if we have any writable attributes - my $hasReadWriteProperties = 0; - foreach my $attribute (@{$interface->attributes}) { - $hasReadWriteProperties = 1 if !IsReadonly($attribute) && !$attribute->isStatic; - } - - my $hasSetter = $hasReadWriteProperties - || $interface->extendedAttributes->{"CustomNamedSetter"} - || $interface->extendedAttributes->{"CustomIndexedSetter"}; - - if ($hasSetter) { - if (!$interface->extendedAttributes->{"CustomPutFunction"}) { - push(@implContent, "void ${className}::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(cell);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - if ($interface->extendedAttributes->{"CustomIndexedSetter"}) { - push(@implContent, " unsigned index = propertyName.asIndex();\n"); - push(@implContent, " if (index != PropertyName::NotAnIndex) {\n"); - push(@implContent, " thisObject->indexSetter(exec, index, value);\n"); - push(@implContent, " return;\n"); - push(@implContent, " }\n"); - } - if ($interface->extendedAttributes->{"CustomNamedSetter"}) { - push(@implContent, " if (thisObject->putDelegate(exec, propertyName, value, slot))\n"); - push(@implContent, " return;\n"); - } - - if ($hasReadWriteProperties) { - push(@implContent, " lookupPut<$className, Base>(exec, propertyName, value, " . hashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, slot);\n"); - } else { - push(@implContent, " Base::put(thisObject, exec, propertyName, value, slot);\n"); - } - push(@implContent, "}\n\n"); - - if ($interface->extendedAttributes->{"CustomIndexedSetter"} || $interface->extendedAttributes->{"CustomNamedSetter"}) { - push(@implContent, "void ${className}::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSValue value, bool shouldThrow)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(cell);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - if ($interface->extendedAttributes->{"CustomIndexedSetter"}) { - push(@implContent, " if (index <= MAX_ARRAY_INDEX) {\n"); - push(@implContent, " UNUSED_PARAM(shouldThrow);\n"); - push(@implContent, " thisObject->indexSetter(exec, index, value);\n"); - push(@implContent, " return;\n"); - push(@implContent, " }\n"); - } - - if ($interface->extendedAttributes->{"CustomNamedSetter"}) { - push(@implContent, " PropertyName propertyName = Identifier::from(exec, index);\n"); - push(@implContent, " PutPropertySlot slot(shouldThrow);\n"); - push(@implContent, " if (thisObject->putDelegate(exec, propertyName, value, slot))\n"); - push(@implContent, " return;\n"); - } - - push(@implContent, " Base::putByIndex(cell, exec, index, value, shouldThrow);\n"); - push(@implContent, "}\n\n"); - } - } - - if ($hasReadWriteProperties) { - foreach my $attribute (@{$interface->attributes}) { - if (!IsReadonly($attribute)) { - my $name = $attribute->signature->name; - my $type = $attribute->signature->type; - my $putFunctionName = GetAttributeSetterName($interfaceName, $className, $attribute); - my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name); - - my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; - - push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject*"); - push(@implContent, " thisObject") if !$attribute->isStatic; - push(@implContent, ", JSValue value)\n"); - push(@implContent, "{\n"); - - push(@implContent, " UNUSED_PARAM(exec);\n"); - - if ($interface->extendedAttributes->{"CheckSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"}) { - if ($interfaceName eq "DOMWindow") { - $implIncludes{"BindingSecurity.h"} = 1; - push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, jsCast<$className*>(thisObject)->impl()))\n"); - } else { - push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n"); - } - push(@implContent, " return;\n"); - } - - if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}) { - push(@implContent, " jsCast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n"); - } elsif ($type eq "EventListener") { - $implIncludes{"JSEventListener.h"} = 1; - push(@implContent, " UNUSED_PARAM(exec);\n"); - push(@implContent, " ${className}* castedThis = jsCast<${className}*>(thisObject);\n"); - my $windowEventListener = $attribute->signature->extendedAttributes->{"JSWindowEventListener"}; - if ($windowEventListener) { - push(@implContent, " JSDOMGlobalObject* globalObject = castedThis->globalObject();\n"); - } - push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n"); - if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") { - $implIncludes{"JSErrorHandler.h"} = 1; - push(@implContent, " impl->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n"); - } else { - push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener)); - } - } elsif ($attribute->signature->type =~ /Constructor$/) { - my $constructorType = $attribute->signature->type; - $constructorType =~ s/Constructor$//; - # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor. - # We do not generate the header file for NamedConstructor of class XXXX, - # since we generate the NamedConstructor declaration into the header file of class XXXX. - if ($constructorType ne "DOMObject" and $constructorType !~ /Constructor$/) { - AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"}); - } - push(@implContent, " // Shadowing a built-in constructor\n"); - if ($interfaceName eq "DOMWindow" && $className eq "JSblah") { - # FIXME: This branch never executes and should be removed. - push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); - } else { - push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); - } - } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) { - push(@implContent, " // Shadowing a built-in object\n"); - push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); - } else { - if (!$attribute->isStatic) { - push(@implContent, " $className* castedThis = jsCast<$className*>(thisObject);\n"); - push(@implContent, " $implType* impl = static_cast<$implType*>(castedThis->impl());\n"); - } - push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; - - # If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an - # interface type, then if the incoming value does not implement that interface, a TypeError - # is thrown rather than silently passing NULL to the C++ code. - # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to - # both strings and numbers, so do not throw TypeError if the attribute is of these types. - if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { - $implIncludes{"<runtime/Error.h>"} = 1; - - my $argType = $attribute->signature->type; - if (!IsNativeType($argType)) { - push(@implContent, " if (!value.isUndefinedOrNull() && !value.inherits(&JS${argType}::s_info)) {\n"); - push(@implContent, " throwVMTypeError(exec);\n"); - push(@implContent, " return;\n"); - push(@implContent, " };\n"); - } - } - - my $nativeValue = JSValueToNative($attribute->signature, "value"); - if ($svgPropertyOrListPropertyType) { - if ($svgPropertyType) { - push(@implContent, " if (impl->isReadOnly()) {\n"); - push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n"); - push(@implContent, " return;\n"); - push(@implContent, " }\n"); - $implIncludes{"ExceptionCode.h"} = 1; - } - push(@implContent, " $svgPropertyOrListPropertyType& podImpl = impl->propertyReference();\n"); - if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber - push(@implContent, " podImpl = $nativeValue;\n"); - } else { - push(@implContent, " podImpl.set$implSetterFunctionName($nativeValue"); - push(@implContent, ", ec") if @{$attribute->setterExceptions}; - push(@implContent, ");\n"); - push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; - } - if ($svgPropertyType) { - if (@{$attribute->setterExceptions}) { - push(@implContent, " if (!ec)\n"); - push(@implContent, " impl->commitChange();\n"); - } else { - push(@implContent, " impl->commitChange();\n"); - } - } - } else { - my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@arguments, $nativeValue); - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "impl") if !$attribute->isStatic; - $functionName = "${implementedBy}::${functionName}"; - } elsif ($attribute->isStatic) { - $functionName = "${interfaceName}::${functionName}"; - } else { - $functionName = "impl->${functionName}"; - } - - unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "")); - - push(@arguments, "ec") if @{$attribute->setterExceptions}; - push(@implContent, " ${functionName}(" . join(", ", @arguments) . ");\n"); - push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; - } - } - - push(@implContent, "}\n\n"); - push(@implContent, "#endif\n") if $attributeConditionalString; - push(@implContent, "\n"); - } - } - } - - if ($interface->extendedAttributes->{"ReplaceableConstructor"}) { - my $constructorFunctionName = "setJS" . $interfaceName . "Constructor"; - - push(@implContent, "void ${constructorFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n"); - push(@implContent, "{\n"); - if ($interface->extendedAttributes->{"CheckSecurity"}) { - if ($interfaceName eq "DOMWindow") { - $implIncludes{"BindingSecurity.h"} = 1; - push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, jsCast<$className*>(thisObject)->impl()))\n"); - } else { - push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n"); - } - push(@implContent, " return;\n"); - } - - push(@implContent, " // Shadowing a built-in constructor\n"); - - if ($interfaceName eq "DOMWindow") { - push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); - } else { - die "No way to handle interface with ReplaceableConstructor extended attribute: $interfaceName"; - } - push(@implContent, "}\n\n"); - } - } - } - - if (($interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}) && !$interface->extendedAttributes->{"CustomEnumerateProperty"}) { - push(@implContent, "void ${className}::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(object);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - if ($interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@implContent, " for (unsigned i = 0; i < static_cast<${interfaceName}*>(thisObject->impl())->length(); ++i)\n"); - push(@implContent, " propertyNames.add(Identifier::from(exec, i));\n"); - } - push(@implContent, " Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);\n"); - push(@implContent, "}\n\n"); - } - - if (!$interface->extendedAttributes->{"OmitConstructor"}) { - push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n"); - push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));\n"); - push(@implContent, "}\n\n"); - } - - # Functions - if ($numFunctions > 0) { - foreach my $function (@{$interface->functions}) { - AddIncludesForTypeInImpl($function->signature->type); - - my $isCustom = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCustom"}; - my $isOverloaded = $function->{overloads} && @{$function->{overloads}} > 1; - - next if $isCustom && $isOverloaded && $function->{overloadIndex} > 1; - - my $functionName = GetFunctionName($className, $function); - - my $conditional = $function->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - push(@implContent, "#if ${conditionalString}\n"); - } - - - if (!$isCustom && $isOverloaded) { - # Append a number to an overloaded method's name to make it unique: - $functionName = $functionName . $function->{overloadIndex}; - # Make this function static to avoid compiler warnings, since we - # don't generate a prototype for it in the header. - push(@implContent, "static "); - } - - my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementedAs"} || $codeGenerator->WK_lcfirst($function->signature->name); - - push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)\n"); - push(@implContent, "{\n"); - - $implIncludes{"<runtime/Error.h>"} = 1; - - if ($function->isStatic) { - if ($isCustom) { - GenerateArgumentsCountCheck(\@implContent, $function, $interface); - push(@implContent, " return JSValue::encode(${className}::" . $functionImplementationName . "(exec));\n"); - } else { - GenerateArgumentsCountCheck(\@implContent, $function, $interface); - - if (@{$function->raisesExceptions}) { - push(@implContent, " ExceptionCode ec = 0;\n"); - } - - my $numParameters = @{$function->parameters}; - my ($functionString, $dummy) = GenerateParametersCheck(\@implContent, $function, $interface, $numParameters, $interfaceName, $functionImplementationName, $svgPropertyType, $svgPropertyOrListPropertyType, $svgListPropertyType); - GenerateImplementationFunctionCall($function, $functionString, " ", $svgPropertyType, $interfaceName); - } - } else { - if ($interfaceName eq "DOMWindow") { - push(@implContent, " $className* castedThis = toJSDOMWindow(exec->hostThisValue().toThisObject(exec));\n"); - push(@implContent, " if (!castedThis)\n"); - push(@implContent, " return throwVMTypeError(exec);\n"); - } elsif ($interface->extendedAttributes->{"IsWorkerContext"}) { - push(@implContent, " $className* castedThis = to${className}(exec->hostThisValue().toThisObject(exec));\n"); - push(@implContent, " if (!castedThis)\n"); - push(@implContent, " return throwVMTypeError(exec);\n"); - } else { - push(@implContent, " JSValue thisValue = exec->hostThisValue();\n"); - push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n"); - push(@implContent, " return throwVMTypeError(exec);\n"); - push(@implContent, " $className* castedThis = jsCast<$className*>(asObject(thisValue));\n"); - } - - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(castedThis, &${className}::s_info);\n"); - - if ($interface->extendedAttributes->{"CheckSecurity"} and - !$function->signature->extendedAttributes->{"DoNotCheckSecurity"}) { - $implIncludes{"BindingSecurity.h"} = 1; - push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))\n"); - push(@implContent, " return JSValue::encode(jsUndefined());\n"); - } - - if ($isCustom) { - push(@implContent, " return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n"); - } else { - if ($function->signature->name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { - my $viewType = $interface->extendedAttributes->{"TypedArray"}; - push(@implContent, " return JSValue::encode(setWebGLArrayHelper<$implType, $viewType>(exec, castedThis->impl()));\n"); - push(@implContent, "}\n\n"); - next; - } - - push(@implContent, " $implType* impl = static_cast<$implType*>(castedThis->impl());\n"); - if ($svgPropertyType) { - push(@implContent, " if (impl->isReadOnly()) {\n"); - push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n"); - push(@implContent, " return JSValue::encode(jsUndefined());\n"); - push(@implContent, " }\n"); - push(@implContent, " $svgPropertyType& podImpl = impl->propertyReference();\n"); - $implIncludes{"ExceptionCode.h"} = 1; - } - - # For compatibility with legacy content, the EventListener calls are generated without GenerateArgumentsCountCheck. - if ($function->signature->name eq "addEventListener") { - push(@implContent, GenerateEventListenerCall($className, "add")); - } elsif ($function->signature->name eq "removeEventListener") { - push(@implContent, GenerateEventListenerCall($className, "remove")); - } else { - GenerateArgumentsCountCheck(\@implContent, $function, $interface); - - if (@{$function->raisesExceptions}) { - push(@implContent, " ExceptionCode ec = 0;\n"); - } - - if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { - push(@implContent, " if (!shouldAllowAccessToNode(exec, impl->" . $function->signature->name . "(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n"); - push(@implContent, " return JSValue::encode(jsNull());\n"); - $implIncludes{"JSDOMBinding.h"} = 1; - } - - my $numParameters = @{$function->parameters}; - my ($functionString, $dummy) = GenerateParametersCheck(\@implContent, $function, $interface, $numParameters, $interfaceName, $functionImplementationName, $svgPropertyType, $svgPropertyOrListPropertyType, $svgListPropertyType); - GenerateImplementationFunctionCall($function, $functionString, " ", $svgPropertyType, $interfaceName); - } - } - } - - push(@implContent, "}\n\n"); - - if (!$isCustom && $isOverloaded && $function->{overloadIndex} == @{$function->{overloads}}) { - # Generate a function dispatching call to the rest of the overloads. - GenerateOverloadedFunction($function, $interface, $interfaceName); - } - - push(@implContent, "#endif\n\n") if $conditional; - } - } - - if ($needsMarkChildren && !$interface->extendedAttributes->{"JSCustomMarkFunction"}) { - push(@implContent, "void ${className}::visitChildren(JSCell* cell, SlotVisitor& visitor)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObject = jsCast<${className}*>(cell);\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);\n"); - push(@implContent, " COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);\n"); - push(@implContent, " ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());\n"); - push(@implContent, " Base::visitChildren(thisObject, visitor);\n"); - if ($interface->extendedAttributes->{"EventTarget"} || $interface->name eq "EventTarget") { - push(@implContent, " thisObject->impl()->visitJSEventListeners(visitor);\n"); - } - if ($numCachedAttributes > 0) { - foreach (@{$interface->attributes}) { - my $attribute = $_; - if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { - push(@implContent, " visitor.append(&thisObject->m_" . $attribute->signature->name . ");\n"); - } - } - } - push(@implContent, "}\n\n"); - } - - # Cached attributes are indeed allowed when there is a custom mark/visitChildren function. - # The custom function must make sure to account for the cached attribute. - # Uncomment the below line to temporarily enforce generated mark functions when cached attributes are present. - # die "Can't generate binding for class with cached attribute and custom mark." if (($numCachedAttributes > 0) and ($interface->extendedAttributes->{"JSCustomMarkFunction"})); - - if ($numConstants > 0) { - push(@implContent, "// Constant getters\n\n"); - - foreach my $constant (@{$interface->constants}) { - my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); - my $conditional = $constant->extendedAttributes->{"Conditional"}; - - if ($conditional) { - my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - push(@implContent, "#if ${conditionalString}\n"); - } - - # FIXME: this casts into int to match our previous behavior which turned 0xFFFFFFFF in -1 for NodeFilter.SHOW_ALL - push(@implContent, "JSValue ${getter}(ExecState* exec, JSValue, PropertyName)\n"); - push(@implContent, "{\n"); - if ($constant->type eq "DOMString") { - push(@implContent, " return jsStringOrNull(exec, String(" . $constant->value . "));\n"); - } else { - push(@implContent, " UNUSED_PARAM(exec);\n"); - push(@implContent, " return jsNumber(static_cast<int>(" . $constant->value . "));\n"); - } - push(@implContent, "}\n\n"); - push(@implContent, "#endif\n") if $conditional; - } - } - - if ($interface->extendedAttributes->{"IndexedGetter"}) { - push(@implContent, "\nJSValue ${className}::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObj = jsCast<$className*>(asObject(slotBase));\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);\n"); - if (IndexGetterReturnsStrings($interfaceName)) { - $implIncludes{"KURL.h"} = 1; - push(@implContent, " return jsStringOrUndefined(exec, thisObj->impl()->item(index));\n"); - } else { - push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$interfaceName*>(thisObj->impl())->item(index));\n"); - } - push(@implContent, "}\n\n"); - if ($interfaceName =~ /^HTML\w*Collection$/ or $interfaceName eq "RadioNodeList") { - $implIncludes{"JSNode.h"} = 1; - $implIncludes{"Node.h"} = 1; - } - } - - if ($interface->extendedAttributes->{"NumericIndexedGetter"}) { - push(@implContent, "\nJSValue ${className}::getByIndex(ExecState*, unsigned index)\n"); - push(@implContent, "{\n"); - push(@implContent, " ASSERT_GC_OBJECT_INHERITS(this, &s_info);\n"); - push(@implContent, " double result = static_cast<$interfaceName*>(impl())->item(index);\n"); - # jsNumber conversion doesn't suppress signalling NaNs, so enforce that here. - push(@implContent, " if (isnan(result))\n"); - push(@implContent, " return jsNaN();\n"); - push(@implContent, " return JSValue(result);\n"); - push(@implContent, "}\n\n"); - if ($interfaceName =~ /^HTML\w*Collection$/) { - $implIncludes{"JSNode.h"} = 1; - $implIncludes{"Node.h"} = 1; - } - } - - if ($interfaceName eq "HTMLPropertiesCollection" or $interfaceName eq "DOMNamedFlowCollection") { - if ($interface->extendedAttributes->{"NamedGetter"}) { - push(@implContent, "bool ${className}::canGetItemsForName(ExecState*, $interfaceName* collection, PropertyName propertyName)\n"); - push(@implContent, "{\n"); - push(@implContent, " return collection->hasNamedItem(propertyNameToAtomicString(propertyName));\n"); - push(@implContent, "}\n\n"); - push(@implContent, "JSValue ${className}::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)\n"); - push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObj = jsCast<$className*>(asObject(slotBase));\n"); - if ($interfaceName eq "HTMLPropertiesCollection") { - push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$interfaceName*>(thisObj->impl())->propertyNodeList(propertyNameToAtomicString(propertyName)));\n"); - } else { - push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$interfaceName*>(thisObj->impl())->namedItem(propertyNameToAtomicString(propertyName)));\n"); - } - push(@implContent, "}\n\n"); - } - } - - if ((!$hasParent && !GetCustomIsReachable($interface))|| GetGenerateIsReachable($interface) || $interface->extendedAttributes->{"ActiveDOMObject"}) { - push(@implContent, "static inline bool isObservable(JS${interfaceName}* js${interfaceName})\n"); - push(@implContent, "{\n"); - push(@implContent, " if (js${interfaceName}->hasCustomProperties())\n"); - push(@implContent, " return true;\n"); - if ($eventTarget) { - push(@implContent, " if (js${interfaceName}->impl()->hasEventListeners())\n"); - push(@implContent, " return true;\n"); - } - push(@implContent, " return false;\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "bool JS${interfaceName}Owner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)\n"); - push(@implContent, "{\n"); - push(@implContent, " JS${interfaceName}* js${interfaceName} = jsCast<JS${interfaceName}*>(handle.get().asCell());\n"); - # All ActiveDOMObjects implement hasPendingActivity(), but not all of them - # increment their C++ reference counts when hasPendingActivity() becomes - # true. As a result, ActiveDOMObjects can be prematurely destroyed before - # their pending activities complete. To wallpaper over this bug, JavaScript - # wrappers unconditionally keep ActiveDOMObjects with pending activity alive. - # FIXME: Fix this lifetime issue in the DOM, and move this hasPendingActivity - # check below the isObservable check. - if ($interface->extendedAttributes->{"ActiveDOMObject"}) { - push(@implContent, " if (js${interfaceName}->impl()->hasPendingActivity())\n"); - push(@implContent, " return true;\n"); - } - if ($codeGenerator->IsSubType($interface, "Node")) { - push(@implContent, " if (JSNodeOwner::isReachableFromOpaqueRoots(handle, 0, visitor))\n"); - push(@implContent, " return true;\n"); - } - push(@implContent, " if (!isObservable(js${interfaceName}))\n"); - push(@implContent, " return false;\n"); - if (GetGenerateIsReachable($interface)) { - my $rootString; - if (GetGenerateIsReachable($interface) eq "Impl") { - $rootString = " ${implType}* root = js${interfaceName}->impl();\n"; - } elsif (GetGenerateIsReachable($interface) eq "ImplContext") { - $rootString = " WebGLRenderingContext* root = js${interfaceName}->impl()->context();\n"; - } elsif (GetGenerateIsReachable($interface) eq "ImplFrame") { - $rootString = " Frame* root = js${interfaceName}->impl()->frame();\n"; - $rootString .= " if (!root)\n"; - $rootString .= " return false;\n"; - } elsif (GetGenerateIsReachable($interface) eq "ImplDocument") { - $rootString = " Document* root = js${interfaceName}->impl()->document();\n"; - $rootString .= " if (!root)\n"; - $rootString .= " return false;\n"; - } elsif (GetGenerateIsReachable($interface) eq "ImplElementRoot") { - $rootString = " Element* element = js${interfaceName}->impl()->element();\n"; - $rootString .= " if (!element)\n"; - $rootString .= " return false;\n"; - $rootString .= " void* root = WebCore::root(element);\n"; - } elsif ($interfaceName eq "CanvasRenderingContext") { - $rootString = " void* root = WebCore::root(js${interfaceName}->impl()->canvas());\n"; - } elsif (GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { - $rootString = " void* root = WebCore::root(js${interfaceName}->impl()->ownerNode());\n"; - } else { - $rootString = " void* root = WebCore::root(js${interfaceName}->impl());\n"; - } - - push(@implContent, $rootString); - push(@implContent, " return visitor.containsOpaqueRoot(root);\n"); - } else { - push(@implContent, " UNUSED_PARAM(visitor);\n"); - push(@implContent, " return false;\n"); - } - push(@implContent, "}\n\n"); - } - - if (!$interface->extendedAttributes->{"JSCustomFinalize"} && - (!$hasParent || - GetGenerateIsReachable($interface) || - GetCustomIsReachable($interface) || - $interface->extendedAttributes->{"ActiveDOMObject"})) { - push(@implContent, "void JS${interfaceName}Owner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)\n"); - push(@implContent, "{\n"); - push(@implContent, " JS${interfaceName}* js${interfaceName} = jsCast<JS${interfaceName}*>(handle.get().asCell());\n"); - push(@implContent, " DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);\n"); - push(@implContent, " uncacheWrapper(world, js${interfaceName}->impl(), js${interfaceName});\n"); - push(@implContent, " js${interfaceName}->releaseImpl();\n"); - push(@implContent, "}\n\n"); - } - - if (ShouldGenerateToJSImplementation($hasParent, $interface)) { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* impl)\n"); - push(@implContent, "{\n"); - if ($svgPropertyType) { - push(@implContent, " return wrap<$className, $implType>(exec, globalObject, impl);\n"); - } else { - push(@implContent, " return wrap<$className>(exec, globalObject, impl);\n"); - } - push(@implContent, "}\n\n"); - } - - if ((!$hasParent or $interface->extendedAttributes->{"JSGenerateToNativeObject"}) and !$interface->extendedAttributes->{"JSCustomToNativeObject"}) { - push(@implContent, "$implType* to${interfaceName}(JSC::JSValue value)\n"); - push(@implContent, "{\n"); - push(@implContent, " return value.inherits(&${className}::s_info) ? jsCast<$className*>(asObject(value))->impl() : 0"); - push(@implContent, ";\n}\n"); - } - - push(@implContent, "\n}\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; -} - -sub GenerateCallWith -{ - my $callWith = shift; - return () unless $callWith; - my $outputArray = shift; - my $returnValue = shift; - my $function = shift; - - my @callWithArgs; - if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { - push(@callWithArgs, "exec"); - } - if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) { - push(@$outputArray, " ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n"); - push(@$outputArray, " if (!scriptContext)\n"); - push(@$outputArray, " return" . ($returnValue ? " " . $returnValue : "") . ";\n"); - push(@callWithArgs, "scriptContext"); - } - if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments")) { - push(@$outputArray, " RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, " . @{$function->parameters} . "));\n"); - $implIncludes{"ScriptArguments.h"} = 1; - $implIncludes{"ScriptCallStackFactory.h"} = 1; - push(@callWithArgs, "scriptArguments.release()"); - } - return @callWithArgs; -} - -sub GenerateArgumentsCountCheck -{ - my $outputArray = shift; - my $function = shift; - my $interface = shift; - - my $numMandatoryParams = @{$function->parameters}; - foreach my $param (reverse(@{$function->parameters})) { - if ($param->extendedAttributes->{"Optional"} or $param->isVariadic) { - $numMandatoryParams--; - } else { - last; - } - } - if ($numMandatoryParams >= 1) - { - push(@$outputArray, " if (exec->argumentCount() < $numMandatoryParams)\n"); - push(@$outputArray, " return throwVMError(exec, createNotEnoughArgumentsError(exec));\n"); - } -} - -sub GenerateParametersCheck -{ - my $outputArray = shift; - my $function = shift; - my $interface = shift; - my $numParameters = shift; - my $interfaceName = shift; - my $functionImplementationName = shift; - my $svgPropertyType = shift; - my $svgPropertyOrListPropertyType = shift; - my $svgListPropertyType = shift; - - my $argsIndex = 0; - my $hasOptionalArguments = 0; - - my @arguments; - my $functionName; - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - if ($implementedBy) { - AddToImplIncludes("${implementedBy}.h"); - unshift(@arguments, "impl") if !$function->isStatic; - $functionName = "${implementedBy}::${functionImplementationName}"; - } elsif ($function->isStatic) { - $functionName = "${interfaceName}::${functionImplementationName}"; - } elsif ($svgPropertyOrListPropertyType and !$svgListPropertyType) { - $functionName = "podImpl.${functionImplementationName}"; - } else { - $functionName = "impl->${functionImplementationName}"; - } - - if (!$function->signature->extendedAttributes->{"Constructor"}) { - push(@arguments, GenerateCallWith($function->signature->extendedAttributes->{"CallWith"}, \@$outputArray, "JSValue::encode(jsUndefined())", $function)); - } - - $implIncludes{"ExceptionCode.h"} = 1; - $implIncludes{"JSDOMBinding.h"} = 1; - - foreach my $parameter (@{$function->parameters}) { - my $argType = $parameter->type; - - # Optional arguments with [Optional] should generate an early call with fewer arguments. - # Optional arguments with [Optional=...] should not generate the early call. - # Optional Dictionary arguments always considered to have default of empty dictionary. - my $optional = $parameter->extendedAttributes->{"Optional"}; - if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && $argType ne "Dictionary" && !$parameter->extendedAttributes->{"Callback"}) { - # Generate early call if there are enough parameters. - if (!$hasOptionalArguments) { - push(@$outputArray, "\n size_t argsCount = exec->argumentCount();\n"); - $hasOptionalArguments = 1; - } - push(@$outputArray, " if (argsCount <= $argsIndex) {\n"); - - my @optionalCallbackArguments = @arguments; - if (@{$function->raisesExceptions}) { - push @optionalCallbackArguments, "ec"; - } - my $functionString = "$functionName(" . join(", ", @optionalCallbackArguments) . ")"; - GenerateImplementationFunctionCall($function, $functionString, " " x 2, $svgPropertyType, $interfaceName); - push(@$outputArray, " }\n\n"); - } - - my $name = $parameter->name; - - if ($argType eq "XPathNSResolver") { - push(@$outputArray, " RefPtr<XPathNSResolver> customResolver;\n"); - push(@$outputArray, " XPathNSResolver* resolver = toXPathNSResolver(exec->argument($argsIndex));\n"); - push(@$outputArray, " if (!resolver) {\n"); - push(@$outputArray, " customResolver = JSCustomXPathNSResolver::create(exec, exec->argument($argsIndex));\n"); - push(@$outputArray, " if (exec->hadException())\n"); - push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); - push(@$outputArray, " resolver = customResolver.get();\n"); - push(@$outputArray, " }\n"); - } elsif ($parameter->extendedAttributes->{"Callback"}) { - my $callbackClassName = GetCallbackClassName($argType); - $implIncludes{"$callbackClassName.h"} = 1; - if ($optional) { - push(@$outputArray, " RefPtr<$argType> $name;\n"); - push(@$outputArray, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n"); - push(@$outputArray, " if (!exec->argument($argsIndex).isFunction())\n"); - push(@$outputArray, " return throwVMTypeError(exec);\n"); - push(@$outputArray, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); - push(@$outputArray, " }\n"); - } else { - push(@$outputArray, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction())\n"); - push(@$outputArray, " return throwVMTypeError(exec);\n"); - push(@$outputArray, " RefPtr<$argType> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); - } - } elsif ($parameter->extendedAttributes->{"Clamp"}) { - my $nativeValue = "${name}NativeValue"; - push(@$outputArray, " $argType $name = 0;\n"); - push(@$outputArray, " double $nativeValue = exec->argument($argsIndex).toNumber(exec);\n"); - push(@$outputArray, " if (exec->hadException())\n"); - push(@$outputArray, " return JSValue::encode(jsUndefined());\n\n"); - push(@$outputArray, " if (!isnan($nativeValue))\n"); - push(@$outputArray, " $name = clampTo<$argType>($nativeValue);\n\n"); - } elsif ($parameter->isVariadic) { - my $nativeElementType; - if ($argType eq "DOMString") { - $nativeElementType = "String"; - } else { - $nativeElementType = GetNativeType($argType); - if ($nativeElementType =~ />$/) { - $nativeElementType .= " "; - } - } - - if (!IsNativeType($argType)) { - push(@$outputArray, " Vector<$nativeElementType> $name;\n"); - push(@$outputArray, " for (unsigned i = $argsIndex; i < exec->argumentCount(); ++i) {\n"); - push(@$outputArray, " if (!exec->argument(i).inherits(&JS${argType}::s_info))\n"); - push(@$outputArray, " return throwVMTypeError(exec);\n"); - push(@$outputArray, " $name.append(to$argType(exec->argument(i)));\n"); - push(@$outputArray, " }\n") - } else { - push(@$outputArray, " Vector<$nativeElementType> $name = toNativeArguments<$nativeElementType>(exec, $argsIndex);\n"); - # Check if the type conversion succeeded. - push(@$outputArray, " if (exec->hadException())\n"); - push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); - } - - } else { - # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an - # interface type, then if the incoming value does not implement that interface, a TypeError - # is thrown rather than silently passing NULL to the C++ code. - # Per the Web IDL and ECMAScript semantics, incoming values can always be converted to both - # strings and numbers, so do not throw TypeError if the argument is of these types. - if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) { - $implIncludes{"<runtime/Error.h>"} = 1; - - my $argValue = "exec->argument($argsIndex)"; - if (!IsNativeType($argType)) { - push(@$outputArray, " if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(&JS${argType}::s_info))\n"); - push(@$outputArray, " return throwVMTypeError(exec);\n"); - } - } - - my $parameterDefaultPolicy = "DefaultIsUndefined"; - if ($optional and $optional eq "DefaultIsNullString") { - $parameterDefaultPolicy = "DefaultIsNullString"; - } - - push(@$outputArray, " " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(exec, $argsIndex, $parameterDefaultPolicy)") . ");\n"); - - # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. - # But this needs to be done in the bindings, because the type is unsigned and the fact that it - # was negative will be lost by the time we're inside the DOM. - if ($parameter->extendedAttributes->{"IsIndex"}) { - push(@$outputArray, " if ($name < 0) {\n"); - push(@$outputArray, " setDOMException(exec, INDEX_SIZE_ERR);\n"); - push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); - push(@$outputArray, " }\n"); - } - - # Check if the type conversion succeeded. - push(@$outputArray, " if (exec->hadException())\n"); - push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); - - if ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $interfaceName =~ /List$/) { - push(@$outputArray, " if (!$name) {\n"); - push(@$outputArray, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); - push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); - push(@$outputArray, " }\n"); - } - } - - if ($argType eq "NodeFilter") { - push @arguments, "$name.get()"; - } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $interfaceName =~ /List$/) { - push @arguments, "$name->propertyReference()"; - } else { - push @arguments, $name; - } - $argsIndex++; - } - - if (@{$function->raisesExceptions}) { - push @arguments, "ec"; - } - return ("$functionName(" . join(", ", @arguments) . ")", scalar @arguments); -} - -sub GenerateCallbackHeader -{ - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $className = "JS$interfaceName"; - - # - Add default header template and header protection - push(@headerContentHeader, GenerateHeaderContentHeader($interface)); - - $headerIncludes{"ActiveDOMCallback.h"} = 1; - $headerIncludes{"$interfaceName.h"} = 1; - $headerIncludes{"JSCallbackData.h"} = 1; - $headerIncludes{"<wtf/Forward.h>"} = 1; - - push(@headerContent, "\nnamespace WebCore {\n\n"); - push(@headerContent, "class $className : public $interfaceName, public ActiveDOMCallback {\n"); - push(@headerContent, "public:\n"); - - # The static create() method. - push(@headerContent, " static PassRefPtr<$className> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)\n"); - push(@headerContent, " {\n"); - push(@headerContent, " return adoptRef(new $className(callback, globalObject));\n"); - push(@headerContent, " }\n\n"); - - # Destructor - push(@headerContent, " virtual ~$className();\n"); - - # Functions - my $numFunctions = @{$interface->functions}; - if ($numFunctions > 0) { - push(@headerContent, "\n // Functions\n"); - foreach my $function (@{$interface->functions}) { - my @params = @{$function->parameters}; - if (!$function->signature->extendedAttributes->{"Custom"} && - !(GetNativeType($function->signature->type) eq "bool")) { - push(@headerContent, " COMPILE_ASSERT(false)"); - } - - push(@headerContent, " virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "("); - - my @args = (); - foreach my $param (@params) { - push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name); - } - push(@headerContent, join(", ", @args)); - - push(@headerContent, ");\n"); - } - } - - push(@headerContent, "\nprivate:\n"); - - # Constructor - push(@headerContent, " $className(JSC::JSObject* callback, JSDOMGlobalObject*);\n\n"); - - # Private members - push(@headerContent, " JSCallbackData* m_data;\n"); - push(@headerContent, "};\n\n"); - - push(@headerContent, "} // namespace WebCore\n\n"); - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; - push(@headerContent, "#endif\n"); -} - -sub GenerateCallbackImplementation -{ - my ($object, $interface) = @_; - - my $interfaceName = $interface->name; - my $className = "JS$interfaceName"; - - # - Add default header template - push(@implContentHeader, GenerateImplementationContentHeader($interface)); - - $implIncludes{"ScriptExecutionContext.h"} = 1; - $implIncludes{"<runtime/JSLock.h>"} = 1; - - @implContent = (); - - push(@implContent, "\nusing namespace JSC;\n\n"); - push(@implContent, "namespace WebCore {\n\n"); - - # Constructor - push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n"); - push(@implContent, " : ActiveDOMCallback(globalObject->scriptExecutionContext())\n"); - push(@implContent, " , m_data(new JSCallbackData(callback, globalObject))\n"); - push(@implContent, "{\n"); - push(@implContent, "}\n\n"); - - # Destructor - push(@implContent, "${className}::~${className}()\n"); - push(@implContent, "{\n"); - push(@implContent, " ScriptExecutionContext* context = scriptExecutionContext();\n"); - push(@implContent, " // When the context is destroyed, all tasks with a reference to a callback\n"); - push(@implContent, " // should be deleted. So if the context is 0, we are on the context thread.\n"); - push(@implContent, " if (!context || context->isContextThread())\n"); - push(@implContent, " delete m_data;\n"); - push(@implContent, " else\n"); - push(@implContent, " context->postTask(DeleteCallbackDataTask::create(m_data));\n"); - push(@implContent, "#ifndef NDEBUG\n"); - push(@implContent, " m_data = 0;\n"); - push(@implContent, "#endif\n"); - push(@implContent, "}\n"); - - # Functions - my $numFunctions = @{$interface->functions}; - if ($numFunctions > 0) { - push(@implContent, "\n// Functions\n"); - foreach my $function (@{$interface->functions}) { - my @params = @{$function->parameters}; - if ($function->signature->extendedAttributes->{"Custom"} || - !(GetNativeType($function->signature->type) eq "bool")) { - next; - } - - AddIncludesForTypeInImpl($function->signature->type); - push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "("); - - my @args = (); - my @argsCheck = (); - my $thisType = $function->signature->extendedAttributes->{"PassThisToCallback"}; - foreach my $param (@params) { - my $paramName = $param->name; - AddIncludesForTypeInImpl($param->type, 1); - push(@args, GetNativeTypeForCallbacks($param->type) . " " . $paramName); - if ($thisType and $thisType eq $param->type) { - push(@argsCheck, <<END); - ASSERT(${paramName}); - -END - } - } - push(@implContent, join(", ", @args)); - push(@implContent, ")\n"); - - push(@implContent, "{\n"); - push(@implContent, @argsCheck) if @argsCheck; - push(@implContent, " if (!canInvokeCallback())\n"); - push(@implContent, " return true;\n\n"); - push(@implContent, " RefPtr<$className> protect(this);\n\n"); - push(@implContent, " JSLockHolder lock(m_data->globalObject()->globalData());\n\n"); - if (@params) { - push(@implContent, " ExecState* exec = m_data->globalObject()->globalExec();\n"); - } - push(@implContent, " MarkedArgumentBuffer args;\n"); - - foreach my $param (@params) { - my $paramName = $param->name; - if ($param->type eq "DOMString") { - push(@implContent, " args.append(jsStringWithCache(exec, ${paramName}));\n"); - } elsif ($param->type eq "boolean") { - push(@implContent, " args.append(jsBoolean(${paramName}));\n"); - } elsif ($param->type eq "SerializedScriptValue") { - push(@implContent, " args.append($paramName ? $paramName->deserialize(exec, m_data->globalObject(), 0) : jsNull());\n"); - } else { - push(@implContent, " args.append(toJS(exec, m_data->globalObject(), ${paramName}));\n"); - } - } - - push(@implContent, "\n bool raisedException = false;\n"); - if ($thisType) { - foreach my $param (@params) { - next if $param->type ne $thisType; - my $paramName = $param->name; - push(@implContent, <<END); - JSValue js${paramName} = toJS(exec, m_data->globalObject(), ${paramName}); - m_data->invokeCallback(js${paramName}, args, &raisedException); - -END - last; - } - } else { - push(@implContent, " m_data->invokeCallback(args, &raisedException);\n"); - } - push(@implContent, " return !raisedException;\n"); - push(@implContent, "}\n"); - } - } - - push(@implContent, "\n}\n"); - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; -} - -sub GenerateImplementationFunctionCall() -{ - my $function = shift; - my $functionString = shift; - my $indent = shift; - my $svgPropertyType = shift; - my $interfaceName = shift; - - if ($function->signature->type eq "void") { - push(@implContent, $indent . "$functionString;\n"); - push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; - - if ($svgPropertyType and !$function->isStatic) { - if (@{$function->raisesExceptions}) { - push(@implContent, $indent . "if (!ec)\n"); - push(@implContent, $indent . " impl->commitChange();\n"); - } else { - push(@implContent, $indent . "impl->commitChange();\n"); - } - } - - push(@implContent, $indent . "return JSValue::encode(jsUndefined());\n"); - } else { - my $thisObject = $function->isStatic ? 0 : "castedThis"; - push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $interfaceName, $functionString, $thisObject) . ";\n"); - push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; - - if ($codeGenerator->ExtendedAttributeContains($function->signature->extendedAttributes->{"CallWith"}, "ScriptState")) { - push(@implContent, $indent . "if (exec->hadException())\n"); - push(@implContent, $indent . " return JSValue::encode(jsUndefined());\n"); - } - - push(@implContent, $indent . "return JSValue::encode(result);\n"); - } -} - -sub GetNativeTypeFromSignature -{ - my $signature = shift; - my $type = $signature->type; - - if ($type eq "unsigned long" and $signature->extendedAttributes->{"IsIndex"}) { - # Special-case index arguments because we need to check that they aren't < 0. - return "int"; - } - - return GetNativeType($type); -} - -my %nativeType = ( - "CompareHow" => "Range::CompareHow", - "DOMString" => "const String&", - # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>. - "DOMString[]" => "RefPtr<DOMStringList>", - "DOMObject" => "ScriptValue", - "NodeFilter" => "RefPtr<NodeFilter>", - "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", - "IDBKey" => "PassRefPtr<IDBKey>", - "Dictionary" => "Dictionary", - "any" => "ScriptValue", - "boolean" => "bool", - "double" => "double", - "float" => "float", - "short" => "short", - "long" => "int", - "unsigned long" => "unsigned", - "unsigned short" => "unsigned short", - "long long" => "long long", - "unsigned long long" => "unsigned long long", - "MediaQueryListListener" => "RefPtr<MediaQueryListListener>", - "DOMTimeStamp" => "DOMTimeStamp", -); - -sub GetNativeType -{ - my $type = shift; - - my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($type); - return "${svgNativeType}*" if $svgNativeType; - return "RefPtr<DOMStringList>" if $type eq "DOMStringList" or $type eq "DOMString[]"; - return $nativeType{$type} if exists $nativeType{$type}; - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - return "Vector<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">" if $arrayOrSequenceType; - - # For all other types, the native type is a pointer with same type name as the IDL type. - return "${type}*"; -} - -sub GetNativeVectorInnerType -{ - my $arrayOrSequenceType = shift; - - return "String" if $arrayOrSequenceType eq "DOMString"; - return $nativeType{$arrayOrSequenceType} if exists $nativeType{$arrayOrSequenceType}; - return "RefPtr<${arrayOrSequenceType}> "; -} - -sub GetNativeTypeForCallbacks -{ - my $type = shift; - return "SerializedScriptValue*" if $type eq "SerializedScriptValue"; - return "PassRefPtr<DOMStringList>" if $type eq "DOMStringList" or $type eq "DOMString[]"; - - return GetNativeType($type); -} - -sub GetSVGPropertyTypes -{ - my $implType = shift; - - my $svgPropertyType; - my $svgListPropertyType; - my $svgNativeType; - - return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $implType =~ /SVG/; - - $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implType); - return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgNativeType; - - # Append space to avoid compilation errors when using PassRefPtr<$svgNativeType> - $svgNativeType = "$svgNativeType "; - - my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implType); - if ($svgNativeType =~ /SVGPropertyTearOff/) { - $svgPropertyType = $svgWrappedNativeType; - $headerIncludes{"$svgWrappedNativeType.h"} = 1; - $headerIncludes{"SVGAnimatedPropertyTearOff.h"} = 1; - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { - $svgListPropertyType = $svgWrappedNativeType; - $headerIncludes{"$svgWrappedNativeType.h"} = 1; - $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; - } elsif ($svgNativeType =~ /SVGTransformListPropertyTearOff/) { - $svgListPropertyType = $svgWrappedNativeType; - $headerIncludes{"$svgWrappedNativeType.h"} = 1; - $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; - $headerIncludes{"SVGTransformListPropertyTearOff.h"} = 1; - } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) { - $svgListPropertyType = $svgWrappedNativeType; - $headerIncludes{"$svgWrappedNativeType.h"} = 1; - $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; - $headerIncludes{"SVGPathSegListPropertyTearOff.h"} = 1; - } - - return ($svgPropertyType, $svgListPropertyType, $svgNativeType); -} - -sub IsNativeType -{ - my $type = shift; - return exists $nativeType{$type}; -} - -sub JSValueToNative -{ - my $signature = shift; - my $value = shift; - - my $conditional = $signature->extendedAttributes->{"Conditional"}; - my $type = $signature->type; - - return "$value.toBoolean(exec)" if $type eq "boolean"; - return "$value.toNumber(exec)" if $type eq "double"; - return "$value.toFloat(exec)" if $type eq "float"; - return "$value.toInt32(exec)" if $type eq "long" or $type eq "short"; - return "$value.toUInt32(exec)" if $type eq "unsigned long" or $type eq "unsigned short"; - return "static_cast<$type>($value.toInteger(exec))" if $type eq "long long" or $type eq "unsigned long long"; - - return "valueToDate(exec, $value)" if $type eq "Date"; - return "static_cast<Range::CompareHow>($value.toInt32(exec))" if $type eq "CompareHow"; - - if ($type eq "DOMString") { - # FIXME: This implements [TreatNullAs=NullString] and [TreatUndefinedAs=NullString], - # but the Web IDL spec requires [TreatNullAs=EmptyString] and [TreatUndefinedAs=EmptyString]. - if (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") and ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString")) { - return "valueToStringWithUndefinedOrNullCheck(exec, $value)" - } - if (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") or $signature->extendedAttributes->{"Reflect"}) { - return "valueToStringWithNullCheck(exec, $value)" - } - # FIXME: Add the case for 'if ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString"))'. - return "$value.isEmpty() ? String() : $value.toString(exec)->value(exec)"; - } - - if ($type eq "DOMObject" or $type eq "any") { - return "exec->globalData(), $value"; - } - - if ($type eq "NodeFilter") { - AddToImplIncludes("JS$type.h", $conditional); - return "to$type(exec->globalData(), $value)"; - } - - if ($type eq "MediaQueryListListener") { - AddToImplIncludes("MediaQueryListListener.h", $conditional); - return "MediaQueryListListener::create(ScriptValue(exec->globalData(), " . $value ."))"; - } - - if ($type eq "SerializedScriptValue") { - AddToImplIncludes("SerializedScriptValue.h", $conditional); - return "SerializedScriptValue::create(exec, $value, 0, 0)"; - } - - if ($type eq "IDBKey") { - AddToImplIncludes("IDBBindingUtilities.h", $conditional); - AddToImplIncludes("IDBKey.h", $conditional); - return "createIDBKeyFromValue(exec, $value)"; - } - - if ($type eq "Dictionary") { - AddToImplIncludes("Dictionary.h", $conditional); - return "exec, $value"; - } - - if ($type eq "DOMString[]" or $type eq "DOMStringList" ) { - AddToImplIncludes("JSDOMStringList.h", $conditional); - return "toDOMStringList(exec, $value)"; - } - - AddToImplIncludes("HTMLOptionElement.h", $conditional) if $type eq "HTMLOptionElement"; - AddToImplIncludes("Event.h", $conditional) if $type eq "Event"; - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - if ($arrayOrSequenceType) { - if ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { - AddToImplIncludes("JS${arrayOrSequenceType}.h"); - return "(toRefPtrNativeArray<${arrayOrSequenceType}, JS${arrayOrSequenceType}>(exec, $value, &to${arrayOrSequenceType}))"; - } - return "toNativeArray<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">(exec, $value)"; - } - - # Default, assume autogenerated type conversion routines - AddToImplIncludes("JS$type.h", $conditional); - return "to$type($value)"; -} - -sub NativeToJSValue -{ - my $signature = shift; - my $inFunctionCall = shift; - my $interfaceName = shift; - my $value = shift; - my $thisValue = shift; - - my $conditional = $signature->extendedAttributes->{"Conditional"}; - my $type = $signature->type; - - return "jsBoolean($value)" if $type eq "boolean"; - - # Need to check Date type before IsPrimitiveType(). - if ($type eq "Date") { - return "jsDateOrNull(exec, $value)"; - } - - if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) { - $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g; - return "jsNumber(std::max(0, " . $value . "))"; - } - - if ($codeGenerator->IsPrimitiveType($type) or $type eq "DOMTimeStamp") { - return "jsNumber($value)"; - } - - if ($codeGenerator->IsStringType($type)) { - AddToImplIncludes("KURL.h", $conditional); - my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"}; - if (defined $conv) { - return "jsStringOrNull(exec, $value)" if $conv eq "Null"; - return "jsStringOrUndefined(exec, $value)" if $conv eq "Undefined"; - - die "Unknown value for TreatReturnedNullStringAs extended attribute"; - } - AddToImplIncludes("<runtime/JSString.h>", $conditional); - return "jsStringWithCache(exec, $value)"; - } - - my $globalObject; - if ($thisValue) { - $globalObject = "$thisValue->globalObject()"; - } - - if ($type eq "CSSStyleDeclaration") { - AddToImplIncludes("StylePropertySet.h", $conditional); - } - - if ($type eq "NodeList") { - AddToImplIncludes("NameNodeList.h", $conditional); - } - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - if ($arrayOrSequenceType) { - if ($arrayType eq "DOMString") { - AddToImplIncludes("JSDOMStringList.h", $conditional); - AddToImplIncludes("DOMStringList.h", $conditional); - - } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { - AddToImplIncludes("JS${arrayOrSequenceType}.h", $conditional); - AddToImplIncludes("${arrayOrSequenceType}.h", $conditional); - } - AddToImplIncludes("<runtime/JSArray.h>", $conditional); - return "jsArray(exec, $thisValue->globalObject(), $value)"; - } - - if ($type eq "DOMObject" or $type eq "any") { - if ($interfaceName eq "Document") { - AddToImplIncludes("JSCanvasRenderingContext2D.h", $conditional); - } else { - return "($value.hasNoValue() ? jsNull() : $value.jsValue())"; - } - } elsif ($type =~ /SVGPathSeg/) { - AddToImplIncludes("JS$type.h", $conditional); - my $joinedName = $type; - $joinedName =~ s/Abs|Rel//; - AddToImplIncludes("$joinedName.h", $conditional); - } elsif ($type eq "SerializedScriptValue" or $type eq "any") { - AddToImplIncludes("SerializedScriptValue.h", $conditional); - return "$value ? $value->deserialize(exec, castedThis->globalObject(), 0) : jsNull()"; - } elsif ($type eq "MessagePortArray") { - AddToImplIncludes("MessagePort.h", $conditional); - AddToImplIncludes("JSMessagePort.h", $conditional); - AddToImplIncludes("<runtime/JSArray.h>", $conditional); - return "jsArray(exec, $globalObject, *$value)"; - } else { - # Default, include header with same name. - AddToImplIncludes("JS$type.h", $conditional); - if ($codeGenerator->IsTypedArrayType($type)) { - AddToImplIncludes("<wtf/$type.h>", $conditional) if not $codeGenerator->SkipIncludeHeader($type); - } else { - AddToImplIncludes("$type.h", $conditional) if not $codeGenerator->SkipIncludeHeader($type); - } - } - - return $value if $codeGenerator->IsSVGAnimatedType($type); - - if ($signature->extendedAttributes->{"ReturnNewObject"}) { - return "toJSNewlyCreated(exec, $globalObject, WTF::getPtr($value))"; - } - - if ($codeGenerator->IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") { - # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked. - $value = "static_cast<" . GetNativeType($type) . ">($value)"; - } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $interfaceName =~ /List$/) { - my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type); - if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($type) and $inFunctionCall eq 0 and not defined $signature->extendedAttributes->{"Immutable"}) { - my $getter = $value; - $getter =~ s/impl\.//; - $getter =~ s/impl->//; - $getter =~ s/\(\)//; - my $updateMethod = "&${interfaceName}::update" . $codeGenerator->WK_ucfirst($getter); - - my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName); - if ($selfIsTearOffType) { - AddToImplIncludes("SVGStaticPropertyWithParentTearOff.h", $conditional); - $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParentTearOff<$interfaceName, /; - - if ($value =~ /matrix/ and $interfaceName eq "SVGTransform") { - # SVGTransform offers a matrix() method for internal usage that returns an AffineTransform - # and a svgMatrix() method returning a SVGMatrix, used for the bindings. - $value =~ s/matrix/svgMatrix/; - } - - $value = "${tearOffType}::create(castedThis->impl(), $value, $updateMethod)"; - } else { - AddToImplIncludes("SVGStaticPropertyTearOff.h", $conditional); - $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$interfaceName, /; - $value = "${tearOffType}::create(impl, $value, $updateMethod)"; - } - } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { - $value = "${tearOffType}::create(impl, $value)"; - } elsif (not $tearOffType =~ /SVG(Point|PathSeg)List/) { - $value = "${tearOffType}::create($value)"; - } - } - if ($globalObject) { - return "toJS(exec, $globalObject, WTF::getPtr($value))"; - } else { - return "toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), WTF::getPtr($value))"; - } -} - -sub ceilingToPowerOf2 -{ - my ($size) = @_; - - my $powerOf2 = 1; - while ($size > $powerOf2) { - $powerOf2 <<= 1; - } - - return $powerOf2; -} - -# Internal Helper -sub GenerateHashTable -{ - my $object = shift; - - my $name = shift; - my $size = shift; - my $keys = shift; - my $specials = shift; - my $value1 = shift; - my $value2 = shift; - my $conditionals = shift; - - # Generate size data for compact' size hash table - - my @table = (); - my @links = (); - - my $compactSize = ceilingToPowerOf2($size * 2); - - my $maxDepth = 0; - my $collisions = 0; - my $numEntries = $compactSize; - - my $i = 0; - foreach (@{$keys}) { - my $depth = 0; - my $h = $object->GenerateHashValue($_) % $numEntries; - - while (defined($table[$h])) { - if (defined($links[$h])) { - $h = $links[$h]; - $depth++; - } else { - $collisions++; - $links[$h] = $compactSize; - $h = $compactSize; - $compactSize++; - } - } - - $table[$h] = $i; - - $i++; - $maxDepth = $depth if ($depth > $maxDepth); - } - - # Start outputing the hashtables - my $nameEntries = "${name}Values"; - $nameEntries =~ s/:/_/g; - - if (($name =~ /Prototype/) or ($name =~ /Constructor/)) { - my $type = $name; - my $implClass; - - if ($name =~ /Prototype/) { - $type =~ s/Prototype.*//; - $implClass = $type; $implClass =~ s/Wrapper$//; - push(@implContent, "/* Hash table for prototype */\n"); - } else { - $type =~ s/Constructor.*//; - $implClass = $type; $implClass =~ s/Constructor$//; - push(@implContent, "/* Hash table for constructor */\n"); - } - } else { - push(@implContent, "/* Hash table */\n"); - } - - # Dump the hash table - push(@implContent, "\nstatic const HashTableValue $nameEntries\[\] =\n\{\n"); - $i = 0; - foreach my $key (@{$keys}) { - my $conditional; - my $targetType; - - if ($conditionals) { - $conditional = $conditionals->{$key}; - } - if ($conditional) { - my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - push(@implContent, "#if ${conditionalString}\n"); - } - - if ("@$specials[$i]" =~ m/Function/) { - $targetType = "static_cast<NativeFunction>"; - } else { - $targetType = "static_cast<PropertySlot::GetValueFunc>"; - } - push(@implContent, " { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i], NoIntrinsic },\n"); - push(@implContent, "#endif\n") if $conditional; - ++$i; - } - push(@implContent, " { 0, 0, 0, 0, NoIntrinsic }\n"); - push(@implContent, "};\n\n"); - my $compactSizeMask = $numEntries - 1; - push(@implContent, "static const HashTable $name = { $compactSize, $compactSizeMask, $nameEntries, 0 };\n"); -} - -# Paul Hsieh's SuperFastHash -# http://www.azillionmonkeys.com/qed/hash.html -sub GenerateHashValue -{ - my $object = shift; - - my @chars = split(/ */, $_[0]); - - # This hash is designed to work on 16-bit chunks at a time. But since the normal case - # (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they - # were 16-bit chunks, which should give matching results - - my $EXP2_32 = 4294967296; - - my $hash = 0x9e3779b9; - my $l = scalar @chars; #I wish this was in Ruby --- Maks - my $rem = $l & 1; - $l = $l >> 1; - - my $s = 0; - - # Main loop - for (; $l > 0; $l--) { - $hash += ord($chars[$s]); - my $tmp = leftShift(ord($chars[$s+1]), 11) ^ $hash; - $hash = (leftShift($hash, 16)% $EXP2_32) ^ $tmp; - $s += 2; - $hash += $hash >> 11; - $hash %= $EXP2_32; - } - - # Handle end case - if ($rem != 0) { - $hash += ord($chars[$s]); - $hash ^= (leftShift($hash, 11)% $EXP2_32); - $hash += $hash >> 17; - } - - # Force "avalanching" of final 127 bits - $hash ^= leftShift($hash, 3); - $hash += ($hash >> 5); - $hash = ($hash% $EXP2_32); - $hash ^= (leftShift($hash, 2)% $EXP2_32); - $hash += ($hash >> 15); - $hash = $hash% $EXP2_32; - $hash ^= (leftShift($hash, 10)% $EXP2_32); - - # Save 8 bits for StringImpl to use as flags. - $hash &= 0xffffff; - - # This avoids ever returning a hash code of 0, since that is used to - # signal "hash not computed yet". Setting the high bit maintains - # reasonable fidelity to a hash code of 0 because it is likely to yield - # exactly 0 when hash lookup masks out the high bits. - $hash = (0x80000000 >> 8) if ($hash == 0); - - return $hash; -} - -sub WriteData -{ - my $object = shift; - my $interface = shift; - my $outputDir = shift; - - my $name = $interface->name; - my $prefix = FileNamePrefix; - my $headerFileName = "$outputDir/$prefix$name.h"; - my $implFileName = "$outputDir/$prefix$name.cpp"; - my $depsFileName = "$outputDir/$prefix$name.dep"; - - # Update a .cpp file if the contents are changed. - my $contents = join "", @implContentHeader; - - my @includes = (); - my %implIncludeConditions = (); - foreach my $include (keys %implIncludes) { - my $condition = $implIncludes{$include}; - my $checkType = $include; - $checkType =~ s/\.h//; - next if $codeGenerator->IsSVGAnimatedType($checkType); - - $include = "\"$include\"" unless $include =~ /^["<]/; # " - - if ($condition eq 1) { - push @includes, $include; - } else { - push @{$implIncludeConditions{$condition}}, $include; - } - } - foreach my $include (sort @includes) { - $contents .= "#include $include\n"; - } - foreach my $condition (sort keys %implIncludeConditions) { - $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n"; - foreach my $include (sort @{$implIncludeConditions{$condition}}) { - $contents .= "#include $include\n"; - } - $contents .= "#endif\n"; - } - - $contents .= join "", @implContent; - $codeGenerator->UpdateFile($implFileName, $contents); - - @implContentHeader = (); - @implContent = (); - %implIncludes = (); - - # Update a .h file if the contents are changed. - $contents = join "", @headerContentHeader; - - @includes = (); - foreach my $include (keys %headerIncludes) { - $include = "\"$include\"" unless $include =~ /^["<]/; # " - push @includes, $include; - } - foreach my $include (sort @includes) { - $contents .= "#include $include\n"; - } - - $contents .= join "", @headerContent; - - @includes = (); - foreach my $include (keys %headerTrailingIncludes) { - $include = "\"$include\"" unless $include =~ /^["<]/; # " - push @includes, $include; - } - foreach my $include (sort @includes) { - $contents .= "#include $include\n"; - } - $codeGenerator->UpdateFile($headerFileName, $contents); - - @headerContentHeader = (); - @headerContent = (); - %headerIncludes = (); - %headerTrailingIncludes = (); - - if (@depsContent) { - # Update a .dep file if the contents are changed. - $contents = join "", @depsContent; - $codeGenerator->UpdateFile($depsFileName, $contents); - - @depsContent = (); - } -} - -sub GenerateConstructorDeclaration -{ - my $outputArray = shift; - my $className = shift; - my $interface = shift; - my $interfaceName = shift; - - my $constructorClassName = "${className}Constructor"; - - push(@$outputArray, "class ${constructorClassName} : public DOMConstructorObject {\n"); - push(@$outputArray, "private:\n"); - push(@$outputArray, " ${constructorClassName}(JSC::Structure*, JSDOMGlobalObject*);\n"); - push(@$outputArray, " void finishCreation(JSC::ExecState*, JSDOMGlobalObject*);\n\n"); - - push(@$outputArray, "public:\n"); - push(@$outputArray, " typedef DOMConstructorObject Base;\n"); - push(@$outputArray, " static $constructorClassName* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)\n"); - push(@$outputArray, " {\n"); - push(@$outputArray, " $constructorClassName* ptr = new (NotNull, JSC::allocateCell<$constructorClassName>(*exec->heap())) $constructorClassName(structure, globalObject);\n"); - push(@$outputArray, " ptr->finishCreation(exec, globalObject);\n"); - push(@$outputArray, " return ptr;\n"); - push(@$outputArray, " }\n\n"); - - push(@$outputArray, " static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);\n"); - push(@$outputArray, " static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);\n"); - push(@$outputArray, " static const JSC::ClassInfo s_info;\n"); - - push(@$outputArray, " static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n"); - push(@$outputArray, " {\n"); - push(@$outputArray, " return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);\n"); - push(@$outputArray, " }\n"); - - push(@$outputArray, "protected:\n"); - push(@$outputArray, " static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;\n"); - - if (IsConstructable($interface) && !$interface->extendedAttributes->{"NamedConstructor"}) { - push(@$outputArray, " static JSC::EncodedJSValue JSC_HOST_CALL construct${className}(JSC::ExecState*);\n"); - - if (!HasCustomConstructor($interface)) { - my @constructors = @{$interface->constructors}; - if (@constructors > 1) { - foreach my $constructor (@constructors) { - my $overloadedIndex = "" . $constructor->{overloadedIndex}; - push(@$outputArray, " static JSC::EncodedJSValue JSC_HOST_CALL construct${className}${overloadedIndex}(JSC::ExecState*);\n"); - } - } - } - - push(@$outputArray, " static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);\n"); - } - push(@$outputArray, "};\n\n"); - - if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { - push(@$outputArray, "bool fill${interfaceName}Init(${interfaceName}Init&, JSDictionary&);\n\n"); - } - - if ($interface->extendedAttributes->{"NamedConstructor"}) { - push(@$outputArray, <<END); -class JS${interfaceName}NamedConstructor : public DOMConstructorWithDocument { -public: - typedef DOMConstructorWithDocument Base; - - static JS${interfaceName}NamedConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) - { - JS${interfaceName}NamedConstructor* constructor = new (NotNull, JSC::allocateCell<JS${interfaceName}NamedConstructor>(*exec->heap())) JS${interfaceName}NamedConstructor(structure, globalObject); - constructor->finishCreation(exec, globalObject); - return constructor; - } - - static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); - } - - static const JSC::ClassInfo s_info; - -private: - JS${interfaceName}NamedConstructor(JSC::Structure*, JSDOMGlobalObject*); - static JSC::EncodedJSValue JSC_HOST_CALL constructJS${interfaceName}(JSC::ExecState*); - static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); -}; - -END - } -} - -sub GenerateConstructorDefinitions -{ - my $outputArray = shift; - my $className = shift; - my $protoClassName = shift; - my $interfaceName = shift; - my $visibleInterfaceName = shift; - my $interface = shift; - my $generatingNamedConstructor = shift; - - if (IsConstructable($interface)) { - my @constructors = @{$interface->constructors}; - if (@constructors > 1) { - foreach my $constructor (@constructors) { - GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $constructor); - } - GenerateOverloadedConstructorDefinition($outputArray, $className, $interface); - } elsif (@constructors == 1) { - GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $constructors[0]); - } else { - GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor); - } - } - - GenerateConstructorHelperMethods($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor); -} - -sub GenerateOverloadedConstructorDefinition -{ - my $outputArray = shift; - my $className = shift; - my $interface = shift; - - my $functionName = "${className}Constructor::construct${className}"; - push(@$outputArray, <<END); -EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec) -{ - size_t argsCount = exec->argumentCount(); -END - - my %fetchedArguments = (); - my $leastNumMandatoryParams = 255; - - my @constructors = @{$interface->constructors}; - foreach my $overload (@constructors) { - my ($numMandatoryParams, $parametersCheck, @neededArguments) = GenerateFunctionParametersCheck($overload); - $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); - - foreach my $parameterIndex (@neededArguments) { - next if exists $fetchedArguments{$parameterIndex}; - push(@$outputArray, " JSValue arg$parameterIndex(exec->argument($parameterIndex));\n"); - $fetchedArguments{$parameterIndex} = 1; - } - - push(@$outputArray, " if ($parametersCheck)\n"); - push(@$outputArray, " return ${functionName}$overload->{overloadedIndex}(exec);\n"); - } - - if ($leastNumMandatoryParams >= 1) { - push(@$outputArray, " if (argsCount < $leastNumMandatoryParams)\n"); - push(@$outputArray, " return throwVMError(exec, createNotEnoughArgumentsError(exec));\n"); - } - push(@$outputArray, <<END); - return throwVMTypeError(exec); -} - -END -} - -sub GenerateConstructorDefinition -{ - my $outputArray = shift; - my $className = shift; - my $protoClassName = shift; - my $interfaceName = shift; - my $visibleInterfaceName = shift; - my $interface = shift; - my $generatingNamedConstructor = shift; - my $function = shift; - - my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor"; - - if (IsConstructable($interface)) { - if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { - $implIncludes{"JSDictionary.h"} = 1; - $implIncludes{"<runtime/Error.h>"} = 1; - - push(@$outputArray, <<END); -EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec) -{ - ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee()); - - ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext(); - if (!executionContext) - return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable")); - - AtomicString eventType = exec->argument(0).toString(exec)->value(exec); - if (exec->hadException()) - return JSValue::encode(jsUndefined()); - - ${interfaceName}Init eventInit; - - JSValue initializerValue = exec->argument(1); - if (!initializerValue.isUndefinedOrNull()) { - // Given the above test, this will always yield an object. - JSObject* initializerObject = initializerValue.toObject(exec); - - // Create the dictionary wrapper from the initializer object. - JSDictionary dictionary(exec, initializerObject); - - // Attempt to fill in the EventInit. - if (!fill${interfaceName}Init(eventInit, dictionary)) - return JSValue::encode(jsUndefined()); - } - - RefPtr<${interfaceName}> event = ${interfaceName}::create(eventType, eventInit); - return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get())); -} - -bool fill${interfaceName}Init(${interfaceName}Init& eventInit, JSDictionary& dictionary) -{ -END - - foreach my $interfaceBase (@{$interface->parents}) { - push(@implContent, <<END); - if (!fill${interfaceBase}Init(eventInit, dictionary)) - return false; - -END - } - - for (my $index = 0; $index < @{$interface->attributes}; $index++) { - my $attribute = @{$interface->attributes}[$index]; - if ($attribute->signature->extendedAttributes->{"InitializedByEventConstructor"}) { - my $attributeName = $attribute->signature->name; - push(@implContent, <<END); - if (!dictionary.tryGetProperty("${attributeName}", eventInit.${attributeName})) - return false; -END - } - } - - push(@$outputArray, <<END); - return true; -} - -END - } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray")) { - $implIncludes{"JSArrayBufferViewHelper.h"} = 1; - my $viewType = $interface->extendedAttributes->{"TypedArray"}; - push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee());\n"); - push(@$outputArray, " RefPtr<$interfaceName> array = constructArrayBufferView<$interfaceName, $viewType>(exec);\n"); - push(@$outputArray, " if (!array.get())\n"); - push(@$outputArray, " // Exception has already been thrown.\n"); - push(@$outputArray, " return JSValue::encode(JSValue());\n"); - push(@$outputArray, " return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));\n"); - push(@$outputArray, "}\n\n"); - - push(@$outputArray, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ${interfaceName}* object)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " return toJSArrayBufferView<${className}>(exec, globalObject, object);\n"); - push(@$outputArray, "}\n\n"); - - if ($interface->extendedAttributes->{"CustomIndexedSetter"}) { - push(@$outputArray, "void ${className}::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " impl()->set(index, value.toNumber(exec));\n"); - push(@$outputArray, "}\n\n"); - } - } elsif (!HasCustomConstructor($interface) && (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor)) { - my $overloadedIndexString = ""; - if ($function->{overloadedIndex} && $function->{overloadedIndex} > 0) { - $overloadedIndexString .= $function->{overloadedIndex}; - } - - push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}${overloadedIndexString}(ExecState* exec)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " ${constructorClassName}* castedThis = jsCast<${constructorClassName}*>(exec->callee());\n"); - - my @constructorArgList; - - $implIncludes{"<runtime/Error.h>"} = 1; - - GenerateArgumentsCountCheck($outputArray, $function, $interface); - - if (@{$function->raisesExceptions} || $interface->extendedAttributes->{"ConstructorRaisesException"}) { - $implIncludes{"ExceptionCode.h"} = 1; - push(@$outputArray, " ExceptionCode ec = 0;\n"); - } - - # FIXME: For now, we do not support SVG constructors. - # FIXME: Currently [Constructor(...)] does not yet support [Optional] arguments. - # It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString]. - my $numParameters = @{$function->parameters}; - my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $interface, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef); - - if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"CallWith"}, "ScriptExecutionContext")) { - push(@constructorArgList, "context"); - push(@$outputArray, " ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n"); - push(@$outputArray, " if (!context)\n"); - push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n"); - } - if ($generatingNamedConstructor) { - push(@constructorArgList, "castedThis->document()"); - } - - my $index = 0; - foreach my $parameter (@{$function->parameters}) { - last if $index eq $paramIndex; - push(@constructorArgList, $parameter->name); - $index++; - } - - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - push(@constructorArgList, "ec"); - } - my $constructorArg = join(", ", @constructorArgList); - if ($generatingNamedConstructor) { - push(@$outputArray, " RefPtr<${interfaceName}> object = ${interfaceName}::createForJSConstructor(${constructorArg});\n"); - } else { - push(@$outputArray, " RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n"); - } - - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - push(@$outputArray, " if (ec) {\n"); - push(@$outputArray, " setDOMException(exec, ec);\n"); - push(@$outputArray, " return JSValue::encode(JSValue());\n"); - push(@$outputArray, " }\n"); - } - - push(@$outputArray, " return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));\n"); - push(@$outputArray, "}\n\n"); - } - } -} - -sub GenerateConstructorHelperMethods -{ - my $outputArray = shift; - my $className = shift; - my $protoClassName = shift; - my $interfaceName = shift; - my $visibleInterfaceName = shift; - my $interface = shift; - my $generatingNamedConstructor = shift; - - my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor"; - my $numberOfConstructorParameters = $interface->extendedAttributes->{"ConstructorParameters"}; - if (!defined $numberOfConstructorParameters) { - if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { - $numberOfConstructorParameters = 2; - } elsif ($interface->extendedAttributes->{"Constructor"}) { - my @constructors = @{$interface->constructors}; - $numberOfConstructorParameters = 255; - foreach my $constructor (@constructors) { - my $currNumberOfParameters = @{$constructor->parameters}; - if ($currNumberOfParameters < $numberOfConstructorParameters) { - $numberOfConstructorParameters = $currNumberOfParameters; - } - } - } - } - - if ($generatingNamedConstructor) { - push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleInterfaceName}Constructor\", &Base::s_info, 0, 0, CREATE_METHOD_TABLE($constructorClassName) };\n\n"); - push(@$outputArray, "${constructorClassName}::${constructorClassName}(Structure* structure, JSDOMGlobalObject* globalObject)\n"); - push(@$outputArray, " : DOMConstructorWithDocument(structure, globalObject)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, "}\n\n"); - } else { - if ($interface->extendedAttributes->{"JSNoStaticTables"}) { - push(@$outputArray, "static const HashTable* get${constructorClassName}Table(ExecState* exec)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " return getHashTableForGlobalData(exec->globalData(), &${constructorClassName}Table);\n"); - push(@$outputArray, "}\n\n"); - push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleInterfaceName}Constructor\", &Base::s_info, 0, get${constructorClassName}Table, CREATE_METHOD_TABLE($constructorClassName) };\n\n"); - } else { - push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleInterfaceName}Constructor\", &Base::s_info, &${constructorClassName}Table, 0, CREATE_METHOD_TABLE($constructorClassName) };\n\n"); - } - - push(@$outputArray, "${constructorClassName}::${constructorClassName}(Structure* structure, JSDOMGlobalObject* globalObject)\n"); - push(@$outputArray, " : DOMConstructorObject(structure, globalObject)\n"); - push(@$outputArray, "{\n}\n\n"); - } - - push(@$outputArray, "void ${constructorClassName}::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)\n"); - push(@$outputArray, "{\n"); - if ($interfaceName eq "DOMWindow") { - push(@$outputArray, " Base::finishCreation(exec->globalData());\n"); - push(@$outputArray, " ASSERT(inherits(&s_info));\n"); - push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().prototype, globalObject->prototype(), DontDelete | ReadOnly);\n"); - } elsif ($generatingNamedConstructor) { - push(@$outputArray, " Base::finishCreation(globalObject);\n"); - push(@$outputArray, " ASSERT(inherits(&s_info));\n"); - push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().prototype, ${className}Prototype::self(exec, globalObject), None);\n"); - } else { - push(@$outputArray, " Base::finishCreation(exec->globalData());\n"); - push(@$outputArray, " ASSERT(inherits(&s_info));\n"); - push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), DontDelete | ReadOnly);\n"); - } - push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(${numberOfConstructorParameters}), ReadOnly | DontDelete | DontEnum);\n") if defined $numberOfConstructorParameters; - push(@$outputArray, "}\n\n"); - - if (!$generatingNamedConstructor) { - my $hasStaticFunctions = 0; - foreach my $function (@{$interface->functions}) { - if ($function->isStatic) { - $hasStaticFunctions = 1; - last; - } - } - - my $kind = $hasStaticFunctions ? "Property" : "Value"; - - push(@$outputArray, "bool ${constructorClassName}::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " return getStatic${kind}Slot<${constructorClassName}, JSDOMWrapper>(exec, " . constructorHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $constructorClassName) . ", jsCast<${constructorClassName}*>(cell), propertyName, slot);\n"); - push(@$outputArray, "}\n\n"); - - push(@$outputArray, "bool ${constructorClassName}::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " return getStatic${kind}Descriptor<${constructorClassName}, JSDOMWrapper>(exec, " . constructorHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $constructorClassName) . ", jsCast<${constructorClassName}*>(object), propertyName, descriptor);\n"); - push(@$outputArray, "}\n\n"); - } - - if (IsConstructable($interface)) { - if (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor) { - push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(JSCell*, ConstructData& constructData)\n"); - push(@$outputArray, "{\n"); - push(@$outputArray, " constructData.native.function = construct${className};\n"); - push(@$outputArray, " return ConstructTypeHost;\n"); - push(@$outputArray, "}\n\n"); - } - } -} - -sub HasCustomConstructor -{ - my $interface = shift; - - return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"JSCustomConstructor"}; -} - -sub IsConstructable -{ - my $interface = shift; - - return HasCustomConstructor($interface) || $interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"NamedConstructor"} || $interface->extendedAttributes->{"ConstructorTemplate"}; -} - -1; diff --git a/contrib/dom/scripts/CodeGeneratorObjC.pm b/contrib/dom/scripts/CodeGeneratorObjC.pm deleted file mode 100644 index cf0c2c5..0000000 --- a/contrib/dom/scripts/CodeGeneratorObjC.pm +++ /dev/null @@ -1,1820 +0,0 @@ -# -# Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> -# Copyright (C) 2006 Anders Carlsson <andersca@mac.com> -# Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> -# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> -# Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. -# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> -# Copyright (C) 2010 Google Inc. -# Copyright (C) Research In Motion Limited 2010. All rights reserved. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# - -package CodeGeneratorObjC; - -use constant FileNamePrefix => "DOM"; - -# Global Variables -my $writeDependencies = 0; -my %publicInterfaces = (); -my $newPublicClass = 0; -my $interfaceAvailabilityVersion = ""; -my $isProtocol = 0; -my $noImpl = 0; - -my @headerContentHeader = (); -my @headerContent = (); -my %headerForwardDeclarations = (); -my %headerForwardDeclarationsForProtocols = (); - -my @privateHeaderContentHeader = (); -my @privateHeaderContent = (); -my %privateHeaderForwardDeclarations = (); -my %privateHeaderForwardDeclarationsForProtocols = (); - -my @internalHeaderContent = (); - -my @implContentHeader = (); -my @implContent = (); -my %implIncludes = (); -my @depsContent = (); - -# Hashes -my %protocolTypeHash = ("XPathNSResolver" => 1, "EventListener" => 1, "EventTarget" => 1, "NodeFilter" => 1, - "SVGLocatable" => 1, "SVGTransformable" => 1, "SVGStylable" => 1, "SVGFilterPrimitiveStandardAttributes" => 1, - "SVGTests" => 1, "SVGLangSpace" => 1, "SVGExternalResourcesRequired" => 1, "SVGURIReference" => 1, - "SVGZoomAndPan" => 1, "SVGFitToViewBox" => 1, "SVGAnimatedPathData" => 1, "ElementTimeControl" => 1); -my %nativeObjCTypeHash = ("URL" => 1, "Color" => 1); - -# FIXME: this should be replaced with a function that recurses up the tree -# to find the actual base type. -my %baseTypeHash = ("Object" => 1, "Node" => 1, "NodeList" => 1, "NamedNodeMap" => 1, "DOMImplementation" => 1, - "Event" => 1, "CSSRule" => 1, "CSSValue" => 1, "StyleSheet" => 1, "MediaList" => 1, - "Counter" => 1, "Rect" => 1, "RGBColor" => 1, "XPathExpression" => 1, "XPathResult" => 1, - "NodeIterator" => 1, "TreeWalker" => 1, "AbstractView" => 1, "Blob" => 1, - "SVGAngle" => 1, "SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, "SVGAnimatedEnumeration" => 1, - "SVGAnimatedInteger" => 1, "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1, - "SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1, - "SVGAnimatedPreserveAspectRatio" => 1, "SVGAnimatedRect" => 1, "SVGAnimatedString" => 1, - "SVGAnimatedTransformList" => 1, "SVGLength" => 1, "SVGLengthList" => 1, "SVGMatrix" => 1, - "SVGNumber" => 1, "SVGNumberList" => 1, "SVGPathSeg" => 1, "SVGPathSegList" => 1, "SVGPoint" => 1, - "SVGPointList" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1, "SVGRenderingIntent" => 1, - "SVGStringList" => 1, "SVGTransform" => 1, "SVGTransformList" => 1, "SVGUnitTypes" => 1); - -# Constants -my $exceptionInit = "WebCore::ExceptionCode ec = 0;"; -my $jsContextSetter = "WebCore::JSMainThreadNullState state;"; -my $exceptionRaiseOnError = "WebCore::raiseOnDOMError(ec);"; -my $assertMainThread = "{ DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }"; - -my %conflictMethod = ( - # FIXME: Add C language keywords? - # FIXME: Add other predefined types like "id"? - - "callWebScriptMethod:withArguments:" => "WebScriptObject", - "evaluateWebScript:" => "WebScriptObject", - "removeWebScriptKey:" => "WebScriptObject", - "setException:" => "WebScriptObject", - "setWebScriptValueAtIndex:value:" => "WebScriptObject", - "stringRepresentation" => "WebScriptObject", - "webScriptValueAtIndex:" => "WebScriptObject", - - "autorelease" => "NSObject", - "awakeAfterUsingCoder:" => "NSObject", - "class" => "NSObject", - "classForCoder" => "NSObject", - "conformsToProtocol:" => "NSObject", - "copy" => "NSObject", - "copyWithZone:" => "NSObject", - "dealloc" => "NSObject", - "description" => "NSObject", - "doesNotRecognizeSelector:" => "NSObject", - "encodeWithCoder:" => "NSObject", - "finalize" => "NSObject", - "forwardInvocation:" => "NSObject", - "hash" => "NSObject", - "init" => "NSObject", - "initWithCoder:" => "NSObject", - "isEqual:" => "NSObject", - "isKindOfClass:" => "NSObject", - "isMemberOfClass:" => "NSObject", - "isProxy" => "NSObject", - "methodForSelector:" => "NSObject", - "methodSignatureForSelector:" => "NSObject", - "mutableCopy" => "NSObject", - "mutableCopyWithZone:" => "NSObject", - "performSelector:" => "NSObject", - "release" => "NSObject", - "replacementObjectForCoder:" => "NSObject", - "respondsToSelector:" => "NSObject", - "retain" => "NSObject", - "retainCount" => "NSObject", - "self" => "NSObject", - "superclass" => "NSObject", - "zone" => "NSObject", -); - -my $fatalError = 0; - -# Default License Templates -my $headerLicenseTemplate = << "EOF"; -/* - * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig\@gmail.com> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -EOF - -my $implementationLicenseTemplate = << "EOF"; -/* - * This file is part of the WebKit open source project. - * This file has been generated by generate-bindings.pl. DO NOT MODIFY! - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -EOF - -# Default constructor -sub new -{ - my $object = shift; - my $reference = { }; - - $codeGenerator = shift; - shift; # $useLayerOnTop - shift; # $preprocessor - $writeDependencies = shift; - - bless($reference, $object); - return $reference; -} - -sub ReadPublicInterfaces -{ - my $class = shift; - my $superClass = shift; - my $defines = shift; - my $isProtocol = shift; - - my $found = 0; - my $actualSuperClass; - %publicInterfaces = (); - - my $fileName = "WebCore/bindings/objc/PublicDOMInterfaces.h"; - my $gccLocation = ""; - if ($ENV{CC}) { - $gccLocation = $ENV{CC}; - } elsif (($Config::Config{'osname'}) =~ /solaris/i) { - $gccLocation = "/usr/sfw/bin/gcc"; - } else { - $gccLocation = "/usr/bin/gcc"; - } - open FILE, "-|", $gccLocation, "-E", "-P", "-x", "objective-c", - (map { "-D$_" } split(/ +/, $defines)), "-DOBJC_CODE_GENERATION", $fileName or die "Could not open $fileName"; - my @documentContent = <FILE>; - close FILE; - - foreach $line (@documentContent) { - if (!$isProtocol && $line =~ /^\s*\@interface\s*$class\s*:\s*(\w+)\s*([A-Z0-9_]*)/) { - if ($superClass ne $1) { - warn "Public API change. Superclass for \"$class\" differs ($1 != $superClass)"; - $fatalError = 1; - } - - $interfaceAvailabilityVersion = $2 if defined $2; - $found = 1; - next; - } elsif ($isProtocol && $line =~ /^\s*\@protocol $class\s*<[^>]+>\s*([A-Z0-9_]*)/) { - $interfaceAvailabilityVersion = $1 if defined $1; - $found = 1; - next; - } - - last if $found and $line =~ /^\s?\@end\s?$/; - - if ($found) { - # trim whitspace - $line =~ s/^\s+//; - $line =~ s/\s+$//; - - my $availabilityMacro = ""; - $line =~ s/\s([A-Z0-9_]+)\s*;$/;/; - $availabilityMacro = $1 if defined $1; - - $publicInterfaces{$line} = $availabilityMacro if length $line; - } - } - - # If this class was not found in PublicDOMInterfaces.h then it should be considered as an entirely new public class. - $newPublicClass = !$found; - $interfaceAvailabilityVersion = "WEBKIT_VERSION_LATEST" if $newPublicClass; -} - -sub GenerateInterface -{ - my $object = shift; - my $interface = shift; - my $defines = shift; - - $fatalError = 0; - - my $name = $interface->name; - my $className = GetClassName($name); - my $parentClassName = "DOM" . GetParentImplClassName($interface); - $isProtocol = $interface->extendedAttributes->{ObjCProtocol}; - $noImpl = $interface->extendedAttributes->{ObjCCustomImplementation} || $isProtocol; - - ReadPublicInterfaces($className, $parentClassName, $defines, $isProtocol); - - # Start actual generation.. - $object->GenerateHeader($interface); - $object->GenerateImplementation($interface) unless $noImpl; - - # Check for missing public API - if (keys %publicInterfaces > 0) { - my $missing = join("\n", keys %publicInterfaces); - warn "Public API change. There are missing public properties and/or methods from the \"$className\" class.\n$missing\n"; - $fatalError = 1; - } - - die if $fatalError; -} - -sub GetClassName -{ - my $name = shift; - - # special cases - return "NSString" if $codeGenerator->IsStringType($name) or $name eq "SerializedScriptValue"; - return "NS$name" if IsNativeObjCType($name); - return "BOOL" if $name eq "boolean"; - return "unsigned" if $name eq "unsigned long"; - return "int" if $name eq "long"; - return "NSTimeInterval" if $name eq "Date"; - return "DOMAbstractView" if $name eq "DOMWindow"; - return $name if $codeGenerator->IsPrimitiveType($name) or $name eq "DOMImplementation" or $name eq "DOMTimeStamp"; - - # Default, assume Objective-C type has the same type name as - # idl type prefixed with "DOM". - return "DOM$name"; -} - -sub GetClassHeaderName -{ - my $name = shift; - - return "DOMDOMImplementation" if $name eq "DOMImplementation"; - return $name; -} - -sub GetImplClassName -{ - my $name = shift; - - return "DOMImplementationFront" if $name eq "DOMImplementation"; - return "DOMWindow" if $name eq "AbstractView"; - return $name; -} - -sub GetParentImplClassName -{ - my $interface = shift; - - return "Object" if @{$interface->parents} eq 0; - - my $parent = $interface->parents(0); - - # special cases - return "Object" if $parent eq "HTMLCollection"; - - return $parent; -} - -sub GetParentAndProtocols -{ - my $interface = shift; - my $numParents = @{$interface->parents}; - - my $parent = ""; - my @protocols = (); - if ($numParents eq 0) { - if ($isProtocol) { - push(@protocols, "NSObject"); - push(@protocols, "NSCopying") if $interface->name eq "EventTarget"; - } else { - $parent = "DOMObject"; - } - } elsif ($numParents eq 1) { - my $parentName = $interface->parents(0); - if ($isProtocol) { - die "Parents of protocols must also be protocols." unless IsProtocolType($parentName); - push(@protocols, "DOM" . $parentName); - } else { - if (IsProtocolType($parentName)) { - push(@protocols, "DOM" . $parentName); - } elsif ($parentName eq "HTMLCollection") { - $parent = "DOMObject"; - } else { - $parent = "DOM" . $parentName; - } - } - } else { - my @parents = @{$interface->parents}; - my $firstParent = shift(@parents); - if (IsProtocolType($firstParent)) { - push(@protocols, "DOM" . $firstParent); - if (!$isProtocol) { - $parent = "DOMObject"; - } - } else { - $parent = "DOM" . $firstParent; - } - - foreach my $parentName (@parents) { - die "Everything past the first class should be a protocol!" unless IsProtocolType($parentName); - - push(@protocols, "DOM" . $parentName); - } - } - - return ($parent, @protocols); -} - -sub GetBaseClass -{ - $parent = shift; - - return $parent if $parent eq "Object" or IsBaseType($parent); - return "Event" if $parent eq "UIEvent" or $parent eq "MouseEvent"; - return "CSSValue" if $parent eq "SVGColor" or $parent eq "CSSValueList"; - return "Node"; -} - -sub IsBaseType -{ - my $type = shift; - - return 1 if $baseTypeHash{$type}; - return 0; -} - -sub IsProtocolType -{ - my $type = shift; - - return 1 if $protocolTypeHash{$type}; - return 0; -} - -sub IsNativeObjCType -{ - my $type = shift; - - return 1 if $nativeObjCTypeHash{$type}; - return 0; -} - -sub SkipFunction -{ - my $function = shift; - - return 1 if $codeGenerator->GetSequenceType($function->signature->type); - return 1 if $codeGenerator->GetArrayType($function->signature->type); - - foreach my $param (@{$function->parameters}) { - return 1 if $codeGenerator->GetSequenceType($param->type); - return 1 if $codeGenerator->GetArrayType($param->type); - return 1 if $param->extendedAttributes->{"Clamp"}; - } - - return 0; -} - -sub SkipAttribute -{ - my $attribute = shift; - - $codeGenerator->AssertNotSequenceType($attribute->signature->type); - return 1 if $codeGenerator->GetArrayType($attribute->signature->type); - return 1 if $codeGenerator->IsTypedArrayType($attribute->signature->type); - - # This is for DynamicsCompressorNode.idl - if ($attribute->signature->name eq "release") { - return 1; - } - - return 0; -} - - -sub GetObjCType -{ - my $type = shift; - my $name = GetClassName($type); - - return "id <$name>" if IsProtocolType($type); - return $name if $codeGenerator->IsPrimitiveType($type) or $type eq "DOMTimeStamp"; - return "unsigned short" if $type eq "CompareHow"; - return "$name *"; -} - -sub GetPropertyAttributes -{ - my $type = shift; - my $readOnly = shift; - - my @attributes = (); - - push(@attributes, "readonly") if $readOnly; - - # FIXME: <rdar://problem/5049934> Consider using 'nonatomic' on the DOM @property declarations. - if ($codeGenerator->IsStringType($type) || IsNativeObjCType($type)) { - push(@attributes, "copy"); - } elsif ($codeGenerator->IsSVGAnimatedType($type)) { - push(@attributes, "retain"); - } elsif (!$codeGenerator->IsStringType($type) && !$codeGenerator->IsPrimitiveType($type) && $type ne "DOMTimeStamp" && $type ne "CompareHow") { - push(@attributes, "retain"); - } - - return "" unless @attributes > 0; - return "(" . join(", ", @attributes) . ")"; -} - -sub ConversionNeeded -{ - my $type = shift; - - return !$codeGenerator->IsNonPointerType($type) && !$codeGenerator->IsStringType($type) && !IsNativeObjCType($type); -} - -sub GetObjCTypeGetter -{ - my $argName = shift; - my $type = shift; - - return $argName if $codeGenerator->IsPrimitiveType($type) or $codeGenerator->IsStringType($type) or IsNativeObjCType($type); - return $argName . "Node" if $type eq "EventTarget"; - return "static_cast<WebCore::Range::CompareHow>($argName)" if $type eq "CompareHow"; - return "WTF::getPtr(nativeEventListener)" if $type eq "EventListener"; - return "WTF::getPtr(nativeNodeFilter)" if $type eq "NodeFilter"; - return "WTF::getPtr(nativeResolver)" if $type eq "XPathNSResolver"; - - if ($type eq "SerializedScriptValue") { - $implIncludes{"SerializedScriptValue.h"} = 1; - return "WebCore::SerializedScriptValue::create(WTF::String($argName))"; - } - return "core($argName)"; -} - -sub AddForwardDeclarationsForType -{ - my $type = shift; - my $public = shift; - - return if $codeGenerator->IsNonPointerType($type); - return if $codeGenerator->GetSequenceType($type); - return if $codeGenerator->GetArrayType($type); - - my $class = GetClassName($type); - - if (IsProtocolType($type)) { - $headerForwardDeclarationsForProtocols{$class} = 1 if $public; - $privateHeaderForwardDeclarationsForProtocols{$class} = 1 if !$public and !$headerForwardDeclarationsForProtocols{$class}; - return; - } - - $headerForwardDeclarations{$class} = 1 if $public; - - # Private headers include the public header, so only add a forward declaration to the private header - # if the public header does not already have the same forward declaration. - $privateHeaderForwardDeclarations{$class} = 1 if !$public and !$headerForwardDeclarations{$class}; -} - -sub AddIncludesForType -{ - my $type = shift; - - return if $codeGenerator->IsNonPointerType($type); - return if $codeGenerator->GetSequenceType($type); - return if $codeGenerator->GetArrayType($type); - - if (IsNativeObjCType($type)) { - if ($type eq "Color") { - $implIncludes{"ColorMac.h"} = 1; - } - return; - } - - if ($codeGenerator->IsStringType($type)) { - $implIncludes{"KURL.h"} = 1; - return; - } - - if ($type eq "DOMWindow") { - $implIncludes{"DOMAbstractViewInternal.h"} = 1; - $implIncludes{"DOMWindow.h"} = 1; - return; - } - - if ($type eq "DOMImplementation") { - $implIncludes{"DOMDOMImplementationInternal.h"} = 1; - $implIncludes{"DOMImplementationFront.h"} = 1; - return; - } - - if ($type eq "EventTarget") { - $implIncludes{"Node.h"} = 1; - $implIncludes{"DOMEventTarget.h"} = 1; - return; - } - - if ($codeGenerator->IsSVGAnimatedType($type)) { - $implIncludes{"${type}.h"} = 1; - $implIncludes{"DOM${type}Internal.h"} = 1; - return; - } - - if ($type =~ /(\w+)(Abs|Rel)$/) { - $implIncludes{"$1.h"} = 1; - $implIncludes{"DOM${type}Internal.h"} = 1; - return; - } - - if ($type eq "NodeFilter") { - $implIncludes{"NodeFilter.h"} = 1; - $implIncludes{"ObjCNodeFilterCondition.h"} = 1; - return; - } - - if ($type eq "EventListener") { - $implIncludes{"EventListener.h"} = 1; - $implIncludes{"ObjCEventListener.h"} = 1; - return; - } - - if ($type eq "XPathNSResolver") { - $implIncludes{"DOMCustomXPathNSResolver.h"} = 1; - $implIncludes{"XPathNSResolver.h"} = 1; - return; - } - - if ($type eq "SerializedScriptValue") { - $implIncludes{"SerializedScriptValue.h"} = 1; - return; - } - - # FIXME: won't compile without these - $implIncludes{"StylePropertySet.h"} = 1 if $type eq "CSSStyleDeclaration"; - $implIncludes{"NameNodeList.h"} = 1 if $type eq "NodeList"; - - # Default, include the same named file (the implementation) and the same name prefixed with "DOM". - $implIncludes{"$type.h"} = 1 if not $codeGenerator->SkipIncludeHeader($type); - $implIncludes{"DOM${type}Internal.h"} = 1; -} - -sub GetSVGTypeWithNamespace -{ - my $type = shift; - my $typeWithNamespace = "WebCore::" . $codeGenerator->GetSVGTypeNeedingTearOff($type); - - # Special case for DOMSVGNumber - $typeWithNamespace =~ s/</\<WebCore::/ unless $type eq "SVGNumber"; - return $typeWithNamespace; -} - -sub GetSVGPropertyTypes -{ - my $implType = shift; - - my $svgPropertyType; - my $svgListPropertyType; - my $svgNativeType; - - return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $implType =~ /SVG/; - - $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implType); - return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgNativeType; - - # Append space to avoid compilation errors when using PassRefPtr<$svgNativeType> - $svgNativeType = "WebCore::$svgNativeType "; - $svgNativeType =~ s/</\<WebCore::/ if not $svgNativeType =~ /float/; - - my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implType); - if ($svgNativeType =~ /SVGPropertyTearOff/) { - if ($svgWrappedNativeType eq "float") { - # Special case for DOMSVGNumber - $svgPropertyType = $svgWrappedNativeType; - } else { - $svgPropertyType = "WebCore::$svgWrappedNativeType"; - $svgPropertyType =~ s/</\<WebCore::/; - } - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { - $svgListPropertyType = "WebCore::$svgWrappedNativeType"; - $svgListPropertyType =~ s/</\<WebCore::/; - } elsif ($svgNativeType =~ /SVGTransformListPropertyTearOff/) { - $svgListPropertyType = "WebCore::$svgWrappedNativeType"; - $svgListPropertyType =~ s/</\<WebCore::/; - } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) { - $svgListPropertyType = "WebCore::$svgWrappedNativeType"; - $svgListPropertyType =~ s/</\<WebCore::/; - } - - return ($svgPropertyType, $svgListPropertyType, $svgNativeType); -} - -sub GenerateHeader -{ - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $className = GetClassName($interfaceName); - - my $parentName = ""; - my @protocolsToImplement = (); - ($parentName, @protocolsToImplement) = GetParentAndProtocols($interface); - - my $numConstants = @{$interface->constants}; - my $numAttributes = @{$interface->attributes}; - my $numFunctions = @{$interface->functions}; - - # - Add default header template - @headerContentHeader = split("\r", $headerLicenseTemplate); - push(@headerContentHeader, "\n"); - - # - INCLUDES - - my $includedWebKitAvailabilityHeader = 0; - unless ($isProtocol) { - my $parentHeaderName = GetClassHeaderName($parentName); - push(@headerContentHeader, "#import <WebCore/$parentHeaderName.h>\n"); - $includedWebKitAvailabilityHeader = 1; - } - - foreach my $parentProtocol (@protocolsToImplement) { - next if $parentProtocol =~ /^NS/; - $parentProtocol = GetClassHeaderName($parentProtocol); - push(@headerContentHeader, "#import <WebCore/$parentProtocol.h>\n"); - $includedWebKitAvailabilityHeader = 1; - } - - # Special case needed for legacy support of DOMRange - if ($interfaceName eq "Range") { - push(@headerContentHeader, "#import <WebCore/DOMCore.h>\n"); - push(@headerContentHeader, "#import <WebCore/DOMDocument.h>\n"); - push(@headerContentHeader, "#import <WebCore/DOMRangeException.h>\n"); - $includedWebKitAvailabilityHeader = 1; - } - - push(@headerContentHeader, "#import <JavaScriptCore/WebKitAvailability.h>\n") unless $includedWebKitAvailabilityHeader; - - my $interfaceAvailabilityVersionCheck = "#if WEBKIT_VERSION_MAX_ALLOWED >= $interfaceAvailabilityVersion\n\n"; - - push(@headerContentHeader, "\n"); - push(@headerContentHeader, $interfaceAvailabilityVersionCheck) if length $interfaceAvailabilityVersion; - - # - Add constants. - if ($numConstants > 0) { - my @headerConstants = (); - my @constants = @{$interface->constants}; - my $combinedConstants = ""; - - # FIXME: we need a way to include multiple enums. - foreach my $constant (@constants) { - my $constantName = $constant->name; - my $constantValue = $constant->value; - my $conditional = $constant->extendedAttributes->{"Conditional"}; - my $notLast = $constant ne $constants[-1]; - - if ($conditional) { - my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - $combinedConstants .= "#if ${conditionalString}\n"; - } - $combinedConstants .= " DOM_$constantName = $constantValue"; - $combinedConstants .= "," if $notLast; - if ($conditional) { - $combinedConstants .= "\n#endif\n"; - } elsif ($notLast) { - $combinedConstants .= "\n"; - } - } - - # FIXME: the formatting of the enums should line up the equal signs. - # FIXME: enums are unconditionally placed in the public header. - push(@headerContent, "enum {\n"); - push(@headerContent, $combinedConstants); - push(@headerContent, "\n};\n\n"); - } - - # - Begin @interface or @protocol - my $interfaceDeclaration = ($isProtocol ? "\@protocol $className" : "\@interface $className : $parentName"); - $interfaceDeclaration .= " <" . join(", ", @protocolsToImplement) . ">" if @protocolsToImplement > 0; - $interfaceDeclaration .= "\n"; - - push(@headerContent, $interfaceDeclaration); - - my @headerAttributes = (); - my @privateHeaderAttributes = (); - - # - Add attribute getters/setters. - if ($numAttributes > 0) { - foreach my $attribute (@{$interface->attributes}) { - next if SkipAttribute($attribute); - my $attributeName = $attribute->signature->name; - - if ($attributeName eq "id" or $attributeName eq "hash" or $attributeName eq "description") { - # Special case some attributes (like id and hash) to have a "Name" suffix to avoid ObjC naming conflicts. - $attributeName .= "Name"; - } elsif ($attributeName eq "frame") { - # Special case attribute frame to be frameBorders. - $attributeName .= "Borders"; - } - - my $attributeType = GetObjCType($attribute->signature->type); - my $attributeIsReadonly = ($attribute->type =~ /^readonly/); - - my $property = "\@property" . GetPropertyAttributes($attribute->signature->type, $attributeIsReadonly); - # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++ - $attributeName =~ s/operator/_operator/ if ($attributeName =~ /operator/); - $property .= " " . $attributeType . ($attributeType =~ /\*$/ ? "" : " ") . $attributeName; - - my $publicInterfaceKey = $property . ";"; - - my $availabilityMacro = ""; - if (defined $publicInterfaces{$publicInterfaceKey} and length $publicInterfaces{$publicInterfaceKey}) { - $availabilityMacro = $publicInterfaces{$publicInterfaceKey}; - } - - my $declarationSuffix = ";\n"; - $declarationSuffix = " $availabilityMacro;\n" if length $availabilityMacro; - - my $public = (defined $publicInterfaces{$publicInterfaceKey} or $newPublicClass); - delete $publicInterfaces{$publicInterfaceKey}; - - AddForwardDeclarationsForType($attribute->signature->type, $public); - - my $setterName = "set" . ucfirst($attributeName) . ":"; - - my $conflict = $conflictMethod{$attributeName}; - if ($conflict) { - warn "$className conflicts with $conflict method $attributeName\n"; - $fatalError = 1; - } - - $conflict = $conflictMethod{$setterName}; - if ($conflict) { - warn "$className conflicts with $conflict method $setterName\n"; - $fatalError = 1; - } - - $property .= $declarationSuffix; - push(@headerAttributes, $property) if $public; - push(@privateHeaderAttributes, $property) unless $public; - } - - push(@headerContent, @headerAttributes) if @headerAttributes > 0; - } - - my @headerFunctions = (); - my @privateHeaderFunctions = (); - my @deprecatedHeaderFunctions = (); - - # - Add functions. - if ($numFunctions > 0) { - foreach my $function (@{$interface->functions}) { - next if SkipFunction($function); - next if ($function->signature->name eq "set" and $interface->extendedAttributes->{"TypedArray"}); - my $functionName = $function->signature->name; - - my $returnType = GetObjCType($function->signature->type); - my $needsDeprecatedVersion = (@{$function->parameters} > 1 and $function->signature->extendedAttributes->{"ObjCLegacyUnnamedParameters"}); - my $numberOfParameters = @{$function->parameters}; - my %typesToForwardDeclare = ($function->signature->type => 1); - - my $parameterIndex = 0; - my $functionSig = "- ($returnType)$functionName"; - my $methodName = $functionName; - foreach my $param (@{$function->parameters}) { - my $paramName = $param->name; - my $paramType = GetObjCType($param->type); - - $typesToForwardDeclare{$param->type} = 1; - - if ($parameterIndex >= 1) { - $functionSig .= " $paramName"; - $methodName .= $paramName; - } - - $functionSig .= ":($paramType)$paramName"; - $methodName .= ":"; - - $parameterIndex++; - } - - my $publicInterfaceKey = $functionSig . ";"; - - my $conflict = $conflictMethod{$methodName}; - if ($conflict) { - warn "$className conflicts with $conflict method $methodName\n"; - $fatalError = 1; - } - - if ($isProtocol && !$newPublicClass && !defined $publicInterfaces{$publicInterfaceKey}) { - warn "Protocol method $publicInterfaceKey is not in PublicDOMInterfaces.h. Protocols require all methods to be public"; - $fatalError = 1; - } - - my $availabilityMacro = ""; - if (defined $publicInterfaces{$publicInterfaceKey} and length $publicInterfaces{$publicInterfaceKey}) { - $availabilityMacro = $publicInterfaces{$publicInterfaceKey}; - } - - my $functionDeclaration = $functionSig; - $functionDeclaration .= " " . $availabilityMacro if length $availabilityMacro; - $functionDeclaration .= ";\n"; - - my $public = (defined $publicInterfaces{$publicInterfaceKey} or $newPublicClass); - delete $publicInterfaces{$publicInterfaceKey}; - - foreach my $type (keys %typesToForwardDeclare) { - # add any forward declarations to the public header if a deprecated version will be generated - AddForwardDeclarationsForType($type, 1) if $needsDeprecatedVersion; - AddForwardDeclarationsForType($type, $public) unless $public and $needsDeprecatedVersion; - } - - my $functionConditionalString = $codeGenerator->GenerateConditionalString($function->signature); - if ($functionConditionalString) { - push(@headerFunctions, "#if ${functionConditionalString}\n") if $public; - push(@privateHeaderFunctions, "#if ${functionConditionalString}\n") unless $public; - push(@deprecatedHeaderFunctions, "#if ${functionConditionalString}\n") if $needsDeprecatedVersion; - } - - push(@headerFunctions, $functionDeclaration) if $public; - push(@privateHeaderFunctions, $functionDeclaration) unless $public; - - # generate the old style method names with un-named parameters, these methods are deprecated - if ($needsDeprecatedVersion) { - my $deprecatedFunctionSig = $functionSig; - $deprecatedFunctionSig =~ s/\s\w+:/ :/g; # remove parameter names - - $publicInterfaceKey = $deprecatedFunctionSig . ";"; - - my $availabilityMacro = "AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0"; - if (defined $publicInterfaces{$publicInterfaceKey} and length $publicInterfaces{$publicInterfaceKey}) { - $availabilityMacro = $publicInterfaces{$publicInterfaceKey}; - } - - $functionDeclaration = "$deprecatedFunctionSig $availabilityMacro;\n"; - - push(@deprecatedHeaderFunctions, $functionDeclaration); - - unless (defined $publicInterfaces{$publicInterfaceKey}) { - warn "Deprecated method $publicInterfaceKey is not in PublicDOMInterfaces.h. All deprecated methods need to be public, or should have the ObjCLegacyUnnamedParameters IDL attribute removed"; - $fatalError = 1; - } - - delete $publicInterfaces{$publicInterfaceKey}; - } - - if ($functionConditionalString) { - push(@headerFunctions, "#endif\n") if $public; - push(@privateHeaderFunctions, "#endif\n") unless $public; - push(@deprecatedHeaderFunctions, "#endif\n") if $needsDeprecatedVersion; - } - } - - if (@headerFunctions > 0) { - push(@headerContent, "\n") if @headerAttributes > 0; - push(@headerContent, @headerFunctions); - } - } - - if (@deprecatedHeaderFunctions > 0 && $isProtocol) { - push(@headerContent, @deprecatedHeaderFunctions); - } - - # - End @interface or @protocol - push(@headerContent, "\@end\n"); - - if (@deprecatedHeaderFunctions > 0 && !$isProtocol) { - # - Deprecated category @interface - push(@headerContent, "\n\@interface $className (" . $className . "Deprecated)\n"); - push(@headerContent, @deprecatedHeaderFunctions); - push(@headerContent, "\@end\n"); - } - - push(@headerContent, "\n#endif\n") if length $interfaceAvailabilityVersion; - - my %alwaysGenerateForNoSVGBuild = map { $_ => 1 } qw(DOMHTMLEmbedElement DOMHTMLObjectElement); - - if (@privateHeaderAttributes > 0 or @privateHeaderFunctions > 0 or exists $alwaysGenerateForNoSVGBuild{$className}) { - # - Private category @interface - @privateHeaderContentHeader = split("\r", $headerLicenseTemplate); - push(@privateHeaderContentHeader, "\n"); - - my $classHeaderName = GetClassHeaderName($className); - push(@privateHeaderContentHeader, "#import <WebCore/$classHeaderName.h>\n\n"); - push(@privateHeaderContentHeader, $interfaceAvailabilityVersionCheck) if length $interfaceAvailabilityVersion; - - @privateHeaderContent = (); - push(@privateHeaderContent, "\@interface $className (" . $className . "Private)\n"); - push(@privateHeaderContent, @privateHeaderAttributes) if @privateHeaderAttributes > 0; - push(@privateHeaderContent, "\n") if @privateHeaderAttributes > 0 and @privateHeaderFunctions > 0; - push(@privateHeaderContent, @privateHeaderFunctions) if @privateHeaderFunctions > 0; - push(@privateHeaderContent, "\@end\n"); - - push(@privateHeaderContent, "\n#endif\n") if length $interfaceAvailabilityVersion; - } - - unless ($isProtocol) { - # Generate internal interfaces - my $implClassName = GetImplClassName($interfaceName); - my $implClassNameWithNamespace = "WebCore::" . $implClassName; - - my $implType = $implClassNameWithNamespace; - my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implClassName); - $implType = $svgNativeType if $svgNativeType; - - # Generate interface definitions. - @internalHeaderContent = split("\r", $implementationLicenseTemplate); - - push(@internalHeaderContent, "\n#import <WebCore/$className.h>\n\n"); - push(@internalHeaderContent, "#import <WebCore/SVGAnimatedPropertyTearOff.h>\n\n") if $svgPropertyType; - if ($svgListPropertyType) { - push(@internalHeaderContent, "#import <WebCore/SVGAnimatedListPropertyTearOff.h>\n\n"); - push(@internalHeaderContent, "#import <WebCore/SVGTransformListPropertyTearOff.h>\n\n") if $svgListPropertyType =~ /SVGTransformList/; - push(@internalHeaderContent, "#import <WebCore/SVGPathSegListPropertyTearOff.h>\n\n") if $svgListPropertyType =~ /SVGPathSegList/; - } - push(@internalHeaderContent, $interfaceAvailabilityVersionCheck) if length $interfaceAvailabilityVersion; - - if ($interfaceName eq "Node") { - push(@internalHeaderContent, "\@protocol DOMEventTarget;\n\n"); - } - - my $startedNamespace = 0; - - if ($codeGenerator->IsSVGAnimatedType($interfaceName)) { - push(@internalHeaderContent, "#import <WebCore/$implClassName.h>\n\n"); - } else { - push(@internalHeaderContent, "namespace WebCore {\n"); - $startedNamespace = 1; - if ($interfaceName eq "Node") { - push(@internalHeaderContent, " class EventTarget;\n class Node;\n"); - } else { - push(@internalHeaderContent, " class $implClassName;\n"); - } - push(@internalHeaderContent, "}\n\n"); - } - - push(@internalHeaderContent, "$implType* core($className *);\n"); - push(@internalHeaderContent, "$className *kit($implType*);\n"); - - if ($interface->extendedAttributes->{"ObjCPolymorphic"}) { - push(@internalHeaderContent, "Class kitClass($implType*);\n"); - } - - if ($interfaceName eq "Node") { - push(@internalHeaderContent, "id <DOMEventTarget> kit(WebCore::EventTarget*);\n"); - } - - push(@internalHeaderContent, "\n#endif\n") if length $interfaceAvailabilityVersion; - } -} - -sub GenerateImplementation -{ - my $object = shift; - my $interface = shift; - - my @ancestorInterfaceNames = (); - - if (@{$interface->parents} > 1) { - $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames); - } - - my $interfaceName = $interface->name; - my $className = GetClassName($interfaceName); - my $implClassName = GetImplClassName($interfaceName); - my $parentImplClassName = GetParentImplClassName($interface); - my $implClassNameWithNamespace = "WebCore::" . $implClassName; - my $baseClass = GetBaseClass($parentImplClassName); - my $classHeaderName = GetClassHeaderName($className); - - my $numAttributes = @{$interface->attributes}; - my $numFunctions = @{$interface->functions}; - my $implType = $implClassNameWithNamespace; - - my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implClassName); - $implType = $svgNativeType if $svgNativeType; - - # - Add default header template. - @implContentHeader = split("\r", $implementationLicenseTemplate); - - # - INCLUDES - - push(@implContentHeader, "\n#import \"config.h\"\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; - - push(@implContentHeader, "#import \"DOMInternal.h\"\n\n"); - push(@implContentHeader, "#import \"$classHeaderName.h\"\n\n"); - - $implIncludes{"ExceptionHandlers.h"} = 1; - $implIncludes{"ThreadCheck.h"} = 1; - $implIncludes{"JSMainThreadExecState.h"} = 1; - $implIncludes{"WebScriptObjectPrivate.h"} = 1; - $implIncludes{$classHeaderName . "Internal.h"} = 1; - - # FIXME: These includes are only needed when the class is a subclass of one of these polymorphic classes. - $implIncludes{"DOMBlobInternal.h"} = 1; - $implIncludes{"DOMCSSRuleInternal.h"} = 1; - $implIncludes{"DOMCSSValueInternal.h"} = 1; - $implIncludes{"DOMEventInternal.h"} = 1; - $implIncludes{"DOMNodeInternal.h"} = 1; - $implIncludes{"DOMStyleSheetInternal.h"} = 1; - - $implIncludes{"DOMSVGPathSegInternal.h"} = 1 if $interfaceName =~ /^SVGPathSeg.+/; - - if ($interfaceName =~ /(\w+)(Abs|Rel)$/) { - $implIncludes{"$1.h"} = 1; - } else { - if (!$codeGenerator->SkipIncludeHeader($implClassName)) { - $implIncludes{"$implClassName.h"} = 1 ; - } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($implClassName)) { - my $includeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); - $implIncludes{"${includeType}.h"} = 1; - } - } - - @implContent = (); - - push(@implContent, "#import <wtf/GetPtr.h>\n\n"); - - # add implementation accessor - if ($parentImplClassName eq "Object") { - push(@implContent, "#define IMPL reinterpret_cast<$implType*>(_internal)\n\n"); - } else { - my $baseClassWithNamespace = "WebCore::$baseClass"; - push(@implContent, "#define IMPL static_cast<$implClassNameWithNamespace*>(reinterpret_cast<$baseClassWithNamespace*>(_internal))\n\n"); - } - - # START implementation - push(@implContent, "\@implementation $className\n\n"); - - # Only generate 'dealloc' and 'finalize' methods for direct subclasses of DOMObject. - if ($parentImplClassName eq "Object") { - $implIncludes{"WebCoreObjCExtras.h"} = 1; - push(@implContent, "- (void)dealloc\n"); - push(@implContent, "{\n"); - push(@implContent, " if (WebCoreObjCScheduleDeallocateOnMainThread([$className class], self))\n"); - push(@implContent, " return;\n"); - push(@implContent, "\n"); - if ($interfaceName eq "NodeIterator") { - push(@implContent, " if (_internal) {\n"); - push(@implContent, " [self detach];\n"); - push(@implContent, " IMPL->deref();\n"); - push(@implContent, " };\n"); - } else { - push(@implContent, " if (_internal)\n"); - push(@implContent, " IMPL->deref();\n"); - } - push(@implContent, " [super dealloc];\n"); - push(@implContent, "}\n\n"); - - push(@implContent, "- (void)finalize\n"); - push(@implContent, "{\n"); - if ($interfaceName eq "NodeIterator") { - push(@implContent, " if (_internal) {\n"); - push(@implContent, " [self detach];\n"); - push(@implContent, " IMPL->deref();\n"); - push(@implContent, " };\n"); - } else { - push(@implContent, " if (_internal)\n"); - push(@implContent, " IMPL->deref();\n"); - } - push(@implContent, " [super finalize];\n"); - push(@implContent, "}\n\n"); - - } - - %attributeNames = (); - - # - Attributes - if ($numAttributes > 0) { - foreach my $attribute (@{$interface->attributes}) { - next if SkipAttribute($attribute); - AddIncludesForType($attribute->signature->type); - - my $idlType = $attribute->signature->type; - - my $attributeName = $attribute->signature->name; - my $attributeType = GetObjCType($attribute->signature->type); - my $attributeIsReadonly = ($attribute->type =~ /^readonly/); - my $attributeClassName = GetClassName($attribute->signature->type); - - my $attributeInterfaceName = $attributeName; - if ($attributeName eq "id" or $attributeName eq "hash" or $attributeName eq "description") { - # Special case some attributes (like id and hash) to have a "Name" suffix to avoid ObjC naming conflicts. - $attributeInterfaceName .= "Name"; - } elsif ($attributeName eq "frame") { - # Special case attribute frame to be frameBorders. - $attributeInterfaceName .= "Borders"; - } elsif ($attributeName eq "operator") { - # Avoid clash with C++ keyword. - $attributeInterfaceName = "_operator"; - } - - $attributeNames{$attributeInterfaceName} = 1; - - # - GETTER - my $getterSig = "- ($attributeType)$attributeInterfaceName\n"; - - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute); - my $getterExpressionPrefix = "$functionName(" . join(", ", @arguments); - - # FIXME: Special case attribute ownerDocument to call document. This makes it return the - # document when called on the document itself. Legacy behavior, see <https://bugs.webkit.org/show_bug.cgi?id=10889>. - $getterExpressionPrefix =~ s/\bownerDocument\b/document/; - - my $hasGetterException = @{$attribute->getterExceptions}; - my $getterContentHead; - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - $getterContentHead = "${implementedBy}::${getterExpressionPrefix}IMPL"; - } else { - $getterContentHead = "IMPL->$getterExpressionPrefix"; - } - - my $getterContentTail = ")"; - - if ($svgPropertyType) { - $getterContentHead = "$getterExpressionPrefix"; - - # TODO: Handle special case for DOMSVGLength. We do need Custom code support for this. - if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") { - $getterContentHead = "value(WebCore::SVGLengthContext(IMPL->contextElement()), "; - } - } - - my $attributeTypeSansPtr = $attributeType; - $attributeTypeSansPtr =~ s/ \*$//; # Remove trailing " *" from pointer types. - - # special case for EventTarget protocol - $attributeTypeSansPtr = "DOMNode" if $idlType eq "EventTarget"; - - # Special cases - my @customGetterContent = (); - if ($attributeTypeSansPtr eq "DOMImplementation") { - # FIXME: We have to special case DOMImplementation until DOMImplementationFront is removed - $getterContentHead = "kit(implementationFront(IMPL"; - $getterContentTail .= ")"; - } elsif ($attributeName =~ /(\w+)DisplayString$/) { - my $attributeToDisplay = $1; - $getterContentHead = "WebCore::displayString(IMPL->$attributeToDisplay(), core(self)"; - $implIncludes{"HitTestResult.h"} = 1; - } elsif ($attributeName =~ /^absolute(\w+)URL$/) { - my $typeOfURL = $1; - $getterContentHead = "[self _getURLAttribute:"; - if ($typeOfURL eq "Link") { - $getterContentTail = "\@\"href\"]"; - } elsif ($typeOfURL eq "Image") { - if ($interfaceName eq "HTMLObjectElement") { - $getterContentTail = "\@\"data\"]"; - } else { - $getterContentTail = "\@\"src\"]"; - } - unless ($interfaceName eq "HTMLImageElement") { - push(@customGetterContent, " if (!IMPL->renderer() || !IMPL->renderer()->isImage())\n"); - push(@customGetterContent, " return nil;\n"); - $implIncludes{"RenderObject.h"} = 1; - } - } - $implIncludes{"DOMPrivate.h"} = 1; - } elsif ($attribute->signature->extendedAttributes->{"ObjCImplementedAsUnsignedLong"}) { - $getterContentHead = "WTF::String::number(" . $getterContentHead; - $getterContentTail .= ")"; - } elsif ($idlType eq "Date") { - $getterContentHead = "kit($getterContentHead"; - $getterContentTail .= ")"; - } elsif ($svgPropertyType) { - # Special case for DOMSVGNumber - if ($svgPropertyType eq "float") { - # Intentional leave out closing brace, it's already contained in getterContentTail - $getterContentHead = "IMPL->propertyReference("; - } else { - $getterContentHead = "IMPL->propertyReference().$getterContentHead"; - } - - if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($idlType) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { - my $getter = $getterContentHead; - $getter =~ s/\(\)//; - - my $tearOffType = GetSVGTypeWithNamespace($idlType); - my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($implClassName); - if ($selfIsTearOffType) { - $implIncludes{"SVGStaticPropertyWithParentTearOff.h"} = 1; - $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParentTearOff<$implClassNameWithNamespace, /; - - my $getter = $getterExpressionPrefix; - $getter =~ s/IMPL->//; - $getter =~ s/\(//; - my $updateMethod = "&${implClassNameWithNamespace}::update" . $codeGenerator->WK_ucfirst($getter); - - if ($getterContentHead =~ /matrix/ and $implClassName eq "SVGTransform") { - # SVGTransform offers a matrix() method for internal usage that returns an AffineTransform - # and a svgMatrix() method returning a SVGMatrix, used for the bindings. - $getterContentHead =~ s/matrix/svgMatrix/; - } - - $getterContentHead = "${tearOffType}::create(IMPL, $getterContentHead$getterContentTail, $updateMethod)"; - - $getterContentHead = "kit(WTF::getPtr($getterContentHead"; - $getterContentTail = "))"; - } - } - } elsif (($codeGenerator->IsSVGAnimatedType($implClassName) or $implClassName eq "SVGViewSpec") and $codeGenerator->IsSVGTypeNeedingTearOff($idlType)) { - my $idlTypeWithNamespace = GetSVGTypeWithNamespace($idlType); - $getterContentHead = "kit(static_cast<$idlTypeWithNamespace*>($getterContentHead)"; - $getterContentTail .= ")"; - } elsif (IsProtocolType($idlType) and $idlType ne "EventTarget") { - $getterContentHead = "kit($getterContentHead"; - $getterContentTail .= ")"; - } elsif ($idlType eq "Color") { - $getterContentHead = "WebCore::nsColor($getterContentHead"; - $getterContentTail .= ")"; - } elsif ($attribute->signature->type eq "SerializedScriptValue") { - $getterContentHead = "$getterContentHead"; - $getterContentTail .= "->toString()"; - } elsif (ConversionNeeded($attribute->signature->type)) { - my $type = $attribute->signature->type; - if ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) { - my $idlTypeWithNamespace = GetSVGTypeWithNamespace($type); - $implIncludes{"$type.h"} = 1 if not $codeGenerator->SkipIncludeHeader($type); - if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($type) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { - $idlTypeWithNamespace =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassNameWithNamespace, /; - $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; - - my $getter = $getterContentHead; - $getter =~ s/IMPL->//; - $getter =~ s/\(//; - my $updateMethod = "&${implClassNameWithNamespace}::update" . $codeGenerator->WK_ucfirst($getter); - $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create(IMPL, $getterContentHead$getterContentTail, $updateMethod"; - $getterContentTail .= "))"; - } elsif ($idlTypeWithNamespace =~ /SVG(Point|PathSeg)List/) { - $getterContentHead = "kit(WTF::getPtr($getterContentHead"; - $getterContentTail .= "))"; - } elsif ($idlTypeWithNamespace =~ /SVGStaticListPropertyTearOff/) { - $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create(IMPL, $getterContentHead"; - $getterContentTail .= ")))"; - } else { - $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($getterContentHead"; - $getterContentTail .= ")))"; - } - } else { - $getterContentHead = "kit(WTF::getPtr($getterContentHead"; - $getterContentTail .= "))"; - } - } - - my $getterContent; - if ($hasGetterException) { - $getterContent = $getterContentHead . ($getterContentHead =~ /\($|, $/ ? "ec" : ", ec") . $getterContentTail; - } else { - $getterContent = $getterContentHead . $getterContentTail; - } - - my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; - push(@implContent, $getterSig); - push(@implContent, "{\n"); - push(@implContent, " $jsContextSetter\n"); - push(@implContent, @customGetterContent); - if ($hasGetterException) { - # Differentiated between when the return type is a pointer and - # not for white space issue (ie. Foo *result vs. int result). - if ($attributeType =~ /\*$/) { - $getterContent = $attributeType . "result = " . $getterContent; - } else { - $getterContent = $attributeType . " result = " . $getterContent; - } - - push(@implContent, " $exceptionInit\n"); - push(@implContent, " $getterContent;\n"); - push(@implContent, " $exceptionRaiseOnError\n"); - push(@implContent, " return result;\n"); - } else { - push(@implContent, " return $getterContent;\n"); - } - push(@implContent, "}\n"); - - # - SETTER - if (!$attributeIsReadonly) { - # Exception handling - my $hasSetterException = @{$attribute->setterExceptions}; - - my $coreSetterName = "set" . $codeGenerator->WK_ucfirst($attributeName); - my $setterName = "set" . ucfirst($attributeInterfaceName); - my $argName = "new" . ucfirst($attributeInterfaceName); - my $arg = GetObjCTypeGetter($argName, $idlType); - - # The definition of ObjCImplementedAsUnsignedLong is flipped for the setter - if ($attribute->signature->extendedAttributes->{"ObjCImplementedAsUnsignedLong"}) { - $arg = "WTF::String($arg).toInt()"; - } - - my $setterSig = "- (void)$setterName:($attributeType)$argName\n"; - - push(@implContent, "\n"); - push(@implContent, $setterSig); - push(@implContent, "{\n"); - push(@implContent, " $jsContextSetter\n"); - - unless ($codeGenerator->IsPrimitiveType($idlType) or $codeGenerator->IsStringType($idlType)) { - push(@implContent, " ASSERT($argName);\n\n"); - } - - if ($idlType eq "Date") { - $arg = "core(" . $arg . ")"; - } - - if ($svgPropertyType) { - $implIncludes{"ExceptionCode.h"} = 1; - $getterContentHead = "$getterExpressionPrefix"; - push(@implContent, " if (IMPL->isReadOnly()) {\n"); - push(@implContent, " WebCore::raiseOnDOMError(WebCore::NO_MODIFICATION_ALLOWED_ERR);\n"); - push(@implContent, " return;\n"); - push(@implContent, " }\n"); - push(@implContent, " $svgPropertyType& podImpl = IMPL->propertyReference();\n"); - my $ec = $hasSetterException ? ", ec" : ""; - push(@implContent, " $exceptionInit\n") if $hasSetterException; - - # Special case for DOMSVGNumber - if ($svgPropertyType eq "float") { - push(@implContent, " podImpl = $arg;\n"); - } else { - # FIXME: Special case for DOMSVGLength. We do need Custom code support for this. - if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") { - push(@implContent, " podImpl.$coreSetterName($arg, WebCore::SVGLengthContext(IMPL->contextElement())$ec);\n"); - } else { - push(@implContent, " podImpl.$coreSetterName($arg$ec);\n"); - } - } - - if ($hasSetterException) { - push(@implContent, " if (!ec)\n"); - push(@implContent, " IMPL->commitChange();\n"); - push(@implContent, " $exceptionRaiseOnError\n"); - } else { - push(@implContent, " IMPL->commitChange();\n"); - } - } elsif ($svgListPropertyType) { - $getterContentHead = "$getterExpressionPrefix"; - push(@implContent, " IMPL->$coreSetterName($arg);\n"); - } else { - my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@arguments, $arg); - push(@arguments, "ec") if $hasSetterException; - push(@implContent, " $exceptionInit\n") if $hasSetterException; - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@arguments, "IMPL"); - $functionName = "${implementedBy}::${functionName}"; - } else { - $functionName = "IMPL->${functionName}"; - } - push(@implContent, " ${functionName}(" . join(", ", @arguments) . ");\n"); - push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException; - } - - push(@implContent, "}\n"); - } - - push(@implContent, "#endif\n") if $attributeConditionalString; - push(@implContent, "\n"); - } - } - - # - Functions - if ($numFunctions > 0) { - foreach my $function (@{$interface->functions}) { - next if SkipFunction($function); - next if ($function->signature->name eq "set" and $interface->extendedAttributes->{"TypedArray"}); - AddIncludesForType($function->signature->type); - - my $functionName = $function->signature->name; - my $returnType = GetObjCType($function->signature->type); - my $hasParameters = @{$function->parameters}; - my $raisesExceptions = @{$function->raisesExceptions}; - - my @parameterNames = (); - my @needsAssert = (); - my %needsCustom = (); - - my $parameterIndex = 0; - my $functionSig = "- ($returnType)$functionName"; - foreach my $param (@{$function->parameters}) { - my $paramName = $param->name; - my $paramType = GetObjCType($param->type); - - # make a new parameter name if the original conflicts with a property name - $paramName = "in" . ucfirst($paramName) if $attributeNames{$paramName}; - - AddIncludesForType($param->type); - - my $idlType = $param->type; - my $implGetter = GetObjCTypeGetter($paramName, $idlType); - - push(@parameterNames, $implGetter); - $needsCustom{"XPathNSResolver"} = $paramName if $idlType eq "XPathNSResolver"; - $needsCustom{"NodeFilter"} = $paramName if $idlType eq "NodeFilter"; - $needsCustom{"EventListener"} = $paramName if $idlType eq "EventListener"; - $needsCustom{"EventTarget"} = $paramName if $idlType eq "EventTarget"; - $needsCustom{"NodeToReturn"} = $paramName if $param->extendedAttributes->{"CustomReturn"}; - - unless ($codeGenerator->IsPrimitiveType($idlType) or $codeGenerator->IsStringType($idlType)) { - push(@needsAssert, " ASSERT($paramName);\n"); - } - - if ($parameterIndex >= 1) { - $functionSig .= " " . $param->name; - } - - $functionSig .= ":($paramType)$paramName"; - - $parameterIndex++; - } - - my @functionContent = (); - my $caller = "IMPL"; - - # special case the XPathNSResolver - if (defined $needsCustom{"XPathNSResolver"}) { - my $paramName = $needsCustom{"XPathNSResolver"}; - push(@functionContent, " WebCore::XPathNSResolver* nativeResolver = 0;\n"); - push(@functionContent, " RefPtr<WebCore::XPathNSResolver> customResolver;\n"); - push(@functionContent, " if ($paramName) {\n"); - push(@functionContent, " if ([$paramName isMemberOfClass:[DOMNativeXPathNSResolver class]])\n"); - push(@functionContent, " nativeResolver = core(static_cast<DOMNativeXPathNSResolver *>($paramName));\n"); - push(@functionContent, " else {\n"); - push(@functionContent, " customResolver = WebCore::DOMCustomXPathNSResolver::create($paramName);\n"); - push(@functionContent, " nativeResolver = WTF::getPtr(customResolver);\n"); - push(@functionContent, " }\n"); - push(@functionContent, " }\n"); - } - - # special case the EventTarget - if (defined $needsCustom{"EventTarget"}) { - my $paramName = $needsCustom{"EventTarget"}; - push(@functionContent, " DOMNode* ${paramName}ObjC = $paramName;\n"); - push(@functionContent, " WebCore::Node* ${paramName}Node = core(${paramName}ObjC);\n"); - $implIncludes{"DOMNode.h"} = 1; - $implIncludes{"Node.h"} = 1; - } - - if ($function->signature->extendedAttributes->{"ObjCUseDefaultView"}) { - push(@functionContent, " WebCore::DOMWindow* dv = $caller->defaultView();\n"); - push(@functionContent, " if (!dv)\n"); - push(@functionContent, " return nil;\n"); - $implIncludes{"DOMWindow.h"} = 1; - $caller = "dv"; - } - - # special case the EventListener - if (defined $needsCustom{"EventListener"}) { - my $paramName = $needsCustom{"EventListener"}; - push(@functionContent, " RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap($paramName);\n"); - } - - # special case the NodeFilter - if (defined $needsCustom{"NodeFilter"}) { - my $paramName = $needsCustom{"NodeFilter"}; - push(@functionContent, " RefPtr<WebCore::NodeFilter> nativeNodeFilter;\n"); - push(@functionContent, " if ($paramName)\n"); - push(@functionContent, " nativeNodeFilter = WebCore::NodeFilter::create(WebCore::ObjCNodeFilterCondition::create($paramName));\n"); - } - - # FIXME! We need [Custom] support for ObjC, to move these hacks into DOMSVGLength/MatrixCustom.mm - my $svgLengthConvertToSpecifiedUnits = ($svgPropertyType and $svgPropertyType eq "WebCore::SVGLength" and $functionName eq "convertToSpecifiedUnits"); - - push(@parameterNames, "WebCore::SVGLengthContext(IMPL->contextElement())") if $svgLengthConvertToSpecifiedUnits; - push(@parameterNames, "ec") if $raisesExceptions; - - # Handle arguments that are 'SVGProperty' based (SVGAngle/SVGLength). We need to convert from SVGPropertyTearOff<Type>* to Type, - # to be able to call the desired WebCore function. If the conversion fails, we can't extract Type and need to raise an exception. - my $currentParameter = -1; - foreach my $param (@{$function->parameters}) { - $currentParameter++; - - my $paramName = $param->name; - - # make a new parameter name if the original conflicts with a property name - $paramName = "in" . ucfirst($paramName) if $attributeNames{$paramName}; - - my $idlType = $param->type; - next if not $codeGenerator->IsSVGTypeNeedingTearOff($idlType) or $implClassName =~ /List$/; - - my $implGetter = GetObjCTypeGetter($paramName, $idlType); - my $idlTypeWithNamespace = GetSVGTypeWithNamespace($idlType); - - $implIncludes{"ExceptionCode.h"} = 1; - push(@functionContent, " $idlTypeWithNamespace* ${paramName}Core = $implGetter;\n"); - push(@functionContent, " if (!${paramName}Core) {\n"); - push(@functionContent, " WebCore::ExceptionCode ec = WebCore::TYPE_MISMATCH_ERR;\n"); - push(@functionContent, " $exceptionRaiseOnError\n"); - if ($returnType eq "void") { - push(@functionContent, " return;\n"); - } else { - push(@functionContent, " return nil;\n"); - } - push(@functionContent, " }\n"); - - # Replace the paramter core() getter, by the cached variable. - splice(@parameterNames, $currentParameter, 1, "${paramName}Core->propertyReference()"); - } - - my $content; - if ($function->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - $implIncludes{"${implementedBy}.h"} = 1; - unshift(@parameterNames, $caller); - $content = "${implementedBy}::" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; - } elsif ($svgPropertyType) { - $implIncludes{"ExceptionCode.h"} = 1; - push(@functionContent, " if (IMPL->isReadOnly()) {\n"); - push(@functionContent, " WebCore::raiseOnDOMError(WebCore::NO_MODIFICATION_ALLOWED_ERR);\n"); - if ($returnType eq "void") { - push(@functionContent, " return;\n"); - } else { - push(@functionContent, " return nil;\n"); - } - push(@functionContent, " }\n"); - push(@functionContent, " $svgPropertyType& podImpl = IMPL->propertyReference();\n"); - $content = "podImpl." . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; - } else { - $content = "$caller->" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; - } - - if ($returnType eq "void") { - # Special case 'void' return type. - if ($raisesExceptions) { - push(@functionContent, " $exceptionInit\n"); - push(@functionContent, " $content;\n"); - if ($svgPropertyType) { - push(@functionContent, " if (!ec)\n"); - push(@functionContent, " IMPL->commitChange();\n"); - } - push(@functionContent, " $exceptionRaiseOnError\n"); - } else { - push(@functionContent, " $content;\n"); - push(@functionContent, " IMPL->commitChange();\n") if $svgPropertyType; - } - } elsif (defined $needsCustom{"NodeToReturn"}) { - # Special case the insertBefore, replaceChild, removeChild - # and appendChild functions from DOMNode - my $toReturn = $needsCustom{"NodeToReturn"}; - if ($raisesExceptions) { - push(@functionContent, " $exceptionInit\n"); - push(@functionContent, " if ($content)\n"); - push(@functionContent, " return $toReturn;\n"); - push(@functionContent, " $exceptionRaiseOnError\n"); - push(@functionContent, " return nil;\n"); - } else { - push(@functionContent, " if ($content)\n"); - push(@functionContent, " return $toReturn;\n"); - push(@functionContent, " return nil;\n"); - } - } elsif ($returnType eq "SerializedScriptValue") { - $content = "foo"; - } else { - if (ConversionNeeded($function->signature->type)) { - if ($codeGenerator->IsSVGTypeNeedingTearOff($function->signature->type) and not $implClassName =~ /List$/) { - my $idlTypeWithNamespace = GetSVGTypeWithNamespace($function->signature->type); - $content = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($content)))"; - } else { - $content = "kit(WTF::getPtr($content))"; - } - } - - if ($raisesExceptions) { - # Differentiated between when the return type is a pointer and - # not for white space issue (ie. Foo *result vs. int result). - if ($returnType =~ /\*$/) { - $content = $returnType . "result = " . $content; - } else { - $content = $returnType . " result = " . $content; - } - - push(@functionContent, " $exceptionInit\n"); - push(@functionContent, " $content;\n"); - push(@functionContent, " $exceptionRaiseOnError\n"); - push(@functionContent, " return result;\n"); - } else { - push(@functionContent, " return $content;\n"); - } - } - - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - - push(@implContent, "$functionSig\n"); - push(@implContent, "{\n"); - push(@implContent, " $jsContextSetter\n"); - push(@implContent, @functionContent); - push(@implContent, "}\n\n"); - - push(@implContent, "#endif\n\n") if $conditionalString; - - # generate the old style method names with un-named parameters, these methods are deprecated - if (@{$function->parameters} > 1 and $function->signature->extendedAttributes->{"ObjCLegacyUnnamedParameters"}) { - my $deprecatedFunctionSig = $functionSig; - $deprecatedFunctionSig =~ s/\s\w+:/ :/g; # remove parameter names - - push(@implContent, "$deprecatedFunctionSig\n"); - push(@implContent, "{\n"); - push(@implContent, " $jsContextSetter\n"); - push(@implContent, @functionContent); - push(@implContent, "}\n\n"); - } - - # Clear the hash - %needsCustom = (); - } - } - - # END implementation - push(@implContent, "\@end\n"); - - # Generate internal interfaces - push(@implContent, "\n$implType* core($className *wrapper)\n"); - push(@implContent, "{\n"); - push(@implContent, " return wrapper ? reinterpret_cast<$implType*>(wrapper->_internal) : 0;\n"); - push(@implContent, "}\n\n"); - - if ($parentImplClassName eq "Object") { - push(@implContent, "$className *kit($implType* value)\n"); - push(@implContent, "{\n"); - push(@implContent, " $assertMainThread;\n"); - push(@implContent, " if (!value)\n"); - push(@implContent, " return nil;\n"); - push(@implContent, " if ($className *wrapper = getDOMWrapper(value))\n"); - push(@implContent, " return [[wrapper retain] autorelease];\n"); - if ($interface->extendedAttributes->{"ObjCPolymorphic"}) { - push(@implContent, " $className *wrapper = [[kitClass(value) alloc] _init];\n"); - push(@implContent, " if (!wrapper)\n"); - push(@implContent, " return nil;\n"); - } else { - push(@implContent, " $className *wrapper = [[$className alloc] _init];\n"); - } - push(@implContent, " wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value);\n"); - push(@implContent, " value->ref();\n"); - push(@implContent, " addDOMWrapper(wrapper, value);\n"); - push(@implContent, " return [wrapper autorelease];\n"); - push(@implContent, "}\n"); - } else { - push(@implContent, "$className *kit($implType* value)\n"); - push(@implContent, "{\n"); - push(@implContent, " $assertMainThread;\n"); - push(@implContent, " return static_cast<$className*>(kit(static_cast<WebCore::$baseClass*>(value)));\n"); - push(@implContent, "}\n"); - } - - # - End the ifdef conditional if necessary - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; - - # - Generate dependencies. - if ($writeDependencies && @ancestorInterfaceNames) { - push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestorInterfaceNames), "\n"); - push(@depsContent, map { "$_.idl :\n" } @ancestorInterfaceNames); - } -} - -# Internal helper -sub WriteData -{ - my $object = shift; - my $dataNode = shift; - my $outputDir = shift; - - # Open files for writing... - my $name = $dataNode->name; - my $prefix = FileNamePrefix; - my $headerFileName = "$outputDir/$prefix$name.h"; - my $privateHeaderFileName = "$outputDir/$prefix${name}Private.h"; - my $implFileName = "$outputDir/$prefix$name.mm"; - my $internalHeaderFileName = "$outputDir/$prefix${name}Internal.h"; - my $depsFileName = "$outputDir/$prefix$name.dep"; - - # Write public header. - my $contents = join "", @headerContentHeader; - map { $contents .= "\@class $_;\n" } sort keys(%headerForwardDeclarations); - map { $contents .= "\@protocol $_;\n" } sort keys(%headerForwardDeclarationsForProtocols); - - my $hasForwardDeclarations = keys(%headerForwardDeclarations) + keys(%headerForwardDeclarationsForProtocols); - $contents .= "\n" if $hasForwardDeclarations; - $contents .= join "", @headerContent; - $codeGenerator->UpdateFile($headerFileName, $contents); - - @headerContentHeader = (); - @headerContent = (); - %headerForwardDeclarations = (); - %headerForwardDeclarationsForProtocols = (); - - if (@privateHeaderContent > 0) { - $contents = join "", @privateHeaderContentHeader; - map { $contents .= "\@class $_;\n" } sort keys(%privateHeaderForwardDeclarations); - map { $contents .= "\@protocol $_;\n" } sort keys(%privateHeaderForwardDeclarationsForProtocols); - - $hasForwardDeclarations = keys(%privateHeaderForwardDeclarations) + keys(%privateHeaderForwardDeclarationsForProtocols); - $contents .= "\n" if $hasForwardDeclarations; - $contents .= join "", @privateHeaderContent; - $codeGenerator->UpdateFile($privateHeaderFileName, $contents); - - @privateHeaderContentHeader = (); - @privateHeaderContent = (); - %privateHeaderForwardDeclarations = (); - %privateHeaderForwardDeclarationsForProtocols = (); - } - - # Write implementation file. - unless ($noImpl) { - $contents = join "", @implContentHeader; - map { $contents .= "#import \"$_\"\n" } sort keys(%implIncludes); - $contents .= join "", @implContent; - $codeGenerator->UpdateFile($implFileName, $contents); - - @implContentHeader = (); - @implContent = (); - %implIncludes = (); - } - - if (@internalHeaderContent > 0) { - $contents = join "", @internalHeaderContent; - $codeGenerator->UpdateFile($internalHeaderFileName, $contents); - - @internalHeaderContent = (); - } - - # Write dependency file. - if (@depsContent) { - $contents = join "", @depsContent; - $codeGenerator->UpdateFile($depsFileName, $contents); - - @depsContent = (); - } -} - -1; diff --git a/contrib/dom/scripts/CodeGeneratorV8.pm b/contrib/dom/scripts/CodeGeneratorV8.pm deleted file mode 100644 index 7652cd2..0000000 --- a/contrib/dom/scripts/CodeGeneratorV8.pm +++ /dev/null @@ -1,4231 +0,0 @@ -# Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> -# Copyright (C) 2006 Anders Carlsson <andersca@mac.com> -# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> -# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> -# Copyright (C) 2006 Apple Computer, Inc. -# Copyright (C) 2007, 2008, 2009, 2012 Google Inc. -# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> -# Copyright (C) Research In Motion Limited 2010. All rights reserved. -# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) -# Copyright (C) 2012 Ericsson AB. All rights reserved. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# - -package CodeGeneratorV8; - -use strict; - -use constant FileNamePrefix => "V8"; - -my $codeGenerator; - - -my @headerContent = (); -my @implContentHeader = (); -my @implContent = (); -my @implContentDecls = (); -my %implIncludes = (); -my %headerIncludes = (); - -# Default .h template -my $headerTemplate = << "EOF"; -/* - This file is part of the WebKit open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ -EOF - -# Default constructor -sub new -{ - my $object = shift; - my $reference = { }; - - $codeGenerator = shift; - - bless($reference, $object); - return $reference; -} - -sub GenerateInterface -{ - my $object = shift; - my $interface = shift; - - # Start actual generation - if ($interface->extendedAttributes->{"Callback"}) { - $object->GenerateCallbackHeader($interface); - $object->GenerateCallbackImplementation($interface); - } else { - $object->GenerateHeader($interface); - $object->GenerateImplementation($interface); - } -} - -sub AddToImplIncludes -{ - my $header = shift; - my $conditional = shift; - - if (not $conditional) { - $implIncludes{$header} = 1; - } elsif (not exists($implIncludes{$header})) { - $implIncludes{$header} = $conditional; - } else { - my $oldValue = $implIncludes{$header}; - if ($oldValue ne 1) { - my %newValue = (); - $newValue{$conditional} = 1; - foreach my $condition (split(/\|/, $oldValue)) { - $newValue{$condition} = 1; - } - $implIncludes{$header} = join("|", sort keys %newValue); - } - } -} - -sub AddIncludesForType -{ - my $type = shift; - - # When we're finished with the one-file-per-class - # reorganization, we won't need these special cases. - if ($codeGenerator->IsTypedArrayType($type)) { - AddToImplIncludes("wtf/${type}.h"); - } - if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringType($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") { - # default, include the same named file - AddToImplIncludes(GetV8HeaderName(${type})); - - if ($type =~ /SVGPathSeg/) { - my $joinedName = $type; - $joinedName =~ s/Abs|Rel//; - AddToImplIncludes("${joinedName}.h"); - } - } - - # additional includes (things needed to compile the bindings but not the header) - - if ($type eq "CanvasRenderingContext2D") { - AddToImplIncludes("CanvasGradient.h"); - AddToImplIncludes("CanvasPattern.h"); - AddToImplIncludes("CanvasStyle.h"); - } - - if ($type eq "CanvasGradient" or $type eq "XPathNSResolver") { - AddToImplIncludes("wtf/text/WTFString.h"); - } - - if ($type eq "CSSStyleSheet" or $type eq "StyleSheet") { - AddToImplIncludes("CSSImportRule.h"); - } - - if ($type eq "CSSStyleDeclaration") { - AddToImplIncludes("StylePropertySet.h"); - } - - if ($type eq "Plugin" or $type eq "PluginArray" or $type eq "MimeTypeArray") { - # So we can get String -> AtomicString conversion for namedItem(). - AddToImplIncludes("wtf/text/AtomicString.h"); - } -} - -sub NeedsCustomOpaqueRootForGC -{ - my $interface = shift; - return GetGenerateIsReachable($interface) || GetCustomIsReachable($interface); -} - -sub GetGenerateIsReachable -{ - my $interface = shift; - return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface->extendedAttributes->{"V8GenerateIsReachable"} || "" -} - -sub GetCustomIsReachable -{ - my $interface = shift; - return $interface->extendedAttributes->{"CustomIsReachable"} || $interface->extendedAttributes->{"V8CustomIsReachable"}; -} - -sub GenerateOpaqueRootForGC -{ - my $interface = shift; - my $interfaceName = $interface->name; - - if (GetCustomIsReachable($interface)) { - return; - } - - push(@implContent, <<END); -void* V8${interfaceName}::opaqueRootForGC(void* object, v8::Persistent<v8::Object> wrapper) -{ - ASSERT(!wrapper.IsIndependent()); - ${interfaceName}* impl = static_cast<${interfaceName}*>(object); -END - if (GetGenerateIsReachable($interface) eq "ImplDocument" || - GetGenerateIsReachable($interface) eq "ImplElementRoot" || - GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || - GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { - - $implIncludes{"V8GCController.h"} = 1; - - my $methodName; - $methodName = "document" if (GetGenerateIsReachable($interface) eq "ImplDocument"); - $methodName = "element" if (GetGenerateIsReachable($interface) eq "ImplElementRoot"); - $methodName = "owner" if (GetGenerateIsReachable($interface) eq "ImplOwnerRoot"); - $methodName = "ownerNode" if (GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot"); - - push(@implContent, <<END); - if (Node* owner = impl->${methodName}()) - return V8GCController::opaqueRootForGC(owner); -END - } - - push(@implContent, <<END); - return object; -} - -END -} - -sub GetSVGPropertyTypes -{ - my $implType = shift; - - my $svgPropertyType; - my $svgListPropertyType; - my $svgNativeType; - - return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $implType =~ /SVG/; - - $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implType); - return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgNativeType; - - # Append space to avoid compilation errors when using PassRefPtr<$svgNativeType> - $svgNativeType = "$svgNativeType "; - - my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implType); - if ($svgNativeType =~ /SVGPropertyTearOff/) { - $svgPropertyType = $svgWrappedNativeType; - AddToImplIncludes("SVGAnimatedPropertyTearOff.h"); - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { - $svgListPropertyType = $svgWrappedNativeType; - $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; - $headerIncludes{"SVGStaticListPropertyTearOff.h"} = 1; - } elsif ($svgNativeType =~ /SVGTransformListPropertyTearOff/) { - $svgListPropertyType = $svgWrappedNativeType; - $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; - $headerIncludes{"SVGTransformListPropertyTearOff.h"} = 1; - } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) { - $svgListPropertyType = $svgWrappedNativeType; - $headerIncludes{"SVGPathSegListPropertyTearOff.h"} = 1; - } - - if ($svgPropertyType) { - $svgPropertyType = "SVGPoint" if $svgPropertyType eq "FloatPoint"; - } - - return ($svgPropertyType, $svgListPropertyType, $svgNativeType); -} - -sub GenerateHeader -{ - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - - # Copy contents of parent interfaces except the first parent. - my @parents; - $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents, 1); - $codeGenerator->LinkOverloadedFunctions($interface); - - # Ensure the IsDOMNodeType function is in sync. - die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMNodeType($interfaceName) != $codeGenerator->IsSubType($interface, "Node"); - - my $hasDependentLifetime = $interface->extendedAttributes->{"V8DependentLifetime"} || $interface->extendedAttributes->{"ActiveDOMObject"} - || GetGenerateIsReachable($interface) || $v8InterfaceName =~ /SVG/; - if (!$hasDependentLifetime) { - foreach (@{$interface->parents}) { - my $parent = $_; - $headerIncludes{"V8${parent}.h"} = 1; - } - } - - # - Add default header template - push(@headerContent, GenerateHeaderContentHeader($interface)); - - $headerIncludes{"wtf/text/StringHash.h"} = 1; - $headerIncludes{"WrapperTypeInfo.h"} = 1; - $headerIncludes{"V8Binding.h"} = 1; - $headerIncludes{"V8DOMWrapper.h"} = 1; - $headerIncludes{"wtf/HashMap.h"} = 1; - $headerIncludes{"v8.h"} = 1; - - my $headerClassInclude = GetHeaderClassInclude($interfaceName); - $headerIncludes{$headerClassInclude} = 1 if $headerClassInclude ne ""; - - my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interfaceName); - - foreach my $headerInclude (sort keys(%headerIncludes)) { - if ($headerInclude =~ /wtf|v8\.h/) { - push(@headerContent, "#include \<${headerInclude}\>\n"); - } else { - push(@headerContent, "#include \"${headerInclude}\"\n"); - } - } - - push(@headerContent, "\nnamespace WebCore {\n"); - push(@headerContent, "\ntemplate<typename PropertyType> class SVGPropertyTearOff;\n") if $svgPropertyType; - if ($svgNativeType) { - if ($svgNativeType =~ /SVGStaticListPropertyTearOff/) { - push(@headerContent, "\ntemplate<typename PropertyType> class SVGStaticListPropertyTearOff;\n"); - } else { - push(@headerContent, "\ntemplate<typename PropertyType> class SVGListPropertyTearOff;\n"); - } - } - - push(@headerContent, "\n"); - push(@headerContent, "class FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect"; - push(@headerContent, "class Dictionary;\n") if $codeGenerator->IsConstructorTemplate($interface, "Event"); - - my $nativeType = GetNativeTypeForConversions($interface); - if ($interface->extendedAttributes->{"NamedConstructor"}) { - push(@headerContent, <<END); -class V8${nativeType}Constructor { -public: - static v8::Persistent<v8::FunctionTemplate> GetTemplate(); - static WrapperTypeInfo info; -}; - -END - } - - push(@headerContent, "class $v8InterfaceName {\n"); - push(@headerContent, "public:\n"); - - push(@headerContent, " static const bool hasDependentLifetime = "); - if ($hasDependentLifetime) { - push(@headerContent, "true;\n"); - } elsif (@{$interface->parents}) { - # Even if this type doesn't have the V8DependentLifetime attribute its parents may. - # Let the compiler statically determine this for us. - my $separator = ""; - foreach (@{$interface->parents}) { - my $parent = $_; - $headerIncludes{"V8${parent}.h"} = 1; - push(@headerContent, "${separator}V8${parent}::hasDependentLifetime"); - $separator = " || "; - } - push(@headerContent, ";\n"); - } else { - push(@headerContent, "false;\n"); - } - - push(@headerContent, <<END); - static bool HasInstance(v8::Handle<v8::Value>); - static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); - static v8::Persistent<v8::FunctionTemplate> GetTemplate(); - static ${nativeType}* toNative(v8::Handle<v8::Object> object) - { - return reinterpret_cast<${nativeType}*>(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)); - } - static void derefObject(void*); - static WrapperTypeInfo info; -END - - if (NeedsCustomOpaqueRootForGC($interface)) { - push(@headerContent, " static void* opaqueRootForGC(void*, v8::Persistent<v8::Object>);\n"); - } - - if ($interface->extendedAttributes->{"ActiveDOMObject"}) { - push(@headerContent, " static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);\n"); - } - - if ($interfaceName eq "DOMWindow") { - push(@headerContent, <<END); - static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(); -END - } - - if ($interfaceName eq "HTMLDocument") { - push(@headerContent, <<END); - static v8::Local<v8::Object> wrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl); - static v8::Handle<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key, v8::Handle<v8::Object> creationContext, v8::Isolate*); -END - } - - my @enabledPerContextFunctions; - foreach my $function (@{$interface->functions}) { - my $name = $function->signature->name; - my $attrExt = $function->signature->extendedAttributes; - - if (($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) && !$attrExt->{"ImplementedBy"} && $function->{overloadIndex} == 1) { - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - push(@headerContent, <<END); - static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments&); -END - push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; - } - if ($attrExt->{"V8EnabledPerContext"}) { - push(@enabledPerContextFunctions, $function); - } - } - - if (IsConstructable($interface)) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); -END - } - if (HasCustomConstructor($interface)) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> constructorCallbackCustom(const v8::Arguments&); -END - } - - my @enabledPerContextAttributes; - foreach my $attribute (@{$interface->attributes}) { - my $name = $attribute->signature->name; - my $attrExt = $attribute->signature->extendedAttributes; - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - if (($attrExt->{"V8CustomGetter"} || $attrExt->{"CustomGetter"} || - $attrExt->{"V8Custom"} || $attrExt->{"Custom"}) && - !$attrExt->{"ImplementedBy"}) { - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - push(@headerContent, <<END); - static v8::Handle<v8::Value> ${name}AccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo&); -END - push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; - } - if (($attrExt->{"V8CustomSetter"} || $attrExt->{"CustomSetter"} || - $attrExt->{"V8Custom"} || $attrExt->{"Custom"}) && - !$attrExt->{"ImplementedBy"}) { - push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; - push(@headerContent, <<END); - static void ${name}AccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&); -END - push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; - } - if ($attrExt->{"V8EnabledPerContext"}) { - push(@enabledPerContextAttributes, $attribute); - } - } - - GenerateHeaderNamedAndIndexedPropertyAccessors($interface); - GenerateHeaderCustomCall($interface); - GenerateHeaderCustomInternalFieldIndices($interface); - - if ($interface->extendedAttributes->{"CheckSecurity"}) { - push(@headerContent, <<END); - static bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data); - static bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data); -END - } - - if (@enabledPerContextAttributes) { - push(@headerContent, <<END); - static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType}*); -END - } else { - push(@headerContent, <<END); - static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType}*) { } -END - } - - if (@enabledPerContextFunctions) { - push(@headerContent, <<END); - static void installPerContextPrototypeProperties(v8::Handle<v8::Object>); -END - } else { - push(@headerContent, <<END); - static void installPerContextPrototypeProperties(v8::Handle<v8::Object>) { } -END - } - - if ($interfaceName eq "HTMLElement") { - push(@headerContent, <<END); - friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*); - friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*); -END - } elsif ($interfaceName eq "SVGElement") { - push(@headerContent, <<END); - friend v8::Handle<v8::Object> createV8SVGWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*); - friend v8::Handle<v8::Object> createV8SVGDirectWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*); - friend v8::Handle<v8::Object> createV8SVGFallbackWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*); -END - } elsif ($interfaceName eq "HTMLUnknownElement") { - push(@headerContent, <<END); - friend v8::Handle<v8::Object> createV8HTMLFallbackWrapper(HTMLUnknownElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*); -END - } elsif ($interfaceName eq "Element") { - push(@headerContent, <<END); - // This is a performance optimization hack. See V8Element::wrap. - friend v8::Handle<v8::Object> wrap(Node*, v8::Handle<v8::Object> creationContext, v8::Isolate*); -END - } - - push(@headerContent, <<END); -private: -END - - if (IsConstructable($interface) && @{$interface->constructors} > 1) { - for (my $i = 1; $i <= @{$interface->constructors}; $i++) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> constructor${i}Callback(const v8::Arguments&); -END - } - } - - my $noToV8 = $interface->extendedAttributes->{"SuppressToJSObject"}; - my $noWrap = $interface->extendedAttributes->{"V8NoWrapperCache"} || $noToV8; - if (!$noWrap) { - my $createWrapperArgumentType = GetPassRefPtrType($nativeType); - push(@headerContent, <<END); - friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> creationContext, v8::Isolate*); - static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8::Handle<v8::Object> creationContext, v8::Isolate*); -END - } - - push(@headerContent, <<END); -}; - -END - - my $customWrap = !!($interface->extendedAttributes->{"CustomToJSObject"} or $interface->extendedAttributes->{"V8CustomToJSObject"}); - if ($noToV8) { - die "Can't suppress toV8 for subclass\n" if @parents; - } elsif ($noWrap) { - die "Must have custom toV8\n" if !$customWrap; - push(@headerContent, <<END); -class ${nativeType}; -v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* = 0); - -template<class HolderContainer, class Wrappable> -inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer& container, Wrappable*) -{ - return toV8(impl, container.Holder(), container.GetIsolate()); -} -END - } else { - - my $createWrapperCall = $customWrap ? "${v8InterfaceName}::wrap" : "${v8InterfaceName}::createWrapper"; - - if ($customWrap) { - push(@headerContent, <<END); - -v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* = 0); -END - } else { - push(@headerContent, <<END); - -inline v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate = 0) -{ - ASSERT(impl); - ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty()); - return $createWrapperCall(impl, creationContext, isolate); -} -END - } - - push(@headerContent, <<END); - -inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0) -{ - if (UNLIKELY(!impl)) - return v8NullWithCheck(isolate); - v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); - if (!wrapper.IsEmpty()) - return wrapper; - return wrap(impl, creationContext, isolate); -} - -template<class HolderContainer, class Wrappable> -inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer& container, Wrappable* wrappable) -{ - if (UNLIKELY(!impl)) - return v8Null(container.GetIsolate()); - v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperFast(impl, container, wrappable); - if (!wrapper.IsEmpty()) - return wrapper; - return wrap(impl, container.Holder(), container.GetIsolate()); -} -END - } - - push(@headerContent, <<END); - -template<class HolderContainer, class Wrappable> -inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< ${nativeType} > impl, const HolderContainer& container, Wrappable* wrappable) -{ - return toV8Fast(impl.get(), container, wrappable); -} - -inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0) -{ - return toV8(impl.get(), creationContext, isolate); -} -END - - if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { - push(@headerContent, "\nbool fill${interfaceName}Init(${interfaceName}Init&, const Dictionary&);\n"); - } - - push(@headerContent, "\n}\n\n"); - push(@headerContent, "#endif // $v8InterfaceName" . "_h\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; -} - -sub GetInternalFields -{ - my $interface = shift; - - my @customInternalFields = (); - # We can't ask whether a parent type has a given extendedAttribute, - # so special-case AbstractWorker and WorkerContext to include all sub-types. - # Event listeners on DOM nodes are explicitly supported in the GC controller. - # FIXME: Simplify this when all EventTargets are subtypes of EventTarget. - if (!$codeGenerator->IsSubType($interface, "Node") - && ($interface->extendedAttributes->{"EventTarget"} - || $interface->extendedAttributes->{"IsWorkerContext"} - || $codeGenerator->IsSubType($interface, "AbstractWorker") - || $codeGenerator->IsSubType($interface, "EventTarget"))) { - push(@customInternalFields, "eventListenerCacheIndex"); - } - - return @customInternalFields; -} - -sub GetHeaderClassInclude -{ - my $v8InterfaceName = shift; - if ($v8InterfaceName =~ /SVGPathSeg/) { - $v8InterfaceName =~ s/Abs|Rel//; - } - return "wtf/${v8InterfaceName}.h" if $codeGenerator->IsTypedArrayType($v8InterfaceName); - return "" if ($codeGenerator->SkipIncludeHeader($v8InterfaceName)); - return "${v8InterfaceName}.h"; -} - -sub GenerateHeaderCustomInternalFieldIndices -{ - my $interface = shift; - my @customInternalFields = GetInternalFields($interface); - my $customFieldCounter = 0; - foreach my $customInternalField (@customInternalFields) { - push(@headerContent, <<END); - static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; -END - $customFieldCounter++; - } - push(@headerContent, <<END); - static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; -END -} - -my %indexerSpecialCases = ( - "Storage" => 1, - "HTMLAppletElement" => 1, - "HTMLEmbedElement" => 1, - "HTMLObjectElement" => 1 -); - -sub GenerateHeaderNamedAndIndexedPropertyAccessors -{ - my $interface = shift; - my $interfaceName = $interface->name; - my $hasCustomIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; - my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexedSetter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"}; - my $hasCustomNamedGetter = $interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; - my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSetter"}; - my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProperty"}; - my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateProperty"}; - if ($interfaceName eq "HTMLOptionsCollection") { - $interfaceName = "HTMLCollection"; - $hasCustomIndexedGetter = 1; - $hasCustomNamedGetter = 1; - } - if ($interfaceName eq "DOMWindow") { - $hasCustomDeleters = 0; - $hasCustomEnumerator = 0; - } - if ($interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedElement" || $interfaceName eq "HTMLObjectElement") { - $hasCustomNamedGetter = 1; - } - if ($interfaceName eq "HTMLDocument") { - $hasCustomNamedGetter = 0; - $hasCustomIndexedGetter = 0; - } - my $isIndexerSpecialCase = exists $indexerSpecialCases{$interfaceName}; - - if ($hasCustomIndexedGetter || $isIndexerSpecialCase) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::AccessorInfo&); -END - } - - if ($isIndexerSpecialCase || $hasCustomIndexedSetter) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> indexedPropertySetter(uint32_t, v8::Local<v8::Value>, const v8::AccessorInfo&); -END - } - if ($hasCustomDeleters) { - push(@headerContent, <<END); - static v8::Handle<v8::Boolean> indexedPropertyDeleter(uint32_t, const v8::AccessorInfo&); -END - } - if ($hasCustomNamedGetter) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, const v8::AccessorInfo&); -END - } - if ($hasCustomNamedSetter) { - push(@headerContent, <<END); - static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo&); -END - } - if ($hasCustomDeleters) { - push(@headerContent, <<END); - static v8::Handle<v8::Boolean> namedPropertyDeleter(v8::Local<v8::String>, const v8::AccessorInfo&); -END - } - if ($hasCustomEnumerator) { - push(@headerContent, <<END); - static v8::Handle<v8::Array> namedPropertyEnumerator(const v8::AccessorInfo&); - static v8::Handle<v8::Integer> namedPropertyQuery(v8::Local<v8::String>, const v8::AccessorInfo&); -END - } -} - -sub GenerateHeaderCustomCall -{ - my $interface = shift; - - if ($interface->extendedAttributes->{"CustomCall"}) { - push(@headerContent, " static v8::Handle<v8::Value> callAsFunctionCallback(const v8::Arguments&);\n"); - } - if ($interface->name eq "Event") { - push(@headerContent, " static v8::Handle<v8::Value> dataTransferAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); - push(@headerContent, " static void valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&);\n"); - } - if ($interface->name eq "Location") { - push(@headerContent, " static v8::Handle<v8::Value> assignAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); - push(@headerContent, " static v8::Handle<v8::Value> reloadAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); - push(@headerContent, " static v8::Handle<v8::Value> replaceAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); - } -} - -sub IsConstructable -{ - my $interface = shift; - - return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"V8CustomConstructor"} || $interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"ConstructorTemplate"}; -} - -sub HasCustomConstructor -{ - my $interface = shift; - - return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"V8CustomConstructor"}; -} - -sub IsReadonly -{ - my $attribute = shift; - my $attrExt = $attribute->signature->extendedAttributes; - return ($attribute->type =~ /readonly/ || $attrExt->{"V8ReadOnly"}) && !$attrExt->{"Replaceable"}; -} - -sub GenerateDomainSafeFunctionGetter -{ - my $function = shift; - my $interfaceName = shift; - - my $v8InterfaceName = "V8" . $interfaceName; - my $funcName = $function->signature->name; - - my $signature = "v8::Signature::New(" . $v8InterfaceName . "::GetRawTemplate())"; - if ($function->signature->extendedAttributes->{"V8DoNotCheckSignature"}) { - $signature = "v8::Local<v8::Signature>()"; - } - - my $callback = GetFunctionTemplateCallbackName($function, $interfaceName); - my $newTemplateString = "v8::FunctionTemplate::New($callback, v8Undefined(), $signature)"; - - AddToImplIncludes("Frame.h"); - push(@implContentDecls, <<END); -static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) -{ - static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); - v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate()); - if (holder.IsEmpty()) { - // can only reach here by 'object.__proto__.func', and it should passed - // domain security check already - return privateTemplate->GetFunction(); - } - ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); - if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError)) { - static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); - return sharedTemplate->GetFunction(); - } - - v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name); - if (!hiddenValue.IsEmpty()) - return hiddenValue; - - return privateTemplate->GetFunction(); -} - -END -} - -sub GenerateDomainSafeFunctionSetter -{ - my $interfaceName = shift; - my $v8InterfaceName = "V8" . $interfaceName; - - push(@implContentDecls, <<END); -static void ${interfaceName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) -{ - v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate()); - if (holder.IsEmpty()) - return; - ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); - if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame())) - return; - - info.This()->SetHiddenValue(name, value); -} - -END -} - -sub GenerateConstructorGetter -{ - my $interface = shift; - my $interfaceName = $interface->name; - - push(@implContentDecls, <<END); -static v8::Handle<v8::Value> ${interfaceName}ConstructorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) -{ - v8::Handle<v8::Value> data = info.Data(); - ASSERT(data->IsExternal()); - V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext()); - if (!perContextData) - return v8Undefined(); - return perContextData->constructorForType(WrapperTypeInfo::unwrap(data)); -} -END -} - -sub GenerateFeatureObservation -{ - my $measureAs = shift; - - if ($measureAs) { - AddToImplIncludes("FeatureObserver.h"); - return " FeatureObserver::observe(activeDOMWindow(BindingState::instance()), FeatureObserver::${measureAs});\n"; - } - - return ""; -} - -sub GenerateNormalAttrGetter -{ - my $attribute = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - my $attrExt = $attribute->signature->extendedAttributes; - my $attrName = $attribute->signature->name; - my $attrType = $attribute->signature->type; - $codeGenerator->AssertNotSequenceType($attrType); - my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); - - my $getterStringUsesImp = $interfaceName ne "SVGNumber"; - my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName); - - # Getter - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; - - push(@implContentDecls, <<END); -static v8::Handle<v8::Value> ${attrName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) -{ -END - push(@implContentDecls, GenerateFeatureObservation($attrExt->{"V8MeasureAs"})); - - if ($svgNativeType) { - my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($interfaceName); - if ($svgWrappedNativeType =~ /List/) { - push(@implContentDecls, <<END); - $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); -END - } else { - push(@implContentDecls, <<END); - $svgNativeType* wrapper = ${v8InterfaceName}::toNative(info.Holder()); - $svgWrappedNativeType& impInstance = wrapper->propertyReference(); -END - if ($getterStringUsesImp) { - push(@implContentDecls, <<END); - $svgWrappedNativeType* imp = &impInstance; -END - } - } - } elsif ($attrExt->{"V8OnProto"} || $attrExt->{"V8Unforgeable"}) { - if ($interfaceName eq "DOMWindow") { - push(@implContentDecls, <<END); - v8::Handle<v8::Object> holder = info.Holder(); -END - } else { - # perform lookup first - push(@implContentDecls, <<END); - v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate()); - if (holder.IsEmpty()) - return v8Undefined(); -END - } - push(@implContentDecls, <<END); - ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); -END - } else { - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $url = $attribute->signature->extendedAttributes->{"URL"}; - if ($getterStringUsesImp && $reflect && !$url && $codeGenerator->IsSubType($interface, "Node") && $codeGenerator->IsStringType($attrType)) { - # Generate super-compact call for regular attribute getter: - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@implContentDecls, " Element* imp = V8Element::toNative(info.Holder());\n"); - push(@implContentDecls, " return v8String(imp->${functionName}(" . join(", ", @arguments) . "), info.GetIsolate());\n"); - push(@implContentDecls, "}\n\n"); - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; - return; - # Skip the rest of the function! - } - if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->{"CachedAttribute"}) { - push(@implContentDecls, <<END); - v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); - v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); - if (!value.IsEmpty()) - return value; -END - } - if (!$attribute->isStatic) { - push(@implContentDecls, <<END); - ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); -END - } - } - - # Generate security checks if necessary - if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { - push(@implContentDecls, " if (!BindingSecurity::shouldAllowAccessToNode(BindingState::instance(), imp->" . $attribute->signature->name . "()))\n return v8::Handle<v8::Value>(v8Null(info.GetIsolate()));\n\n"); - } - - my $useExceptions = 1 if @{$attribute->getterExceptions}; - if ($useExceptions) { - AddToImplIncludes("ExceptionCode.h"); - push(@implContentDecls, " ExceptionCode ec = 0;\n"); - } - - my $returnType = $attribute->signature->type; - my $getterString; - - if ($getterStringUsesImp) { - my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@arguments, "ec") if $useExceptions; - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - AddToImplIncludes("${implementedBy}.h"); - unshift(@arguments, "imp") if !$attribute->isStatic; - $functionName = "${implementedBy}::${functionName}"; - } elsif ($attribute->isStatic) { - $functionName = "${interfaceName}::${functionName}"; - } else { - $functionName = "imp->${functionName}"; - } - unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, " ", 0)); - $getterString = "${functionName}(" . join(", ", @arguments) . ")"; - } else { - $getterString = "impInstance"; - } - - my $result; - if ($attribute->signature->type eq "EventListener" && $interface->name eq "DOMWindow") { - push(@implContentDecls, " if (!imp->document())\n"); - push(@implContentDecls, " return v8Undefined();\n"); - } - - if ($useExceptions) { - if ($nativeType =~ /^V8StringResource/) { - push(@implContentDecls, " " . ConvertToV8StringResource($attribute->signature, $nativeType, "v", $getterString) . ";\n"); - } else { - push(@implContentDecls, " $nativeType v = $getterString;\n"); - } - push(@implContentDecls, " if (UNLIKELY(ec))\n"); - push(@implContentDecls, " return setDOMException(ec, info.GetIsolate());\n"); - - if ($codeGenerator->ExtendedAttributeContains($attribute->signature->extendedAttributes->{"CallWith"}, "ScriptState")) { - push(@implContentDecls, " if (state.hadException())\n"); - push(@implContentDecls, " return throwError(state.exception(), info.GetIsolate());\n"); - } - - $result = "v"; - $result .= ".release()" if ($codeGenerator->IsRefPtrType($returnType)); - } else { - # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary - $result = $getterString; - # Fix amigious conversion problem, by casting to the base type first ($getterString returns a type that inherits from SVGAnimatedEnumeration, not the base class directly). - $result = "static_pointer_cast<SVGAnimatedEnumeration>($result)" if $returnType eq "SVGAnimatedEnumeration"; - } - - # Special case for readonly or Replaceable attributes (with a few exceptions). This attempts to ensure that JS wrappers don't get - # garbage-collected prematurely when their lifetime is strongly tied to their owner. We accomplish this by inserting a reference to - # the newly created wrapper into an internal field of the holder object. - if ((!$codeGenerator->IsSubType($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->signature->extendedAttributes->{"Replaceable"} || $attrName eq "location") - && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow" - && $returnType ne "MessagePortArray" - && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType)) - || $attribute->signature->extendedAttributes->{"V8CacheAttributeForGC"}) { - - my $arrayType = $codeGenerator->GetArrayType($returnType); - if ($arrayType) { - if (!$codeGenerator->SkipIncludeHeader($arrayType)) { - AddToImplIncludes("V8$arrayType.h"); - AddToImplIncludes("$arrayType.h"); - } - push(@implContentDecls, " return v8Array(${getterString}, info.GetIsolate());\n"); - push(@implContentDecls, "}\n\n"); - return; - } - - AddIncludesForType($returnType); - # Check for a wrapper in the wrapper cache. If there is one, we know that a hidden reference has already - # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. - push(@implContentDecls, " RefPtr<$returnType> result = ${getterString};\n"); - push(@implContentDecls, " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Undefined();\n"); - push(@implContentDecls, " if (wrapper.IsEmpty()) {\n"); - push(@implContentDecls, " wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());\n"); # FIXME: Could use wrap here since the wrapper is empty. - push(@implContentDecls, " if (!wrapper.IsEmpty())\n"); - push(@implContentDecls, " V8DOMWrapper::setNamedHiddenReference(info.Holder(), \"${attrName}\", wrapper);\n"); - push(@implContentDecls, " }\n"); - push(@implContentDecls, " return wrapper;\n"); - push(@implContentDecls, "}\n\n"); - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; - return; - } - - if (($codeGenerator->IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") and $codeGenerator->IsSVGTypeNeedingTearOff($attrType)) { - AddToImplIncludes("V8$attrType.h"); - my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); - # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked. - push(@implContentDecls, " return toV8Fast(static_cast<$svgNativeType*>($result), info, imp);\n"); - } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$/) { - AddToImplIncludes("V8$attrType.h"); - AddToImplIncludes("SVGPropertyTearOff.h"); - my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); - my $wrappedValue; - if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { - my $getter = $result; - $getter =~ s/imp->//; - $getter =~ s/\(\)//; - - my $updateMethod = "&${interfaceName}::update" . $codeGenerator->WK_ucfirst($getter); - - my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName); - if ($selfIsTearOffType) { - AddToImplIncludes("SVGStaticPropertyWithParentTearOff.h"); - $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParentTearOff<$interfaceName, /; - - if ($result =~ /matrix/ and $interfaceName eq "SVGTransform") { - # SVGTransform offers a matrix() method for internal usage that returns an AffineTransform - # and a svgMatrix() method returning a SVGMatrix, used for the bindings. - $result =~ s/matrix/svgMatrix/; - } - - $wrappedValue = "WTF::getPtr(${tearOffType}::create(wrapper, $result, $updateMethod))"; - } else { - AddToImplIncludes("SVGStaticPropertyTearOff.h"); - $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$interfaceName, /; - - $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $result, $updateMethod))"; - } - } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { - $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $result))"; - } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { - $wrappedValue = "WTF::getPtr($result)"; - } else { - $wrappedValue = "WTF::getPtr(${tearOffType}::create($result))"; - } - push(@implContentDecls, " return toV8Fast($wrappedValue, info, imp);\n"); - } elsif ($attribute->signature->type eq "MessagePortArray") { - AddToImplIncludes("MessagePort.h"); - AddToImplIncludes("V8MessagePort.h"); - my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name); - push(@implContentDecls, <<END); - MessagePortArray* ports = imp->${getterFunc}(); - if (!ports) - return v8::Array::New(0); - MessagePortArray portsCopy(*ports); - v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); - for (size_t i = 0; i < portsCopy.size(); ++i) - portArray->Set(v8Integer(i, info.GetIsolate()), toV8Fast(portsCopy[i].get(), info, imp)); - return portArray; -END - } elsif ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->{"CachedAttribute"}) { - my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name); - push(@implContentDecls, <<END); - SerializedScriptValue* serialized = imp->${getterFunc}(); - value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Null(info.GetIsolate())); - info.Holder()->SetHiddenValue(propertyName, value); - return value; -END - } else { - push(@implContentDecls, " return " . NativeToJSValue($attribute->signature, $result, "info.Holder()", "info.GetIsolate()", "info", "imp").";\n"); - } - - push(@implContentDecls, "}\n\n"); # end of getter - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; -} - -sub GenerateReplaceableAttrSetter -{ - my $interface = shift; - my $interfaceName = $interface->name; - - push(@implContentDecls, <<END); -static void ${interfaceName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) -{ -END - push(@implContentDecls, GenerateFeatureObservation($interface->extendedAttributes->{"V8MeasureAs"})); - - if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"CheckSecurity"}) { - AddToImplIncludes("Frame.h"); - push(@implContentDecls, <<END); - ${interfaceName}* imp = V8${interfaceName}::toNative(info.Holder()); - if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame())) - return; -END - } - - push(@implContentDecls, <<END); - info.This()->ForceSet(name, value); -} - -END -} - -sub GenerateNormalAttrSetter -{ - my $attribute = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - my $attrName = $attribute->signature->name; - my $attrExt = $attribute->signature->extendedAttributes; - - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; - - push(@implContentDecls, "static void ${attrName}AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n{\n"); - push(@implContentDecls, GenerateFeatureObservation($attribute->signature->extendedAttributes->{"V8MeasureAs"})); - - # If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an - # interface type, then if the incoming value does not implement that interface, a TypeError is - # thrown rather than silently passing NULL to the C++ code. - # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both - # strings and numbers, so do not throw TypeError if the attribute is of these types. - if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { - my $argType = $attribute->signature->type; - if (IsWrapperType($argType)) { - push(@implContentDecls, " if (!isUndefinedOrNull(value) && !V8${argType}::HasInstance(value)) {\n"); - push(@implContentDecls, " throwTypeError(0, info.GetIsolate());\n"); - push(@implContentDecls, " return;\n"); - push(@implContentDecls, " }\n"); - } - } - - my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName); - if ($svgNativeType) { - my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($interfaceName); - if ($svgWrappedNativeType =~ /List$/) { - push(@implContentDecls, <<END); - $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); -END - } else { - AddToImplIncludes("ExceptionCode.h"); - push(@implContentDecls, " $svgNativeType* wrapper = ${v8InterfaceName}::toNative(info.Holder());\n"); - push(@implContentDecls, " if (wrapper->isReadOnly()) {\n"); - push(@implContentDecls, " setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.GetIsolate());\n"); - push(@implContentDecls, " return;\n"); - push(@implContentDecls, " }\n"); - push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); - push(@implContentDecls, " $svgWrappedNativeType* imp = &impInstance;\n"); - } - } elsif ($attrExt->{"V8OnProto"}) { - push(@implContentDecls, <<END); - ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); -END - } else { - my $attrType = $attribute->signature->type; - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - if ($reflect && $codeGenerator->IsSubType($interface, "Node") && $codeGenerator->IsStringType($attrType)) { - # Generate super-compact call for regular attribute setter: - my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attrName : $reflect; - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - AddToImplIncludes("${namespace}.h"); - push(@implContentDecls, " Element* imp = V8Element::toNative(info.Holder());\n"); - push(@implContentDecls, " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, stringResource, value);\n"); - push(@implContentDecls, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, stringResource);\n"); - push(@implContentDecls, "}\n\n"); - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; - return; - # Skip the rest of the function! - } - - if (!$attribute->isStatic) { - push(@implContentDecls, <<END); - ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); -END - } - } - - my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); - if ($attribute->signature->type eq "EventListener") { - if ($interface->name eq "DOMWindow") { - push(@implContentDecls, " if (!imp->document())\n"); - push(@implContentDecls, " return;\n"); - } - } else { - my $value = JSValueToNative($attribute->signature, "value", "info.GetIsolate()"); - my $arrayType = $codeGenerator->GetArrayType($nativeType); - - if ($nativeType =~ /^V8StringResource/) { - push(@implContentDecls, " " . ConvertToV8StringResource($attribute->signature, $nativeType, "v", $value, "VOID") . "\n"); - } elsif ($arrayType) { - push(@implContentDecls, " Vector<$arrayType> v = $value;\n"); - } else { - push(@implContentDecls, " $nativeType v = $value;\n"); - } - } - - my $result = "v"; - my $returnType = $attribute->signature->type; - if ($codeGenerator->IsRefPtrType($returnType) && !$codeGenerator->GetArrayType($returnType)) { - $result = "WTF::getPtr(" . $result . ")"; - } - - my $useExceptions = 1 if @{$attribute->setterExceptions}; - - if ($useExceptions) { - AddToImplIncludes("ExceptionCode.h"); - push(@implContentDecls, " ExceptionCode ec = 0;\n"); - } - - if ($interfaceName eq "SVGNumber") { - push(@implContentDecls, " *imp = $result;\n"); - } else { - if ($attribute->signature->type eq "EventListener") { - my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); - AddToImplIncludes("V8AbstractEventListener.h"); - if (!$codeGenerator->IsSubType($interface, "Node")) { - push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, ${v8InterfaceName}::eventListenerCacheIndex);\n"); - } - if ($interfaceName eq "WorkerContext" and $attribute->signature->name eq "onerror") { - AddToImplIncludes("V8EventListenerList.h"); - AddToImplIncludes("V8WorkerContextErrorHandler.h"); - push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"); - } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->name eq "onerror") { - AddToImplIncludes("V8EventListenerList.h"); - AddToImplIncludes("V8WindowErrorHandler.h"); - push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"); - } else { - push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)"); - } - push(@implContentDecls, ", ec") if $useExceptions; - push(@implContentDecls, ");\n"); - } else { - my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute); - push(@arguments, $result); - push(@arguments, "ec") if $useExceptions; - if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { - my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"}; - AddToImplIncludes("${implementedBy}.h"); - unshift(@arguments, "imp") if !$attribute->isStatic; - $functionName = "${implementedBy}::${functionName}"; - } elsif ($attribute->isStatic) { - $functionName = "${interfaceName}::${functionName}"; - } else { - $functionName = "imp->${functionName}"; - } - unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, " ", 1)); - push(@implContentDecls, " ${functionName}(" . join(", ", @arguments) . ");\n"); - } - } - - if ($useExceptions) { - push(@implContentDecls, " if (UNLIKELY(ec))\n"); - push(@implContentDecls, " setDOMException(ec, info.GetIsolate());\n"); - } - - if ($codeGenerator->ExtendedAttributeContains($attribute->signature->extendedAttributes->{"CallWith"}, "ScriptState")) { - push(@implContentDecls, " if (state.hadException())\n"); - push(@implContentDecls, " throwError(state.exception(), info.GetIsolate());\n"); - } - - if ($svgNativeType) { - if ($useExceptions) { - push(@implContentDecls, " if (!ec)\n"); - push(@implContentDecls, " wrapper->commitChange();\n"); - } else { - push(@implContentDecls, " wrapper->commitChange();\n"); - } - } - - if ($attribute->signature->type eq "SerializedScriptValue" && $attribute->signature->extendedAttributes->{"CachedAttribute"}) { - push(@implContentDecls, <<END); - info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // Invalidate the cached value. -END - } - - push(@implContentDecls, " return;\n"); - push(@implContentDecls, "}\n\n"); # end of setter - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; -} - -sub GetFunctionTemplateCallbackName -{ - my $function = shift; - my $interfaceName = shift; - - my $name = $function->signature->name; - - if ($function->signature->extendedAttributes->{"Custom"} || - $function->signature->extendedAttributes->{"V8Custom"}) { - if ($function->signature->extendedAttributes->{"Custom"} && - $function->signature->extendedAttributes->{"V8Custom"}) { - die "Custom and V8Custom should be mutually exclusive!" - } - return "V8${interfaceName}::${name}Callback"; - } else { - return "${interfaceName}V8Internal::${name}Callback"; - } -} - -sub GenerateEventListenerCallback -{ - my $interfaceName = shift; - my $requiresHiddenDependency = shift; - my $functionName = shift; - my $lookupType = ($functionName eq "add") ? "OrCreate" : "Only"; - my $passRefPtrHandling = ($functionName eq "add") ? "" : ".get()"; - my $hiddenDependencyAction = ($functionName eq "add") ? "create" : "remove"; - - push(@implContentDecls, <<END); -static v8::Handle<v8::Value> ${functionName}EventListenerCallback(const v8::Arguments& args) -{ - RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFind${lookupType}); - if (listener) { - V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<WithNullCheck>, stringResource, args[0]); - V8${interfaceName}::toNative(args.Holder())->${functionName}EventListener(stringResource, listener${passRefPtrHandling}, args[2]->BooleanValue()); -END - if ($requiresHiddenDependency) { - push(@implContentDecls, <<END); - ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], V8${interfaceName}::eventListenerCacheIndex); -END - } - push(@implContentDecls, <<END); - } - return v8Undefined(); -} - -END -} - -sub GenerateParametersCheckExpression -{ - my $numParameters = shift; - my $function = shift; - - my @andExpression = (); - push(@andExpression, "args.Length() == $numParameters"); - my $parameterIndex = 0; - foreach my $parameter (@{$function->parameters}) { - last if $parameterIndex >= $numParameters; - my $value = "args[$parameterIndex]"; - my $type = $parameter->type; - - # Only DOMString or wrapper types are checked. - # For DOMString with StrictTypeChecking only Null, Undefined and Object - # are accepted for compatibility. Otherwise, no restrictions are made to - # match the non-overloaded behavior. - # FIXME: Implement WebIDL overload resolution algorithm. - if ($codeGenerator->IsStringType($type)) { - if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { - push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())"); - } - } elsif ($parameter->extendedAttributes->{"Callback"}) { - # For Callbacks only checks if the value is null or object. - push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())"); - } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) { - if ($parameter->isNullable) { - push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())"); - } else { - push(@andExpression, "(${value}->IsArray())"); - } - } elsif (IsWrapperType($type)) { - if ($parameter->isNullable) { - push(@andExpression, "(${value}->IsNull() || V8${type}::HasInstance($value))"); - } else { - push(@andExpression, "(V8${type}::HasInstance($value))"); - } - } - - $parameterIndex++; - } - my $res = join(" && ", @andExpression); - $res = "($res)" if @andExpression > 1; - return $res; -} - -sub GenerateFunctionParametersCheck -{ - my $function = shift; - - my @orExpression = (); - my $numParameters = 0; - my $hasVariadic = 0; - my $numMandatoryParams = @{$function->parameters}; - foreach my $parameter (@{$function->parameters}) { - if ($parameter->extendedAttributes->{"Optional"}) { - push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); - $numMandatoryParams--; - } - if ($parameter->isVariadic) { - $hasVariadic = 1; - last; - } - $numParameters++; - } - if (!$hasVariadic) { - push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); - } - return ($numMandatoryParams, join(" || ", @orExpression)); -} - -sub GenerateOverloadedFunctionCallback -{ - my $function = shift; - my $interface = shift; - my $interfaceName = $interface->name; - - # Generate code for choosing the correct overload to call. Overloads are - # chosen based on the total number of arguments passed and the type of - # values passed in non-primitive argument slots. When more than a single - # overload is applicable, precedence is given according to the order of - # declaration in the IDL. - - my $name = $function->signature->name; - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - my $leastNumMandatoryParams = 255; - push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; - push(@implContentDecls, <<END); -static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments& args) -{ -END - push(@implContentDecls, GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"})); - - foreach my $overload (@{$function->{overloads}}) { - my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($overload); - $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); - push(@implContentDecls, " if ($parametersCheck)\n"); - push(@implContentDecls, " return ${name}$overload->{overloadIndex}Callback(args);\n"); - } - if ($leastNumMandatoryParams >= 1) { - push(@implContentDecls, " if (args.Length() < $leastNumMandatoryParams)\n"); - push(@implContentDecls, " return throwNotEnoughArgumentsError(args.GetIsolate());\n"); - } - push(@implContentDecls, <<END); - return throwTypeError(0, args.GetIsolate()); -END - push(@implContentDecls, "}\n\n"); - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; -} - -sub GenerateFunctionCallback -{ - my $function = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - my $name = $function->signature->name; - - if (@{$function->{overloads}} > 1) { - # Append a number to an overloaded method's name to make it unique: - $name = $name . $function->{overloadIndex}; - } - - # Adding and removing event listeners are not standard callback behavior, - # but they are extremely consistent across the various interfaces that take event listeners, - # so we can generate them as a "special case". - if ($name eq "addEventListener") { - GenerateEventListenerCallback($interfaceName, !$codeGenerator->IsSubType($interface, "Node"), "add"); - return; - } elsif ($name eq "removeEventListener") { - GenerateEventListenerCallback($interfaceName, !$codeGenerator->IsSubType($interface, "Node"), "remove"); - return; - } - - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; - push(@implContentDecls, <<END); -static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments& args) -{ -END - push(@implContentDecls, GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"})); - - push(@implContentDecls, GenerateArgumentsCountCheck($function, $interface)); - - if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { - AddToImplIncludes("V8ArrayBufferViewCustom.h"); - push(@implContentDecls, <<END); - return setWebGLArrayHelper<$interfaceName, ${v8InterfaceName}>(args); -} - -END - return; - } - - my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interfaceName); - - if ($svgNativeType) { - my $nativeClassName = GetNativeType($interfaceName); - if ($interfaceName =~ /List$/) { - push(@implContentDecls, " $nativeClassName imp = ${v8InterfaceName}::toNative(args.Holder());\n"); - } else { - AddToImplIncludes("ExceptionCode.h"); - push(@implContentDecls, " $nativeClassName wrapper = ${v8InterfaceName}::toNative(args.Holder());\n"); - push(@implContentDecls, " if (wrapper->isReadOnly())\n"); - push(@implContentDecls, " return setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n"); - my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($interfaceName); - push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); - push(@implContentDecls, " $svgWrappedNativeType* imp = &impInstance;\n"); - } - } elsif (!$function->isStatic) { - push(@implContentDecls, <<END); - ${interfaceName}* imp = ${v8InterfaceName}::toNative(args.Holder()); -END - } - - # Check domain security if needed - if (($interface->extendedAttributes->{"CheckSecurity"} - || $interfaceName eq "DOMWindow") - && !$function->signature->extendedAttributes->{"DoNotCheckSecurity"}) { - # We have not find real use cases yet. - AddToImplIncludes("Frame.h"); - push(@implContentDecls, <<END); - if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame())) - return v8Undefined(); -END - } - - my $raisesExceptions = @{$function->raisesExceptions}; - if (!$raisesExceptions) { - foreach my $parameter (@{$function->parameters}) { - if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { - $raisesExceptions = 1; - } - } - } - - if ($raisesExceptions) { - AddToImplIncludes("ExceptionCode.h"); - push(@implContentDecls, " ExceptionCode ec = 0;\n"); - push(@implContentDecls, " {\n"); - # The brace here is needed to prevent the ensuing 'goto fail's from jumping past constructors - # of objects (like Strings) declared later, causing compile errors. The block scope ends - # right before the label 'fail:'. - } - - if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { - push(@implContentDecls, " if (!BindingSecurity::shouldAllowAccessToNode(BindingState::instance(), imp->" . $function->signature->name . "(ec)))\n"); - push(@implContentDecls, " return v8::Handle<v8::Value>(v8Null(args.GetIsolate()));\n"); -END - } - - my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interfaceName); - push(@implContentDecls, $parameterCheckString); - - # Build the function call string. - push(@implContentDecls, GenerateFunctionCallString($function, $paramIndex, " ", $interfaceName, %replacements)); - - if ($raisesExceptions) { - push(@implContentDecls, " }\n"); - push(@implContentDecls, " fail:\n"); - push(@implContentDecls, " return setDOMException(ec, args.GetIsolate());\n"); - } - - push(@implContentDecls, "}\n\n"); - push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; -} - -sub GenerateCallWith -{ - my $callWith = shift; - return () unless $callWith; - my $outputArray = shift; - my $indent = shift; - my $returnVoid = shift; - my $function = shift; - - my @callWithArgs; - if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { - push(@$outputArray, $indent . "ScriptState* currentState = ScriptState::current();\n"); - push(@$outputArray, $indent . "if (!currentState)\n"); - push(@$outputArray, $indent . " return" . ($returnVoid ? "" : " v8Undefined()") . ";\n"); - push(@$outputArray, $indent . "ScriptState& state = *currentState;\n"); - push(@callWithArgs, "&state"); - } - if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) { - push(@$outputArray, $indent . "ScriptExecutionContext* scriptContext = getScriptExecutionContext();\n"); - push(@callWithArgs, "scriptContext"); - } - if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments")) { - push(@$outputArray, $indent . "RefPtr<ScriptArguments> scriptArguments(createScriptArguments(args, " . @{$function->parameters} . "));\n"); - push(@callWithArgs, "scriptArguments.release()"); - AddToImplIncludes("ScriptArguments.h"); - AddToImplIncludes("ScriptCallStackFactory.h"); - } - return @callWithArgs; -} - -sub GenerateArgumentsCountCheck -{ - my $function = shift; - my $interface = shift; - - my $numMandatoryParams = 0; - my $allowNonOptional = 1; - foreach my $param (@{$function->parameters}) { - if ($param->extendedAttributes->{"Optional"} or $param->isVariadic) { - $allowNonOptional = 0; - } else { - die "An argument must not be declared to be optional unless all subsequent arguments to the operation are also optional." if !$allowNonOptional; - $numMandatoryParams++; - } - } - - my $argumentsCountCheckString = ""; - if ($numMandatoryParams >= 1) { - $argumentsCountCheckString .= " if (args.Length() < $numMandatoryParams)\n"; - $argumentsCountCheckString .= " return throwNotEnoughArgumentsError(args.GetIsolate());\n"; - } - return $argumentsCountCheckString; -} - -sub GetIndexOf -{ - my $paramName = shift; - my @paramList = @_; - my $index = 0; - foreach my $param (@paramList) { - if ($paramName eq $param) { - return $index; - } - $index++; - } - return -1; -} - -sub GenerateParametersCheck -{ - my $function = shift; - my $interfaceName = shift; - - my $parameterCheckString = ""; - my $paramIndex = 0; - my @paramTransferListNames = (); - my %replacements = (); - - foreach my $parameter (@{$function->parameters}) { - TranslateParameter($parameter); - my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); - - # Optional arguments with [Optional] should generate an early call with fewer arguments. - # Optional arguments with [Optional=...] should not generate the early call. - # Optional Dictionary arguments always considered to have default of empty dictionary. - my $optional = $parameter->extendedAttributes->{"Optional"}; - if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && $nativeType ne "Dictionary" && !$parameter->extendedAttributes->{"Callback"}) { - $parameterCheckString .= " if (args.Length() <= $paramIndex) {\n"; - my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $interfaceName, %replacements); - $parameterCheckString .= $functionCall; - $parameterCheckString .= " }\n"; - } - - my $parameterDefaultPolicy = "DefaultIsUndefined"; - if ($optional and $optional eq "DefaultIsNullString") { - $parameterDefaultPolicy = "DefaultIsNullString"; - } - - my $parameterName = $parameter->name; - if (GetIndexOf($parameterName, @paramTransferListNames) != -1) { - $replacements{$parameterName} = "messagePortArray" . ucfirst($parameterName); - $paramIndex++; - next; - } - - AddToImplIncludes("ExceptionCode.h"); - if ($parameter->extendedAttributes->{"Callback"}) { - my $v8InterfaceName = "V8" . $parameter->type; - AddToImplIncludes("$v8InterfaceName.h"); - if ($optional) { - $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName;\n"; - $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; - $parameterCheckString .= " if (!args[$paramIndex]->IsFunction())\n"; - $parameterCheckString .= " return throwTypeError(0, args.GetIsolate());\n"; - $parameterCheckString .= " $parameterName = ${v8InterfaceName}::create(args[$paramIndex], getScriptExecutionContext());\n"; - $parameterCheckString .= " }\n"; - } else { - $parameterCheckString .= " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsFunction())\n"; - $parameterCheckString .= " return throwTypeError(0, args.GetIsolate());\n"; - $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName = ${v8InterfaceName}::create(args[$paramIndex], getScriptExecutionContext());\n"; - } - } elsif ($parameter->extendedAttributes->{"Clamp"}) { - my $nativeValue = "${parameterName}NativeValue"; - my $paramType = $parameter->type; - $parameterCheckString .= " $paramType $parameterName = 0;\n"; - $parameterCheckString .= " V8TRYCATCH(double, $nativeValue, args[$paramIndex]->NumberValue());\n"; - $parameterCheckString .= " if (!isnan($nativeValue))\n"; - $parameterCheckString .= " $parameterName = clampTo<$paramType>($nativeValue);\n"; - } elsif ($parameter->type eq "SerializedScriptValue") { - AddToImplIncludes("SerializedScriptValue.h"); - my $useTransferList = 0; - my $transferListName = ""; - my $TransferListName = ""; - if ($parameter->extendedAttributes->{"TransferList"}) { - $transferListName = $parameter->extendedAttributes->{"TransferList"}; - push(@paramTransferListNames, $transferListName); - - my @allParameterNames = (); - foreach my $parameter (@{$function->parameters}) { - push(@allParameterNames, $parameter->name); - } - my $transferListIndex = GetIndexOf($transferListName, @allParameterNames); - if ($transferListIndex == -1) { - die "IDL error: TransferList refers to a nonexistent argument"; - } - - AddToImplIncludes("wtf/ArrayBuffer.h"); - AddToImplIncludes("MessagePort.h"); - $TransferListName = ucfirst($transferListName); - $parameterCheckString .= " MessagePortArray messagePortArray$TransferListName;\n"; - $parameterCheckString .= " ArrayBufferArray arrayBufferArray$TransferListName;\n"; - $parameterCheckString .= " if (args.Length() > $transferListIndex) {\n"; - $parameterCheckString .= " if (!extractTransferables(args[$transferListIndex], messagePortArray$TransferListName, arrayBufferArray$TransferListName, args.GetIsolate()))\n"; - $parameterCheckString .= " return throwTypeError(\"Could not extract transferables\");\n"; - $parameterCheckString .= " }\n"; - $useTransferList = 1; - } - $parameterCheckString .= " bool ${parameterName}DidThrow = false;\n"; - if (!$useTransferList) { - $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.GetIsolate());\n"; - } else { - $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], &messagePortArray$TransferListName, &arrayBufferArray$TransferListName, ${parameterName}DidThrow, args.GetIsolate());\n"; - } - $parameterCheckString .= " if (${parameterName}DidThrow)\n"; - $parameterCheckString .= " return v8Undefined();\n"; - } elsif (TypeCanFailConversion($parameter)) { - $parameterCheckString .= " $nativeType $parameterName = " . - JSValueToNative($parameter, "args[$paramIndex]", "args.GetIsolate()") . ";\n"; - $parameterCheckString .= " if (UNLIKELY(!$parameterName)) {\n"; - $parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n"; - $parameterCheckString .= " goto fail;\n"; - $parameterCheckString .= " }\n"; - } elsif ($parameter->isVariadic) { - my $nativeElementType = GetNativeType($parameter->type); - if ($nativeElementType =~ />$/) { - $nativeElementType .= " "; - } - - my $argType = $parameter->type; - if (IsWrapperType($argType)) { - $parameterCheckString .= " Vector<$nativeElementType> $parameterName;\n"; - $parameterCheckString .= " for (int i = $paramIndex; i < args.Length(); ++i) {\n"; - $parameterCheckString .= " if (!V8${argType}::HasInstance(args[i]))\n"; - $parameterCheckString .= " return throwTypeError(0, args.GetIsolate());\n"; - $parameterCheckString .= " $parameterName.append(V8${argType}::toNative(v8::Handle<v8::Object>::Cast(args[i])));\n"; - $parameterCheckString .= " }\n"; - } else { - $parameterCheckString .= " V8TRYCATCH(Vector<$nativeElementType>, $parameterName, toNativeArguments<$nativeElementType>(args, $paramIndex));\n"; - } - } elsif ($nativeType =~ /^V8StringResource/) { - my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)", "args.GetIsolate()"); - $parameterCheckString .= " " . ConvertToV8StringResource($parameter, $nativeType, $parameterName, $value) . "\n"; - } else { - # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an - # interface type, then if the incoming value does not implement that interface, a TypeError - # is thrown rather than silently passing NULL to the C++ code. - # Per the Web IDL and ECMAScript specifications, incoming values can always be converted - # to both strings and numbers, so do not throw TypeError if the argument is of these - # types. - if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) { - my $argValue = "args[$paramIndex]"; - my $argType = $parameter->type; - if (IsWrapperType($argType)) { - $parameterCheckString .= " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue))\n"; - $parameterCheckString .= " return throwTypeError(0, args.GetIsolate());\n"; - } - } - $parameterCheckString .= " V8TRYCATCH($nativeType, $parameterName, " . - JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)", "args.GetIsolate()") . ");\n"; - if ($nativeType eq 'Dictionary') { - $parameterCheckString .= " if (!$parameterName.isUndefinedOrNull() && !$parameterName.isObject())\n"; - $parameterCheckString .= " return throwTypeError(\"Not an object.\", args.GetIsolate());\n"; - } - } - - if ($parameter->extendedAttributes->{"IsIndex"}) { - $parameterCheckString .= " if (UNLIKELY($parameterName < 0)) {\n"; - $parameterCheckString .= " ec = INDEX_SIZE_ERR;\n"; - $parameterCheckString .= " goto fail;\n"; - $parameterCheckString .= " }\n"; - } - - $paramIndex++; - } - return ($parameterCheckString, $paramIndex, %replacements); -} - -sub GenerateOverloadedConstructorCallback -{ - my $interface = shift; - my $interfaceName = $interface->name; - - push(@implContent, <<END); -v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(const v8::Arguments& args) -{ -END - push(@implContent, GenerateConstructorHeader()); - - my $leastNumMandatoryParams = 255; - foreach my $constructor (@{$interface->constructors}) { - my $name = "constructor" . $constructor->{overloadedIndex} . "Callback"; - my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($constructor); - $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); - push(@implContent, " if ($parametersCheck)\n"); - push(@implContent, " return $name(args);\n"); - } - if ($leastNumMandatoryParams >= 1) { - push(@implContent, " if (args.Length() < $leastNumMandatoryParams)\n"); - push(@implContent, " return throwNotEnoughArgumentsError(args.GetIsolate());\n"); - } - push(@implContent, <<END); - return throwTypeError(0, args.GetIsolate()); -END - push(@implContent, "}\n\n"); -} - -sub GenerateSingleConstructorCallback -{ - my $interface = shift; - my $function = shift; - - my $interfaceName = $interface->name; - my $overloadedIndexString = ""; - if ($function->{overloadedIndex} > 0) { - $overloadedIndexString .= $function->{overloadedIndex}; - } - - my $raisesExceptions = @{$function->raisesExceptions}; - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - $raisesExceptions = 1; - } - if (!$raisesExceptions) { - foreach my $parameter (@{$function->parameters}) { - if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { - $raisesExceptions = 1; - } - } - } - - my $maybeObserveFeature = GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"}); - - my @beforeArgumentList; - my @afterArgumentList; - push(@implContent, <<END); -v8::Handle<v8::Value> V8${interfaceName}::constructor${overloadedIndexString}Callback(const v8::Arguments& args) -{ - ${maybeObserveFeature} -END - - if ($function->{overloadedIndex} == 0) { - push(@implContent, GenerateConstructorHeader()); - push(@implContent, GenerateArgumentsCountCheck($function, $interface)); - } - - if ($raisesExceptions) { - AddToImplIncludes("ExceptionCode.h"); - push(@implContent, "\n"); - push(@implContent, " ExceptionCode ec = 0;\n"); - } - - # FIXME: Currently [Constructor(...)] does not yet support [Optional] arguments. - # It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString]. - my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interfaceName); - push(@implContent, $parameterCheckString); - - if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") { - push(@beforeArgumentList, "context"); - push(@implContent, <<END); - - ScriptExecutionContext* context = getScriptExecutionContext(); -END - } - - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - push(@afterArgumentList, "ec"); - } - - my @argumentList; - my $index = 0; - foreach my $parameter (@{$function->parameters}) { - last if $index eq $paramIndex; - if ($replacements{$parameter->name}) { - push(@argumentList, $replacements{$parameter->name}); - } else { - push(@argumentList, $parameter->name); - } - $index++; - } - - my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterArgumentList); - push(@implContent, "\n"); - push(@implContent, " RefPtr<${interfaceName}> impl = ${interfaceName}::create(${argumentString});\n"); - push(@implContent, " v8::Handle<v8::Object> wrapper = args.Holder();\n"); - - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - push(@implContent, " if (ec)\n"); - push(@implContent, " goto fail;\n"); - } - - push(@implContent, <<END); - - V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate()); - return wrapper; -END - - if ($raisesExceptions) { - push(@implContent, " fail:\n"); - push(@implContent, " return setDOMException(ec, args.GetIsolate());\n"); - } - - push(@implContent, "}\n"); - push(@implContent, "\n"); -} - -sub GenerateCustomConstructorCallback -{ - my $interface = shift; - - my $interfaceName = $interface->name; - my $maybeObserveFeature = GenerateFeatureObservation($interface->extendedAttributes->{"V8MeasureAs"}); - push(@implContent, <<END); -v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(const v8::Arguments& args) -{ - ${maybeObserveFeature} -END - push(@implContent, GenerateConstructorHeader()); - push(@implContent, <<END); - - return V8${interfaceName}::constructorCallbackCustom(args); -} - -END -} - -sub GenerateConstructorCallback -{ - my $interface = shift; - my $interfaceName = $interface->name; - - if (@{$interface->constructors} == 1) { - GenerateSingleConstructorCallback($interface, @{$interface->constructors}[0]); - } else { - foreach my $constructor (@{$interface->constructors}) { - GenerateSingleConstructorCallback($interface, $constructor); - } - GenerateOverloadedConstructorCallback($interface); - } -} - -sub GenerateEventConstructorCallback -{ - my $interface = shift; - my $interfaceName = $interface->name; - - AddToImplIncludes("Dictionary.h"); - push(@implContent, <<END); -v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(const v8::Arguments& args) -{ -END - push(@implContent, GenerateConstructorHeader()); - - push(@implContent, <<END); - if (args.Length() < 1) - return throwNotEnoughArgumentsError(args.GetIsolate()); - - V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); - ${interfaceName}Init eventInit; - if (args.Length() >= 2) { - V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); - if (!fill${interfaceName}Init(eventInit, options)) - return v8Undefined(); - } - - RefPtr<${interfaceName}> event = ${interfaceName}::create(type, eventInit); - - v8::Handle<v8::Object> wrapper = args.Holder(); - V8DOMWrapper::associateObjectWithWrapper(event.release(), &info, wrapper, args.GetIsolate()); - return wrapper; -} - -bool fill${interfaceName}Init(${interfaceName}Init& eventInit, const Dictionary& options) -{ -END - - foreach my $interfaceBase (@{$interface->parents}) { - push(@implContent, <<END); - if (!fill${interfaceBase}Init(eventInit, options)) - return false; - -END - } - - for (my $index = 0; $index < @{$interface->attributes}; $index++) { - my $attribute = @{$interface->attributes}[$index]; - if ($attribute->signature->extendedAttributes->{"InitializedByEventConstructor"}) { - my $attributeName = $attribute->signature->name; - push(@implContent, " options.get(\"$attributeName\", eventInit.$attributeName);\n"); - } - } - - push(@implContent, <<END); - return true; -} - -END -} - -sub GenerateTypedArrayConstructorCallback -{ - my $interface = shift; - my $interfaceName = $interface->name; - my $viewType = GetTypeNameOfExternalTypedArray($interface); - my $type = $interface->extendedAttributes->{"TypedArray"}; - AddToImplIncludes("V8ArrayBufferViewCustom.h"); - - push(@implContent, <<END); -v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(const v8::Arguments& args) -{ - return constructWebGLArray<$interfaceName, V8${interfaceName}, $type>(args, &info, $viewType); -} - -END -} - -sub GenerateNamedConstructorCallback -{ - my $function = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - my $raisesExceptions = @{$function->raisesExceptions}; - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - $raisesExceptions = 1; - } - if (!$raisesExceptions) { - foreach my $parameter (@{$function->parameters}) { - if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { - $raisesExceptions = 1; - } - } - } - - my $maybeObserveFeature = GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"}); - - my @beforeArgumentList; - my @afterArgumentList; - - my $toActiveDOMObject = "0"; - if ($interface->extendedAttributes->{"ActiveDOMObject"}) { - $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject"; - } - AddToImplIncludes("Frame.h"); - - push(@implContent, <<END); -WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constructor::GetTemplate, ${v8InterfaceName}::derefObject, ${toActiveDOMObject}, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype }; - -static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arguments& args) -{ - ${maybeObserveFeature} -END - push(@implContent, GenerateConstructorHeader()); - push(@implContent, <<END); - Document* document = currentDocument(BindingState::instance()); - - // Make sure the document is added to the DOM Node map. Otherwise, the ${interfaceName} instance - // may end up being the only node in the map and get garbage-collected prematurely. - toV8(document, args.Holder(), args.GetIsolate()); - -END - - push(@implContent, GenerateArgumentsCountCheck($function, $interface)); - - if ($raisesExceptions) { - AddToImplIncludes("ExceptionCode.h"); - push(@implContent, "\n"); - push(@implContent, " ExceptionCode ec = 0;\n"); - } - - my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interfaceName); - push(@implContent, $parameterCheckString); - - push(@beforeArgumentList, "document"); - - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - push(@afterArgumentList, "ec"); - } - - my @argumentList; - my $index = 0; - foreach my $parameter (@{$function->parameters}) { - last if $index eq $paramIndex; - if ($replacements{$parameter->name}) { - push(@argumentList, $replacements{$parameter->name}); - } else { - push(@argumentList, $parameter->name); - } - $index++; - } - - my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterArgumentList); - push(@implContent, "\n"); - push(@implContent, " RefPtr<${interfaceName}> impl = ${interfaceName}::createForJSConstructor(${argumentString});\n"); - push(@implContent, " v8::Handle<v8::Object> wrapper = args.Holder();\n"); - - if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { - push(@implContent, " if (ec)\n"); - push(@implContent, " goto fail;\n"); - } - - push(@implContent, <<END); - - V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8InterfaceName}Constructor::info, wrapper, args.GetIsolate()); - return wrapper; -END - - if ($raisesExceptions) { - push(@implContent, " fail:\n"); - push(@implContent, " return setDOMException(ec, args.GetIsolate());\n"); - } - - push(@implContent, "}\n"); - - push(@implContent, <<END); - -v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate() -{ - static v8::Persistent<v8::FunctionTemplate> cachedTemplate; - if (!cachedTemplate.IsEmpty()) - return cachedTemplate; - - v8::HandleScope scope; - v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(${v8InterfaceName}ConstructorCallback); - - v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); - instance->SetInternalFieldCount(${v8InterfaceName}::internalFieldCount); - result->SetClassName(v8::String::NewSymbol("${interfaceName}")); - result->Inherit(${v8InterfaceName}::GetTemplate()); - - cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(result); - return cachedTemplate; -} - -END -} - -sub GenerateConstructorHeader -{ - my $content = <<END; - if (!args.IsConstructCall()) - return throwTypeError("DOM object constructor cannot be called as a function."); - - if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) - return args.Holder(); -END - return $content; -} - -sub GenerateBatchedAttributeData -{ - my $interface = shift; - my $attributes = shift; - my $interfaceName = $interface->name; - - foreach my $attribute (@$attributes) { - my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); - push(@implContent, "#if ${conditionalString}\n") if $conditionalString; - GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", ""); - push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; - } -} - -sub GenerateSingleBatchedAttribute -{ - my $interfaceName = shift; - my $attribute = shift; - my $delimiter = shift; - my $indent = shift; - my $attrName = $attribute->signature->name; - my $attrExt = $attribute->signature->extendedAttributes; - - my $accessControl = "v8::DEFAULT"; - if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { - $accessControl = "v8::ALL_CAN_READ"; - } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { - $accessControl = "v8::ALL_CAN_WRITE"; - } elsif ($attrExt->{"DoNotCheckSecurity"}) { - $accessControl = "v8::ALL_CAN_READ"; - if (!IsReadonly($attribute)) { - $accessControl .= " | v8::ALL_CAN_WRITE"; - } - } - if ($attrExt->{"V8Unforgeable"}) { - $accessControl .= " | v8::PROHIBITS_OVERWRITING"; - } - $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; - - my $customAccessor = - $attrExt->{"Custom"} || - $attrExt->{"CustomSetter"} || - $attrExt->{"CustomGetter"} || - $attrExt->{"V8Custom"} || - $attrExt->{"V8CustomSetter"} || - $attrExt->{"V8CustomGetter"} || - ""; - if ($customAccessor eq "VALUE_IS_MISSING") { - # use the naming convension, interface + (capitalize) attr name - $customAccessor = $interfaceName . "::" . $attrName; - } - - my $getter; - my $setter; - my $propAttr = "v8::None"; - - # Check attributes. - if ($attrExt->{"NotEnumerable"}) { - $propAttr .= " | v8::DontEnum"; - } - if ($attrExt->{"V8Unforgeable"}) { - $propAttr .= " | v8::DontDelete"; - } - - my $on_proto = "0 /* on instance */"; - my $data = "0 /* no data */"; - - # Constructor - if ($attribute->signature->type =~ /Constructor$/) { - my $constructorType = $attribute->signature->type; - $constructorType =~ s/Constructor$//; - # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor. - # We do not generate the header file for NamedConstructor of class XXXX, - # since we generate the NamedConstructor declaration into the header file of class XXXX. - if ($constructorType !~ /Constructor$/ || $attribute->signature->extendedAttributes->{"V8CustomConstructor"} || $attribute->signature->extendedAttributes->{"CustomConstructor"}) { - AddToImplIncludes("V8${constructorType}.h", $attribute->signature->extendedAttributes->{"Conditional"}); - } - if ($customAccessor) { - $getter = "V8${customAccessor}AccessorGetter"; - } else { - $data = "&V8${constructorType}::info"; - $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter"; - } - $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSetter"; - } else { - # Default Getter and Setter - $getter = "${interfaceName}V8Internal::${attrName}AttrGetter"; - $setter = "${interfaceName}V8Internal::${attrName}AttrSetter"; - - if ($attrExt->{"Replaceable"}) { - $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSetter"; - } - - # Custom Setter - if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { - $setter = "V8${customAccessor}AccessorSetter"; - } - - # Custom Getter - if ($attrExt->{"CustomGetter"} || $attrExt->{"V8CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { - $getter = "V8${customAccessor}AccessorGetter"; - } - } - - # Read only attributes - if (IsReadonly($attribute)) { - $setter = "0"; - } - - # An accessor can be installed on the proto - if ($attrExt->{"V8OnProto"}) { - $on_proto = "1 /* on proto */"; - } - - my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . - "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; - - push(@implContent, $indent . " \/\/ $commentInfo\n"); - push(@implContent, $indent . " {\"$attrName\", $getter, $setter, $data, $accessControl, static_cast<v8::PropertyAttribute>($propAttr), $on_proto}" . $delimiter . "\n"); -} - -sub IsStandardFunction -{ - my $interface = shift; - my $function = shift; - - my $interfaceName = $interface->name; - my $attrExt = $function->signature->extendedAttributes; - return 0 if $attrExt->{"V8Unforgeable"}; - return 0 if $function->isStatic; - return 0 if $attrExt->{"V8EnabledAtRuntime"}; - return 0 if $attrExt->{"V8EnabledPerContext"}; - return 0 if RequiresCustomSignature($function); - return 0 if $attrExt->{"V8DoNotCheckSignature"}; - return 0 if ($attrExt->{"DoNotCheckSecurity"} && ($interface->extendedAttributes->{"CheckSecurity"} || $interfaceName eq "DOMWindow")); - return 0 if $attrExt->{"NotEnumerable"}; - return 0 if $attrExt->{"V8ReadOnly"}; - return 1; -} - -sub GenerateNonStandardFunction -{ - my $interface = shift; - my $function = shift; - - my $interfaceName = $interface->name; - my $attrExt = $function->signature->extendedAttributes; - my $name = $function->signature->name; - - my $property_attributes = "v8::DontDelete"; - if ($attrExt->{"NotEnumerable"}) { - $property_attributes .= " | v8::DontEnum"; - } - if ($attrExt->{"V8ReadOnly"}) { - $property_attributes .= " | v8::ReadOnly"; - } - - my $commentInfo = "Function '$name' (ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; - - my $template = "proto"; - if ($attrExt->{"V8Unforgeable"}) { - $template = "instance"; - } - if ($function->isStatic) { - $template = "desc"; - } - - my $conditional = ""; - if ($attrExt->{"V8EnabledAtRuntime"}) { - # Only call Set()/SetAccessor() if this method should be enabled - my $enable_function = GetRuntimeEnableFunctionName($function->signature); - $conditional = "if (${enable_function}())\n "; - } - if ($attrExt->{"V8EnabledPerContext"}) { - # Only call Set()/SetAccessor() if this method should be enabled - my $enable_function = GetContextEnableFunction($function->signature); - $conditional = "if (${enable_function}(impl->document()))\n "; - } - - if ($attrExt->{"DoNotCheckSecurity"} && - ($interface->extendedAttributes->{"CheckSecurity"} || $interfaceName eq "DOMWindow")) { - # Functions that are marked DoNotCheckSecurity are always readable but if they are changed - # and then accessed on a different domain we do not return the underlying value but instead - # return a new copy of the original function. This is achieved by storing the changed value - # as hidden property. - push(@implContent, <<END); - - // $commentInfo - ${conditional}$template->SetAccessor(v8::String::NewSymbol("$name"), ${interfaceName}V8Internal::${name}AttrGetter, ${interfaceName}V8Internal::${interfaceName}DomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes)); -END - return; - } - - my $signature = "defaultSignature"; - if ($attrExt->{"V8DoNotCheckSignature"} || $function->isStatic) { - $signature = "v8::Local<v8::Signature>()"; - } - - if (RequiresCustomSignature($function)) { - $signature = "${name}Signature"; - push(@implContent, "\n // Custom Signature '$name'\n", CreateCustomSignature($function)); - } - - # Normal function call is a template - my $callback = GetFunctionTemplateCallbackName($function, $interfaceName); - - if ($property_attributes eq "v8::DontDelete") { - $property_attributes = ""; - } else { - $property_attributes = ", static_cast<v8::PropertyAttribute>($property_attributes)"; - } - - if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSignature" && $property_attributes eq "") { - die "This shouldn't happen: Intraface '$interfaceName' $commentInfo\n"; - } - - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@implContent, "#if ${conditionalString}\n") if $conditionalString; - - push(@implContent, " ${conditional}$template->Set(v8::String::NewSymbol(\"$name\"), v8::FunctionTemplate::New($callback, v8Undefined(), ${signature})$property_attributes);\n"); - - push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; -} - -sub GenerateImplementationIndexer -{ - my $interface = shift; - my $indexer = shift; - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - - # FIXME: Figure out what NumericIndexedGetter is really supposed to do. Right now, it's only set on WebGL-related files. - my $hasCustomSetter = $interface->extendedAttributes->{"CustomIndexedSetter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"}; - my $hasGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; - - # FIXME: Investigate and remove this nastinesss. In V8, named property handling and indexer handling are apparently decoupled, - # which means that object[X] where X is a number doesn't reach named property indexer. So we need to provide - # simplistic, mirrored indexer handling in addition to named property handling. - my $isSpecialCase = exists $indexerSpecialCases{$interfaceName}; - if ($isSpecialCase) { - $hasGetter = 1; - if ($interface->extendedAttributes->{"CustomNamedSetter"}) { - $hasCustomSetter = 1; - } - } - - my $hasEnumerator = !$isSpecialCase && $codeGenerator->IsSubType($interface, "Node"); - - # FIXME: Find a way to not have to special-case HTMLOptionsCollection. - if ($interfaceName eq "HTMLOptionsCollection") { - $hasEnumerator = 1; - $hasGetter = 1; - } - - if (!$hasGetter) { - return; - } - - AddToImplIncludes("V8Collection.h"); - - if (!$indexer) { - $indexer = $codeGenerator->FindSuperMethod($interface, "item"); - } - - my $indexerType = $indexer ? $indexer->type : 0; - - # FIXME: Remove this once toV8 helper methods are implemented (see https://bugs.webkit.org/show_bug.cgi?id=32563). - if ($interfaceName eq "WebKitCSSKeyframesRule") { - $indexerType = "WebKitCSSKeyframeRule"; - } - - if ($indexerType && !$hasCustomSetter) { - if ($indexerType eq "DOMString") { - my $conversion = $indexer->extendedAttributes->{"TreatReturnedNullStringAs"}; - if ($conversion && $conversion eq "Null") { - push(@implContent, <<END); - setCollectionStringOrUndefinedIndexedGetter<${interfaceName}>(desc); -END - } else { - push(@implContent, <<END); - setCollectionStringIndexedGetter<${interfaceName}>(desc); -END - } - } else { - push(@implContent, <<END); - setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc); -END - # Include the header for this indexer type, because setCollectionIndexedGetter() requires toV8() for this type. - AddToImplIncludes("V8${indexerType}.h"); - } - - return; - } - - my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; - my $setOn = "Instance"; - - # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallbacks) and it's used on DOMWindow - # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to - # get implementation straight out of the DOMWindow prototype regardless of what prototype is actually set - # on the object. - if ($interfaceName eq "DOMWindow") { - $setOn = "Prototype"; - $hasDeleter = 0; - } - - push(@implContent, " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8InterfaceName}::indexedPropertyGetter"); - push(@implContent, $hasCustomSetter ? ", ${v8InterfaceName}::indexedPropertySetter" : ", 0"); - push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the moment. - push(@implContent, $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDeleter" : ", 0"); - push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceName}>") if $hasEnumerator; - push(@implContent, ");\n"); -} - -sub GenerateImplementationNamedPropertyGetter -{ - my $interface = shift; - my $namedPropertyGetter = shift; - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; - - if ($interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedElement" || $interfaceName eq "HTMLObjectElement") { - $hasCustomNamedGetter = 1; - } - - if ($interfaceName eq "HTMLDocument") { - $hasCustomNamedGetter = 0; - } - - my $hasGetter = $interface->extendedAttributes->{"NamedGetter"} || $hasCustomNamedGetter; - if (!$hasGetter) { - return; - } - - if (!$namedPropertyGetter) { - $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "namedItem"); - } - - if ($namedPropertyGetter && $namedPropertyGetter->type ne "Node" && !$namedPropertyGetter->extendedAttributes->{"Custom"} && !$hasCustomNamedGetter) { - AddToImplIncludes("V8Collection.h"); - my $type = $namedPropertyGetter->type; - push(@implContent, <<END); - setCollectionNamedGetter<${interfaceName}, ${type}>(desc); -END - return; - } - - my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSetter"}; - my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; - my $hasEnumerator = $interface->extendedAttributes->{"CustomEnumerateProperty"}; - my $setOn = "Instance"; - - # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallbacks) and it's used on DOMWindow - # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to - # get implementation straight out of the DOMWindow prototype regardless of what prototype is actually set - # on the object. - if ($interfaceName eq "DOMWindow") { - $setOn = "Prototype"; - $hasDeleter = 0; - $hasEnumerator = 0; - } - - push(@implContent, " desc->${setOn}Template()->SetNamedPropertyHandler(${v8InterfaceName}::namedPropertyGetter, "); - push(@implContent, $hasCustomNamedSetter ? "${v8InterfaceName}::namedPropertySetter, " : "0, "); - # If there is a custom enumerator, there MUST be custom query to properly communicate property attributes. - push(@implContent, $hasEnumerator ? "${v8InterfaceName}::namedPropertyQuery, " : "0, "); - push(@implContent, $hasDeleter ? "${v8InterfaceName}::namedPropertyDeleter, " : "0, "); - push(@implContent, $hasEnumerator ? "${v8InterfaceName}::namedPropertyEnumerator" : "0"); - push(@implContent, ");\n"); -} - -sub GenerateImplementationCustomCall -{ - my $interface = shift; - my $interfaceName = $interface->name; - - if ($interface->extendedAttributes->{"CustomCall"}) { - push(@implContent, " desc->InstanceTemplate()->SetCallAsFunctionHandler(V8${interfaceName}::callAsFunctionCallback);\n"); - } -} - -sub GenerateImplementationMasqueradesAsUndefined -{ - my $interface = shift; - if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) - { - push(@implContent, " desc->InstanceTemplate()->MarkAsUndetectable();\n"); - } -} - -sub GenerateImplementation -{ - my $object = shift; - my $interface = shift; - my $interfaceName = $interface->name; - my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface); - my $v8InterfaceName = "V8$interfaceName"; - my $nativeType = GetNativeTypeForConversions($interface); - - # - Add default header template - push(@implContentHeader, GenerateImplementationContentHeader($interface)); - - AddToImplIncludes("BindingState.h"); - AddToImplIncludes("ContextFeatures.h"); - AddToImplIncludes("RuntimeEnabledFeatures.h"); - AddToImplIncludes("V8Binding.h"); - AddToImplIncludes("V8DOMWrapper.h"); - - AddIncludesForType($interfaceName); - - my $toActive = $interface->extendedAttributes->{"ActiveDOMObject"} ? "${v8InterfaceName}::toActiveDOMObject" : "0"; - my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName}::opaqueRootForGC" : "0"; - - # Find the super descriptor. - my $parentClass = ""; - my $parentClassTemplate = ""; - foreach (@{$interface->parents}) { - my $parent = $_; - AddToImplIncludes("V8${parent}.h"); - $parentClass = "V8" . $parent; - $parentClassTemplate = $parentClass . "::GetTemplate()"; - last; - } - push(@implContentDecls, "namespace WebCore {\n\n"); - my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; - - my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorPrototype" : "WrapperTypeObjectPrototype"; - - push(@implContentDecls, "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8InterfaceName}::GetTemplate, ${v8InterfaceName}::derefObject, $toActive, $rootForGC, ${v8InterfaceName}::installPerContextPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n\n"); - push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n"); - - push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n"); - - my $hasConstructors = 0; - my $hasReplaceable = 0; - - # Generate property accessors for attributes. - for (my $index = 0; $index < @{$interface->attributes}; $index++) { - my $attribute = @{$interface->attributes}[$index]; - my $attrType = $attribute->signature->type; - - # Generate special code for the constructor attributes. - if ($attrType =~ /Constructor$/) { - if (!($attribute->signature->extendedAttributes->{"CustomGetter"} || - $attribute->signature->extendedAttributes->{"V8CustomGetter"})) { - $hasConstructors = 1; - } - next; - } - - if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") { - $attribute->signature->extendedAttributes->{"V8OnProto"} = 1; - } - - if ($attrType eq "SerializedScriptValue") { - AddToImplIncludes("SerializedScriptValue.h"); - } - - # Do not generate accessor if this is a custom attribute. The - # call will be forwarded to a hand-written accessor - # implementation. - if ($attribute->signature->extendedAttributes->{"Custom"} || - $attribute->signature->extendedAttributes->{"V8Custom"}) { - next; - } - - # Generate the accessor. - if (!($attribute->signature->extendedAttributes->{"CustomGetter"} || - $attribute->signature->extendedAttributes->{"V8CustomGetter"})) { - GenerateNormalAttrGetter($attribute, $interface); - } - - if ($attribute->signature->extendedAttributes->{"Replaceable"}) { - $hasReplaceable = 1; - } elsif (!$attribute->signature->extendedAttributes->{"CustomSetter"} && - !$attribute->signature->extendedAttributes->{"V8CustomSetter"} && - !IsReadonly($attribute)) { - GenerateNormalAttrSetter($attribute, $interface); - } - } - - if ($hasConstructors) { - GenerateConstructorGetter($interface); - } - - if ($hasConstructors || $hasReplaceable) { - GenerateReplaceableAttrSetter($interface); - } - - if (NeedsCustomOpaqueRootForGC($interface)) { - GenerateOpaqueRootForGC($interface); - } - - if ($interface->extendedAttributes->{"TypedArray"}) { - my $viewType = GetTypeNameOfExternalTypedArray($interface); - push(@implContent, <<END); -v8::Handle<v8::Object> wrap($interfaceName* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) -{ - ASSERT(impl); - v8::Handle<v8::Object> wrapper = ${v8InterfaceName}::createWrapper(impl, creationContext, isolate); - if (!wrapper.IsEmpty()) - wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $viewType, impl->length()); - return wrapper; -} - -END - } - - my $indexer; - my $namedPropertyGetter; - my @enabledPerContextFunctions; - my @normalFunctions; - my $needsDomainSafeFunctionSetter = 0; - # Generate methods for functions. - foreach my $function (@{$interface->functions}) { - my $isCustom = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"}; - if (!$isCustom) { - GenerateFunctionCallback($function, $interface); - if ($function->{overloadIndex} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) { - GenerateOverloadedFunctionCallback($function, $interface); - } - } - - if ($function->signature->name eq "item") { - $indexer = $function->signature; - } - - if ($interfaceName eq "HTMLPropertiesCollection") { - if ($function->signature->name eq "propertyNodeList") { - $namedPropertyGetter = $function->signature; - } - } elsif ($function->signature->name eq "namedItem") { - $namedPropertyGetter = $function->signature; - } - - # If the function does not need domain security check, we need to - # generate an access getter that returns different function objects - # for different calling context. - if (($interface->extendedAttributes->{"CheckSecurity"} || ($interfaceName eq "DOMWindow")) && $function->signature->extendedAttributes->{"DoNotCheckSecurity"}) { - if (!$isCustom || $function->{overloadIndex} == 1) { - GenerateDomainSafeFunctionGetter($function, $interfaceName); - $needsDomainSafeFunctionSetter = 1; - } - } - - # Separate out functions that are enabled per context so we can process them specially. - if ($function->signature->extendedAttributes->{"V8EnabledPerContext"}) { - push(@enabledPerContextFunctions, $function); - } else { - push(@normalFunctions, $function); - } - } - - if ($needsDomainSafeFunctionSetter) { - GenerateDomainSafeFunctionSetter($interfaceName); - } - - # Attributes - my $attributes = $interface->attributes; - - # For the DOMWindow interface we partition the attributes into the - # ones that disallows shadowing and the rest. - my @disallowsShadowing; - # Also separate out attributes that are enabled at runtime so we can process them specially. - my @enabledAtRuntimeAttributes; - my @enabledPerContextAttributes; - my @normalAttributes; - foreach my $attribute (@$attributes) { - - if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttributes->{"V8Unforgeable"}) { - push(@disallowsShadowing, $attribute); - } elsif ($attribute->signature->extendedAttributes->{"V8EnabledAtRuntime"}) { - push(@enabledAtRuntimeAttributes, $attribute); - } elsif ($attribute->signature->extendedAttributes->{"V8EnabledPerContext"}) { - push(@enabledPerContextAttributes, $attribute); - } else { - push(@normalAttributes, $attribute); - } - } - $attributes = \@normalAttributes; - # Put the attributes that disallow shadowing on the shadow object. - if (@disallowsShadowing) { - push(@implContent, "static const V8DOMConfiguration::BatchedAttribute shadowAttrs[] = {\n"); - GenerateBatchedAttributeData($interface, \@disallowsShadowing); - push(@implContent, "};\n\n"); - } - - my $has_attributes = 0; - if (@$attributes) { - $has_attributes = 1; - push(@implContent, "static const V8DOMConfiguration::BatchedAttribute ${v8InterfaceName}Attrs[] = {\n"); - GenerateBatchedAttributeData($interface, $attributes); - push(@implContent, "};\n\n"); - } - - # Setup table of standard callback functions - my $num_callbacks = 0; - my $has_callbacks = 0; - foreach my $function (@normalFunctions) { - # Only one table entry is needed for overloaded methods: - next if $function->{overloadIndex} > 1; - # Don't put any nonstandard functions into this table: - next if !IsStandardFunction($interface, $function); - if (!$has_callbacks) { - $has_callbacks = 1; - push(@implContent, "static const V8DOMConfiguration::BatchedCallback ${v8InterfaceName}Callbacks[] = {\n"); - } - my $name = $function->signature->name; - my $callback = GetFunctionTemplateCallbackName($function, $interfaceName); - my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); - push(@implContent, "#if ${conditionalString}\n") if $conditionalString; - push(@implContent, <<END); - {"$name", $callback}, -END - push(@implContent, "#endif\n") if $conditionalString; - $num_callbacks++; - } - push(@implContent, "};\n\n") if $has_callbacks; - - # Setup constants - my $has_constants = 0; - my @constantsEnabledAtRuntime; - if (@{$interface->constants}) { - $has_constants = 1; - push(@implContent, "static const V8DOMConfiguration::BatchedConstant ${v8InterfaceName}Consts[] = {\n"); - } - foreach my $constant (@{$interface->constants}) { - my $name = $constant->name; - my $value = $constant->value; - my $attrExt = $constant->extendedAttributes; - my $conditional = $attrExt->{"Conditional"}; - my $implementedBy = $attrExt->{"ImplementedBy"}; - if ($implementedBy) { - AddToImplIncludes("${implementedBy}.h"); - } - if ($attrExt->{"V8EnabledAtRuntime"}) { - push(@constantsEnabledAtRuntime, $constant); - } else { - # FIXME: we need the static_cast here only because of one constant, NodeFilter.idl - # defines "const unsigned long SHOW_ALL = 0xFFFFFFFF". It would be better if we - # handled this here, and converted it to a -1 constant in the c++ output. - if ($conditional) { - my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - push(@implContent, "#if ${conditionalString}\n"); - } - push(@implContent, <<END); - {"${name}", static_cast<signed int>($value)}, -END - push(@implContent, "#endif\n") if $conditional; - } - } - if ($has_constants) { - push(@implContent, "};\n\n"); - push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNeeded($interface)); - } - - push(@implContentDecls, "} // namespace ${interfaceName}V8Internal\n\n"); - - if (HasCustomConstructor($interface)) { - GenerateCustomConstructorCallback($interface); - } elsif ($interface->extendedAttributes->{"NamedConstructor"}) { - GenerateNamedConstructorCallback(@{$interface->constructors}[0], $interface); - } elsif ($interface->extendedAttributes->{"Constructor"}) { - GenerateConstructorCallback($interface); - } elsif ($codeGenerator->IsConstructorTemplate($interface, "Event")) { - GenerateEventConstructorCallback($interface); - } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray")) { - GenerateTypedArrayConstructorCallback($interface); - } - - my $access_check = ""; - if ($interface->extendedAttributes->{"CheckSecurity"} && !($interfaceName eq "DOMWindow")) { - $access_check = "instance->SetAccessCheckCallbacks(${v8InterfaceName}::namedSecurityCheck, ${v8InterfaceName}::indexedSecurityCheck, v8::External::New(&${v8InterfaceName}::info));"; - } - - # For the DOMWindow interface, generate the shadow object template - # configuration method. - if ($interfaceName eq "DOMWindow") { - push(@implContent, <<END); -static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Persistent<v8::ObjectTemplate> templ) -{ - V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTemplate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs)); - - // Install a security handler with V8. - templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::New(&V8DOMWindow::info)); - templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount); - return templ; -} -END - } - - if (!$parentClassTemplate) { - $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()"; - } - - # Generate the template configuration method - push(@implContent, <<END); -static v8::Persistent<v8::FunctionTemplate> Configure${v8InterfaceName}Template(v8::Persistent<v8::FunctionTemplate> desc) -{ - desc->ReadOnlyPrototype(); - - v8::Local<v8::Signature> defaultSignature; -END - if ($interface->extendedAttributes->{"V8EnabledAtRuntime"}) { - my $enable_function = GetRuntimeEnableFunctionName($interface); - push(@implContent, <<END); - if (!${enable_function}()) - defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $parentClassTemplate, ${v8InterfaceName}::internalFieldCount, 0, 0, 0, 0); - else -END - } - push(@implContent, <<END); - defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${visibleInterfaceName}\", $parentClassTemplate, ${v8InterfaceName}::internalFieldCount, -END - # Set up our attributes if we have them - if ($has_attributes) { - push(@implContent, <<END); - ${v8InterfaceName}Attrs, WTF_ARRAY_LENGTH(${v8InterfaceName}Attrs), -END - } else { - push(@implContent, <<END); - 0, 0, -END - } - - if ($has_callbacks) { - push(@implContent, <<END); - ${v8InterfaceName}Callbacks, WTF_ARRAY_LENGTH(${v8InterfaceName}Callbacks)); -END - } else { - push(@implContent, <<END); - 0, 0); -END - } - - AddToImplIncludes("wtf/UnusedParam.h"); - push(@implContent, <<END); - UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. -END - - if (IsConstructable($interface)) { - push(@implContent, <<END); - desc->SetCallHandler(${v8InterfaceName}::constructorCallback); -END - } - - if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has_constants) { - push(@implContent, <<END); - v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); - UNUSED_PARAM(instance); // In some cases, it will not be used. - UNUSED_PARAM(proto); // In some cases, it will not be used. -END - } - - push(@implContent, " $access_check\n"); - - # Setup the enable-at-runtime attrs if we have them - foreach my $runtime_attr (@enabledAtRuntimeAttributes) { - my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signature); - my $conditionalString = $codeGenerator->GenerateConditionalString($runtime_attr->signature); - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - push(@implContent, " if (${enable_function}()) {\n"); - push(@implContent, " static const V8DOMConfiguration::BatchedAttribute attrData =\\\n"); - GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, ";", " "); - push(@implContent, <<END); - V8DOMConfiguration::configureAttribute(instance, proto, attrData); - } -END - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; - } - - # Setup the enable-at-runtime constants if we have them - foreach my $runtime_const (@constantsEnabledAtRuntime) { - my $enable_function = GetRuntimeEnableFunctionName($runtime_const); - my $conditionalString = $codeGenerator->GenerateConditionalString($runtime_const); - my $name = $runtime_const->name; - my $value = $runtime_const->value; - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - push(@implContent, " if (${enable_function}()) {\n"); - push(@implContent, <<END); - static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; - V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1); -END - push(@implContent, " }\n"); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; - } - - GenerateImplementationIndexer($interface, $indexer); - GenerateImplementationNamedPropertyGetter($interface, $namedPropertyGetter); - GenerateImplementationCustomCall($interface); - GenerateImplementationMasqueradesAsUndefined($interface); - - # Define our functions with Set() or SetAccessor() - my $total_functions = 0; - foreach my $function (@normalFunctions) { - # Only one accessor is needed for overloaded methods: - next if $function->{overloadIndex} > 1; - - $total_functions++; - next if IsStandardFunction($interface, $function); - GenerateNonStandardFunction($interface, $function); - $num_callbacks++; - } - - die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions; - - if ($has_constants) { - push(@implContent, <<END); - V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8InterfaceName}Consts, WTF_ARRAY_LENGTH(${v8InterfaceName}Consts)); -END - } - - # Special cases - if ($interfaceName eq "DOMWindow") { - push(@implContent, <<END); - - proto->SetInternalFieldCount(V8DOMWindow::internalFieldCount); - desc->SetHiddenPrototype(true); - instance->SetInternalFieldCount(V8DOMWindow::internalFieldCount); - // Set access check callbacks, but turned off initially. - // When a context is detached from a frame, turn on the access check. - // Turning on checks also invalidates inline caches of the object. - instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::New(&V8DOMWindow::info), false); -END - } - if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerContext" or $interfaceName eq "SharedWorkerContext") { - push(@implContent, <<END); - desc->SetHiddenPrototype(true); -END - } - if ($interfaceName eq "Location") { - push(@implContent, <<END); - - // For security reasons, these functions are on the instance instead - // of on the prototype object to ensure that they cannot be overwritten. - instance->SetAccessor(v8::String::NewSymbol("reload"), V8Location::reloadAccessorGetter, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); - instance->SetAccessor(v8::String::NewSymbol("replace"), V8Location::replaceAccessorGetter, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); - instance->SetAccessor(v8::String::NewSymbol("assign"), V8Location::assignAccessorGetter, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); -END - } - - push(@implContent, <<END); - - // Custom toString template - desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate()); - return desc; -} - -v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetRawTemplate() -{ - V8PerIsolateData* data = V8PerIsolateData::current(); - V8PerIsolateData::TemplateMap::iterator result = data->rawTemplateMap().find(&info); - if (result != data->rawTemplateMap().end()) - return result->value; - - v8::HandleScope handleScope; - v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate(); - data->rawTemplateMap().add(&info, templ); - return templ; -} - -v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate() -{ - V8PerIsolateData* data = V8PerIsolateData::current(); - V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info); - if (result != data->templateMap().end()) - return result->value; - - v8::HandleScope handleScope; - v8::Persistent<v8::FunctionTemplate> templ = - Configure${v8InterfaceName}Template(GetRawTemplate()); - data->templateMap().add(&info, templ); - return templ; -} - -bool ${v8InterfaceName}::HasInstance(v8::Handle<v8::Value> value) -{ - return GetRawTemplate()->HasInstance(value); -} - -END - - if (@enabledPerContextAttributes) { - push(@implContent, <<END); -void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> instance, ${nativeType}* impl) -{ - v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetPrototype()); - // When building QtWebkit with V8 this variable is unused when none of the features are enabled. - UNUSED_PARAM(proto); -END - - # Setup the enable-by-settings attrs if we have them - foreach my $runtimeAttr (@enabledPerContextAttributes) { - my $enableFunction = GetContextEnableFunction($runtimeAttr->signature); - my $conditionalString = $codeGenerator->GenerateConditionalString($runtimeAttr->signature); - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - push(@implContent, " if (${enableFunction}(impl->document())) {\n"); - push(@implContent, " static const V8DOMConfiguration::BatchedAttribute attrData =\\\n"); - GenerateSingleBatchedAttribute($interfaceName, $runtimeAttr, ";", " "); - push(@implContent, <<END); - V8DOMConfiguration::configureAttribute(instance, proto, attrData); -END - push(@implContent, " }\n"); - push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; - } - push(@implContent, <<END); -} -END - } - - if (@enabledPerContextFunctions) { - push(@implContent, <<END); -void ${v8InterfaceName}::installPerContextPrototypeProperties(v8::Handle<v8::Object> proto) -{ - UNUSED_PARAM(proto); -END - # Setup the enable-by-settings functions if we have them - push(@implContent, <<END); - v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate()); - UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. - - ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationContext()); -END - - foreach my $runtimeFunc (@enabledPerContextFunctions) { - my $enableFunction = GetContextEnableFunction($runtimeFunc->signature); - my $conditionalString = $codeGenerator->GenerateConditionalString($runtimeFunc->signature); - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - push(@implContent, " if (context && context->isDocument() && ${enableFunction}(static_cast<Document*>(context))) {\n"); - my $name = $runtimeFunc->signature->name; - my $callback = GetFunctionTemplateCallbackName($runtimeFunc, $interfaceName); - push(@implContent, <<END); - proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New(${callback}, v8Undefined(), defaultSignature)->GetFunction()); -END - push(@implContent, " }\n"); - push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; - } - - push(@implContent, <<END); -} -END - } - - if ($interface->extendedAttributes->{"ActiveDOMObject"}) { - # MessagePort is handled like an active dom object even though it doesn't inherit - # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject. - my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(object)"; - push(@implContent, <<END); -ActiveDOMObject* ${v8InterfaceName}::toActiveDOMObject(v8::Handle<v8::Object> object) -{ - return ${returnValue}; -} -END - } - - if ($interfaceName eq "DOMWindow") { - push(@implContent, <<END); -v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate() -{ - static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCache; - if (V8DOMWindowShadowObjectCache.IsEmpty()) { - V8DOMWindowShadowObjectCache = v8::Persistent<v8::ObjectTemplate>::New(v8::ObjectTemplate::New()); - ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCache); - } - return V8DOMWindowShadowObjectCache; -} -END - } - - GenerateToV8Converters($interface, $v8InterfaceName, $nativeType); - - push(@implContent, <<END); - -void ${v8InterfaceName}::derefObject(void* object) -{ - static_cast<${nativeType}*>(object)->deref(); -} - -} // namespace WebCore -END - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; - - # We've already added the header for this file in implContentHeader, so remove - # it from implIncludes to ensure we don't #include it twice. - delete $implIncludes{"${v8InterfaceName}.h"}; -} - -sub GenerateHeaderContentHeader -{ - my $interface = shift; - my $v8InterfaceName = "V8" . $interface->name; - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - - my @headerContentHeader = split("\r", $headerTemplate); - - push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString; - push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h"); - push(@headerContentHeader, "\n#define ${v8InterfaceName}" . "_h\n\n"); - return @headerContentHeader; -} - -sub GenerateImplementationContentHeader -{ - my $interface = shift; - my $v8InterfaceName = "V8" . $interface->name; - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - - my @implContentHeader = split("\r", $headerTemplate); - - push(@implContentHeader, "\n#include \"config.h\"\n"); - push(@implContentHeader, "#include \"${v8InterfaceName}.h\"\n\n"); - push(@implContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; - return @implContentHeader; -} - -sub GenerateCallbackHeader -{ - my $object = shift; - my $interface = shift; - - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - - - # - Add default header template - push(@headerContent, GenerateHeaderContentHeader($interface)); - - my @unsortedIncludes = (); - push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); - push(@unsortedIncludes, "#include \"$interfaceName.h\""); - push(@unsortedIncludes, "#include \"ScopedPersistent.h\""); - push(@unsortedIncludes, "#include \"WorldContextHandle.h\""); - push(@unsortedIncludes, "#include <v8.h>"); - push(@unsortedIncludes, "#include <wtf/Forward.h>"); - push(@headerContent, join("\n", sort @unsortedIncludes)); - - push(@headerContent, "\n\nnamespace WebCore {\n\n"); - push(@headerContent, "class ScriptExecutionContext;\n\n"); - push(@headerContent, "class $v8InterfaceName : public $interfaceName, public ActiveDOMCallback {\n"); - - push(@headerContent, <<END); -public: - static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner = v8::Handle<v8::Object>()) - { - ASSERT(value->IsObject()); - ASSERT(context); - return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context, owner)); - } - - virtual ~${v8InterfaceName}(); - -END - - # Functions - my $numFunctions = @{$interface->functions}; - if ($numFunctions > 0) { - push(@headerContent, " // Functions\n"); - foreach my $function (@{$interface->functions}) { - my @params = @{$function->parameters}; - if (!$function->signature->extendedAttributes->{"Custom"} && - !(GetNativeType($function->signature->type) eq "bool")) { - push(@headerContent, " COMPILE_ASSERT(false)"); - } - - push(@headerContent, " virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "("); - - my @args = (); - foreach my $param (@params) { - push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name); - } - push(@headerContent, join(", ", @args)); - push(@headerContent, ");\n"); - } - } - - push(@headerContent, <<END); - -private: - ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>); - - static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter) - { - ${v8InterfaceName}* object = static_cast<${v8InterfaceName}*>(parameter); - object->m_callback.clear(); - } - - ScopedPersistent<v8::Object> m_callback; - WorldContextHandle m_worldContext; -}; - -END - - push(@headerContent, "}\n\n"); - push(@headerContent, "#endif // $v8InterfaceName" . "_h\n\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; -} - -sub GenerateCallbackImplementation -{ - my $object = shift; - my $interface = shift; - my $interfaceName = $interface->name; - my $v8InterfaceName = "V8$interfaceName"; - - # - Add default header template - push(@implContentHeader, GenerateImplementationContentHeader($interface)); - - AddToImplIncludes("ScriptExecutionContext.h"); - AddToImplIncludes("V8Binding.h"); - AddToImplIncludes("V8Callback.h"); - - push(@implContent, "#include <wtf/Assertions.h>\n\n"); - push(@implContent, "namespace WebCore {\n\n"); - push(@implContent, <<END); -${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner) - : ActiveDOMCallback(context) - , m_callback(callback) - , m_worldContext(UseCurrentWorld) -{ - if (owner.IsEmpty()) - return; - owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback); - m_callback.get().MakeWeak(this, &${v8InterfaceName}::weakCallback); -} - -${v8InterfaceName}::~${v8InterfaceName}() -{ -} - -END - - # Functions - my $numFunctions = @{$interface->functions}; - if ($numFunctions > 0) { - push(@implContent, "// Functions\n"); - foreach my $function (@{$interface->functions}) { - my @params = @{$function->parameters}; - if ($function->signature->extendedAttributes->{"Custom"} || - !(GetNativeTypeForCallbacks($function->signature->type) eq "bool")) { - next; - } - - AddIncludesForType($function->signature->type); - push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${v8InterfaceName}::" . $function->signature->name . "("); - - my @args = (); - my @argsCheck = (); - my $thisType = $function->signature->extendedAttributes->{"PassThisToCallback"}; - foreach my $param (@params) { - my $paramName = $param->name; - AddIncludesForType($param->type); - push(@args, GetNativeTypeForCallbacks($param->type) . " " . $paramName); - if ($thisType and $thisType eq $param->type) { - push(@argsCheck, <<END); - ASSERT(${paramName}); - -END - } - } - push(@implContent, join(", ", @args)); - - push(@implContent, ")\n"); - push(@implContent, "{\n"); - push(@implContent, @argsCheck) if @argsCheck; - push(@implContent, " if (!canInvokeCallback())\n"); - push(@implContent, " return true;\n\n"); - push(@implContent, " v8::HandleScope handleScope;\n\n"); - push(@implContent, " v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);\n"); - push(@implContent, " if (v8Context.IsEmpty())\n"); - push(@implContent, " return true;\n\n"); - push(@implContent, " v8::Context::Scope scope(v8Context);\n\n"); - - @args = (); - foreach my $param (@params) { - my $paramName = $param->name; - push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n"); - push(@implContent, " if (${paramName}Handle.IsEmpty()) {\n"); - push(@implContent, " if (!isScriptControllerTerminating())\n"); - push(@implContent, " CRASH();\n"); - push(@implContent, " return true;\n"); - push(@implContent, " }\n"); - push(@args, " ${paramName}Handle"); - } - - if (scalar(@args) > 0) { - push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); - push(@implContent, join(",\n", @args)); - push(@implContent, "\n };\n\n"); - } else { - push(@implContent, "\n v8::Handle<v8::Value> *argv = 0;\n\n"); - } - push(@implContent, " bool callbackReturnValue = false;\n"); - if ($thisType) { - foreach my $param (@params) { - next if $param->type ne $thisType; - my $paramName = $param->name; - push(@implContent, " return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); - last; - } - } else { - push(@implContent, " return !invokeCallback(m_callback.get(), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); - } - push(@implContent, "}\n"); - } - } - - push(@implContent, "\n} // namespace WebCore\n\n"); - - my $conditionalString = $codeGenerator->GenerateConditionalString($interface); - push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; -} - -sub BaseInterfaceName -{ - my $interface = shift; - - while (@{$interface->parents}) { - $interface = $codeGenerator->ParseInterface(@{$interface->parents}[0], 1); - } - - return $interface->name; -} - -sub GenerateToV8Converters -{ - my $interface = shift; - my $v8InterfaceName = shift; - my $nativeType = shift; - my $interfaceName = $interface->name; - - if ($interface->extendedAttributes->{"V8NoWrapperCache"} || $interface->extendedAttributes->{"SuppressToJSObject"}) { - return; - } - - my $createWrapperArgumentType = GetPassRefPtrType($nativeType); - my $baseType = BaseInterfaceName($interface); - - push(@implContent, <<END); - -v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgumentType} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) -{ - ASSERT(impl.get()); - ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); -END - if ($baseType ne $interfaceName) { - push(@implContent, <<END); - ASSERT(static_cast<void*>(static_cast<${baseType}*>(impl.get())) == static_cast<void*>(impl.get())); -END - } - - AddToImplIncludes("Frame.h"); - - if ($codeGenerator->IsSubType($interface, "Document")) { - push(@implContent, <<END); - if (Frame* frame = impl->frame()) { - if (frame->script()->initializeMainWorld()) { - // initializeMainWorld may have created a wrapper for the object, retry from the start. - v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper(impl.get(), isolate); - if (!wrapper.IsEmpty()) - return wrapper; - } - } -END - } - - push(@implContent, <<END); - - v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, impl.get()); - if (UNLIKELY(wrapper.IsEmpty())) - return wrapper; - - installPerContextProperties(wrapper, impl.get()); - v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); - if (!hasDependentLifetime) - wrapperHandle.MarkIndependent(); - return wrapper; -} -END -} - -sub GetNativeTypeForConversions -{ - my $interface = shift; - my $interfaceName = $interface->name; - - $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) if $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName); - return $interfaceName;; -} - -sub GenerateFunctionCallString() -{ - my $function = shift; - my $numberOfParameters = shift; - my $indent = shift; - my $interfaceName = shift; - my %replacements = @_; - - my $name = $function->signature->name; - my $returnType = $function->signature->type; - my $nativeReturnType = GetNativeType($returnType, 0); - my $result = ""; - - my $isSVGTearOffType = ($codeGenerator->IsSVGTypeNeedingTearOff($returnType) and not $interfaceName =~ /List$/); - $nativeReturnType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTearOffType; - - if ($function->signature->extendedAttributes->{"ImplementedAs"}) { - $name = $function->signature->extendedAttributes->{"ImplementedAs"}; - } - - my $index = 0; - - my @arguments; - my $functionName; - my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"}; - if ($implementedBy) { - AddToImplIncludes("${implementedBy}.h"); - unshift(@arguments, "imp") if !$function->isStatic; - $functionName = "${implementedBy}::${name}"; - } elsif ($function->isStatic) { - $functionName = "${interfaceName}::${name}"; - } else { - $functionName = "imp->${name}"; - } - - my $callWith = $function->signature->extendedAttributes->{"CallWith"}; - my @callWithOutput = (); - my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, $function); - $result .= join("", @callWithOutput); - unshift(@arguments, @callWithArgs); - $index += @callWithArgs; - $numberOfParameters += @callWithArgs; - - foreach my $parameter (@{$function->parameters}) { - if ($index eq $numberOfParameters) { - last; - } - my $paramName = $parameter->name; - my $paramType = $parameter->type; - - if ($replacements{$paramName}) { - push @arguments, $replacements{$paramName}; - } elsif ($parameter->type eq "IDBKey" || $parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") { - push @arguments, "$paramName.get()"; - } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceName =~ /List$/) { - push @arguments, "$paramName->propertyReference()"; - $result .= $indent . "if (!$paramName)\n"; - $result .= $indent . " return setDOMException(WebCore::TYPE_MISMATCH_ERR, args.GetIsolate());\n"; - } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTransformList") { - push @arguments, "$paramName.get()"; - } else { - push @arguments, $paramName; - } - $index++; - } - - if (@{$function->raisesExceptions}) { - push @arguments, "ec"; - } - - my $functionString = "$functionName(" . join(", ", @arguments) . ")"; - - my $return = "result"; - my $returnIsRef = $codeGenerator->IsRefPtrType($returnType); - - if ($returnType eq "void") { - $result .= $indent . "$functionString;\n"; - } elsif ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState") or @{$function->raisesExceptions}) { - $result .= $indent . $nativeReturnType . " result = $functionString;\n"; - } else { - # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary - $return = $functionString; - $returnIsRef = 0; - - if ($interfaceName eq "SVGTransformList" and $codeGenerator->IsRefPtrType($returnType)) { - $return = "WTF::getPtr(" . $return . ")"; - } - } - - if (@{$function->raisesExceptions}) { - $result .= $indent . "if (UNLIKELY(ec))\n"; - $result .= $indent . " goto fail;\n"; - } - - if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { - $result .= $indent . "if (state.hadException()) {\n"; - $result .= $indent . " v8::Local<v8::Value> exception = state.exception();\n"; - $result .= $indent . " state.clearException();\n"; - $result .= $indent . " return throwError(exception, args.GetIsolate());\n"; - $result .= $indent . "}\n"; - } - - if ($isSVGTearOffType) { - AddToImplIncludes("V8$returnType.h"); - AddToImplIncludes("SVGPropertyTearOff.h"); - my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($returnType); - # FIXME: Update for all ScriptWrappables. - if (IsDOMNodeType($interfaceName)) { - $result .= $indent . "return toV8Fast(WTF::getPtr(${svgNativeType}::create($return)), args, imp);\n"; - } else { - $result .= $indent . "return toV8(WTF::getPtr(${svgNativeType}::create($return)), args.Holder(), args.GetIsolate());\n"; - } - return $result; - } - - # If the implementing class is a POD type, commit changes - if ($codeGenerator->IsSVGTypeNeedingTearOff($interfaceName) and not $interfaceName =~ /List$/) { - $result .= $indent . "wrapper->commitChange();\n"; - } - - $return .= ".release()" if ($returnIsRef); - - my $nativeValue; - # FIXME: Update for all ScriptWrappables. - if (IsDOMNodeType($interfaceName)) { - $nativeValue = NativeToJSValue($function->signature, $return, "args.Holder()", "args.GetIsolate()", "args", "imp"); - } else { - $nativeValue = NativeToJSValue($function->signature, $return, "args.Holder()", "args.GetIsolate()"); - } - - $result .= $indent . "return " . $nativeValue . ";\n"; - - return $result; -} - -sub GetNativeTypeFromSignature -{ - my $signature = shift; - my $parameterIndex = shift; - - my $type = $signature->type; - - if ($type eq "unsigned long" and $signature->extendedAttributes->{"IsIndex"}) { - # Special-case index arguments because we need to check that they aren't < 0. - return "int"; - } - - $type = GetNativeType($type, $parameterIndex >= 0 ? 1 : 0); - - if ($parameterIndex >= 0 && $type eq "V8StringResource") { - # FIXME: This implements [TreatNullAs=NullString] and [TreatUndefinedAs=NullString], - # but the Web IDL spec requires [TreatNullAs=EmptyString] and [TreatUndefinedAs=EmptyString]. - my $mode = ""; - if (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") and ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString")) { - $mode = "WithUndefinedOrNullCheck"; - } elsif (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") or $signature->extendedAttributes->{"Reflect"}) { - $mode = "WithNullCheck"; - } - # FIXME: Add the case for 'elsif ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString"))'. - $type .= "<$mode>"; - } - - return $type; -} - -sub GetNativeType -{ - my $type = shift; - my $isParameter = shift; - - my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($type); - if ($svgNativeType) { - if ($svgNativeType =~ /List$/) { - return "${svgNativeType}*"; - } else { - return "RefPtr<${svgNativeType} >"; - } - } - - return "float" if $type eq "float"; - return "double" if $type eq "double"; - return "int" if $type eq "long" or $type eq "int" or $type eq "short" or $type eq "unsigned short"; - return "unsigned" if $type eq "unsigned long" or $type eq "unsigned int"; - return "long long" if $type eq "long long"; - return "unsigned long long" if $type eq "unsigned long long"; - return "bool" if $type eq "boolean"; - - return "V8StringResource" if $type eq "DOMString" and $isParameter; - return "String" if $type eq "DOMString"; - - return "Range::CompareHow" if $type eq "CompareHow"; - return "DOMTimeStamp" if $type eq "DOMTimeStamp"; - return "double" if $type eq "Date"; - - # FIXME: When EventTarget is an interface and not a mixin, fix this so that - # EventTarget can be passed as a parameter. - return "Node*" if $type eq "EventTarget" and $isParameter; - - return "ScriptValue" if $type eq "DOMObject" or $type eq "any"; - return "Dictionary" if $type eq "Dictionary"; - - # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>. - return "RefPtr<DOMStringList>" if $type eq "DOMString[]" or $type eq "DOMStringList"; - - return "RefPtr<IDBKey>" if $type eq "IDBKey"; - return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"; - return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; - return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; - return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; - return "RefPtr<${type}>" if $codeGenerator->IsRefPtrType($type) and not $isParameter; - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - if ($arrayOrSequenceType) { - my $nativeType = GetNativeType($arrayOrSequenceType); - $nativeType .= " " if ($nativeType =~ />$/); - return "Vector<${nativeType}>"; - } - - # Default, assume native type is a pointer with same type name as idl type - return "${type}*"; -} - -sub GetNativeTypeForCallbacks -{ - my $type = shift; - return "const String&" if $type eq "DOMString"; - return "SerializedScriptValue*" if $type eq "SerializedScriptValue"; - - # Callbacks use raw pointers, so pass isParameter = 1 - return GetNativeType($type, 1); -} - -sub TranslateParameter -{ - my $signature = shift; - - # The IDL uses some pseudo-types which don't really exist. - if ($signature->type eq "TimeoutHandler") { - $signature->type("DOMString"); - } -} - -sub TypeCanFailConversion -{ - my $signature = shift; - my $type = $signature->type; - - AddToImplIncludes("ExceptionCode.h") if $type eq "Attr"; - return 1 if $type eq "Attr"; - return 0; -} - -sub JSValueToNative -{ - my $signature = shift; - my $value = shift; - my $getIsolate = shift; - - my $type = $signature->type; - - return "$value" if $type eq "JSObject"; - return "$value->BooleanValue()" if $type eq "boolean"; - return "static_cast<$type>($value->NumberValue())" if $type eq "float" or $type eq "double"; - - return "toInt32($value)" if $type eq "long" or $type eq "short"; - return "toUInt32($value)" if $type eq "unsigned long" or $type eq "unsigned short"; - return "toInt64($value)" if $type eq "unsigned long long" or $type eq "long long"; - return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow"; - return "toWebCoreDate($value)" if $type eq "Date"; - return "toDOMStringList($value, $getIsolate)" if $type eq "DOMStringList"; - # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>. - return "toDOMStringList($value, $getIsolate)" if $type eq "DOMString[]"; - - if ($type eq "DOMString") { - return $value; - } - - if ($type eq "SerializedScriptValue") { - AddToImplIncludes("SerializedScriptValue.h"); - return "SerializedScriptValue::create($value, $getIsolate)"; - } - - if ($type eq "IDBKey") { - AddToImplIncludes("IDBBindingUtilities.h"); - AddToImplIncludes("IDBKey.h"); - return "createIDBKeyFromValue($value)"; - } - - if ($type eq "Dictionary") { - AddToImplIncludes("Dictionary.h"); - return "Dictionary($value, $getIsolate)"; - } - - if ($type eq "DOMObject" or $type eq "any") { - AddToImplIncludes("ScriptValue.h"); - return "ScriptValue($value)"; - } - - if ($type eq "NodeFilter") { - return "toNodeFilter($value)"; - } - - if ($type eq "MediaQueryListListener") { - AddToImplIncludes("MediaQueryListListener.h"); - return "MediaQueryListListener::create(" . $value . ")"; - } - - # Default, assume autogenerated type conversion routines - # FIXME: When EventTarget is an interface and not a mixin, fix this to use - # V8EventTarget::HasInstance etc. - if ($type eq "EventTarget") { - AddToImplIncludes("V8Node.h"); - - # EventTarget is not in DOM hierarchy, but all Nodes are EventTarget. - return "V8Node::HasInstance($value) ? V8Node::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; - } - - if ($type eq "XPathNSResolver") { - return "toXPathNSResolver($value)"; - } - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - if ($arrayOrSequenceType) { - if ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { - AddToImplIncludes("V8${arrayOrSequenceType}.h"); - return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequenceType}>($value))"; - } - return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($value)"; - } - - AddIncludesForType($type); - - AddToImplIncludes("V8${type}.h"); - return "V8${type}::HasInstance($value) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; -} - -sub GetV8HeaderName -{ - my $type = shift; - return "V8Event.h" if $type eq "DOMTimeStamp"; - return "EventListener.h" if $type eq "EventListener"; - return "SerializedScriptValue.h" if $type eq "SerializedScriptValue"; - return "ScriptValue.h" if $type eq "DOMObject" or $type eq "any"; - return "V8DOMStringList.h" if $type eq "DOMString[]"; - return "V8${type}.h"; -} - -sub CreateCustomSignature -{ - my $function = shift; - my $count = @{$function->parameters}; - my $name = $function->signature->name; - my $result = " const int ${name}Argc = ${count};\n" . - " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; - my $first = 1; - foreach my $parameter (@{$function->parameters}) { - if ($first) { $first = 0; } - else { $result .= ", "; } - if (IsWrapperType($parameter->type)) { - if ($parameter->type eq "XPathNSResolver") { - # Special case for XPathNSResolver. All other browsers accepts a callable, - # so, even though it's against IDL, accept objects here. - $result .= "v8::Handle<v8::FunctionTemplate>()"; - } else { - my $type = $parameter->type; - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - if ($arrayOrSequenceType) { - if ($arrayType eq "DOMString") { - AddToImplIncludes("V8DOMStringList.h"); - AddToImplIncludes("DOMStringList.h"); - - } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { - AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)); - AddToImplIncludes("${arrayOrSequenceType}.h"); - } else { - $result .= "v8::Handle<v8::FunctionTemplate>()"; - next; - } - } else { - AddToImplIncludes(GetV8HeaderName($type)); - } - $result .= "V8${type}::GetRawTemplate()"; - } - } else { - $result .= "v8::Handle<v8::FunctionTemplate>()"; - } - } - $result .= " };\n"; - $result .= " v8::Handle<v8::Signature> ${name}Signature = v8::Signature::New(desc, ${name}Argc, ${name}Argv);\n"; - return $result; -} - - -sub RequiresCustomSignature -{ - my $function = shift; - # No signature needed for Custom function - if ($function->signature->extendedAttributes->{"Custom"} || - $function->signature->extendedAttributes->{"V8Custom"}) { - return 0; - } - # No signature needed for overloaded function - if (@{$function->{overloads}} > 1) { - return 0; - } - if ($function->isStatic) { - return 0; - } - # Type checking is performed in the generated code - if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) { - return 0; - } - foreach my $parameter (@{$function->parameters}) { - my $optional = $parameter->extendedAttributes->{"Optional"}; - if (($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString") || $parameter->extendedAttributes->{"Callback"}) { - return 0; - } - } - - foreach my $parameter (@{$function->parameters}) { - if (IsWrapperType($parameter->type)) { - return 1; - } - } - return 0; -} - - -my %non_wrapper_types = ( - 'CompareHow' => 1, - 'DOMObject' => 1, - 'DOMString' => 1, - 'DOMString[]' => 1, - 'DOMTimeStamp' => 1, - 'Date' => 1, - 'Dictionary' => 1, - 'EventListener' => 1, - # FIXME: When EventTarget is an interface and not a mixin, fix this so that - # EventTarget is treated as a wrapper type. - 'EventTarget' => 1, - 'IDBKey' => 1, - 'JSObject' => 1, - 'MediaQueryListListener' => 1, - 'NodeFilter' => 1, - 'SerializedScriptValue' => 1, - 'any' => 1, - 'boolean' => 1, - 'double' => 1, - 'float' => 1, - 'int' => 1, - 'long long' => 1, - 'long' => 1, - 'short' => 1, - 'unsigned int' => 1, - 'unsigned long long' => 1, - 'unsigned long' => 1, - 'unsigned short' => 1 -); - - -sub IsWrapperType -{ - my $type = shift; - return !($non_wrapper_types{$type}); -} - -sub GetTypeNameOfExternalTypedArray -{ - my $interface = shift; - my $interfaceName = $interface->name; - my $viewType = $interface->extendedAttributes->{"TypedArray"}; - return "v8::kExternalByteArray" if $viewType eq "signed char" and $interfaceName eq "Int8Array"; - return "v8::kExternalPixelArray" if $viewType eq "unsigned char" and $interfaceName eq "Uint8ClampedArray"; - return "v8::kExternalUnsignedByteArray" if $viewType eq "unsigned char" and $interfaceName eq "Uint8Array"; - return "v8::kExternalShortArray" if $viewType eq "short" and $interfaceName eq "Int16Array"; - return "v8::kExternalUnsignedShortArray" if $viewType eq "unsigned short" and $interfaceName eq "Uint16Array"; - return "v8::kExternalIntArray" if $viewType eq "int" and $interfaceName eq "Int32Array"; - return "v8::kExternalUnsignedIntArray" if $viewType eq "unsigned int" and $interfaceName eq "Uint32Array"; - return "v8::kExternalFloatArray" if $viewType eq "float" and $interfaceName eq "Float32Array"; - return "v8::kExternalDoubleArray" if $viewType eq "double" and $interfaceName eq "Float64Array"; - - die "TypedArray of unknown type is found"; -} - -sub IsDOMNodeType -{ - my $type = shift; - - return 1 if $type eq 'Attr'; - return 1 if $type eq 'CDATASection'; - return 1 if $type eq 'CharacterData'; - return 1 if $type eq 'Comment'; - return 1 if $type eq 'Document'; - return 1 if $type eq 'DocumentFragment'; - return 1 if $type eq 'DocumentType'; - return 1 if $type eq 'Element'; - return 1 if $type eq 'Entity'; - return 1 if $type eq 'EntityReference'; - return 1 if $type eq 'HTMLDocument'; - return 1 if $type eq 'Node'; - return 1 if $type eq 'Notation'; - return 1 if $type eq 'ProcessingInstruction'; - return 1 if $type eq 'ShadowRoot'; - return 1 if $type eq 'SVGDocument'; - return 1 if $type eq 'Text'; - - return 1 if $type =~ /^HTML.*Element$/; - return 1 if $type =~ /^SVG.*Element$/; - - return 1 if $type eq 'TestNode'; - - return 0; -} - - -sub NativeToJSValue -{ - my $signature = shift; - my $value = shift; - my $getCreationContext = shift; - my $getCreationContextArg = $getCreationContext ? ", $getCreationContext" : ""; - my $getIsolate = shift; - my $getIsolateArg = $getIsolate ? ", $getIsolate" : ""; - my $getHolderContainer = shift; - my $getHolderContainerArg = $getHolderContainer ? ", $getHolderContainer" : ""; - my $getScriptWrappable = shift; - my $getScriptWrappableArg = $getScriptWrappable ? ", $getScriptWrappable" : ""; - my $type = $signature->type; - - return ($getIsolate ? "v8Boolean($value, $getIsolate)" : "v8Boolean($value)") if $type eq "boolean"; - return "v8Undefined()" if $type eq "void"; # equivalent to v8Undefined() - - # HTML5 says that unsigned reflected attributes should be in the range - # [0, 2^31). When a value isn't in this range, a default value (or 0) - # should be returned instead. - if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) { - $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g; - return "v8UnsignedInteger(std::max(0, " . $value . ")$getIsolateArg)"; - } - - # For all the types where we use 'int' as the representation type, - # we use v8Integer() which has a fast small integer conversion check. - my $nativeType = GetNativeType($type); - return "v8Integer($value$getIsolateArg)" if $nativeType eq "int"; - return "v8UnsignedInteger($value$getIsolateArg)" if $nativeType eq "unsigned"; - - return "v8DateOrNull($value$getIsolateArg)" if $type eq "Date"; - # long long and unsigned long long are not representable in ECMAScript. - return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp"; - return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type); - return "$value.v8Value()" if $nativeType eq "ScriptValue"; - - if ($codeGenerator->IsStringType($type)) { - my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"}; - if (defined $conv) { - return "v8StringOrNull($value$getIsolateArg)" if $conv eq "Null"; - return "v8StringOrUndefined($value$getIsolateArg)" if $conv eq "Undefined"; - - die "Unknown value for TreatReturnedNullStringAs extended attribute"; - } - return $getIsolate ? "v8String($value, $getIsolate)" : "deprecatedV8String($value)"; - } - - my $arrayType = $codeGenerator->GetArrayType($type); - my $sequenceType = $codeGenerator->GetSequenceType($type); - my $arrayOrSequenceType = $arrayType || $sequenceType; - - if ($arrayOrSequenceType) { - if ($arrayType eq "DOMString") { - AddToImplIncludes("V8DOMStringList.h"); - AddToImplIncludes("DOMStringList.h"); - - } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { - AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)); - AddToImplIncludes("${arrayOrSequenceType}.h"); - } - return "v8Array(${value}${getIsolateArg})"; - } - - AddIncludesForType($type); - - if (IsDOMNodeType($type) || $type eq "EventTarget") { - if ($getScriptWrappable) { - return "toV8Fast($value$getHolderContainerArg$getScriptWrappableArg)"; - } - return "toV8($value$getCreationContextArg$getIsolateArg)"; - } - - if ($type eq "EventListener") { - AddToImplIncludes("V8AbstractEventListener.h"); - return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(" . ($getIsolate ? "v8Null($getIsolate)" : "v8::Null()") . ")"; - } - - if ($type eq "SerializedScriptValue") { - AddToImplIncludes("$type.h"); - return "$value ? $value->deserialize() : v8::Handle<v8::Value>(" . ($getIsolate ? "v8Null($getIsolate)" : "v8::Null()") . ")"; - } - - AddToImplIncludes("wtf/RefCounted.h"); - AddToImplIncludes("wtf/RefPtr.h"); - AddToImplIncludes("wtf/GetPtr.h"); - - if ($getScriptWrappable) { - return "toV8Fast($value$getHolderContainerArg$getScriptWrappableArg)"; - } - return "toV8($value$getCreationContextArg$getIsolateArg)"; -} - -sub WriteData -{ - my $object = shift; - my $interface = shift; - my $outputDir = shift; - my $outputHeadersDir = shift; - - my $name = $interface->name; - my $prefix = FileNamePrefix; - my $headerFileName = "$outputHeadersDir/$prefix$name.h"; - my $implFileName = "$outputDir/$prefix$name.cpp"; - - # Update a .cpp file if the contents are changed. - my $contents = join "", @implContentHeader; - - my @includes = (); - my %implIncludeConditions = (); - foreach my $include (keys %implIncludes) { - my $condition = $implIncludes{$include}; - my $checkType = $include; - $checkType =~ s/\.h//; - next if $codeGenerator->IsSVGAnimatedType($checkType); - - if ($include =~ /wtf/) { - $include = "\<$include\>"; - } else { - $include = "\"$include\""; - } - - if ($condition eq 1) { - push @includes, $include; - } else { - push @{$implIncludeConditions{$condition}}, $include; - } - } - foreach my $include (sort @includes) { - $contents .= "#include $include\n"; - } - foreach my $condition (sort keys %implIncludeConditions) { - $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n"; - foreach my $include (sort @{$implIncludeConditions{$condition}}) { - $contents .= "#include $include\n"; - } - $contents .= "#endif\n"; - } - - $contents .= "\n"; - $contents .= join "", @implContentDecls, @implContent; - $codeGenerator->UpdateFile($implFileName, $contents); - - %implIncludes = (); - @implContentHeader = (); - @implContentDecls = (); - @implContent = (); - - # Update a .h file if the contents are changed. - $contents = join "", @headerContent; - $codeGenerator->UpdateFile($headerFileName, $contents); - - @headerContent = (); -} - -sub ConvertToV8StringResource -{ - my $signature = shift; - my $nativeType = shift; - my $variableName = shift; - my $value = shift; - my $suffix = shift; - - die "Wrong native type passed: $nativeType" unless $nativeType =~ /^V8StringResource/; - if ($signature->type eq "DOMString") { - my $macro = "V8TRYCATCH_FOR_V8STRINGRESOURCE"; - $macro .= "_$suffix" if $suffix; - return "$macro($nativeType, $variableName, $value);" - } else { - return "$nativeType $variableName($value, true);"; - } -} - -# Returns the RuntimeEnabledFeatures function name that is hooked up to check if a method/attribute is enabled. -sub GetRuntimeEnableFunctionName -{ - my $signature = shift; - - # If a parameter is given (e.g. "V8EnabledAtRuntime=FeatureName") return the RuntimeEnabledFeatures::{FeatureName}Enabled() method. - return "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($signature->extendedAttributes->{"V8EnabledAtRuntime"}) . "Enabled" if ($signature->extendedAttributes->{"V8EnabledAtRuntime"} && $signature->extendedAttributes->{"V8EnabledAtRuntime"} ne "VALUE_IS_MISSING"); - - # Otherwise return a function named RuntimeEnabledFeatures::{methodName}Enabled(). - return "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($signature->name) . "Enabled"; -} - -sub GetContextEnableFunction -{ - my $signature = shift; - - # If a parameter is given (e.g. "V8EnabledPerContext=FeatureName") return the {FeatureName}Allowed() method. - if ($signature->extendedAttributes->{"V8EnabledPerContext"} && $signature->extendedAttributes->{"V8EnabledPerContext"} ne "VALUE_IS_MISSING") { - return "ContextFeatures::" . $codeGenerator->WK_lcfirst($signature->extendedAttributes->{"V8EnabledPerContext"}) . "Enabled"; - } - - # Or it fallbacks to the attribute name if the parameter value is missing. - return "ContextFeatures::" . $codeGenerator->WK_lcfirst($signature->name) . "Enabled"; -} - -sub GetPassRefPtrType -{ - my $v8InterfaceName = shift; - - my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; - return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; -} - -1; diff --git a/contrib/dom/scripts/deps.txt b/contrib/dom/scripts/deps.txt deleted file mode 100644 index f7db419..0000000 --- a/contrib/dom/scripts/deps.txt +++ /dev/null @@ -1,636 +0,0 @@ -../../bindings/scripts/test/TestCallback.idl -../../bindings/scripts/test/TestCustomNamedGetter.idl -../../bindings/scripts/test/TestDomainSecurity.idl -../../bindings/scripts/test/TestEventConstructor.idl -../../bindings/scripts/test/TestEventTarget.idl -../../bindings/scripts/test/TestException.idl -../../bindings/scripts/test/TestInterface.idl -../../bindings/scripts/test/TestMediaQueryListListener.idl -../../bindings/scripts/test/TestNamedConstructor.idl -../../bindings/scripts/test/TestNode.idl -../../bindings/scripts/test/TestObj.idl -../../bindings/scripts/test/TestOverloadedConstructors.idl -../../bindings/scripts/test/TestSerializedScriptValueInterface.idl -../../bindings/scripts/test/TestSupplemental.idl -../../bindings/scripts/test/TestTypedArray.idl -../../css/Counter.idl -../../css/CSSCharsetRule.idl -../../css/CSSFontFaceRule.idl -../../css/CSSImportRule.idl -../../css/CSSMediaRule.idl -../../css/CSSPageRule.idl -../../css/CSSPrimitiveValue.idl -../../css/CSSRule.idl -../../css/CSSRuleList.idl -../../css/CSSStyleDeclaration.idl -../../css/CSSStyleRule.idl -../../css/CSSStyleSheet.idl -../../css/CSSUnknownRule.idl -../../css/CSSValue.idl -../../css/CSSValueList.idl -../../css/MediaList.idl -../../css/MediaQueryList.idl -../../css/MediaQueryListListener.idl -../../css/Rect.idl -../../css/RGBColor.idl -../../css/StyleMedia.idl -../../css/StyleSheet.idl -../../css/StyleSheetList.idl -../../css/WebKitCSSFilterValue.idl -../../css/WebKitCSSKeyframeRule.idl -../../css/WebKitCSSKeyframesRule.idl -../../css/WebKitCSSMatrix.idl -../../css/WebKitCSSMixFunctionValue.idl -../../css/WebKitCSSRegionRule.idl -../../css/WebKitCSSTransformValue.idl -../../css/WebKitCSSViewportRule.idl -../../dom/Attr.idl -../../dom/BeforeLoadEvent.idl -../../dom/CDATASection.idl -../../dom/CharacterData.idl -../../dom/ClientRect.idl -../../dom/ClientRectList.idl -../../dom/Clipboard.idl -../../dom/Comment.idl -../../dom/CompositionEvent.idl -../../dom/CustomEvent.idl -../../dom/DataTransferItem.idl -../../dom/DataTransferItemList.idl -../../dom/DeviceMotionEvent.idl -../../dom/DeviceOrientationEvent.idl -../../dom/Document.idl -../../dom/DocumentFragment.idl -../../dom/DocumentType.idl -../../dom/DOMCoreException.idl -../../dom/DOMError.idl -../../dom/DOMImplementation.idl -../../dom/DOMNamedFlowCollection.idl -../../dom/DOMStringList.idl -../../dom/DOMStringMap.idl -../../dom/Element.idl -../../dom/Entity.idl -../../dom/EntityReference.idl -../../dom/ErrorEvent.idl -../../dom/Event.idl -../../dom/EventException.idl -../../dom/EventListener.idl -../../dom/EventTarget.idl -../../dom/HashChangeEvent.idl -../../dom/KeyboardEvent.idl -../../dom/MessageChannel.idl -../../dom/MessageEvent.idl -../../dom/MessagePort.idl -../../dom/MouseEvent.idl -../../dom/MutationCallback.idl -../../dom/MutationEvent.idl -../../dom/MutationObserver.idl -../../dom/MutationRecord.idl -../../dom/NamedNodeMap.idl -../../dom/Node.idl -../../dom/NodeFilter.idl -../../dom/NodeIterator.idl -../../dom/NodeList.idl -../../dom/Notation.idl -../../dom/OverflowEvent.idl -../../dom/PageTransitionEvent.idl -../../dom/PopStateEvent.idl -../../dom/ProcessingInstruction.idl -../../dom/ProgressEvent.idl -../../dom/PropertyNodeList.idl -../../dom/Range.idl -../../dom/RangeException.idl -../../dom/RequestAnimationFrameCallback.idl -../../dom/ShadowRoot.idl -../../dom/StringCallback.idl -../../dom/Text.idl -../../dom/TextEvent.idl -../../dom/Touch.idl -../../dom/TouchEvent.idl -../../dom/TouchList.idl -../../dom/TreeWalker.idl -../../dom/UIEvent.idl -../../dom/WebKitAnimationEvent.idl -../../dom/WebKitNamedFlow.idl -../../dom/WebKitTransitionEvent.idl -../../dom/WheelEvent.idl -../../fileapi/Blob.idl -../../fileapi/File.idl -../../fileapi/FileError.idl -../../fileapi/FileException.idl -../../fileapi/FileList.idl -../../fileapi/FileReader.idl -../../fileapi/FileReaderSync.idl -../../html/canvas/ArrayBuffer.idl -../../html/canvas/ArrayBufferView.idl -../../html/canvas/CanvasGradient.idl -../../html/canvas/CanvasPattern.idl -../../html/canvas/CanvasRenderingContext.idl -../../html/canvas/CanvasRenderingContext2D.idl -../../html/canvas/DataView.idl -../../html/canvas/EXTTextureFilterAnisotropic.idl -../../html/canvas/Float32Array.idl -../../html/canvas/Float64Array.idl -../../html/canvas/Int16Array.idl -../../html/canvas/Int32Array.idl -../../html/canvas/Int8Array.idl -../../html/canvas/OESElementIndexUint.idl -../../html/canvas/OESStandardDerivatives.idl -../../html/canvas/OESTextureFloat.idl -../../html/canvas/OESVertexArrayObject.idl -../../html/canvas/Uint16Array.idl -../../html/canvas/Uint32Array.idl -../../html/canvas/Uint8Array.idl -../../html/canvas/Uint8ClampedArray.idl -../../html/canvas/WebGLActiveInfo.idl -../../html/canvas/WebGLBuffer.idl -../../html/canvas/WebGLCompressedTextureS3TC.idl -../../html/canvas/WebGLContextAttributes.idl -../../html/canvas/WebGLContextEvent.idl -../../html/canvas/WebGLDebugRendererInfo.idl -../../html/canvas/WebGLDebugShaders.idl -../../html/canvas/WebGLDepthTexture.idl -../../html/canvas/WebGLFramebuffer.idl -../../html/canvas/WebGLLoseContext.idl -../../html/canvas/WebGLProgram.idl -../../html/canvas/WebGLRenderbuffer.idl -../../html/canvas/WebGLRenderingContext.idl -../../html/canvas/WebGLShader.idl -../../html/canvas/WebGLShaderPrecisionFormat.idl -../../html/canvas/WebGLTexture.idl -../../html/canvas/WebGLUniformLocation.idl -../../html/canvas/WebGLVertexArrayObjectOES.idl -../../html/DOMFormData.idl -../../html/DOMSettableTokenList.idl -../../html/DOMTokenList.idl -../../html/DOMURL.idl -../../html/HTMLAllCollection.idl -../../html/HTMLAnchorElement.idl -../../html/HTMLAppletElement.idl -../../html/HTMLAreaElement.idl -../../html/HTMLAudioElement.idl -../../html/HTMLBaseElement.idl -../../html/HTMLBaseFontElement.idl -../../html/HTMLBodyElement.idl -../../html/HTMLBRElement.idl -../../html/HTMLButtonElement.idl -../../html/HTMLCanvasElement.idl -../../html/HTMLCollection.idl -../../html/HTMLDataListElement.idl -../../html/HTMLDetailsElement.idl -../../html/HTMLDialogElement.idl -../../html/HTMLDirectoryElement.idl -../../html/HTMLDivElement.idl -../../html/HTMLDListElement.idl -../../html/HTMLDocument.idl -../../html/HTMLElement.idl -../../html/HTMLEmbedElement.idl -../../html/HTMLFieldSetElement.idl -../../html/HTMLFontElement.idl -../../html/HTMLFormControlsCollection.idl -../../html/HTMLFormElement.idl -../../html/HTMLFrameElement.idl -../../html/HTMLFrameSetElement.idl -../../html/HTMLHeadElement.idl -../../html/HTMLHeadingElement.idl -../../html/HTMLHRElement.idl -../../html/HTMLHtmlElement.idl -../../html/HTMLIFrameElement.idl -../../html/HTMLImageElement.idl -../../html/HTMLInputElement.idl -../../html/HTMLIntentElement.idl -../../html/HTMLKeygenElement.idl -../../html/HTMLLabelElement.idl -../../html/HTMLLegendElement.idl -../../html/HTMLLIElement.idl -../../html/HTMLLinkElement.idl -../../html/HTMLMapElement.idl -../../html/HTMLMarqueeElement.idl -../../html/HTMLMediaElement.idl -../../html/HTMLMenuElement.idl -../../html/HTMLMetaElement.idl -../../html/HTMLMeterElement.idl -../../html/HTMLModElement.idl -../../html/HTMLObjectElement.idl -../../html/HTMLOListElement.idl -../../html/HTMLOptGroupElement.idl -../../html/HTMLOptionElement.idl -../../html/HTMLOptionsCollection.idl -../../html/HTMLOutputElement.idl -../../html/HTMLParagraphElement.idl -../../html/HTMLParamElement.idl -../../html/HTMLPreElement.idl -../../html/HTMLProgressElement.idl -../../html/HTMLPropertiesCollection.idl -../../html/HTMLQuoteElement.idl -../../html/HTMLScriptElement.idl -../../html/HTMLSelectElement.idl -../../html/HTMLSourceElement.idl -../../html/HTMLSpanElement.idl -../../html/HTMLStyleElement.idl -../../html/HTMLTableCaptionElement.idl -../../html/HTMLTableCellElement.idl -../../html/HTMLTableColElement.idl -../../html/HTMLTableElement.idl -../../html/HTMLTableRowElement.idl -../../html/HTMLTableSectionElement.idl -../../html/HTMLTemplateElement.idl -../../html/HTMLTextAreaElement.idl -../../html/HTMLTitleElement.idl -../../html/HTMLTrackElement.idl -../../html/HTMLUListElement.idl -../../html/HTMLUnknownElement.idl -../../html/HTMLVideoElement.idl -../../html/ImageData.idl -../../html/MediaController.idl -../../html/MediaError.idl -../../html/MediaKeyError.idl -../../html/MediaKeyEvent.idl -../../html/MicroDataItemValue.idl -../../html/RadioNodeList.idl -../../html/shadow/HTMLContentElement.idl -../../html/shadow/HTMLShadowElement.idl -../../html/TextMetrics.idl -../../html/TimeRanges.idl -../../html/track/TextTrack.idl -../../html/track/TextTrackCue.idl -../../html/track/TextTrackCueList.idl -../../html/track/TextTrackList.idl -../../html/track/TrackEvent.idl -../../html/ValidityState.idl -../../html/VoidCallback.idl -../../inspector/InjectedScriptHost.idl -../../inspector/InspectorFrontendHost.idl -../../inspector/JavaScriptCallFrame.idl -../../inspector/ScriptProfile.idl -../../inspector/ScriptProfileNode.idl -../../loader/appcache/DOMApplicationCache.idl -../../Modules/battery/BatteryManager.idl -../../Modules/battery/NavigatorBattery.idl -../../Modules/filesystem/DataTransferItemFileSystem.idl -../../Modules/filesystem/DirectoryEntry.idl -../../Modules/filesystem/DirectoryEntrySync.idl -../../Modules/filesystem/DirectoryReader.idl -../../Modules/filesystem/DirectoryReaderSync.idl -../../Modules/filesystem/DOMFileSystem.idl -../../Modules/filesystem/DOMFileSystemSync.idl -../../Modules/filesystem/DOMWindowFileSystem.idl -../../Modules/filesystem/EntriesCallback.idl -../../Modules/filesystem/Entry.idl -../../Modules/filesystem/EntryArray.idl -../../Modules/filesystem/EntryArraySync.idl -../../Modules/filesystem/EntryCallback.idl -../../Modules/filesystem/EntrySync.idl -../../Modules/filesystem/ErrorCallback.idl -../../Modules/filesystem/FileCallback.idl -../../Modules/filesystem/FileEntry.idl -../../Modules/filesystem/FileEntrySync.idl -../../Modules/filesystem/FileSystemCallback.idl -../../Modules/filesystem/FileWriter.idl -../../Modules/filesystem/FileWriterCallback.idl -../../Modules/filesystem/FileWriterSync.idl -../../Modules/filesystem/HTMLInputElementFileSystem.idl -../../Modules/filesystem/Metadata.idl -../../Modules/filesystem/MetadataCallback.idl -../../Modules/filesystem/WorkerContextFileSystem.idl -../../Modules/gamepad/Gamepad.idl -../../Modules/gamepad/GamepadList.idl -../../Modules/gamepad/NavigatorGamepad.idl -../../Modules/geolocation/Geolocation.idl -../../Modules/geolocation/Geoposition.idl -../../Modules/geolocation/NavigatorGeolocation.idl -../../Modules/geolocation/PositionCallback.idl -../../Modules/geolocation/PositionError.idl -../../Modules/geolocation/PositionErrorCallback.idl -../../Modules/indexeddb/DOMWindowIndexedDatabase.idl -../../Modules/indexeddb/IDBAny.idl -../../Modules/indexeddb/IDBCursor.idl -../../Modules/indexeddb/IDBCursorWithValue.idl -../../Modules/indexeddb/IDBDatabase.idl -../../Modules/indexeddb/IDBFactory.idl -../../Modules/indexeddb/IDBIndex.idl -../../Modules/indexeddb/IDBKey.idl -../../Modules/indexeddb/IDBKeyRange.idl -../../Modules/indexeddb/IDBObjectStore.idl -../../Modules/indexeddb/IDBOpenDBRequest.idl -../../Modules/indexeddb/IDBRequest.idl -../../Modules/indexeddb/IDBTransaction.idl -../../Modules/indexeddb/IDBUpgradeNeededEvent.idl -../../Modules/indexeddb/IDBVersionChangeEvent.idl -../../Modules/indexeddb/IDBVersionChangeRequest.idl -../../Modules/indexeddb/WorkerContextIndexedDatabase.idl -../../Modules/intents/DeliveredIntent.idl -../../Modules/intents/DOMWindowIntents.idl -../../Modules/intents/Intent.idl -../../Modules/intents/IntentResultCallback.idl -../../Modules/intents/NavigatorIntents.idl -../../Modules/mediasource/MediaSource.idl -../../Modules/mediasource/SourceBuffer.idl -../../Modules/mediasource/SourceBufferList.idl -../../Modules/mediastream/DOMWindowMediaStream.idl -../../Modules/mediastream/LocalMediaStream.idl -../../Modules/mediastream/MediaStream.idl -../../Modules/mediastream/MediaStreamEvent.idl -../../Modules/mediastream/MediaStreamList.idl -../../Modules/mediastream/MediaStreamTrack.idl -../../Modules/mediastream/MediaStreamTrackEvent.idl -../../Modules/mediastream/MediaStreamTrackList.idl -../../Modules/mediastream/NavigatorMediaStream.idl -../../Modules/mediastream/NavigatorUserMediaError.idl -../../Modules/mediastream/NavigatorUserMediaErrorCallback.idl -../../Modules/mediastream/NavigatorUserMediaSuccessCallback.idl -../../Modules/mediastream/RTCDataChannel.idl -../../Modules/mediastream/RTCDataChannelEvent.idl -../../Modules/mediastream/RTCErrorCallback.idl -../../Modules/mediastream/RTCIceCandidate.idl -../../Modules/mediastream/RTCIceCandidateEvent.idl -../../Modules/mediastream/RTCPeerConnection.idl -../../Modules/mediastream/RTCSessionDescription.idl -../../Modules/mediastream/RTCSessionDescriptionCallback.idl -../../Modules/mediastream/RTCStatsCallback.idl -../../Modules/mediastream/RTCStatsElement.idl -../../Modules/mediastream/RTCStatsReport.idl -../../Modules/mediastream/RTCStatsResponse.idl -../../Modules/navigatorcontentutils/NavigatorContentUtils.idl -../../Modules/networkinfo/NavigatorNetworkInfoConnection.idl -../../Modules/networkinfo/NetworkInfoConnection.idl -../../Modules/notifications/DOMWindowNotifications.idl -../../Modules/notifications/Notification.idl -../../Modules/notifications/NotificationCenter.idl -../../Modules/notifications/NotificationPermissionCallback.idl -../../Modules/notifications/WorkerContextNotifications.idl -../../Modules/proximity/DeviceProximityEvent.idl -../../Modules/quota/DOMWindowQuota.idl -../../Modules/quota/StorageInfo.idl -../../Modules/quota/StorageInfoErrorCallback.idl -../../Modules/quota/StorageInfoQuotaCallback.idl -../../Modules/quota/StorageInfoUsageCallback.idl -../../Modules/speech/DOMWindowSpeech.idl -../../Modules/speech/SpeechGrammar.idl -../../Modules/speech/SpeechGrammarList.idl -../../Modules/speech/SpeechRecognition.idl -../../Modules/speech/SpeechRecognitionAlternative.idl -../../Modules/speech/SpeechRecognitionError.idl -../../Modules/speech/SpeechRecognitionEvent.idl -../../Modules/speech/SpeechRecognitionResult.idl -../../Modules/speech/SpeechRecognitionResultList.idl -../../Modules/vibration/NavigatorVibration.idl -../../Modules/webaudio/AnalyserNode.idl -../../Modules/webaudio/AudioBuffer.idl -../../Modules/webaudio/AudioBufferCallback.idl -../../Modules/webaudio/AudioBufferSourceNode.idl -../../Modules/webaudio/AudioContext.idl -../../Modules/webaudio/AudioDestinationNode.idl -../../Modules/webaudio/AudioGain.idl -../../Modules/webaudio/AudioListener.idl -../../Modules/webaudio/AudioNode.idl -../../Modules/webaudio/AudioParam.idl -../../Modules/webaudio/AudioProcessingEvent.idl -../../Modules/webaudio/AudioSourceNode.idl -../../Modules/webaudio/BiquadFilterNode.idl -../../Modules/webaudio/ChannelMergerNode.idl -../../Modules/webaudio/ChannelSplitterNode.idl -../../Modules/webaudio/ConvolverNode.idl -../../Modules/webaudio/DelayNode.idl -../../Modules/webaudio/DOMWindowWebAudio.idl -../../Modules/webaudio/DynamicsCompressorNode.idl -../../Modules/webaudio/GainNode.idl -../../Modules/webaudio/MediaElementAudioSourceNode.idl -../../Modules/webaudio/MediaStreamAudioDestinationNode.idl -../../Modules/webaudio/MediaStreamAudioSourceNode.idl -../../Modules/webaudio/OfflineAudioCompletionEvent.idl -../../Modules/webaudio/OfflineAudioContext.idl -../../Modules/webaudio/OscillatorNode.idl -../../Modules/webaudio/PannerNode.idl -../../Modules/webaudio/ScriptProcessorNode.idl -../../Modules/webaudio/WaveShaperNode.idl -../../Modules/webaudio/WaveTable.idl -../../Modules/webdatabase/Database.idl -../../Modules/webdatabase/DatabaseCallback.idl -../../Modules/webdatabase/DatabaseSync.idl -../../Modules/webdatabase/DOMWindowWebDatabase.idl -../../Modules/webdatabase/SQLError.idl -../../Modules/webdatabase/SQLException.idl -../../Modules/webdatabase/SQLResultSet.idl -../../Modules/webdatabase/SQLResultSetRowList.idl -../../Modules/webdatabase/SQLStatementCallback.idl -../../Modules/webdatabase/SQLStatementErrorCallback.idl -../../Modules/webdatabase/SQLTransaction.idl -../../Modules/webdatabase/SQLTransactionCallback.idl -../../Modules/webdatabase/SQLTransactionErrorCallback.idl -../../Modules/webdatabase/SQLTransactionSync.idl -../../Modules/webdatabase/SQLTransactionSyncCallback.idl -../../Modules/webdatabase/WorkerContextWebDatabase.idl -../../Modules/websockets/CloseEvent.idl -../../Modules/websockets/DOMWindowWebSocket.idl -../../Modules/websockets/WebSocket.idl -../../Modules/websockets/WorkerContextWebSocket.idl -../../page/AbstractView.idl -../../page/BarInfo.idl -../../page/Console.idl -../../page/Coordinates.idl -../../page/Crypto.idl -../../page/DOMSecurityPolicy.idl -../../page/DOMSelection.idl -../../page/DOMWindow.idl -../../page/DOMWindowPagePopup.idl -../../page/EventSource.idl -../../page/History.idl -../../page/Location.idl -../../page/MemoryInfo.idl -../../page/Navigator.idl -../../page/PagePopupController.idl -../../page/Performance.idl -../../page/PerformanceEntry.idl -../../page/PerformanceEntryList.idl -../../page/PerformanceMark.idl -../../page/PerformanceMeasure.idl -../../page/PerformanceNavigation.idl -../../page/PerformanceResourceTiming.idl -../../page/PerformanceTiming.idl -../../page/Screen.idl -../../page/SpeechInputEvent.idl -../../page/SpeechInputResult.idl -../../page/SpeechInputResultList.idl -../../page/WebKitPoint.idl -../../page/WorkerNavigator.idl -../../plugins/DOMMimeType.idl -../../plugins/DOMMimeTypeArray.idl -../../plugins/DOMPlugin.idl -../../plugins/DOMPluginArray.idl -../../storage/Storage.idl -../../storage/StorageEvent.idl -../../svg/ElementTimeControl.idl -../../svg/SVGAElement.idl -../../svg/SVGAltGlyphDefElement.idl -../../svg/SVGAltGlyphElement.idl -../../svg/SVGAltGlyphItemElement.idl -../../svg/SVGAngle.idl -../../svg/SVGAnimateColorElement.idl -../../svg/SVGAnimatedAngle.idl -../../svg/SVGAnimatedBoolean.idl -../../svg/SVGAnimatedEnumeration.idl -../../svg/SVGAnimatedInteger.idl -../../svg/SVGAnimatedLength.idl -../../svg/SVGAnimatedLengthList.idl -../../svg/SVGAnimatedNumber.idl -../../svg/SVGAnimatedNumberList.idl -../../svg/SVGAnimatedPreserveAspectRatio.idl -../../svg/SVGAnimatedRect.idl -../../svg/SVGAnimatedString.idl -../../svg/SVGAnimatedTransformList.idl -../../svg/SVGAnimateElement.idl -../../svg/SVGAnimateMotionElement.idl -../../svg/SVGAnimateTransformElement.idl -../../svg/SVGAnimationElement.idl -../../svg/SVGCircleElement.idl -../../svg/SVGClipPathElement.idl -../../svg/SVGColor.idl -../../svg/SVGComponentTransferFunctionElement.idl -../../svg/SVGCursorElement.idl -../../svg/SVGDefsElement.idl -../../svg/SVGDescElement.idl -../../svg/SVGDocument.idl -../../svg/SVGElement.idl -../../svg/SVGElementInstance.idl -../../svg/SVGElementInstanceList.idl -../../svg/SVGEllipseElement.idl -../../svg/SVGException.idl -../../svg/SVGExternalResourcesRequired.idl -../../svg/SVGFEBlendElement.idl -../../svg/SVGFEColorMatrixElement.idl -../../svg/SVGFEComponentTransferElement.idl -../../svg/SVGFECompositeElement.idl -../../svg/SVGFEConvolveMatrixElement.idl -../../svg/SVGFEDiffuseLightingElement.idl -../../svg/SVGFEDisplacementMapElement.idl -../../svg/SVGFEDistantLightElement.idl -../../svg/SVGFEDropShadowElement.idl -../../svg/SVGFEFloodElement.idl -../../svg/SVGFEFuncAElement.idl -../../svg/SVGFEFuncBElement.idl -../../svg/SVGFEFuncGElement.idl -../../svg/SVGFEFuncRElement.idl -../../svg/SVGFEGaussianBlurElement.idl -../../svg/SVGFEImageElement.idl -../../svg/SVGFEMergeElement.idl -../../svg/SVGFEMergeNodeElement.idl -../../svg/SVGFEMorphologyElement.idl -../../svg/SVGFEOffsetElement.idl -../../svg/SVGFEPointLightElement.idl -../../svg/SVGFESpecularLightingElement.idl -../../svg/SVGFESpotLightElement.idl -../../svg/SVGFETileElement.idl -../../svg/SVGFETurbulenceElement.idl -../../svg/SVGFilterElement.idl -../../svg/SVGFilterPrimitiveStandardAttributes.idl -../../svg/SVGFitToViewBox.idl -../../svg/SVGFontElement.idl -../../svg/SVGFontFaceElement.idl -../../svg/SVGFontFaceFormatElement.idl -../../svg/SVGFontFaceNameElement.idl -../../svg/SVGFontFaceSrcElement.idl -../../svg/SVGFontFaceUriElement.idl -../../svg/SVGForeignObjectElement.idl -../../svg/SVGGElement.idl -../../svg/SVGGlyphElement.idl -../../svg/SVGGlyphRefElement.idl -../../svg/SVGGradientElement.idl -../../svg/SVGHKernElement.idl -../../svg/SVGImageElement.idl -../../svg/SVGLangSpace.idl -../../svg/SVGLength.idl -../../svg/SVGLengthList.idl -../../svg/SVGLinearGradientElement.idl -../../svg/SVGLineElement.idl -../../svg/SVGLocatable.idl -../../svg/SVGMarkerElement.idl -../../svg/SVGMaskElement.idl -../../svg/SVGMatrix.idl -../../svg/SVGMetadataElement.idl -../../svg/SVGMissingGlyphElement.idl -../../svg/SVGMPathElement.idl -../../svg/SVGNumber.idl -../../svg/SVGNumberList.idl -../../svg/SVGPaint.idl -../../svg/SVGPathElement.idl -../../svg/SVGPathSeg.idl -../../svg/SVGPathSegArcAbs.idl -../../svg/SVGPathSegArcRel.idl -../../svg/SVGPathSegClosePath.idl -../../svg/SVGPathSegCurvetoCubicAbs.idl -../../svg/SVGPathSegCurvetoCubicRel.idl -../../svg/SVGPathSegCurvetoCubicSmoothAbs.idl -../../svg/SVGPathSegCurvetoCubicSmoothRel.idl -../../svg/SVGPathSegCurvetoQuadraticAbs.idl -../../svg/SVGPathSegCurvetoQuadraticRel.idl -../../svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl -../../svg/SVGPathSegCurvetoQuadraticSmoothRel.idl -../../svg/SVGPathSegLinetoAbs.idl -../../svg/SVGPathSegLinetoHorizontalAbs.idl -../../svg/SVGPathSegLinetoHorizontalRel.idl -../../svg/SVGPathSegLinetoRel.idl -../../svg/SVGPathSegLinetoVerticalAbs.idl -../../svg/SVGPathSegLinetoVerticalRel.idl -../../svg/SVGPathSegList.idl -../../svg/SVGPathSegMovetoAbs.idl -../../svg/SVGPathSegMovetoRel.idl -../../svg/SVGPatternElement.idl -../../svg/SVGPoint.idl -../../svg/SVGPointList.idl -../../svg/SVGPolygonElement.idl -../../svg/SVGPolylineElement.idl -../../svg/SVGPreserveAspectRatio.idl -../../svg/SVGRadialGradientElement.idl -../../svg/SVGRect.idl -../../svg/SVGRectElement.idl -../../svg/SVGRenderingIntent.idl -../../svg/SVGScriptElement.idl -../../svg/SVGSetElement.idl -../../svg/SVGStopElement.idl -../../svg/SVGStringList.idl -../../svg/SVGStylable.idl -../../svg/SVGStyleElement.idl -../../svg/SVGSVGElement.idl -../../svg/SVGSwitchElement.idl -../../svg/SVGSymbolElement.idl -../../svg/SVGTests.idl -../../svg/SVGTextContentElement.idl -../../svg/SVGTextElement.idl -../../svg/SVGTextPathElement.idl -../../svg/SVGTextPositioningElement.idl -../../svg/SVGTitleElement.idl -../../svg/SVGTransform.idl -../../svg/SVGTransformable.idl -../../svg/SVGTransformList.idl -../../svg/SVGTRefElement.idl -../../svg/SVGTSpanElement.idl -../../svg/SVGUnitTypes.idl -../../svg/SVGURIReference.idl -../../svg/SVGUseElement.idl -../../svg/SVGViewElement.idl -../../svg/SVGViewSpec.idl -../../svg/SVGVKernElement.idl -../../svg/SVGZoomAndPan.idl -../../svg/SVGZoomEvent.idl -../../testing/Internals.idl -../../testing/InternalSettings.idl -../../testing/MallocStatistics.idl -../../workers/AbstractWorker.idl -../../workers/DedicatedWorkerContext.idl -../../workers/SharedWorker.idl -../../workers/SharedWorkerContext.idl -../../workers/Worker.idl -../../workers/WorkerContext.idl -../../workers/WorkerLocation.idl -../../xml/DOMParser.idl -../../xml/XMLHttpRequest.idl -../../xml/XMLHttpRequestException.idl -../../xml/XMLHttpRequestProgressEvent.idl -../../xml/XMLHttpRequestUpload.idl -../../xml/XMLSerializer.idl -../../xml/XPathEvaluator.idl -../../xml/XPathException.idl -../../xml/XPathExpression.idl -../../xml/XPathNSResolver.idl -../../xml/XPathResult.idl -../../xml/XSLTProcessor.idl diff --git a/contrib/dom/scripts/gobject-generate-headers.pl b/contrib/dom/scripts/gobject-generate-headers.pl deleted file mode 100644 index 6955955..0000000 --- a/contrib/dom/scripts/gobject-generate-headers.pl +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (C) 2009 Adam Dingle <adam@yorba.org> -# -# This file is part of WebKit -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# aint with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# - -my $classlist = <STDIN>; -chomp($classlist); -my @classes = split / /, $classlist; -@classes = sort @classes; - -print <<EOF; -/* This file is part of the WebKit open source project. - This file has been generated by gobject-generate-headers.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -EOF - -my $outType = $ARGV[0]; -my $header; -if ($outType eq "defines") { - $header = "webkitdomdefines_h"; -} elsif ($outType eq "gdom") { - $header = "webkitdom_h"; -} else { - die "unknown output type"; -} - -print "#ifndef ${header}\n"; -print "#define ${header}\n"; -print "\n"; - -if ($outType eq "defines") { - print "#include <glib.h>\n\n"; - print "#ifdef G_OS_WIN32\n"; - print " #ifdef BUILDING_WEBKIT\n"; - print " #define WEBKIT_API __declspec(dllexport)\n"; - print " #else\n"; - print " #define WEBKIT_API __declspec(dllimport)\n"; - print " #endif\n"; - print " #define WEBKIT_OBSOLETE_API WEBKIT_API\n"; - print "#else\n"; - print " #define WEBKIT_API __attribute__((visibility(\"default\")))\n"; - print " #define WEBKIT_OBSOLETE_API WEBKIT_API __attribute__((deprecated))\n"; - print "#endif\n\n"; - print "#ifndef WEBKIT_API\n"; - print " #define WEBKIT_API\n"; - print "#endif\n"; - - foreach my $class (@classes) { - print "typedef struct _WebKitDOM${class} WebKitDOM${class};\n"; - print "typedef struct _WebKitDOM${class}Class WebKitDOM${class}Class;\n"; - print "\n"; - } -} elsif ($outType eq "gdom") { - foreach my $class (@classes) { - print "#include <webkitdom/WebKitDOM${class}.h>\n"; - } -} - -print "\n"; -print "#endif\n"; diff --git a/contrib/dom/scripts/preprocess-idls.pl b/contrib/dom/scripts/preprocess-idls.pl deleted file mode 100644 index 2f20c1a..0000000 --- a/contrib/dom/scripts/preprocess-idls.pl +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (C) 2011 Google Inc. All rights reserved. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# - -use strict; - -use File::Basename; -use Getopt::Long; -use Cwd; - -use IDLParser; - -my $defines; -my $preprocessor; -my $verbose; -my $idlFilesList; -my $idlAttributesFile; -my $supplementalDependencyFile; -my $supplementalMakefileDeps; - -GetOptions('defines=s' => \$defines, - 'preprocessor=s' => \$preprocessor, - 'verbose' => \$verbose, - 'idlFilesList=s' => \$idlFilesList, - 'idlAttributesFile=s' => \$idlAttributesFile, - 'supplementalDependencyFile=s' => \$supplementalDependencyFile, - 'supplementalMakefileDeps=s' => \$supplementalMakefileDeps); - -die('Must specify #define macros using --defines.') unless defined($defines); -die('Must specify an output file using --supplementalDependencyFile.') unless defined($supplementalDependencyFile); -die('Must specify the file listing all IDLs using --idlFilesList.') unless defined($idlFilesList); - -if ($verbose) { - print "Resolving [Supplemental=XXX] dependencies in all IDL files.\n"; -} - -open FH, "< $idlFilesList" or die "Cannot open $idlFilesList\n"; -my @idlFiles = <FH>; -chomp(@idlFiles); -close FH; - -# Parse all IDL files. -my %documents; -my %interfaceNameToIdlFile; -my %idlFileToInterfaceName; -foreach my $idlFile (@idlFiles) { - my $fullPath = Cwd::realpath($idlFile); - my $parser = IDLParser->new(!$verbose); - $documents{$fullPath} = $parser->Parse($idlFile, $defines, $preprocessor); - my $interfaceName = fileparse(basename($idlFile), ".idl"); - $interfaceNameToIdlFile{$interfaceName} = $fullPath; - $idlFileToInterfaceName{$fullPath} = $interfaceName; -} - -# Runs the IDL attribute checker. -my $idlAttributes = loadIDLAttributes($idlAttributesFile); -foreach my $idlFile (keys %documents) { - checkIDLAttributes($idlAttributes, $documents{$idlFile}, basename($idlFile)); -} - -# Resolves [Supplemental=XXX] dependencies. -my %supplementals; -foreach my $idlFile (keys %documents) { - $supplementals{$idlFile} = []; -} -foreach my $idlFile (keys %documents) { - foreach my $interface (@{$documents{$idlFile}->interfaces}) { - if ($interface->extendedAttributes->{"Supplemental"}) { - my $targetIdlFile = $interfaceNameToIdlFile{$interface->extendedAttributes->{"Supplemental"}}; - push(@{$supplementals{$targetIdlFile}}, $idlFile); - # Treats as if this IDL file does not exist. - delete $supplementals{$idlFile}; - } - } -} - -# Outputs the dependency. -# The format of a supplemental dependency file: -# -# DOMWindow.idl P.idl Q.idl R.idl -# Document.idl S.idl -# Event.idl -# ... -# -# The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl, -# Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs. -# The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file. - -open FH, "> $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n"; - -foreach my $idlFile (sort keys %supplementals) { - print FH $idlFile, " @{$supplementals{$idlFile}}\n"; -} -close FH; - - -if ($supplementalMakefileDeps) { - open MAKE_FH, "> $supplementalMakefileDeps" or die "Cannot open $supplementalMakefileDeps\n"; - my @all_dependencies = []; - foreach my $idlFile (sort keys %supplementals) { - my $basename = $idlFileToInterfaceName{$idlFile}; - - my @dependencies = map { basename($_) } @{$supplementals{$idlFile}}; - - print MAKE_FH "JS${basename}.h: @{dependencies}\n"; - print MAKE_FH "DOM${basename}.h: @{dependencies}\n"; - print MAKE_FH "WebDOM${basename}.h: @{dependencies}\n"; - foreach my $dependency (@dependencies) { - print MAKE_FH "${dependency}:\n"; - } - } - - close MAKE_FH; -} - - -sub loadIDLAttributes -{ - my $idlAttributesFile = shift; - - my %idlAttributes; - open FH, "<", $idlAttributesFile or die "Couldn't open $idlAttributesFile: $!"; - while (my $line = <FH>) { - chomp $line; - next if $line =~ /^\s*#/; - next if $line =~ /^\s*$/; - - if ($line =~ /^\s*([^=\s]*)\s*=?\s*(.*)/) { - my $name = $1; - $idlAttributes{$name} = {}; - if ($2) { - foreach my $rightValue (split /\|/, $2) { - $rightValue =~ s/^\s*|\s*$//g; - $rightValue = "VALUE_IS_MISSING" unless $rightValue; - $idlAttributes{$name}{$rightValue} = 1; - } - } else { - $idlAttributes{$name}{"VALUE_IS_MISSING"} = 1; - } - } else { - die "The format of " . basename($idlAttributesFile) . " is wrong: line $.\n"; - } - } - close FH; - - return \%idlAttributes; -} - -sub checkIDLAttributes -{ - my $idlAttributes = shift; - my $document = shift; - my $idlFile = shift; - - foreach my $interface (@{$document->interfaces}) { - checkIfIDLAttributesExists($idlAttributes, $interface->extendedAttributes, $idlFile); - - foreach my $attribute (@{$interface->attributes}) { - checkIfIDLAttributesExists($idlAttributes, $attribute->signature->extendedAttributes, $idlFile); - } - - foreach my $function (@{$interface->functions}) { - checkIfIDLAttributesExists($idlAttributes, $function->signature->extendedAttributes, $idlFile); - foreach my $parameter (@{$function->parameters}) { - checkIfIDLAttributesExists($idlAttributes, $parameter->extendedAttributes, $idlFile); - } - } - } -} - -sub checkIfIDLAttributesExists -{ - my $idlAttributes = shift; - my $extendedAttributes = shift; - my $idlFile = shift; - - my $error; - OUTER: for my $name (keys %$extendedAttributes) { - if (!exists $idlAttributes->{$name}) { - $error = "Unknown IDL attribute [$name] is found at $idlFile."; - last OUTER; - } - if ($idlAttributes->{$name}{"*"}) { - next; - } - for my $rightValue (split /\s*\|\s*/, $extendedAttributes->{$name}) { - if (!exists $idlAttributes->{$name}{$rightValue}) { - $error = "Unknown IDL attribute [$name=" . $extendedAttributes->{$name} . "] is found at $idlFile."; - last OUTER; - } - } - } - if ($error) { - die "IDL ATTRIBUTE CHECKER ERROR: $error -If you want to add a new IDL attribute, you need to add it to WebCore/bindings/scripts/IDLAttributes.txt and add explanations to the WebKit IDL document (https://trac.webkit.org/wiki/WebKitIDL). -"; - } -} diff --git a/contrib/dom/webkit/dom/Attr.idl b/contrib/dom/webkit/dom/Attr.idl deleted file mode 100644 index bd3b50f..0000000 --- a/contrib/dom/webkit/dom/Attr.idl +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - JSCustomMarkFunction, - JSGenerateToNativeObject -] interface Attr : Node { - - // DOM Level 1 - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString name; - - readonly attribute boolean specified; - - [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString value - setter raises(DOMException); - - // DOM Level 2 - - readonly attribute Element ownerElement; - - // DOM Level 3 - - readonly attribute boolean isId; - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - // This extension is no longer needed, but it has to remain available in Objective C, as it's public API. - readonly attribute CSSStyleDeclaration style; -#endif -}; - diff --git a/contrib/dom/webkit/dom/BeforeLoadEvent.idl b/contrib/dom/webkit/dom/BeforeLoadEvent.idl deleted file mode 100644 index 54b8501..0000000 --- a/contrib/dom/webkit/dom/BeforeLoadEvent.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -[ - ConstructorTemplate=Event -] interface BeforeLoadEvent : Event { - [InitializedByEventConstructor] readonly attribute DOMString url; -}; - diff --git a/contrib/dom/webkit/dom/CDATASection.idl b/contrib/dom/webkit/dom/CDATASection.idl deleted file mode 100644 index 939fe27..0000000 --- a/contrib/dom/webkit/dom/CDATASection.idl +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface CDATASection : Text { -}; - diff --git a/contrib/dom/webkit/dom/CharacterData.idl b/contrib/dom/webkit/dom/CharacterData.idl deleted file mode 100644 index bd6265b..0000000 --- a/contrib/dom/webkit/dom/CharacterData.idl +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface CharacterData : Node { - - [TreatNullAs=NullString] attribute DOMString data - setter raises(DOMException); - - readonly attribute unsigned long length; - - [TreatReturnedNullStringAs=Null, ObjCLegacyUnnamedParameters] DOMString substringData(in [IsIndex,Optional=DefaultIsUndefined] unsigned long offset, - in [IsIndex,Optional=DefaultIsUndefined] unsigned long length) - raises(DOMException); - - void appendData(in [Optional=DefaultIsUndefined] DOMString data) - raises(DOMException); - - [ObjCLegacyUnnamedParameters] void insertData(in [IsIndex,Optional=DefaultIsUndefined] unsigned long offset, - in [Optional=DefaultIsUndefined] DOMString data) - raises(DOMException); - - [ObjCLegacyUnnamedParameters] void deleteData(in [IsIndex,Optional=DefaultIsUndefined] unsigned long offset, - in [IsIndex,Optional=DefaultIsUndefined] unsigned long length) - raises(DOMException); - - [ObjCLegacyUnnamedParameters] void replaceData(in [IsIndex,Optional=DefaultIsUndefined] unsigned long offset, - in [IsIndex,Optional=DefaultIsUndefined] unsigned long length, - in [Optional=DefaultIsUndefined] DOMString data) - raises(DOMException); - - // DOM 4 - void remove() - raises(DOMException); -}; - diff --git a/contrib/dom/webkit/dom/ClientRect.idl b/contrib/dom/webkit/dom/ClientRect.idl deleted file mode 100644 index ab5d170..0000000 --- a/contrib/dom/webkit/dom/ClientRect.idl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -interface ClientRect { - readonly attribute float top; - readonly attribute float right; - readonly attribute float bottom; - readonly attribute float left; - readonly attribute float width; - readonly attribute float height; -}; - diff --git a/contrib/dom/webkit/dom/ClientRectList.idl b/contrib/dom/webkit/dom/ClientRectList.idl deleted file mode 100644 index 93513a4..0000000 --- a/contrib/dom/webkit/dom/ClientRectList.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -[ - IndexedGetter -] interface ClientRectList { - readonly attribute unsigned long length; - ClientRect item(in [IsIndex,Optional=DefaultIsUndefined] unsigned long index); - // FIXME: Fix list behavior to allow custom exceptions to be thrown. -}; - diff --git a/contrib/dom/webkit/dom/Clipboard.idl b/contrib/dom/webkit/dom/Clipboard.idl deleted file mode 100644 index 43f3aaa..0000000 --- a/contrib/dom/webkit/dom/Clipboard.idl +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -interface Clipboard { - [TreatReturnedNullStringAs=Undefined] attribute DOMString dropEffect; - [TreatReturnedNullStringAs=Undefined] attribute DOMString effectAllowed; - [CustomGetter] readonly attribute Array types; - readonly attribute FileList files; - - [Custom] void clearData(in [Optional] DOMString type) - raises(DOMException); - DOMString getData(in DOMString type); - boolean setData(in DOMString type, in DOMString data); - [Custom] void setDragImage(in HTMLImageElement image, in long x, in long y) - raises(DOMException); - - [Conditional=DATA_TRANSFER_ITEMS, V8EnabledAtRuntime=DataTransferItems] readonly attribute DataTransferItemList items; -}; - diff --git a/contrib/dom/webkit/dom/Comment.idl b/contrib/dom/webkit/dom/Comment.idl deleted file mode 100644 index 5c07e2f..0000000 --- a/contrib/dom/webkit/dom/Comment.idl +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface Comment : CharacterData { -}; - diff --git a/contrib/dom/webkit/dom/CompositionEvent.idl b/contrib/dom/webkit/dom/CompositionEvent.idl deleted file mode 100644 index 9f12133..0000000 --- a/contrib/dom/webkit/dom/CompositionEvent.idl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Introduced in DOM Level 3: -interface CompositionEvent : UIEvent { - - readonly attribute DOMString data; - - void initCompositionEvent(in [Optional=DefaultIsUndefined] DOMString typeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg, - in [Optional=DefaultIsUndefined] DOMWindow viewArg, - in [Optional=DefaultIsUndefined] DOMString dataArg); - -}; - diff --git a/contrib/dom/webkit/dom/CustomEvent.idl b/contrib/dom/webkit/dom/CustomEvent.idl deleted file mode 100644 index 474f3c5..0000000 --- a/contrib/dom/webkit/dom/CustomEvent.idl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP -// Introduced in DOM Level 3: -[ - ConstructorTemplate=Event -] interface CustomEvent : Event { - [InitializedByEventConstructor, V8Custom] readonly attribute DOMObject detail; - - void initCustomEvent(in [Optional=DefaultIsUndefined] DOMString typeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg, - in [Optional=DefaultIsUndefined] DOMObject detailArg); -}; -#endif - diff --git a/contrib/dom/webkit/dom/DOMCoreException.idl b/contrib/dom/webkit/dom/DOMCoreException.idl deleted file mode 100644 index 419202c..0000000 --- a/contrib/dom/webkit/dom/DOMCoreException.idl +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - JSNoStaticTables, - DoNotCheckConstants, - InterfaceName=DOMException -] exception DOMCoreException { - - readonly attribute unsigned short code; - readonly attribute DOMString name; - readonly attribute DOMString message; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - // Override in a Mozilla compatible format - [NotEnumerable] DOMString toString(); -#endif - - // ExceptionCode - const unsigned short INDEX_SIZE_ERR = 1; - const unsigned short DOMSTRING_SIZE_ERR = 2; - const unsigned short HIERARCHY_REQUEST_ERR = 3; - const unsigned short WRONG_DOCUMENT_ERR = 4; - const unsigned short INVALID_CHARACTER_ERR = 5; - const unsigned short NO_DATA_ALLOWED_ERR = 6; - const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; - const unsigned short NOT_FOUND_ERR = 8; - const unsigned short NOT_SUPPORTED_ERR = 9; - const unsigned short INUSE_ATTRIBUTE_ERR = 10; - // Introduced in DOM Level 2: - const unsigned short INVALID_STATE_ERR = 11; - // Introduced in DOM Level 2: - const unsigned short SYNTAX_ERR = 12; - // Introduced in DOM Level 2: - const unsigned short INVALID_MODIFICATION_ERR = 13; - // Introduced in DOM Level 2: - const unsigned short NAMESPACE_ERR = 14; - // Introduced in DOM Level 2: - const unsigned short INVALID_ACCESS_ERR = 15; - // Introduced in DOM Level 3: - const unsigned short VALIDATION_ERR = 16; - // Introduced in DOM Level 3: - const unsigned short TYPE_MISMATCH_ERR = 17; - // Introduced as an XHR extension: - const unsigned short SECURITY_ERR = 18; - // Introduced in HTML5: - const unsigned short NETWORK_ERR = 19; - const unsigned short ABORT_ERR = 20; - const unsigned short URL_MISMATCH_ERR = 21; - const unsigned short QUOTA_EXCEEDED_ERR = 22; - // TIMEOUT_ERR is currently unused but was added for completeness. - const unsigned short TIMEOUT_ERR = 23; - // INVALID_NODE_TYPE_ERR is currently unused but was added for completeness. - const unsigned short INVALID_NODE_TYPE_ERR = 24; - const unsigned short DATA_CLONE_ERR = 25; -}; - diff --git a/contrib/dom/webkit/dom/DOMError.idl b/contrib/dom/webkit/dom/DOMError.idl deleted file mode 100644 index 7014e84..0000000 --- a/contrib/dom/webkit/dom/DOMError.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - interface [ -] DOMError { - readonly attribute DOMString name; - }; - diff --git a/contrib/dom/webkit/dom/DOMImplementation.idl b/contrib/dom/webkit/dom/DOMImplementation.idl deleted file mode 100644 index 1b92054..0000000 --- a/contrib/dom/webkit/dom/DOMImplementation.idl +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - GenerateIsReachable=ImplDocument, -] interface DOMImplementation { - - // DOM Level 1 - - [ObjCLegacyUnnamedParameters] boolean hasFeature(in [Optional=DefaultIsUndefined] DOMString feature, - in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString version); - - // DOM Level 2 - - [ObjCLegacyUnnamedParameters] DocumentType createDocumentType(in [TreatNullAs=NullString, TreatUndefinedAs=NullString,Optional=DefaultIsUndefined] DOMString qualifiedName, - in [TreatNullAs=NullString, TreatUndefinedAs=NullString,Optional=DefaultIsUndefined] DOMString publicId, - in [TreatNullAs=NullString, TreatUndefinedAs=NullString,Optional=DefaultIsUndefined] DOMString systemId) - raises(DOMException); - [ObjCLegacyUnnamedParameters] Document createDocument(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString qualifiedName, - in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DocumentType doctype) - raises(DOMException); - - // DOMImplementationCSS interface from DOM Level 2 CSS - - [ObjCLegacyUnnamedParameters] CSSStyleSheet createCSSStyleSheet(in [Optional=DefaultIsUndefined] DOMString title, - in [Optional=DefaultIsUndefined] DOMString media) - raises(DOMException); - - // HTMLDOMImplementation interface from DOM Level 2 HTML - - HTMLDocument createHTMLDocument(in [Optional=DefaultIsNullString] DOMString title); -}; - diff --git a/contrib/dom/webkit/dom/DOMNamedFlowCollection.idl b/contrib/dom/webkit/dom/DOMNamedFlowCollection.idl deleted file mode 100644 index 86757e8..0000000 --- a/contrib/dom/webkit/dom/DOMNamedFlowCollection.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -[ - Conditional=CSS_REGIONS, - V8EnabledAtRuntime=cssRegions, - InterfaceName=WebKitNamedFlowCollection, - JSGenerateToJSObject, - IndexedGetter, - NamedGetter -] interface DOMNamedFlowCollection { - readonly attribute unsigned long length; - WebKitNamedFlow item(in unsigned long index); - WebKitNamedFlow namedItem(in DOMString name); -}; diff --git a/contrib/dom/webkit/dom/DOMStringList.idl b/contrib/dom/webkit/dom/DOMStringList.idl deleted file mode 100644 index aa643e6..0000000 --- a/contrib/dom/webkit/dom/DOMStringList.idl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - IndexedGetter, - JSCustomToNativeObject, - JSNoStaticTables -] interface DOMStringList { - readonly attribute unsigned long length; - [TreatReturnedNullStringAs=Null] DOMString item(in [Optional=DefaultIsUndefined] unsigned long index); - boolean contains(in [Optional=DefaultIsUndefined] DOMString string); -}; - diff --git a/contrib/dom/webkit/dom/DOMStringMap.idl b/contrib/dom/webkit/dom/DOMStringMap.idl deleted file mode 100644 index 732ab1c..0000000 --- a/contrib/dom/webkit/dom/DOMStringMap.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - GenerateIsReachable=ImplElementRoot, - NamedGetter, - CustomDeleteProperty, - CustomEnumerateProperty, - CustomNamedSetter -] interface DOMStringMap { -}; - diff --git a/contrib/dom/webkit/dom/DataTransferItem.idl b/contrib/dom/webkit/dom/DataTransferItem.idl deleted file mode 100644 index a66656e..0000000 --- a/contrib/dom/webkit/dom/DataTransferItem.idl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=DATA_TRANSFER_ITEMS, -] interface DataTransferItem { - readonly attribute DOMString kind; - readonly attribute DOMString type; - - void getAsString(in [Callback,Optional=DefaultIsUndefined] StringCallback callback); - Blob getAsFile(); -}; - diff --git a/contrib/dom/webkit/dom/DataTransferItemList.idl b/contrib/dom/webkit/dom/DataTransferItemList.idl deleted file mode 100644 index 67956a1..0000000 --- a/contrib/dom/webkit/dom/DataTransferItemList.idl +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=DATA_TRANSFER_ITEMS, - IndexedGetter, - JSGenerateToNativeObject, -#if defined(V8_BINDING) && V8_BINDING - CustomDeleteProperty, -#endif -] interface DataTransferItemList { - readonly attribute long length; - DataTransferItem item(in [Optional=DefaultIsUndefined] unsigned long index); - - void clear(); - void add(in File? file); - void add(in [Optional=DefaultIsUndefined] DOMString data, - in [Optional=DefaultIsUndefined] DOMString type) raises(DOMException); -}; - diff --git a/contrib/dom/webkit/dom/DeviceMotionEvent.idl b/contrib/dom/webkit/dom/DeviceMotionEvent.idl deleted file mode 100644 index 7c39c2f..0000000 --- a/contrib/dom/webkit/dom/DeviceMotionEvent.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=DEVICE_ORIENTATION, -] interface DeviceMotionEvent : Event { - [Custom] readonly attribute Acceleration acceleration; - [Custom] readonly attribute Acceleration accelerationIncludingGravity; - [Custom] readonly attribute RotationRate rotationRate; - [Custom] readonly attribute double interval; - [Custom] void initDeviceMotionEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean bubbles, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] Acceleration acceleration, - in [Optional=DefaultIsUndefined] Acceleration accelerationIncludingGravity, - in [Optional=DefaultIsUndefined] RotationRate rotationRate, - in [Optional=DefaultIsUndefined] double interval); -}; - diff --git a/contrib/dom/webkit/dom/DeviceOrientationEvent.idl b/contrib/dom/webkit/dom/DeviceOrientationEvent.idl deleted file mode 100644 index e826503..0000000 --- a/contrib/dom/webkit/dom/DeviceOrientationEvent.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=DEVICE_ORIENTATION, -] interface DeviceOrientationEvent : Event { - [Custom] readonly attribute double alpha; - [Custom] readonly attribute double beta; - [Custom] readonly attribute double gamma; - [Custom] readonly attribute boolean absolute; - [Custom] void initDeviceOrientationEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean bubbles, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] double alpha, - in [Optional=DefaultIsUndefined] double beta, - in [Optional=DefaultIsUndefined] double gamma, - in [Optional=DefaultIsUndefined] boolean absolute); -}; - diff --git a/contrib/dom/webkit/dom/Document.idl b/contrib/dom/webkit/dom/Document.idl deleted file mode 100644 index b706496..0000000 --- a/contrib/dom/webkit/dom/Document.idl +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved. - * Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - CustomToJSObject, - JSGenerateToNativeObject, - JSInlineGetOwnPropertySlot -] interface Document : Node { - - // DOM Level 1 Core - readonly attribute DocumentType doctype; - readonly attribute DOMImplementation implementation; - readonly attribute Element documentElement; - - [ReturnNewObject] Element createElement(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString tagName) - raises (DOMException); - DocumentFragment createDocumentFragment(); - [ReturnNewObject] Text createTextNode(in [Optional=DefaultIsUndefined] DOMString data); - [ReturnNewObject] Comment createComment(in [Optional=DefaultIsUndefined] DOMString data); - [ReturnNewObject] CDATASection createCDATASection(in [Optional=DefaultIsUndefined] DOMString data) - raises(DOMException); - [ObjCLegacyUnnamedParameters, ReturnNewObject] ProcessingInstruction createProcessingInstruction(in [Optional=DefaultIsUndefined] DOMString target, - in [Optional=DefaultIsUndefined] DOMString data) - raises (DOMException); - [ReturnNewObject] Attr createAttribute(in [Optional=DefaultIsUndefined] DOMString name) - raises (DOMException); - [ReturnNewObject] EntityReference createEntityReference(in [Optional=DefaultIsUndefined] DOMString name) - raises(DOMException); - NodeList getElementsByTagName(in [Optional=DefaultIsUndefined] DOMString tagname); - - // Introduced in DOM Level 2: - - [ObjCLegacyUnnamedParameters, ReturnNewObject] Node importNode(in [Optional=DefaultIsUndefined] Node importedNode, - in [Optional] boolean deep) - raises (DOMException); - [ObjCLegacyUnnamedParameters, ReturnNewObject] Element createElementNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString qualifiedName) - raises (DOMException); - [ObjCLegacyUnnamedParameters, ReturnNewObject] Attr createAttributeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString qualifiedName) - raises (DOMException); - [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName); - Element getElementById(in [Optional=DefaultIsUndefined] DOMString elementId); - - // DOM Level 3 Core - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString inputEncoding; - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString xmlEncoding; - [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString xmlVersion - setter raises (DOMException); - attribute boolean xmlStandalone - setter raises (DOMException); - - Node adoptNode(in [Optional=DefaultIsUndefined] Node source) - raises (DOMException); - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT - // document.documentURI was writable in DOM3 Core, but is read-only in DOM4 - // (see http://www.w3.org/TR/2011/WD-dom-20110915/#document). We need to keep - // the writable version around for Objective C clients, but are moving to - // read-only for other clients. - [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString documentURI; -#else - [TreatReturnedNullStringAs=Null] readonly attribute DOMString documentURI; -#endif - - // DOM Level 2 Events (DocumentEvents interface) - - Event createEvent(in [Optional=DefaultIsUndefined] DOMString eventType) - raises(DOMException); - - // DOM Level 2 Tranversal and Range (DocumentRange interface) - - Range createRange(); - - // DOM Level 2 Tranversal and Range (DocumentTraversal interface) - - [ObjCLegacyUnnamedParameters] NodeIterator createNodeIterator(in [Optional=DefaultIsUndefined] Node root, - in [Optional=DefaultIsUndefined] unsigned long whatToShow, - in [Optional=DefaultIsUndefined] NodeFilter filter, - in [Optional=DefaultIsUndefined] boolean expandEntityReferences) - raises(DOMException); - [ObjCLegacyUnnamedParameters] TreeWalker createTreeWalker(in [Optional=DefaultIsUndefined] Node root, - in [Optional=DefaultIsUndefined] unsigned long whatToShow, - in [Optional=DefaultIsUndefined] NodeFilter filter, - in [Optional=DefaultIsUndefined] boolean expandEntityReferences) - raises(DOMException); - - // DOM Level 2 Abstract Views (DocumentView interface) - - readonly attribute DOMWindow defaultView; - - // DOM Level 2 Style (DocumentStyle interface) - - readonly attribute StyleSheetList styleSheets; - - // DOM Level 2 Style (DocumentCSS interface) - - [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle(in [Optional=DefaultIsUndefined] Element element, - in [Optional=DefaultIsUndefined] DOMString pseudoElement); - - // DOM Level 3 XPath (XPathEvaluator interface) - [ObjCLegacyUnnamedParameters] XPathExpression createExpression(in [Optional=DefaultIsUndefined] DOMString expression, - in [Optional=DefaultIsUndefined] XPathNSResolver resolver) - raises(DOMException); - XPathNSResolver createNSResolver(in Node nodeResolver); - [ObjCLegacyUnnamedParameters, V8Custom] XPathResult evaluate(in [Optional=DefaultIsUndefined] DOMString expression, - in [Optional=DefaultIsUndefined] Node contextNode, - in [Optional=DefaultIsUndefined] XPathNSResolver resolver, - in [Optional=DefaultIsUndefined] unsigned short type, - in [Optional=DefaultIsUndefined] XPathResult inResult) - raises(DOMException); - - // Common extensions - - boolean execCommand(in [Optional=DefaultIsUndefined] DOMString command, - in [Optional=DefaultIsUndefined] boolean userInterface, - in [TreatNullAs=NullString, TreatUndefinedAs=NullString,Optional=DefaultIsUndefined] DOMString value); - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - // FIXME: remove the these two versions once [Optional] is implemented for Objective-C. - boolean execCommand(in DOMString command, - in boolean userInterface); - boolean execCommand(in DOMString command); -#endif - - boolean queryCommandEnabled(in [Optional=DefaultIsUndefined] DOMString command); - boolean queryCommandIndeterm(in [Optional=DefaultIsUndefined] DOMString command); - boolean queryCommandState(in [Optional=DefaultIsUndefined] DOMString command); - boolean queryCommandSupported(in [Optional=DefaultIsUndefined] DOMString command); - DOMString queryCommandValue(in [Optional=DefaultIsUndefined] DOMString command); - - // Moved down from HTMLDocument - - [TreatNullAs=NullString] attribute DOMString title; - readonly attribute DOMString referrer; -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - [TreatNullAs=NullString] attribute DOMString domain - setter raises (DOMException); -#else - readonly attribute DOMString domain; -#endif - readonly attribute DOMString URL; - - [TreatNullAs=NullString] attribute DOMString cookie - setter raises (DOMException), - getter raises (DOMException); - - attribute HTMLElement body - setter raises (DOMException); - - readonly attribute HTMLHeadElement head; - readonly attribute HTMLCollection images; - readonly attribute HTMLCollection applets; - readonly attribute HTMLCollection links; - readonly attribute HTMLCollection forms; - readonly attribute HTMLCollection anchors; - readonly attribute DOMString lastModified; - - NodeList getElementsByName(in [Optional=DefaultIsUndefined] DOMString elementName); - -#if defined(ENABLE_MICRODATA) && ENABLE_MICRODATA - NodeList getItems(in [TreatNullAs=NullString, TreatUndefinedAs=NullString, Optional=DefaultIsUndefined] DOMString typeNames); -#endif - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - [Custom] attribute Location location; -#endif - - // IE extensions - - [TreatReturnedNullStringAs=Undefined, TreatNullAs=NullString] attribute DOMString charset; - [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString defaultCharset; - [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString readyState; - - Element elementFromPoint(in [Optional=DefaultIsUndefined] long x, - in [Optional=DefaultIsUndefined] long y); - Range caretRangeFromPoint(in [Optional=DefaultIsUndefined] long x, - in [Optional=DefaultIsUndefined] long y); - - // Mozilla extensions -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - DOMSelection getSelection(); -#endif - [TreatReturnedNullStringAs=Null] readonly attribute DOMString characterSet; - - // WebKit extensions - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString preferredStylesheetSet; - [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString selectedStylesheetSet; - -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - CSSStyleDeclaration createCSSStyleDeclaration(); -#endif - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - // DOM Level 2 Style Interface - [ObjCLegacyUnnamedParameters, ObjCUseDefaultView] CSSStyleDeclaration getComputedStyle(in Element element, - in DOMString pseudoElement); - - // WebKit extension - // FIXME: remove the first version once [Optional] is implemented for Objective-C. - [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(in Element element, - in DOMString pseudoElement); - [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(in Element element, - in DOMString pseudoElement, - in [Optional] boolean authorOnly); - -#endif - -#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP -#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C - CanvasRenderingContext getCSSCanvasContext(in DOMString contextId, in DOMString name, in long width, in long height); -#endif -#endif - - // HTML 5 - NodeList getElementsByClassName(in [Optional=DefaultIsUndefined] DOMString tagname); - - readonly attribute DOMString compatMode; - - // NodeSelector - Selector API - Element querySelector(in DOMString selectors) - raises(DOMException); - NodeList querySelectorAll(in DOMString selectors) - raises(DOMException); - -#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API - // Mozilla version - [V8EnabledAtRuntime] readonly attribute boolean webkitIsFullScreen; - [V8EnabledAtRuntime] readonly attribute boolean webkitFullScreenKeyboardInputAllowed; - [V8EnabledAtRuntime] readonly attribute Element webkitCurrentFullScreenElement; - [V8EnabledAtRuntime] void webkitCancelFullScreen(); - - // W3C version - [V8EnabledAtRuntime] readonly attribute boolean webkitFullscreenEnabled; - [V8EnabledAtRuntime] readonly attribute Element webkitFullscreenElement; - [V8EnabledAtRuntime] void webkitExitFullscreen(); -#endif - - [Conditional=POINTER_LOCK] void webkitExitPointerLock(); - [Conditional=POINTER_LOCK] readonly attribute Element webkitPointerLockElement; - - [Conditional=CSS_REGIONS, V8EnabledAtRuntime=cssRegions] DOMNamedFlowCollection webkitGetNamedFlows(); - -#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C - // Event handler DOM attributes - [NotEnumerable] attribute EventListener onabort; - [NotEnumerable] attribute EventListener onblur; - [NotEnumerable] attribute EventListener onchange; - [NotEnumerable] attribute EventListener onclick; - [NotEnumerable] attribute EventListener oncontextmenu; - [NotEnumerable] attribute EventListener ondblclick; - [NotEnumerable] attribute EventListener ondrag; - [NotEnumerable] attribute EventListener ondragend; - [NotEnumerable] attribute EventListener ondragenter; - [NotEnumerable] attribute EventListener ondragleave; - [NotEnumerable] attribute EventListener ondragover; - [NotEnumerable] attribute EventListener ondragstart; - [NotEnumerable] attribute EventListener ondrop; - [NotEnumerable] attribute EventListener onerror; - [NotEnumerable] attribute EventListener onfocus; - [NotEnumerable] attribute EventListener oninput; - [NotEnumerable] attribute EventListener oninvalid; - [NotEnumerable] attribute EventListener onkeydown; - [NotEnumerable] attribute EventListener onkeypress; - [NotEnumerable] attribute EventListener onkeyup; - [NotEnumerable] attribute EventListener onload; - [NotEnumerable] attribute EventListener onmousedown; - [NotEnumerable] attribute EventListener onmousemove; - [NotEnumerable] attribute EventListener onmouseout; - [NotEnumerable] attribute EventListener onmouseover; - [NotEnumerable] attribute EventListener onmouseup; - [NotEnumerable] attribute EventListener onmousewheel; - [NotEnumerable] attribute EventListener onreadystatechange; - [NotEnumerable] attribute EventListener onscroll; - [NotEnumerable] attribute EventListener onselect; - [NotEnumerable] attribute EventListener onsubmit; - - // attribute [NotEnumerable] EventListener oncanplay; - // attribute [NotEnumerable] EventListener oncanplaythrough; - // attribute [NotEnumerable] EventListener ondurationchange; - // attribute [NotEnumerable] EventListener onemptied; - // attribute [NotEnumerable] EventListener onended; - // attribute [NotEnumerable] EventListener onloadeddata; - // attribute [NotEnumerable] EventListener onloadedmetadata; - // attribute [NotEnumerable] EventListener onloadstart; - // attribute [NotEnumerable] EventListener onpause; - // attribute [NotEnumerable] EventListener onplay; - // attribute [NotEnumerable] EventListener onplaying; - // attribute [NotEnumerable] EventListener onprogress; - // attribute [NotEnumerable] EventListener onratechange; - // attribute [NotEnumerable] EventListener onseeked; - // attribute [NotEnumerable] EventListener onseeking; - // attribute [NotEnumerable] EventListener onshow; - // attribute [NotEnumerable] EventListener onstalled; - // attribute [NotEnumerable] EventListener onsuspend; - // attribute [NotEnumerable] EventListener ontimeupdate; - // attribute [NotEnumerable] EventListener onvolumechange; - // attribute [NotEnumerable] EventListener onwaiting; - - // WebKit extensions - [NotEnumerable] attribute EventListener onbeforecut; - [NotEnumerable] attribute EventListener oncut; - [NotEnumerable] attribute EventListener onbeforecopy; - [NotEnumerable] attribute EventListener oncopy; - [NotEnumerable] attribute EventListener onbeforepaste; - [NotEnumerable] attribute EventListener onpaste; - [NotEnumerable] attribute EventListener onreset; - [NotEnumerable] attribute EventListener onsearch; - [NotEnumerable] attribute EventListener onselectstart; - [NotEnumerable] attribute EventListener onselectionchange; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchstart; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchmove; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchend; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchcancel; - [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenchange; - [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenerror; - [NotEnumerable, Conditional=POINTER_LOCK] attribute EventListener onwebkitpointerlockchange; - [NotEnumerable, Conditional=POINTER_LOCK] attribute EventListener onwebkitpointerlockerror; -#endif - -#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS - [ReturnNewObject, V8EnabledAtRuntime] Touch createTouch(in [Optional=DefaultIsUndefined] DOMWindow window, - in [Optional=DefaultIsUndefined] EventTarget target, - in [Optional=DefaultIsUndefined] long identifier, - in [Optional=DefaultIsUndefined] long pageX, - in [Optional=DefaultIsUndefined] long pageY, - in [Optional=DefaultIsUndefined] long screenX, - in [Optional=DefaultIsUndefined] long screenY, - in [Optional=DefaultIsUndefined] long webkitRadiusX, - in [Optional=DefaultIsUndefined] long webkitRadiusY, - in [Optional=DefaultIsUndefined] float webkitRotationAngle, - in [Optional=DefaultIsUndefined] float webkitForce) - raises (DOMException); - [ReturnNewObject, V8EnabledAtRuntime, Custom] TouchList createTouchList() - raises (DOMException); -#endif - -#if defined(LANGUAGE_CPP) && LANGUAGE_CPP - // Extra WebCore methods exposed to allow compile-time casting in C++ - boolean isHTMLDocument(); -#endif - - // Page visibility API. - [Conditional=PAGE_VISIBILITY_API] readonly attribute DOMString webkitVisibilityState; - [Conditional=PAGE_VISIBILITY_API] readonly attribute boolean webkitHidden; - - // Security Policy API: http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#script-interfaces - [Conditional=CSP_NEXT, V8EnabledAtRuntime=experimentalContentSecurityPolicyFeatures] readonly attribute DOMSecurityPolicy securityPolicy; - -}; - diff --git a/contrib/dom/webkit/dom/DocumentFragment.idl b/contrib/dom/webkit/dom/DocumentFragment.idl deleted file mode 100644 index bcf035c..0000000 --- a/contrib/dom/webkit/dom/DocumentFragment.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface DocumentFragment : Node { - // NodeSelector - Selector API - Element querySelector(in DOMString selectors) - raises(DOMException); - NodeList querySelectorAll(in DOMString selectors) - raises(DOMException); -}; - diff --git a/contrib/dom/webkit/dom/DocumentType.idl b/contrib/dom/webkit/dom/DocumentType.idl deleted file mode 100644 index 0dbcdb8..0000000 --- a/contrib/dom/webkit/dom/DocumentType.idl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - JSGenerateToNativeObject -] interface DocumentType : Node { - - // DOM Level 1 - - readonly attribute DOMString name; - readonly attribute NamedNodeMap entities; - readonly attribute NamedNodeMap notations; - - // DOM Level 2 - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString publicId; - [TreatReturnedNullStringAs=Null] readonly attribute DOMString systemId; - [TreatReturnedNullStringAs=Null] readonly attribute DOMString internalSubset; - - // DOM 4 - void remove() - raises(DOMException); -}; - diff --git a/contrib/dom/webkit/dom/Element.idl b/contrib/dom/webkit/dom/Element.idl deleted file mode 100644 index 93a66fb..0000000 --- a/contrib/dom/webkit/dom/Element.idl +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - JSGenerateToNativeObject, - JSInlineGetOwnPropertySlot, - V8CustomToJSObject -] interface Element : Node { - - // DOM Level 1 Core - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString tagName; - - [TreatReturnedNullStringAs=Null] DOMString getAttribute(in [Optional=DefaultIsUndefined] DOMString name); - [ObjCLegacyUnnamedParameters] void setAttribute(in [Optional=DefaultIsUndefined] DOMString name, - in [Optional=DefaultIsUndefined] DOMString value) - raises(DOMException); - void removeAttribute(in [Optional=DefaultIsUndefined] DOMString name); - Attr getAttributeNode(in [Optional=DefaultIsUndefined] DOMString name); - Attr setAttributeNode(in [Optional=DefaultIsUndefined] Attr newAttr) - raises(DOMException); - Attr removeAttributeNode(in [Optional=DefaultIsUndefined] Attr oldAttr) - raises(DOMException); - NodeList getElementsByTagName(in [Optional=DefaultIsUndefined] DOMString name); - - // DOM Level 2 Core - - [ObjCLegacyUnnamedParameters] DOMString getAttributeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName); - [ObjCLegacyUnnamedParameters] void setAttributeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString qualifiedName, - in [Optional=DefaultIsUndefined] DOMString value) - raises(DOMException); - [ObjCLegacyUnnamedParameters] void removeAttributeNS(in [TreatNullAs=NullString] DOMString namespaceURI, - in DOMString localName); - [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName); - [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName); - Attr setAttributeNodeNS(in [Optional=DefaultIsUndefined] Attr newAttr) - raises(DOMException); - boolean hasAttribute(in DOMString name); - [ObjCLegacyUnnamedParameters] boolean hasAttributeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName); - - readonly attribute CSSStyleDeclaration style; - - // Common extensions - - readonly attribute long offsetLeft; - readonly attribute long offsetTop; - readonly attribute long offsetWidth; - readonly attribute long offsetHeight; - readonly attribute Element offsetParent; - readonly attribute long clientLeft; - readonly attribute long clientTop; - readonly attribute long clientWidth; - readonly attribute long clientHeight; - attribute long scrollLeft; - attribute long scrollTop; - readonly attribute long scrollWidth; - readonly attribute long scrollHeight; - - void focus(); - void blur(); - void scrollIntoView(in [Optional] boolean alignWithTop); - - // WebKit extensions - - void scrollIntoViewIfNeeded(in [Optional] boolean centerIfNeeded); - void scrollByLines(in [Optional=DefaultIsUndefined] long lines); - void scrollByPages(in [Optional=DefaultIsUndefined] long pages); - - // HTML 5 - NodeList getElementsByClassName(in [Optional=DefaultIsUndefined] DOMString name); - - [Reflect=class] attribute DOMString className; - readonly attribute DOMTokenList classList; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - readonly attribute DOMStringMap dataset; -#endif - - // NodeSelector - Selector API - Element querySelector(in DOMString selectors) - raises(DOMException); - NodeList querySelectorAll(in DOMString selectors) - raises(DOMException); - - // WebKit extension, pending specification. - boolean webkitMatchesSelector(in [Optional=DefaultIsUndefined] DOMString selectors) - raises(DOMException); - - // ElementTraversal API - readonly attribute Element firstElementChild; - readonly attribute Element lastElementChild; - readonly attribute Element previousElementSibling; - readonly attribute Element nextElementSibling; - readonly attribute unsigned long childElementCount; - - // ShadowAware API -#if defined(ENABLE_SHADOW_DOM) && ENABLE_SHADOW_DOM - [Reflect=pseudo, V8EnabledAtRuntime=shadowDOM, ImplementedAs=pseudo] attribute DOMString webkitPseudo; - [V8EnabledAtRuntime=shadowDOM, ImplementedAs=createShadowRoot] ShadowRoot webkitCreateShadowRoot() raises(DOMException); - [V8EnabledAtRuntime=shadowDOM, ImplementedAs=shadowRoot] readonly attribute ShadowRoot webkitShadowRoot; -#endif - - // DOM 4 - void remove() - raises(DOMException); - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - // CSSOM View Module API - ClientRectList getClientRects(); - ClientRect getBoundingClientRect(); -#endif - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - // Objective-C extensions - readonly attribute DOMString innerText; -#endif - -#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API - // Mozilla version - const unsigned short ALLOW_KEYBOARD_INPUT = 1; - [V8EnabledAtRuntime] void webkitRequestFullScreen(in [Optional=DefaultIsUndefined] unsigned short flags); - - // W3C version - [V8EnabledAtRuntime] void webkitRequestFullscreen(); -#endif - - [Conditional=POINTER_LOCK] void webkitRequestPointerLock(); - - // CSS Regions API - [Conditional=CSS_REGIONS, V8EnabledAtRuntime=cssRegions] readonly attribute DOMString webkitRegionOverset; - [Conditional=CSS_REGIONS, V8EnabledAtRuntime=cssRegions] sequence<Range> webkitGetRegionFlowRanges(); - -#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C - // Event handler DOM attributes - [NotEnumerable] attribute EventListener onabort; - [NotEnumerable] attribute EventListener onblur; - [NotEnumerable] attribute EventListener onchange; - [NotEnumerable] attribute EventListener onclick; - [NotEnumerable] attribute EventListener oncontextmenu; - [NotEnumerable] attribute EventListener ondblclick; - [NotEnumerable] attribute EventListener ondrag; - [NotEnumerable] attribute EventListener ondragend; - [NotEnumerable] attribute EventListener ondragenter; - [NotEnumerable] attribute EventListener ondragleave; - [NotEnumerable] attribute EventListener ondragover; - [NotEnumerable] attribute EventListener ondragstart; - [NotEnumerable] attribute EventListener ondrop; - [NotEnumerable] attribute EventListener onerror; - [NotEnumerable] attribute EventListener onfocus; - [NotEnumerable] attribute EventListener oninput; - [NotEnumerable] attribute EventListener oninvalid; - [NotEnumerable] attribute EventListener onkeydown; - [NotEnumerable] attribute EventListener onkeypress; - [NotEnumerable] attribute EventListener onkeyup; - [NotEnumerable] attribute EventListener onload; - [NotEnumerable] attribute EventListener onmousedown; - [NotEnumerable] attribute EventListener onmousemove; - [NotEnumerable] attribute EventListener onmouseout; - [NotEnumerable] attribute EventListener onmouseover; - [NotEnumerable] attribute EventListener onmouseup; - [NotEnumerable] attribute EventListener onmousewheel; - [NotEnumerable] attribute EventListener onscroll; - [NotEnumerable] attribute EventListener onselect; - [NotEnumerable] attribute EventListener onsubmit; - - // attribute [NotEnumerable] EventListener oncanplay; - // attribute [NotEnumerable] EventListener oncanplaythrough; - // attribute [NotEnumerable] EventListener ondurationchange; - // attribute [NotEnumerable] EventListener onemptied; - // attribute [NotEnumerable] EventListener onended; - // attribute [NotEnumerable] EventListener onloadeddata; - // attribute [NotEnumerable] EventListener onloadedmetadata; - // attribute [NotEnumerable] EventListener onloadstart; - // attribute [NotEnumerable] EventListener onpause; - // attribute [NotEnumerable] EventListener onplay; - // attribute [NotEnumerable] EventListener onplaying; - // attribute [NotEnumerable] EventListener onprogress; - // attribute [NotEnumerable] EventListener onratechange; - // attribute [NotEnumerable] EventListener onreadystatechange; - // attribute [NotEnumerable] EventListener onseeked; - // attribute [NotEnumerable] EventListener onseeking; - // attribute [NotEnumerable] EventListener onshow; - // attribute [NotEnumerable] EventListener onstalled; - // attribute [NotEnumerable] EventListener onsuspend; - // attribute [NotEnumerable] EventListener ontimeupdate; - // attribute [NotEnumerable] EventListener onvolumechange; - // attribute [NotEnumerable] EventListener onwaiting; - - // WebKit extensions - [NotEnumerable] attribute EventListener onbeforecut; - [NotEnumerable] attribute EventListener oncut; - [NotEnumerable] attribute EventListener onbeforecopy; - [NotEnumerable] attribute EventListener oncopy; - [NotEnumerable] attribute EventListener onbeforepaste; - [NotEnumerable] attribute EventListener onpaste; - [NotEnumerable] attribute EventListener onreset; - [NotEnumerable] attribute EventListener onsearch; - [NotEnumerable] attribute EventListener onselectstart; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchstart; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchmove; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchend; - [NotEnumerable,Conditional=TOUCH_EVENTS,V8EnabledAtRuntime] attribute EventListener ontouchcancel; - [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenchange; - [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenerror; -#endif -}; - diff --git a/contrib/dom/webkit/dom/Entity.idl b/contrib/dom/webkit/dom/Entity.idl deleted file mode 100644 index f6c2247..0000000 --- a/contrib/dom/webkit/dom/Entity.idl +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface Entity : Node { - [TreatReturnedNullStringAs=Null] readonly attribute DOMString publicId; - [TreatReturnedNullStringAs=Null] readonly attribute DOMString systemId; - [TreatReturnedNullStringAs=Null] readonly attribute DOMString notationName; -}; - diff --git a/contrib/dom/webkit/dom/EntityReference.idl b/contrib/dom/webkit/dom/EntityReference.idl deleted file mode 100644 index 363554a..0000000 --- a/contrib/dom/webkit/dom/EntityReference.idl +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface EntityReference : Node { -}; - diff --git a/contrib/dom/webkit/dom/ErrorEvent.idl b/contrib/dom/webkit/dom/ErrorEvent.idl deleted file mode 100644 index 433e8d9..0000000 --- a/contrib/dom/webkit/dom/ErrorEvent.idl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - JSNoStaticTables, - ConstructorTemplate=Event -] interface ErrorEvent : Event { - [InitializedByEventConstructor] readonly attribute DOMString message; - [InitializedByEventConstructor] readonly attribute DOMString filename; - [InitializedByEventConstructor] readonly attribute unsigned long lineno; -}; - diff --git a/contrib/dom/webkit/dom/Event.idl b/contrib/dom/webkit/dom/Event.idl deleted file mode 100644 index a9af046..0000000 --- a/contrib/dom/webkit/dom/Event.idl +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -[ - CustomToJSObject, - ConstructorTemplate=Event, - JSNoStaticTables, - ObjCPolymorphic -] interface Event { - - // DOM PhaseType - const unsigned short NONE = 0; - const unsigned short CAPTURING_PHASE = 1; - const unsigned short AT_TARGET = 2; - const unsigned short BUBBLING_PHASE = 3; - -#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C - // Reverse-engineered from Netscape - const unsigned short MOUSEDOWN = 1; - const unsigned short MOUSEUP = 2; - const unsigned short MOUSEOVER = 4; - const unsigned short MOUSEOUT = 8; - const unsigned short MOUSEMOVE = 16; - const unsigned short MOUSEDRAG = 32; - const unsigned short CLICK = 64; - const unsigned short DBLCLICK = 128; - const unsigned short KEYDOWN = 256; - const unsigned short KEYUP = 512; - const unsigned short KEYPRESS = 1024; - const unsigned short DRAGDROP = 2048; - const unsigned short FOCUS = 4096; - const unsigned short BLUR = 8192; - const unsigned short SELECT = 16384; - const unsigned short CHANGE = 32768; -#endif - - readonly attribute DOMString type; - readonly attribute EventTarget target; - readonly attribute EventTarget currentTarget; - readonly attribute unsigned short eventPhase; - [InitializedByEventConstructor] readonly attribute boolean bubbles; - [InitializedByEventConstructor] readonly attribute boolean cancelable; - readonly attribute DOMTimeStamp timeStamp; - - void stopPropagation(); - void preventDefault(); - [ObjCLegacyUnnamedParameters] void initEvent(in [Optional=DefaultIsUndefined] DOMString eventTypeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg); - - // DOM Level 3 Additions. - readonly attribute boolean defaultPrevented; - void stopImmediatePropagation(); - - // IE Extensions - readonly attribute EventTarget srcElement; - attribute boolean returnValue; - attribute boolean cancelBubble; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - [Custom] readonly attribute Clipboard clipboardData; -#endif - -#if defined(LANGUAGE_CPP) && LANGUAGE_CPP - // Extra WebCore methods exposed to allow compile-time casting in C++ - boolean isMouseEvent(); - boolean isUIEvent(); -#endif - -}; - diff --git a/contrib/dom/webkit/dom/EventException.idl b/contrib/dom/webkit/dom/EventException.idl deleted file mode 100644 index d9438a1..0000000 --- a/contrib/dom/webkit/dom/EventException.idl +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Introduced in DOM Level 2: -[ - JSNoStaticTables, - DoNotCheckConstants -] exception EventException { - - readonly attribute unsigned short code; - readonly attribute DOMString name; - readonly attribute DOMString message; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - // Override in a Mozilla compatible format - [NotEnumerable] DOMString toString(); -#endif - - // EventExceptionCode - const unsigned short UNSPECIFIED_EVENT_TYPE_ERR = 0; - const unsigned short DISPATCH_REQUEST_ERR = 1; -}; - diff --git a/contrib/dom/webkit/dom/EventListener.idl b/contrib/dom/webkit/dom/EventListener.idl deleted file mode 100644 index 3786408..0000000 --- a/contrib/dom/webkit/dom/EventListener.idl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -[ - JSNoStaticTables, - ObjCProtocol, - CPPPureInterface, - OmitConstructor -] interface EventListener { - void handleEvent(in Event evt); -}; - diff --git a/contrib/dom/webkit/dom/EventTarget.idl b/contrib/dom/webkit/dom/EventTarget.idl deleted file mode 100644 index 02799a8..0000000 --- a/contrib/dom/webkit/dom/EventTarget.idl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -[ - ObjCProtocol, - CPPPureInterface, - OmitConstructor, - CustomToJSObject, - JSCustomToNativeObject, - V8NoWrapperCache -] interface EventTarget { - [ObjCLegacyUnnamedParameters] void addEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - [ObjCLegacyUnnamedParameters] void removeEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - boolean dispatchEvent(in Event event) - raises(EventException); -}; - diff --git a/contrib/dom/webkit/dom/HashChangeEvent.idl b/contrib/dom/webkit/dom/HashChangeEvent.idl deleted file mode 100644 index da8f71b..0000000 --- a/contrib/dom/webkit/dom/HashChangeEvent.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-hashchange -[ - ConstructorTemplate=Event -] interface HashChangeEvent : Event { - void initHashChangeEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean canBubble, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] DOMString oldURL, - in [Optional=DefaultIsUndefined] DOMString newURL); - [InitializedByEventConstructor] readonly attribute DOMString oldURL; - [InitializedByEventConstructor] readonly attribute DOMString newURL; -}; - diff --git a/contrib/dom/webkit/dom/KeyboardEvent.idl b/contrib/dom/webkit/dom/KeyboardEvent.idl deleted file mode 100644 index ff56cee..0000000 --- a/contrib/dom/webkit/dom/KeyboardEvent.idl +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 3: -interface KeyboardEvent : UIEvent { - -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - // KeyLocationCode - const unsigned long KEY_LOCATION_STANDARD = 0x00; - const unsigned long KEY_LOCATION_LEFT = 0x01; - const unsigned long KEY_LOCATION_RIGHT = 0x02; - const unsigned long KEY_LOCATION_NUMPAD = 0x03; -#endif - - readonly attribute DOMString keyIdentifier; - readonly attribute unsigned long keyLocation; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean altKey; - readonly attribute boolean metaKey; - readonly attribute boolean altGraphKey; - -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - boolean getModifierState(in [Optional=DefaultIsUndefined] DOMString keyIdentifierArg); -#endif - - // FIXME: this does not match the version in the DOM spec. - void initKeyboardEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean canBubble, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] DOMString keyIdentifier, - in [Optional=DefaultIsUndefined] unsigned long keyLocation, - in [Optional=DefaultIsUndefined] boolean ctrlKey, - in [Optional=DefaultIsUndefined] boolean altKey, - in [Optional=DefaultIsUndefined] boolean shiftKey, - in [Optional=DefaultIsUndefined] boolean metaKey, - in [Optional=DefaultIsUndefined] boolean altGraphKey); - - // WebKit Extensions -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - readonly attribute long keyCode; - readonly attribute long charCode; - - void initKeyboardEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean canBubble, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] DOMString keyIdentifier, - in [Optional=DefaultIsUndefined] unsigned long keyLocation, - in [Optional=DefaultIsUndefined] boolean ctrlKey, - in [Optional=DefaultIsUndefined] boolean altKey, - in [Optional=DefaultIsUndefined] boolean shiftKey, - in [Optional=DefaultIsUndefined] boolean metaKey); -#endif - -}; - diff --git a/contrib/dom/webkit/dom/MessageChannel.idl b/contrib/dom/webkit/dom/MessageChannel.idl deleted file mode 100644 index 00649f7..0000000 --- a/contrib/dom/webkit/dom/MessageChannel.idl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -[ - Constructor, - CallWith=ScriptExecutionContext, - V8CustomConstructor, - JSCustomMarkFunction, - JSNoStaticTables -] interface MessageChannel { - - readonly attribute MessagePort port1; - readonly attribute MessagePort port2; - -}; - diff --git a/contrib/dom/webkit/dom/MessageEvent.idl b/contrib/dom/webkit/dom/MessageEvent.idl deleted file mode 100644 index 805997c..0000000 --- a/contrib/dom/webkit/dom/MessageEvent.idl +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007 Henry Mason <hmason@mac.com> - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -[ - JSNoStaticTables, - ConstructorTemplate=Event -] interface MessageEvent : Event { - [InitializedByEventConstructor] readonly attribute DOMString origin; - [InitializedByEventConstructor] readonly attribute DOMString lastEventId; - [InitializedByEventConstructor] readonly attribute DOMWindow source; -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - [InitializedByEventConstructor, CachedAttribute, CustomGetter] readonly attribute DOMObject data; - [InitializedByEventConstructor, CustomGetter] readonly attribute Array ports; - - [Custom] void initMessageEvent(in [Optional=DefaultIsUndefined] DOMString typeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg, - in [Optional=DefaultIsUndefined] DOMObject dataArg, - in [Optional=DefaultIsUndefined] DOMString originArg, - in [Optional=DefaultIsUndefined] DOMString lastEventIdArg, - in [Optional=DefaultIsUndefined] DOMWindow sourceArg, - in [Optional=DefaultIsUndefined] Array messagePorts); - - [Custom] void webkitInitMessageEvent(in [Optional=DefaultIsUndefined] DOMString typeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg, - in [Optional=DefaultIsUndefined] DOMObject dataArg, - in [Optional=DefaultIsUndefined] DOMString originArg, - in [Optional=DefaultIsUndefined] DOMString lastEventIdArg, - in [Optional=DefaultIsUndefined] DOMWindow sourceArg, - in [Optional=DefaultIsUndefined] Array transferables); -#else - // Code generator for ObjC bindings does not support custom bindings, thus there is no good way to - // return a variant value. As workaround, expose the data attribute as SerializedScriptValue. - readonly attribute SerializedScriptValue data; - - // There's no good way to expose an array via the ObjC bindings, so for now just expose a single port. - readonly attribute MessagePort messagePort; - - void initMessageEvent(in [Optional=DefaultIsUndefined] DOMString typeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg, - in [Optional=DefaultIsUndefined] SerializedScriptValue dataArg, - in [Optional=DefaultIsUndefined] DOMString originArg, - in [Optional=DefaultIsUndefined] DOMString lastEventIdArg, - in [Optional=DefaultIsUndefined] DOMWindow sourceArg, - in [Optional=DefaultIsUndefined] MessagePort messagePort); -#endif - -}; - diff --git a/contrib/dom/webkit/dom/MessagePort.idl b/contrib/dom/webkit/dom/MessagePort.idl deleted file mode 100644 index bbd48c0..0000000 --- a/contrib/dom/webkit/dom/MessagePort.idl +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2011 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -[ - JSCustomMarkFunction, - JSGenerateIsReachable=Impl, - ActiveDOMObject, - EventTarget, - JSNoStaticTables -] interface MessagePort { -// We need to have something as an ObjC binding, because MessagePort is used in MessageEvent, which already has one, -// but we don't want to actually expose the API while it is in flux. -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - [Custom] void postMessage(in any message, in [Optional] Array messagePorts) - raises(DOMException); - - void start(); - void close(); - - // event handler attributes - attribute EventListener onmessage; - - // EventTarget interface - void addEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - void removeEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - boolean dispatchEvent(in Event evt) - raises(EventException); -#endif -}; - diff --git a/contrib/dom/webkit/dom/MouseEvent.idl b/contrib/dom/webkit/dom/MouseEvent.idl deleted file mode 100644 index c0e2f01..0000000 --- a/contrib/dom/webkit/dom/MouseEvent.idl +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -interface MouseEvent : UIEvent { - readonly attribute long screenX; - readonly attribute long screenY; - readonly attribute long clientX; - readonly attribute long clientY; - [Conditional=POINTER_LOCK] readonly attribute long webkitMovementX; - [Conditional=POINTER_LOCK] readonly attribute long webkitMovementY; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean altKey; - readonly attribute boolean metaKey; - readonly attribute unsigned short button; - readonly attribute EventTarget relatedTarget; - - [ObjCLegacyUnnamedParameters] void initMouseEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean canBubble, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] long detail, - in [Optional=DefaultIsUndefined] long screenX, - in [Optional=DefaultIsUndefined] long screenY, - in [Optional=DefaultIsUndefined] long clientX, - in [Optional=DefaultIsUndefined] long clientY, - in [Optional=DefaultIsUndefined] boolean ctrlKey, - in [Optional=DefaultIsUndefined] boolean altKey, - in [Optional=DefaultIsUndefined] boolean shiftKey, - in [Optional=DefaultIsUndefined] boolean metaKey, - in [Optional=DefaultIsUndefined] unsigned short button, - in [Optional=DefaultIsUndefined] EventTarget relatedTarget); - - // extensions - readonly attribute long offsetX; - readonly attribute long offsetY; - readonly attribute long x; - readonly attribute long y; - readonly attribute Node fromElement; - readonly attribute Node toElement; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - readonly attribute Clipboard dataTransfer; -#endif -}; - diff --git a/contrib/dom/webkit/dom/MutationCallback.idl b/contrib/dom/webkit/dom/MutationCallback.idl deleted file mode 100644 index 9c76e18..0000000 --- a/contrib/dom/webkit/dom/MutationCallback.idl +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=MUTATION_OBSERVERS, - Callback -] interface MutationCallback { - [Custom] boolean handleEvent(in MutationRecordArray mutations, in MutationObserver observer); -}; diff --git a/contrib/dom/webkit/dom/MutationEvent.idl b/contrib/dom/webkit/dom/MutationEvent.idl deleted file mode 100644 index 0550cba..0000000 --- a/contrib/dom/webkit/dom/MutationEvent.idl +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -interface MutationEvent : Event { - - // attrChangeType - const unsigned short MODIFICATION = 1; - const unsigned short ADDITION = 2; - const unsigned short REMOVAL = 3; - - readonly attribute Node relatedNode; - readonly attribute DOMString prevValue; - readonly attribute DOMString newValue; - readonly attribute DOMString attrName; - readonly attribute unsigned short attrChange; - - [ObjCLegacyUnnamedParameters] void initMutationEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean canBubble, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] Node relatedNode, - in [Optional=DefaultIsUndefined] DOMString prevValue, - in [Optional=DefaultIsUndefined] DOMString newValue, - in [Optional=DefaultIsUndefined] DOMString attrName, - in [Optional=DefaultIsUndefined] unsigned short attrChange); - -}; - diff --git a/contrib/dom/webkit/dom/MutationObserver.idl b/contrib/dom/webkit/dom/MutationObserver.idl deleted file mode 100644 index cd400bb..0000000 --- a/contrib/dom/webkit/dom/MutationObserver.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=MUTATION_OBSERVERS, - CustomConstructor, - ConstructorParameters=1, - JSCustomIsReachable -] interface MutationObserver { - void observe(in Node target, in Dictionary options) - raises(DOMException); - sequence<MutationRecord> takeRecords(); - void disconnect(); -}; diff --git a/contrib/dom/webkit/dom/MutationRecord.idl b/contrib/dom/webkit/dom/MutationRecord.idl deleted file mode 100644 index c19618d..0000000 --- a/contrib/dom/webkit/dom/MutationRecord.idl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=MUTATION_OBSERVERS -] interface MutationRecord { - readonly attribute DOMString type; - readonly attribute Node target; - - readonly attribute NodeList addedNodes; - readonly attribute NodeList removedNodes; - readonly attribute Node previousSibling; - readonly attribute Node nextSibling; - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString attributeName; - [TreatReturnedNullStringAs=Null] readonly attribute DOMString attributeNamespace; - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString oldValue; -}; diff --git a/contrib/dom/webkit/dom/NamedNodeMap.idl b/contrib/dom/webkit/dom/NamedNodeMap.idl deleted file mode 100644 index e1791da..0000000 --- a/contrib/dom/webkit/dom/NamedNodeMap.idl +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - GenerateIsReachable=ImplElementRoot, - IndexedGetter, - JSCustomMarkFunction, - NamedGetter -] interface NamedNodeMap { - - Node getNamedItem(in [Optional=DefaultIsUndefined] DOMString name); - - Node setNamedItem(in [Optional=DefaultIsUndefined] Node node) - raises(DOMException); - - Node removeNamedItem(in [Optional=DefaultIsUndefined] DOMString name) - raises(DOMException); - - Node item(in [Optional=DefaultIsUndefined] unsigned long index); - - readonly attribute unsigned long length; - - - // Introduced in DOM Level 2: - - [ObjCLegacyUnnamedParameters] Node getNamedItemNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName) - // FIXME: the implementation does take an exceptioncode parameter. - /*raises(DOMException)*/; - - Node setNamedItemNS(in [Optional=DefaultIsUndefined] Node node) - raises(DOMException); - - [ObjCLegacyUnnamedParameters] Node removeNamedItemNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName) - raises(DOMException); - -}; - diff --git a/contrib/dom/webkit/dom/Node.idl b/contrib/dom/webkit/dom/Node.idl deleted file mode 100644 index 3752641..0000000 --- a/contrib/dom/webkit/dom/Node.idl +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - JSCustomHeader, - JSCustomMarkFunction, - JSCustomPushEventHandlerScope, - JSCustomIsReachable, - JSCustomFinalize, - CustomToJSObject, - EventTarget, - JSGenerateToNativeObject, - JSInlineGetOwnPropertySlot, - ObjCPolymorphic, - V8DependentLifetime -] interface Node -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - : Object, EventTarget -#endif /* defined(LANGUAGE_OBJECTIVE_C) */ - { - // NodeType - const unsigned short ELEMENT_NODE = 1; - const unsigned short ATTRIBUTE_NODE = 2; - const unsigned short TEXT_NODE = 3; - const unsigned short CDATA_SECTION_NODE = 4; - const unsigned short ENTITY_REFERENCE_NODE = 5; - const unsigned short ENTITY_NODE = 6; - const unsigned short PROCESSING_INSTRUCTION_NODE = 7; - const unsigned short COMMENT_NODE = 8; - const unsigned short DOCUMENT_NODE = 9; - const unsigned short DOCUMENT_TYPE_NODE = 10; - const unsigned short DOCUMENT_FRAGMENT_NODE = 11; - const unsigned short NOTATION_NODE = 12; - - readonly attribute [TreatReturnedNullStringAs=Null] DOMString nodeName; - - // FIXME: the spec says this can also raise on retrieval. - attribute [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] DOMString nodeValue - setter raises(DOMException); - - readonly attribute unsigned short nodeType; - readonly attribute Node parentNode; - readonly attribute NodeList childNodes; - readonly attribute Node firstChild; - readonly attribute Node lastChild; - readonly attribute Node previousSibling; - readonly attribute Node nextSibling; - readonly attribute NamedNodeMap attributes; - readonly attribute Document ownerDocument; - - [ObjCLegacyUnnamedParameters, Custom] Node insertBefore(in [CustomReturn] Node newChild, - in Node refChild) - raises(DOMException); - [ObjCLegacyUnnamedParameters, Custom] Node replaceChild(in Node newChild, - in [CustomReturn] Node oldChild) - raises(DOMException); - [Custom] Node removeChild(in [CustomReturn] Node oldChild) - raises(DOMException); - [Custom] Node appendChild(in [CustomReturn] Node newChild) - raises(DOMException); - - boolean hasChildNodes(); - Node cloneNode(in [Optional=DefaultIsUndefined] boolean deep); - void normalize(); - - // Introduced in DOM Level 2: - - [ObjCLegacyUnnamedParameters] boolean isSupported(in [Optional=DefaultIsUndefined] DOMString feature, - in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString version); - - readonly attribute [TreatReturnedNullStringAs=Null] DOMString namespaceURI; - attribute [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] DOMString prefix - setter raises(DOMException); - readonly attribute [TreatReturnedNullStringAs=Null] DOMString localName; - - boolean hasAttributes(); - - // Introduced in DOM Level 3: - - readonly attribute [TreatReturnedNullStringAs=Null] DOMString baseURI; - - // FIXME: the spec says this can also raise on retrieval. - attribute [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] DOMString textContent - setter raises(DOMException); - - boolean isSameNode(in [Optional=DefaultIsUndefined] Node other); - boolean isEqualNode(in [Optional=DefaultIsUndefined] Node other); - [TreatReturnedNullStringAs=Null] DOMString lookupPrefix(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI); - boolean isDefaultNamespace(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI); - [TreatReturnedNullStringAs=Null] DOMString lookupNamespaceURI(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString prefix); - - // DocumentPosition - const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; - const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; - const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; - const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; - const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; - const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; - - unsigned short compareDocumentPosition(in [Optional=DefaultIsUndefined] Node other); - - // Introduced in DOM4 - boolean contains(in [Optional=DefaultIsUndefined] Node other); - - // IE extensions - readonly attribute Element parentElement; - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - // Objective-C extensions - readonly attribute boolean isContentEditable; - - void inspect(); -#endif /* defined(LANGUAGE_OBJECTIVE_C) */ - -#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP -#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C - void addEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - void removeEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - boolean dispatchEvent(in Event event) - raises(EventException); -#endif -#endif - -#if defined(LANGUAGE_CPP) && LANGUAGE_CPP - [Custom] void addEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - [Custom] void removeEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - boolean dispatchEvent(in Event event) - raises(EventException); -#endif - -}; - diff --git a/contrib/dom/webkit/dom/NodeFilter.idl b/contrib/dom/webkit/dom/NodeFilter.idl deleted file mode 100644 index abd5ce4..0000000 --- a/contrib/dom/webkit/dom/NodeFilter.idl +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -[ - JSCustomMarkFunction, - JSCustomToNativeObject, - ObjCProtocol, - CPPPureInterface -] interface NodeFilter { - // Constants returned by acceptNode - const short FILTER_ACCEPT = 1; - const short FILTER_REJECT = 2; - const short FILTER_SKIP = 3; - - // Constants for whatToShow - const unsigned long SHOW_ALL = 0xFFFFFFFF; - const unsigned long SHOW_ELEMENT = 0x00000001; - const unsigned long SHOW_ATTRIBUTE = 0x00000002; - const unsigned long SHOW_TEXT = 0x00000004; - const unsigned long SHOW_CDATA_SECTION = 0x00000008; - const unsigned long SHOW_ENTITY_REFERENCE = 0x00000010; - const unsigned long SHOW_ENTITY = 0x00000020; - const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x00000040; - const unsigned long SHOW_COMMENT = 0x00000080; - const unsigned long SHOW_DOCUMENT = 0x00000100; - const unsigned long SHOW_DOCUMENT_TYPE = 0x00000200; - const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400; - const unsigned long SHOW_NOTATION = 0x00000800; - - [CallWith=ScriptState] short acceptNode(in [Optional=DefaultIsUndefined] Node n); - -}; - diff --git a/contrib/dom/webkit/dom/NodeIterator.idl b/contrib/dom/webkit/dom/NodeIterator.idl deleted file mode 100644 index b360d05..0000000 --- a/contrib/dom/webkit/dom/NodeIterator.idl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -[ - JSCustomMarkFunction -] interface NodeIterator { - readonly attribute Node root; - readonly attribute unsigned long whatToShow; - readonly attribute NodeFilter filter; - readonly attribute boolean expandEntityReferences; - readonly attribute Node referenceNode; - readonly attribute boolean pointerBeforeReferenceNode; - - [CallWith=ScriptState] Node nextNode() - raises (DOMException); - [CallWith=ScriptState] Node previousNode() - raises (DOMException); - void detach(); -}; - diff --git a/contrib/dom/webkit/dom/NodeList.idl b/contrib/dom/webkit/dom/NodeList.idl deleted file mode 100644 index b69ed4d..0000000 --- a/contrib/dom/webkit/dom/NodeList.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - CustomIsReachable, - IndexedGetter, - NamedGetter, - V8DependentLifetime -] interface NodeList { - - Node item(in [IsIndex,Optional=DefaultIsUndefined] unsigned long index); - - readonly attribute unsigned long length; - -}; - diff --git a/contrib/dom/webkit/dom/Notation.idl b/contrib/dom/webkit/dom/Notation.idl deleted file mode 100644 index 4ac628f..0000000 --- a/contrib/dom/webkit/dom/Notation.idl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface Notation : Node { - [TreatReturnedNullStringAs=Null] readonly attribute DOMString publicId; - [TreatReturnedNullStringAs=Null] readonly attribute DOMString systemId; -}; - diff --git a/contrib/dom/webkit/dom/OverflowEvent.idl b/contrib/dom/webkit/dom/OverflowEvent.idl deleted file mode 100644 index cc52f3d..0000000 --- a/contrib/dom/webkit/dom/OverflowEvent.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - ConstructorTemplate=Event -] interface OverflowEvent : Event { - const unsigned short HORIZONTAL = 0; - const unsigned short VERTICAL = 1; - const unsigned short BOTH = 2; - - [InitializedByEventConstructor] readonly attribute unsigned short orient; - [InitializedByEventConstructor] readonly attribute boolean horizontalOverflow; - [InitializedByEventConstructor] readonly attribute boolean verticalOverflow; - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - void initOverflowEvent(in [Optional=DefaultIsUndefined] unsigned short orient, - in [Optional=DefaultIsUndefined] boolean horizontalOverflow, - in [Optional=DefaultIsUndefined] boolean verticalOverflow); -#endif -}; - diff --git a/contrib/dom/webkit/dom/PageTransitionEvent.idl b/contrib/dom/webkit/dom/PageTransitionEvent.idl deleted file mode 100644 index c8cea7f..0000000 --- a/contrib/dom/webkit/dom/PageTransitionEvent.idl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - ConstructorTemplate=Event -] interface PageTransitionEvent : Event { - [InitializedByEventConstructor] readonly attribute boolean persisted; -}; - diff --git a/contrib/dom/webkit/dom/PopStateEvent.idl b/contrib/dom/webkit/dom/PopStateEvent.idl deleted file mode 100644 index 09dc786..0000000 --- a/contrib/dom/webkit/dom/PopStateEvent.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP -[ - ConstructorTemplate=Event -] interface PopStateEvent : Event { - [InitializedByEventConstructor, CachedAttribute, CustomGetter] readonly attribute DOMObject state; -}; -#endif - diff --git a/contrib/dom/webkit/dom/ProcessingInstruction.idl b/contrib/dom/webkit/dom/ProcessingInstruction.idl deleted file mode 100644 index 55599de..0000000 --- a/contrib/dom/webkit/dom/ProcessingInstruction.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface ProcessingInstruction : Node { - - // DOM Level 1 - - [TreatReturnedNullStringAs=Null] readonly attribute DOMString target; - [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString data - setter raises(DOMException); - - // interface LinkStyle from DOM Level 2 Style Sheets - readonly attribute StyleSheet sheet; -}; - diff --git a/contrib/dom/webkit/dom/ProgressEvent.idl b/contrib/dom/webkit/dom/ProgressEvent.idl deleted file mode 100644 index ae25a95..0000000 --- a/contrib/dom/webkit/dom/ProgressEvent.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - ConstructorTemplate=Event, - JSNoStaticTables -] interface ProgressEvent : Event { - [InitializedByEventConstructor] readonly attribute boolean lengthComputable; - [InitializedByEventConstructor] readonly attribute unsigned long long loaded; - [InitializedByEventConstructor] readonly attribute unsigned long long total; -}; - diff --git a/contrib/dom/webkit/dom/PropertyNodeList.idl b/contrib/dom/webkit/dom/PropertyNodeList.idl deleted file mode 100644 index 5b2b484..0000000 --- a/contrib/dom/webkit/dom/PropertyNodeList.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=MICRODATA, - IndexedGetter, - JSGenerateToJSObject -] interface PropertyNodeList : NodeList { - - sequence<MicroDataItemValue> getValues(); - Node item(in unsigned long index); - - readonly attribute unsigned long length; -}; diff --git a/contrib/dom/webkit/dom/Range.idl b/contrib/dom/webkit/dom/Range.idl deleted file mode 100644 index 05c6e2a..0000000 --- a/contrib/dom/webkit/dom/Range.idl +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -interface Range { - - readonly attribute Node startContainer - getter raises(DOMException); - readonly attribute long startOffset - getter raises(DOMException); - readonly attribute Node endContainer - getter raises(DOMException); - readonly attribute long endOffset - getter raises(DOMException); - readonly attribute boolean collapsed - getter raises(DOMException); - readonly attribute Node commonAncestorContainer - getter raises(DOMException); - - [ObjCLegacyUnnamedParameters] void setStart(in [Optional=DefaultIsUndefined] Node refNode, - in [Optional=DefaultIsUndefined] long offset) - raises(RangeException, DOMException); - [ObjCLegacyUnnamedParameters] void setEnd(in [Optional=DefaultIsUndefined] Node refNode, - in [Optional=DefaultIsUndefined] long offset) - raises(RangeException, DOMException); - void setStartBefore(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - void setStartAfter(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - void setEndBefore(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - void setEndAfter(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - void collapse(in [Optional=DefaultIsUndefined] boolean toStart) - raises(DOMException); - void selectNode(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - void selectNodeContents(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - - // CompareHow - const unsigned short START_TO_START = 0; - const unsigned short START_TO_END = 1; - const unsigned short END_TO_END = 2; - const unsigned short END_TO_START = 3; - - [ObjCLegacyUnnamedParameters] short compareBoundaryPoints(in [Optional=DefaultIsUndefined] CompareHow how, - in [Optional=DefaultIsUndefined] Range sourceRange) - raises(DOMException); - - void deleteContents() - raises(DOMException); - DocumentFragment extractContents() - raises(DOMException); - DocumentFragment cloneContents() - raises(DOMException); - void insertNode(in [Optional=DefaultIsUndefined] Node newNode) - raises(DOMException, RangeException); - void surroundContents(in [Optional=DefaultIsUndefined] Node newParent) - raises(DOMException, RangeException); - Range cloneRange() - raises(DOMException); - DOMString toString() - raises(DOMException); - - void detach() - raises(DOMException); - -#if defined(LANGUAGE_JAVASCRIPT) || LANGUAGE_JAVASCRIPT - // CSSOM View Module API extensions - - ClientRectList getClientRects(); - ClientRect getBoundingClientRect(); -#endif - - // extensions - - DocumentFragment createContextualFragment(in [Optional=DefaultIsUndefined] DOMString html) - raises(DOMException); - - // WebKit extensions - - boolean intersectsNode(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - - short compareNode(in [Optional=DefaultIsUndefined] Node refNode) - raises(RangeException, DOMException); - - // CompareResults - const unsigned short NODE_BEFORE = 0; - const unsigned short NODE_AFTER = 1; - const unsigned short NODE_BEFORE_AND_AFTER = 2; - const unsigned short NODE_INSIDE = 3; - - short comparePoint(in [Optional=DefaultIsUndefined] Node refNode, - in [Optional=DefaultIsUndefined] long offset) - raises(RangeException, DOMException); - - boolean isPointInRange(in [Optional=DefaultIsUndefined] Node refNode, - in [Optional=DefaultIsUndefined] long offset) - raises(RangeException, DOMException); - - void expand(in [Optional=DefaultIsUndefined] DOMString unit) - raises(RangeException, DOMException); - -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - readonly attribute DOMString text; -#endif -}; - diff --git a/contrib/dom/webkit/dom/RangeException.idl b/contrib/dom/webkit/dom/RangeException.idl deleted file mode 100644 index df92b42..0000000 --- a/contrib/dom/webkit/dom/RangeException.idl +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - DoNotCheckConstants -] exception RangeException { - - readonly attribute unsigned short code; - readonly attribute DOMString name; - readonly attribute DOMString message; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - [NotEnumerable] DOMString toString(); -#endif - - // DOM Level 2 - - const unsigned short BAD_BOUNDARYPOINTS_ERR = 1; - const unsigned short INVALID_NODE_TYPE_ERR = 2; -}; - diff --git a/contrib/dom/webkit/dom/RequestAnimationFrameCallback.idl b/contrib/dom/webkit/dom/RequestAnimationFrameCallback.idl deleted file mode 100644 index b4347cf..0000000 --- a/contrib/dom/webkit/dom/RequestAnimationFrameCallback.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Callback, - Conditional=REQUEST_ANIMATION_FRAME, -] interface RequestAnimationFrameCallback{ - // highResTime is passed as high resolution timestamp, see - // http://www.w3.org/TR/hr-time/ for details. -#if defined(V8_BINDING) && V8_BINDING - boolean handleEvent(in double highResTime); -#else - [Custom] boolean handleEvent(in double highResTime); -#endif - -}; diff --git a/contrib/dom/webkit/dom/ShadowRoot.idl b/contrib/dom/webkit/dom/ShadowRoot.idl deleted file mode 100644 index a39ca92..0000000 --- a/contrib/dom/webkit/dom/ShadowRoot.idl +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=SHADOW_DOM, - JSGenerateToJSObject -] interface ShadowRoot : DocumentFragment { - readonly attribute Element activeElement; - attribute boolean applyAuthorStyles; - attribute boolean resetStyleInheritance; - - [TreatNullAs=NullString] attribute DOMString innerHTML - setter raises(DOMException); - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - Node cloneNode(in [Optional=DefaultIsUndefined] boolean deep) raises(DOMException); -#endif - DOMSelection getSelection(); - Element getElementById(in [Optional=DefaultIsUndefined] DOMString elementId); - NodeList getElementsByClassName(in [Optional=DefaultIsUndefined] DOMString className); - NodeList getElementsByTagName(in [Optional=DefaultIsUndefined] DOMString tagName); - NodeList getElementsByTagNameNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, - in [Optional=DefaultIsUndefined] DOMString localName); - - Element elementFromPoint(in [Optional=DefaultIsUndefined] long x, - in [Optional=DefaultIsUndefined] long y); -}; diff --git a/contrib/dom/webkit/dom/StringCallback.idl b/contrib/dom/webkit/dom/StringCallback.idl deleted file mode 100644 index a26831b..0000000 --- a/contrib/dom/webkit/dom/StringCallback.idl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Callback -] interface StringCallback { - boolean handleEvent(in DOMString data); -}; diff --git a/contrib/dom/webkit/dom/Text.idl b/contrib/dom/webkit/dom/Text.idl deleted file mode 100644 index da243fc..0000000 --- a/contrib/dom/webkit/dom/Text.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface Text : CharacterData { - - // DOM Level 1 - - Text splitText(in [IsIndex,Optional=DefaultIsUndefined] unsigned long offset) - raises (DOMException); - - // Introduced in DOM Level 3: - readonly attribute DOMString wholeText; - Text replaceWholeText(in [Optional=DefaultIsUndefined] DOMString content) - raises(DOMException); -}; - diff --git a/contrib/dom/webkit/dom/TextEvent.idl b/contrib/dom/webkit/dom/TextEvent.idl deleted file mode 100644 index 709500a..0000000 --- a/contrib/dom/webkit/dom/TextEvent.idl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Introduced in DOM Level 3: -interface TextEvent : UIEvent { - - readonly attribute DOMString data; - - void initTextEvent(in [Optional=DefaultIsUndefined] DOMString typeArg, - in [Optional=DefaultIsUndefined] boolean canBubbleArg, - in [Optional=DefaultIsUndefined] boolean cancelableArg, - in [Optional=DefaultIsUndefined] DOMWindow viewArg, - in [Optional=DefaultIsUndefined] DOMString dataArg); - -}; - diff --git a/contrib/dom/webkit/dom/Touch.idl b/contrib/dom/webkit/dom/Touch.idl deleted file mode 100644 index 3a50e07..0000000 --- a/contrib/dom/webkit/dom/Touch.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=TOUCH_EVENTS -] interface Touch { - readonly attribute long clientX; - readonly attribute long clientY; - readonly attribute long screenX; - readonly attribute long screenY; - readonly attribute long pageX; - readonly attribute long pageY; - readonly attribute EventTarget target; - readonly attribute unsigned long identifier; - readonly attribute long webkitRadiusX; - readonly attribute long webkitRadiusY; - readonly attribute float webkitRotationAngle; - readonly attribute float webkitForce; -}; diff --git a/contrib/dom/webkit/dom/TouchEvent.idl b/contrib/dom/webkit/dom/TouchEvent.idl deleted file mode 100644 index 4712f9e..0000000 --- a/contrib/dom/webkit/dom/TouchEvent.idl +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=TOUCH_EVENTS -] interface TouchEvent : UIEvent { - readonly attribute TouchList touches; - readonly attribute TouchList targetTouches; - readonly attribute TouchList changedTouches; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean altKey; - readonly attribute boolean metaKey; - - void initTouchEvent(in [Optional=DefaultIsUndefined] TouchList touches, - in [Optional=DefaultIsUndefined] TouchList targetTouches, - in [Optional=DefaultIsUndefined] TouchList changedTouches, - in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] long screenX, - in [Optional=DefaultIsUndefined] long screenY, - in [Optional=DefaultIsUndefined] long clientX, - in [Optional=DefaultIsUndefined] long clientY, - in [Optional=DefaultIsUndefined] boolean ctrlKey, - in [Optional=DefaultIsUndefined] boolean altKey, - in [Optional=DefaultIsUndefined] boolean shiftKey, - in [Optional=DefaultIsUndefined] boolean metaKey); -}; diff --git a/contrib/dom/webkit/dom/TouchList.idl b/contrib/dom/webkit/dom/TouchList.idl deleted file mode 100644 index f66c6cc..0000000 --- a/contrib/dom/webkit/dom/TouchList.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - Conditional=TOUCH_EVENTS, - IndexedGetter -] interface TouchList { - readonly attribute unsigned long length; - - Touch item(in unsigned long index); -}; diff --git a/contrib/dom/webkit/dom/TreeWalker.idl b/contrib/dom/webkit/dom/TreeWalker.idl deleted file mode 100644 index 52cf98f..0000000 --- a/contrib/dom/webkit/dom/TreeWalker.idl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -[ - JSCustomMarkFunction -] interface TreeWalker { - readonly attribute Node root; - readonly attribute unsigned long whatToShow; - readonly attribute NodeFilter filter; - readonly attribute boolean expandEntityReferences; - attribute Node currentNode - setter raises(DOMException); - - [CallWith=ScriptState] Node parentNode(); - [CallWith=ScriptState] Node firstChild(); - [CallWith=ScriptState] Node lastChild(); - [CallWith=ScriptState] Node previousSibling(); - [CallWith=ScriptState] Node nextSibling(); - [CallWith=ScriptState] Node previousNode(); - [CallWith=ScriptState] Node nextNode(); -}; - diff --git a/contrib/dom/webkit/dom/UIEvent.idl b/contrib/dom/webkit/dom/UIEvent.idl deleted file mode 100644 index 23a62de..0000000 --- a/contrib/dom/webkit/dom/UIEvent.idl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in DOM Level 2: -interface UIEvent : Event { - readonly attribute DOMWindow view; - readonly attribute long detail; - - [ObjCLegacyUnnamedParameters] void initUIEvent(in [Optional=DefaultIsUndefined] DOMString type, - in [Optional=DefaultIsUndefined] boolean canBubble, - in [Optional=DefaultIsUndefined] boolean cancelable, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] long detail); - - // extensions - readonly attribute long keyCode; - readonly attribute long charCode; - readonly attribute long layerX; - readonly attribute long layerY; - readonly attribute long pageX; - readonly attribute long pageY; - readonly attribute long which; -}; - diff --git a/contrib/dom/webkit/dom/WebKitAnimationEvent.idl b/contrib/dom/webkit/dom/WebKitAnimationEvent.idl deleted file mode 100644 index 6f1844b..0000000 --- a/contrib/dom/webkit/dom/WebKitAnimationEvent.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - ConstructorTemplate=Event -] interface WebKitAnimationEvent : Event { - [InitializedByEventConstructor] readonly attribute DOMString animationName; - [InitializedByEventConstructor] readonly attribute double elapsedTime; -}; - diff --git a/contrib/dom/webkit/dom/WebKitNamedFlow.idl b/contrib/dom/webkit/dom/WebKitNamedFlow.idl deleted file mode 100644 index 11ee4ad..0000000 --- a/contrib/dom/webkit/dom/WebKitNamedFlow.idl +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -[ - EventTarget, - JSGenerateToJSObject, - GenerateIsReachable=ImplOwnerNodeRoot -] interface WebKitNamedFlow { - readonly attribute DOMString name; - readonly attribute boolean overset; - readonly attribute long firstEmptyRegionIndex; - NodeList getRegionsByContent(in Node contentNode); - NodeList getRegions(); - NodeList getContent(); - - // EventTarget interface - void addEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - void removeEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - boolean dispatchEvent(in Event event) - raises(EventException); -}; diff --git a/contrib/dom/webkit/dom/WebKitTransitionEvent.idl b/contrib/dom/webkit/dom/WebKitTransitionEvent.idl deleted file mode 100644 index 218ccab..0000000 --- a/contrib/dom/webkit/dom/WebKitTransitionEvent.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - ConstructorTemplate=Event -] interface WebKitTransitionEvent : Event { - [InitializedByEventConstructor] readonly attribute DOMString propertyName; - [InitializedByEventConstructor] readonly attribute double elapsedTime; -}; - diff --git a/contrib/dom/webkit/dom/WheelEvent.idl b/contrib/dom/webkit/dom/WheelEvent.idl deleted file mode 100644 index 1b4ed6f..0000000 --- a/contrib/dom/webkit/dom/WheelEvent.idl +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Based off http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-wheelevents -interface WheelEvent : MouseEvent -{ - readonly attribute long wheelDelta; - readonly attribute long wheelDeltaX; - readonly attribute long wheelDeltaY; - - // WebKit Extension - readonly attribute boolean webkitDirectionInvertedFromDevice; - -#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C - readonly attribute boolean isHorizontal; -#endif /* defined(LANGUAGE_OBJECTIVE_C) */ - -#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT - void initWheelEvent(in [Optional=DefaultIsUndefined] long wheelDeltaX, - in [Optional=DefaultIsUndefined] long wheelDeltaY, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] long screenX, - in [Optional=DefaultIsUndefined] long screenY, - in [Optional=DefaultIsUndefined] long clientX, - in [Optional=DefaultIsUndefined] long clientY, - in [Optional=DefaultIsUndefined] boolean ctrlKey, - in [Optional=DefaultIsUndefined] boolean altKey, - in [Optional=DefaultIsUndefined] boolean shiftKey, - in [Optional=DefaultIsUndefined] boolean metaKey); -#endif /* !defined(LANGUAGE_JAVASCRIPT) */ - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - void initWebKitWheelEvent(in [Optional=DefaultIsUndefined] long wheelDeltaX, - in [Optional=DefaultIsUndefined] long wheelDeltaY, - in [Optional=DefaultIsUndefined] DOMWindow view, - in [Optional=DefaultIsUndefined] long screenX, - in [Optional=DefaultIsUndefined] long screenY, - in [Optional=DefaultIsUndefined] long clientX, - in [Optional=DefaultIsUndefined] long clientY, - in [Optional=DefaultIsUndefined] boolean ctrlKey, - in [Optional=DefaultIsUndefined] boolean altKey, - in [Optional=DefaultIsUndefined] boolean shiftKey, - in [Optional=DefaultIsUndefined] boolean metaKey); -#endif /* defined(LANGUAGE_JAVASCRIPT) */ -}; diff --git a/contrib/dom/webkit/xml/DOMParser.idl b/contrib/dom/webkit/xml/DOMParser.idl deleted file mode 100644 index 2e67aa5..0000000 --- a/contrib/dom/webkit/xml/DOMParser.idl +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - Constructor -] interface DOMParser { - Document parseFromString(in [Optional=DefaultIsUndefined] DOMString str, - in [Optional=DefaultIsUndefined] DOMString contentType); -}; diff --git a/contrib/dom/webkit/xml/XMLHttpRequest.idl b/contrib/dom/webkit/xml/XMLHttpRequest.idl deleted file mode 100644 index 244da04..0000000 --- a/contrib/dom/webkit/xml/XMLHttpRequest.idl +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2008, 2011 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - ActiveDOMObject, - Constructor, - CallWith=ScriptExecutionContext, - V8CustomConstructor, - JSCustomMarkFunction, - EventTarget, - JSNoStaticTables -] interface XMLHttpRequest { - // From XMLHttpRequestEventTarget - // event handler attributes - attribute EventListener onabort; - attribute EventListener onerror; - attribute EventListener onload; - attribute EventListener onloadend; - attribute EventListener onloadstart; - attribute EventListener onprogress; - [Conditional=XHR_TIMEOUT] attribute EventListener ontimeout; - - // event handler attributes - attribute EventListener onreadystatechange; - - // state - const unsigned short UNSENT = 0; - const unsigned short OPENED = 1; - const unsigned short HEADERS_RECEIVED = 2; - const unsigned short LOADING = 3; - const unsigned short DONE = 4; - - [Conditional=XHR_TIMEOUT] attribute unsigned long timeout - setter raises(DOMException); - readonly attribute unsigned short readyState; - - attribute boolean withCredentials - setter raises(DOMException); - - [Custom] void open(in DOMString method, in DOMString url, in [Optional] boolean async, in [Optional] DOMString user, in [Optional] DOMString password) - raises(DOMException); - - void setRequestHeader(in DOMString header, in DOMString value) - raises(DOMException); - - [Custom] void send() - raises(DOMException); - [Custom] void send(in ArrayBuffer data) // FIXME: this should be eventually deprecated. - raises(DOMException); - [Custom] void send(in ArrayBufferView data) - raises(DOMException); - [Conditional=BLOB, Custom] void send(in Blob data) - raises(DOMException); - [Custom] void send(in Document data) - raises(DOMException); - [Custom] void send(in [StrictTypeChecking] DOMString data) - raises(DOMException); - [Custom] void send(in DOMFormData data) - raises(DOMException); - - void abort(); - - readonly attribute XMLHttpRequestUpload upload; - - // response - [TreatReturnedNullStringAs=Undefined] DOMString getAllResponseHeaders() - raises(DOMException); - [TreatReturnedNullStringAs=Null] DOMString getResponseHeader(in DOMString header) - raises(DOMException); - [CustomGetter] readonly attribute DOMString responseText // The custom getter implements TreatReturnedNullStringAs=Null - getter raises(DOMException); - readonly attribute Document responseXML - getter raises(DOMException); - - attribute DOMString responseType - setter raises(DOMException); - [CustomGetter] readonly attribute Object response - getter raises(DOMException); - - readonly attribute unsigned short status - getter raises(DOMException); - readonly attribute DOMString statusText - getter raises(DOMException); - - // Extension - void overrideMimeType(in DOMString override); - - // EventTarget interface - void addEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - void removeEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - boolean dispatchEvent(in Event evt) - raises(EventException); -}; diff --git a/contrib/dom/webkit/xml/XMLHttpRequestException.idl b/contrib/dom/webkit/xml/XMLHttpRequestException.idl deleted file mode 100644 index 4114292..0000000 --- a/contrib/dom/webkit/xml/XMLHttpRequestException.idl +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - JSNoStaticTables, - DoNotCheckConstants -] exception XMLHttpRequestException { - - readonly attribute unsigned short code; - readonly attribute DOMString name; - readonly attribute DOMString message; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - // Override in a Mozilla compatible format - [NotEnumerable] DOMString toString(); -#endif - - // XMLHttpRequestExceptionCode - const unsigned short NETWORK_ERR = 101; - const unsigned short ABORT_ERR = 102; -}; - diff --git a/contrib/dom/webkit/xml/XMLHttpRequestProgressEvent.idl b/contrib/dom/webkit/xml/XMLHttpRequestProgressEvent.idl deleted file mode 100644 index 5ed5c21..0000000 --- a/contrib/dom/webkit/xml/XMLHttpRequestProgressEvent.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - JSNoStaticTables -// We should also inherit from LSProgressEvent when the idl is added. -] interface XMLHttpRequestProgressEvent : ProgressEvent { - readonly attribute unsigned long long position; - readonly attribute unsigned long long totalSize; -}; - diff --git a/contrib/dom/webkit/xml/XMLHttpRequestUpload.idl b/contrib/dom/webkit/xml/XMLHttpRequestUpload.idl deleted file mode 100644 index 61031df..0000000 --- a/contrib/dom/webkit/xml/XMLHttpRequestUpload.idl +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - JSGenerateIsReachable=Impl, - EventTarget, - JSNoStaticTables -] interface XMLHttpRequestUpload { - // From XMLHttpRequestEventTarget - // event handler attributes - attribute EventListener onabort; - attribute EventListener onerror; - attribute EventListener onload; - attribute EventListener onloadend; - attribute EventListener onloadstart; - attribute EventListener onprogress; - - // EventTarget interface - void addEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - void removeEventListener(in DOMString type, - in EventListener listener, - in [Optional] boolean useCapture); - boolean dispatchEvent(in Event evt) - raises(EventException); -}; - diff --git a/contrib/dom/webkit/xml/XMLSerializer.idl b/contrib/dom/webkit/xml/XMLSerializer.idl deleted file mode 100644 index 709fe1d..0000000 --- a/contrib/dom/webkit/xml/XMLSerializer.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - Constructor -] interface XMLSerializer { - DOMString serializeToString(in [Optional=DefaultIsUndefined] Node node) - raises(DOMException); -}; - diff --git a/contrib/dom/webkit/xml/XPathEvaluator.idl b/contrib/dom/webkit/xml/XPathEvaluator.idl deleted file mode 100644 index 6cf4dc0..0000000 --- a/contrib/dom/webkit/xml/XPathEvaluator.idl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - Constructor -] interface XPathEvaluator { - XPathExpression createExpression(in [Optional=DefaultIsUndefined] DOMString expression, - in [Optional=DefaultIsUndefined] XPathNSResolver resolver) - raises(DOMException); - - XPathNSResolver createNSResolver(in [Optional=DefaultIsUndefined] Node nodeResolver); - - XPathResult evaluate(in [Optional=DefaultIsUndefined] DOMString expression, - in [Optional=DefaultIsUndefined] Node contextNode, - in [Optional=DefaultIsUndefined] XPathNSResolver resolver, - in [Optional=DefaultIsUndefined] unsigned short type, - in [Optional=DefaultIsUndefined] XPathResult inResult) - raises(DOMException); -}; diff --git a/contrib/dom/webkit/xml/XPathException.idl b/contrib/dom/webkit/xml/XPathException.idl deleted file mode 100644 index 2398187..0000000 --- a/contrib/dom/webkit/xml/XPathException.idl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - DoNotCheckConstants -] exception XPathException { - - readonly attribute unsigned short code; - readonly attribute DOMString name; - readonly attribute DOMString message; - -#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - // Override in a Mozilla compatible format - [NotEnumerable] DOMString toString(); -#endif - - // XPathExceptionCode - const unsigned short INVALID_EXPRESSION_ERR = 51; - const unsigned short TYPE_ERR = 52; -}; - diff --git a/contrib/dom/webkit/xml/XPathExpression.idl b/contrib/dom/webkit/xml/XPathExpression.idl deleted file mode 100644 index 1f3c8c4..0000000 --- a/contrib/dom/webkit/xml/XPathExpression.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface XPathExpression { - [ObjCLegacyUnnamedParameters] XPathResult evaluate(in [Optional=DefaultIsUndefined] Node contextNode, - in [Optional=DefaultIsUndefined] unsigned short type, - in [Optional=DefaultIsUndefined] XPathResult inResult) - raises(DOMException); -}; - diff --git a/contrib/dom/webkit/xml/XPathNSResolver.idl b/contrib/dom/webkit/xml/XPathNSResolver.idl deleted file mode 100644 index 518e1da..0000000 --- a/contrib/dom/webkit/xml/XPathNSResolver.idl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -[ - ObjCProtocol, - OmitConstructor -] interface XPathNSResolver { - [TreatReturnedNullStringAs=Null] DOMString lookupNamespaceURI(in [Optional=DefaultIsUndefined] DOMString prefix); -}; - diff --git a/contrib/dom/webkit/xml/XPathResult.idl b/contrib/dom/webkit/xml/XPathResult.idl deleted file mode 100644 index 51b7afd..0000000 --- a/contrib/dom/webkit/xml/XPathResult.idl +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface XPathResult { - const unsigned short ANY_TYPE = 0; - const unsigned short NUMBER_TYPE = 1; - const unsigned short STRING_TYPE = 2; - const unsigned short BOOLEAN_TYPE = 3; - const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4; - const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5; - const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6; - const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7; - const unsigned short ANY_UNORDERED_NODE_TYPE = 8; - const unsigned short FIRST_ORDERED_NODE_TYPE = 9; - - readonly attribute unsigned short resultType; - readonly attribute double numberValue - getter raises (DOMException); - - readonly attribute DOMString stringValue - getter raises (DOMException); - - readonly attribute boolean booleanValue - getter raises (DOMException); - - readonly attribute Node singleNodeValue - getter raises (DOMException); - - readonly attribute boolean invalidIteratorState; - readonly attribute unsigned long snapshotLength - getter raises (DOMException); - - Node iterateNext() - raises (DOMException); - Node snapshotItem(in [Optional=DefaultIsUndefined] unsigned long index) - raises (DOMException); -}; - diff --git a/contrib/dom/webkit/xml/XSLTProcessor.idl b/contrib/dom/webkit/xml/XSLTProcessor.idl deleted file mode 100644 index 0914e06..0000000 --- a/contrib/dom/webkit/xml/XSLTProcessor.idl +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Eventually we should implement XSLTException: -// http://lxr.mozilla.org/seamonkey/source/content/xsl/public/nsIXSLTException.idl -// http://bugs.webkit.org/show_bug.cgi?id=5446 - -[ - Conditional=XSLT, - Constructor -] interface XSLTProcessor { - - void importStylesheet(in [Optional=DefaultIsUndefined] Node stylesheet); - DocumentFragment transformToFragment(in [Optional=DefaultIsUndefined] Node source, in [Optional=DefaultIsUndefined] Document docVal); - Document transformToDocument(in [Optional=DefaultIsUndefined] Node source); - - [Custom] void setParameter(in DOMString namespaceURI, in DOMString localName, in DOMString value); - [Custom, TreatReturnedNullStringAs=Undefined] DOMString getParameter(in DOMString namespaceURI, in DOMString localName); - [Custom] void removeParameter(in DOMString namespaceURI, in DOMString localName); - void clearParameters(); - - void reset(); - -}; - |