diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/WebCore/bindings/scripts | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/WebCore/bindings/scripts')
63 files changed, 22638 insertions, 0 deletions
diff --git a/Source/WebCore/bindings/scripts/CodeGenerator.pm b/Source/WebCore/bindings/scripts/CodeGenerator.pm new file mode 100644 index 0000000..9a9e9d7 --- /dev/null +++ b/Source/WebCore/bindings/scripts/CodeGenerator.pm @@ -0,0 +1,580 @@ +# +# WebKit IDL parser +# +# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org> +# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> +# Copyright (C) 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. +# +# 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 CodeGenerator; + +use strict; + +use File::Find; + +my $useDocument = ""; +my $useGenerator = ""; +my $useOutputDir = ""; +my $useOutputHeadersDir = ""; +my $useDirectories = ""; +my $useLayerOnTop = 0; +my $preprocessor; +my $writeDependencies = 0; +my $defines = ""; + +my $codeGenerator = 0; + +my $verbose = 0; + +my %numericTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1, + "unsigned int" => 1, "unsigned short" => 1, + "unsigned long" => 1, "unsigned long long" => 1, + "float" => 1, "double" => 1); + +my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1); + +my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); + +my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" => 1); + +my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, + "SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1, + "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1, + "SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1, + "SVGAnimatedPreserveAspectRatio" => 1, + "SVGAnimatedRect" => 1, "SVGAnimatedString" => 1, + "SVGAnimatedTransformList" => 1); + +my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick" => 1, + "onerror" => 1, "onload" => 1, "onmousedown" => 1, + "onmousemove" => 1, "onmouseout" => 1, "onmouseover" => 1, + "onmouseup" => 1, "onresize" => 1, "onscroll" => 1, + "onunload" => 1); + +my %svgTypeNeedingTearOff = ( + "SVGAngle" => "SVGPropertyTearOff<SVGAngle>", + "SVGLength" => "SVGPropertyTearOff<SVGLength>", + "SVGLengthList" => "SVGListPropertyTearOff<SVGLengthList>", + "SVGMatrix" => "SVGPropertyTearOff<SVGMatrix>", + "SVGNumber" => "SVGPropertyTearOff<float>", + "SVGNumberList" => "SVGListPropertyTearOff<SVGNumberList>", + "SVGPathSegList" => "SVGPathSegListPropertyTearOff", + "SVGPoint" => "SVGPropertyTearOff<FloatPoint>", + "SVGPointList" => "SVGListPropertyTearOff<SVGPointList>", + "SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>", + "SVGRect" => "SVGPropertyTearOff<FloatRect>", + "SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>", + "SVGTransform" => "SVGPropertyTearOff<SVGTransform>", + "SVGTransformList" => "SVGTransformListPropertyTearOff" +); + +my %svgTypeWithWritablePropertiesNeedingTearOff = ( + "SVGPoint" => 1, + "SVGMatrix" => 1 +); + +# Cache of IDL file pathnames. +my $idlFiles; + +# Default constructor +sub new +{ + my $object = shift; + my $reference = { }; + + $useDirectories = shift; + $useGenerator = shift; + $useOutputDir = shift; + $useOutputHeadersDir = shift; + $useLayerOnTop = shift; + $preprocessor = shift; + $writeDependencies = shift; + $verbose = shift; + + bless($reference, $object); + return $reference; +} + +sub StripModule($) +{ + my $object = shift; + my $name = shift; + $name =~ s/[a-zA-Z0-9]*:://; + return $name; +} + +sub ProcessDocument +{ + my $object = shift; + $useDocument = shift; + $defines = shift; + + my $ifaceName = "CodeGenerator" . $useGenerator; + require $ifaceName . ".pm"; + + # Dynamically load external code generation perl module + $codeGenerator = $ifaceName->new($object, $useOutputDir, $useOutputHeadersDir, $useLayerOnTop, $preprocessor, $writeDependencies, $verbose); + unless (defined($codeGenerator)) { + my $classes = $useDocument->classes; + foreach my $class (@$classes) { + print "Skipping $useGenerator code generation for IDL interface \"" . $class->name . "\".\n" if $verbose; + } + return; + } + + # Start the actual code generation! + $codeGenerator->GenerateModule($useDocument, $defines); + + my $classes = $useDocument->classes; + foreach my $class (@$classes) { + print "Generating $useGenerator bindings code for IDL interface \"" . $class->name . "\"...\n" if $verbose; + $codeGenerator->GenerateInterface($class, $defines); + } + + $codeGenerator->finish(); +} + +sub ForAllParents +{ + my $object = shift; + my $dataNode = shift; + my $beforeRecursion = shift; + my $afterRecursion = shift; + my $parentsOnly = shift; + + my $recurse; + $recurse = sub { + my $interface = shift; + + for (@{$interface->parents}) { + my $interfaceName = $object->StripModule($_); + my $parentInterface = $object->ParseInterface($interfaceName, $parentsOnly); + + if ($beforeRecursion) { + &$beforeRecursion($parentInterface) eq 'prune' and next; + } + &$recurse($parentInterface); + &$afterRecursion($parentInterface) if $afterRecursion; + } + }; + + &$recurse($dataNode); +} + +sub AddMethodsConstantsAndAttributesFromParentClasses +{ + # Add to $dataNode all of its inherited interface members, except for those + # inherited through $dataNode's first listed parent. If an array reference + # is passed in as $parents, the names of all ancestor interfaces visited + # will be appended to the array. If $collectDirectParents is true, then + # even the names of $dataNode's first listed parent and its ancestors will + # be appended to $parents. + + my $object = shift; + my $dataNode = shift; + my $parents = shift; + my $collectDirectParents = shift; + + my $first = 1; + + $object->ForAllParents($dataNode, sub { + my $interface = shift; + + if ($first) { + # Ignore first parent class, already handled by the generation itself. + $first = 0; + + if ($collectDirectParents) { + # Just collect the names of the direct ancestor interfaces, + # if necessary. + push(@$parents, $interface->name); + $object->ForAllParents($interface, sub { + my $interface = shift; + push(@$parents, $interface->name); + }, undef, 1); + } + + # Prune the recursion here. + return 'prune'; + } + + # Collect the name of this additional parent. + push(@$parents, $interface->name) if $parents; + + print " | |> -> Inheriting " + . @{$interface->constants} . " constants, " + . @{$interface->functions} . " functions, " + . @{$interface->attributes} . " attributes...\n | |>\n" if $verbose; + + # Add this parent's members to $dataNode. + push(@{$dataNode->constants}, @{$interface->constants}); + push(@{$dataNode->functions}, @{$interface->functions}); + push(@{$dataNode->attributes}, @{$interface->attributes}); + }); +} + +sub GetMethodsAndAttributesFromParentClasses +{ + # For the passed interface, recursively parse all parent + # IDLs in order to find out all inherited properties/methods. + + my $object = shift; + my $dataNode = shift; + + my @parentList = (); + + $object->ForAllParents($dataNode, undef, sub { + my $interface = shift; + + my $hash = { + "name" => $interface->name, + "functions" => $interface->functions, + "attributes" => $interface->attributes + }; + + unshift(@parentList, $hash); + }); + + return @parentList; +} + +sub IDLFileForInterface +{ + my $object = shift; + my $interfaceName = shift; + + unless ($idlFiles) { + my $sourceRoot = $ENV{SOURCE_ROOT}; + my @directories = map { $_ = "$sourceRoot/$_" if $sourceRoot && -d "$sourceRoot/$_"; $_ } @$useDirectories; + + $idlFiles = { }; + + my $wanted = sub { + $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/; + $File::Find::prune = 1 if /^\../; + }; + find($wanted, @directories); + } + + return $idlFiles->{$interfaceName}; +} + +sub ParseInterface +{ + my $object = shift; + my $interfaceName = shift; + my $parentsOnly = shift; + + return undef if $interfaceName eq 'Object'; + + # Step #1: Find the IDL file associated with 'interface' + my $filename = $object->IDLFileForInterface($interfaceName) + or die("Could NOT find IDL file for interface \"$interfaceName\"!\n"); + + print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceName\"\n" if $verbose; + + # Step #2: Parse the found IDL file (in quiet mode). + my $parser = IDLParser->new(1); + my $document = $parser->Parse($filename, $defines, $preprocessor, $parentsOnly); + + foreach my $interface (@{$document->classes}) { + return $interface if $interface->name eq $interfaceName; + } + + die("Could NOT find interface definition for $interfaceName in $filename"); +} + +# Helpers for all CodeGenerator***.pm modules + +sub AvoidInclusionOfType +{ + my $object = shift; + my $type = shift; + + # Special case: SVGPoint.h / SVGNumber.h do not exist. + return 1 if $type eq "SVGPoint" or $type eq "SVGNumber"; + return 0; +} + +sub IsNumericType +{ + my $object = shift; + my $type = shift; + + return 1 if $numericTypeHash{$type}; + return 0; +} + +sub IsPrimitiveType +{ + my $object = shift; + my $type = shift; + + return 1 if $primitiveTypeHash{$type}; + return 1 if $numericTypeHash{$type}; + return 0; +} + +sub IsStringType +{ + my $object = shift; + my $type = shift; + + return 1 if $stringTypeHash{$type}; + return 0; +} + +sub IsNonPointerType +{ + my $object = shift; + my $type = shift; + + return 1 if $nonPointerTypeHash{$type} or $primitiveTypeHash{$type} or $numericTypeHash{$type}; + return 0; +} + +sub IsSVGTypeNeedingTearOff +{ + my $object = shift; + my $type = shift; + + return 1 if exists $svgTypeNeedingTearOff{$type}; + return 0; +} + +sub IsSVGTypeWithWritablePropertiesNeedingTearOff +{ + my $object = shift; + my $type = shift; + + return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type}; + return 0; +} + +sub GetSVGTypeNeedingTearOff +{ + my $object = shift; + my $type = shift; + + return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type}; + return undef; +} + +sub GetSVGWrappedTypeNeedingTearOff +{ + my $object = shift; + my $type = shift; + + my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOff($type); + return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff; + + if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//; + } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGListPropertyTearOff<//; + } elsif ($svgTypeNeedingTearOff =~ /SVGStaticListPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGStaticListPropertyTearOff<//; + } elsif ($svgTypeNeedingTearOff =~ /SVGTransformListPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGTransformListPropertyTearOff<//; + } + + $svgTypeNeedingTearOff =~ s/>//; + return $svgTypeNeedingTearOff; +} + +sub IsSVGAnimatedType +{ + my $object = shift; + my $type = shift; + + return 1 if $svgAnimatedTypeHash{$type}; + return 0; +} + +# Uppercase the first letter while respecting WebKit style guidelines. +# E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang. +sub WK_ucfirst +{ + my ($object, $param) = @_; + my $ret = ucfirst($param); + $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/; + + return $ret; +} + +# Lowercase the first letter while respecting WebKit style guidelines. +# URL becomes url, but SetURL becomes setURL. +sub WK_lcfirst +{ + my ($object, $param) = @_; + my $ret = lcfirst($param); + $ret =~ s/hTML/html/ if $ret =~ /^hTML/; + $ret =~ s/uRL/url/ if $ret =~ /^uRL/; + $ret =~ s/jS/js/ if $ret =~ /^jS/; + $ret =~ s/xML/xml/ if $ret =~ /^xML/; + $ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/; + + # For HTML5 FileSystem API Flags attributes. + # (create is widely used to instantiate an object and must be avoided.) + $ret =~ s/^create/isCreate/ if $ret =~ /^create$/; + $ret =~ s/^exclusive/isExclusive/ if $ret =~ /^exclusive$/; + + return $ret; +} + +# Return the C++ namespace that a given attribute name string is defined in. +sub NamespaceForAttributeName +{ + my ($object, $interfaceName, $attributeName) = @_; + return "SVGNames" if $interfaceName =~ /^SVG/ && !$svgAttributesInHTMLHash{$attributeName}; + return "HTMLNames"; +} + +# Identifies overloaded functions and for each function adds an array with +# links to its respective overloads (including itself). +sub LinkOverloadedFunctions +{ + my ($object, $dataNode) = @_; + + my %nameToFunctionsMap = (); + foreach my $function (@{$dataNode->functions}) { + my $name = $function->signature->name; + $nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name}; + push(@{$nameToFunctionsMap{$name}}, $function); + $function->{overloads} = $nameToFunctionsMap{$name}; + $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; + } +} + +sub AttributeNameForGetterAndSetter +{ + my ($generator, $attribute) = @_; + + my $attributeName = $attribute->signature->name; + my $attributeType = $generator->StripModule($attribute->signature->type); + + # Avoid clash with C++ keyword. + $attributeName = "_operator" if $attributeName eq "operator"; + + # SVGAElement defines a non-virtual "String& target() const" method which clashes with "virtual String target() const" in Element. + # To solve this issue the SVGAElement method was renamed to "svgTarget", take care of that when calling this method. + $attributeName = "svgTarget" if $attributeName eq "target" and $attributeType eq "SVGAnimatedString"; + + # SVG animated types need to use a special attribute name. + # The rest of the special casing for SVG animated types is handled in the language-specific code generators. + $attributeName .= "Animated" if $generator->IsSVGAnimatedType($attributeType); + + return $attributeName; +} + +sub ContentAttributeName +{ + my ($generator, $implIncludes, $interfaceName, $attribute) = @_; + + my $contentAttributeName = $attribute->signature->extendedAttributes->{"Reflect"}; + return undef if !$contentAttributeName; + + $contentAttributeName = lc $generator->AttributeNameForGetterAndSetter($attribute) if $contentAttributeName eq "1"; + + my $namespace = $generator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + + $implIncludes->{"${namespace}.h"} = 1; + return "WebCore::${namespace}::${contentAttributeName}Attr"; +} + +sub GetterExpressionPrefix +{ + my ($generator, $implIncludes, $interfaceName, $attribute) = @_; + + my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute); + + if (!$contentAttributeName) { + return $generator->WK_lcfirst($generator->AttributeNameForGetterAndSetter($attribute)) . "("; + } + + my $functionName; + if ($attribute->signature->extendedAttributes->{"URL"}) { + if ($attribute->signature->extendedAttributes->{"NonEmpty"}) { + $functionName = "getNonEmptyURLAttribute"; + } else { + $functionName = "getURLAttribute"; + } + } elsif ($attribute->signature->type eq "boolean") { + $functionName = "hasAttribute"; + } elsif ($attribute->signature->type eq "long") { + $functionName = "getIntegralAttribute"; + } elsif ($attribute->signature->type eq "unsigned long") { + $functionName = "getUnsignedIntegralAttribute"; + } else { + $functionName = "getAttribute"; + } + + return "$functionName($contentAttributeName" +} + +sub SetterExpressionPrefix +{ + my ($generator, $implIncludes, $interfaceName, $attribute) = @_; + + my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute); + + if (!$contentAttributeName) { + return "set" . $generator->WK_ucfirst($generator->AttributeNameForGetterAndSetter($attribute)) . "("; + } + + my $functionName; + if ($attribute->signature->type eq "boolean") { + $functionName = "setBooleanAttribute"; + } elsif ($attribute->signature->type eq "long") { + $functionName = "setIntegralAttribute"; + } elsif ($attribute->signature->type eq "unsigned long") { + $functionName = "setUnsignedIntegralAttribute"; + } else { + $functionName = "setAttribute"; + } + + return "$functionName($contentAttributeName, " +} + +sub ShouldCheckEnums +{ + my $dataNode = shift; + return not $dataNode->extendedAttributes->{"DontCheckEnums"}; +} + +sub GenerateCompileTimeCheckForEnumsIfNeeded +{ + my ($object, $dataNode) = @_; + my $interfaceName = $dataNode->name; + my @checks = (); + # If necessary, check that all constants are available as enums with the same value. + if (ShouldCheckEnums($dataNode) && @{$dataNode->constants}) { + push(@checks, "\n"); + foreach my $constant (@{$dataNode->constants}) { + my $name = $constant->name; + my $value = $constant->value; + push(@checks, "COMPILE_ASSERT($value == ${interfaceName}::$name, ${interfaceName}Enum${name}IsWrongUseDontCheckEnums);\n"); + } + push(@checks, "\n"); + } + return @checks; +} + +1; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm b/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm new file mode 100644 index 0000000..9b3f21e --- /dev/null +++ b/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm @@ -0,0 +1,960 @@ + +# 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; + +# Global Variables +my $module = ""; +my $outputDir = ""; + +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; + $outputDir = shift; + shift; # $outputHeadersDir + shift; # $useLayerOnTop + shift; # $preprocessor + shift; # $writeDependencies + + bless($reference, $object); + return $reference; +} + +sub finish +{ + my $object = shift; +} + +# Params: 'domClass' struct +sub GenerateInterface +{ + my $object = shift; + my $dataNode = shift; + my $defines = shift; + + my $name = $dataNode->name; + my $className = GetClassName($name); + my $parentClassName = "WebDOM" . GetParentImplClassName($dataNode); + + # Start actual generation. + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + + # Write changes. + $object->WriteData("WebDOM" . $name); +} + +# Params: 'idlDocument' struct +sub GenerateModule +{ + my $object = shift; + my $dataNode = shift; + + $module = $dataNode->module; +} + +sub GetClassName +{ + my $name = $codeGenerator->StripModule(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 "WebDOMCustomVoidCallback" if $name eq "VoidCallback"; + + return "WebDOM$name"; +} + +sub GetImplClassName +{ + return $codeGenerator->StripModule(shift); +} + +sub GetParentImplClassName +{ + my $dataNode = shift; + + if (@{$dataNode->parents} eq 0) { + return "EventTarget" if $dataNode->extendedAttributes->{"EventTarget"}; + return "Object"; + } + + return $codeGenerator->StripModule($dataNode->parents(0)); +} + +sub GetParent +{ + my $dataNode = shift; + my $numParents = @{$dataNode->parents}; + + my $parent = ""; + if ($numParents eq 0) { + $parent = "WebDOMObject"; + $parent = "WebDOMEventTarget" if $dataNode->extendedAttributes->{"EventTarget"}; + } elsif ($numParents eq 1) { + my $parentName = $codeGenerator->StripModule($dataNode->parents(0)); + $parent = "WebDOM" . $parentName; + } else { + my @parents = @{$dataNode->parents}; + my $firstParent = $codeGenerator->StripModule(shift(@parents)); + $parent = "WebDOM" . $firstParent; + } + + return $parent; +} + +sub ShouldSkipTypeInImplementation +{ + my $typeInfo = shift; + + return 1 if $typeInfo->signature->extendedAttributes->{"Custom"} + and !$typeInfo->signature->extendedAttributes->{"NoCPPCustom"}; + + return 1 if $typeInfo->signature->extendedAttributes->{"CustomArgumentHandling"} + or $typeInfo->signature->extendedAttributes->{"CustomGetter"} + or $typeInfo->signature->extendedAttributes->{"NeedsUserGestureCheck"} + or $typeInfo->signature->extendedAttributes->{"CPPCustom"}; + + # FIXME: We don't generate bindings for SVG related interfaces yet + return 1 if $typeInfo->signature->name =~ /getSVGDocument/; + + return 1 if $typeInfo->signature->name =~ /Constructor/; + return 0; +} + +sub ShouldSkipTypeInHeader +{ + my $typeInfo = shift; + + # FIXME: We currently ignore any attribute/function needing custom code + return 1 if $typeInfo->signature->extendedAttributes->{"CustomArgumentHandling"} + or $typeInfo->signature->extendedAttributes->{"CustomGetter"}; + + # FIXME: We don't generate bindings for SVG related interfaces yet + return 1 if $typeInfo->signature->name =~ /getSVGDocument/; + + return 1 if $typeInfo->signature->name =~ /Constructor/; + 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"; + + 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 = $codeGenerator->StripModule(shift); + return !$codeGenerator->IsNonPointerType($type) && !$codeGenerator->IsStringType($type); +} + +sub GetCPPTypeGetter +{ + my $argName = shift; + my $type = $codeGenerator->StripModule(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 "toWebCore($argName)"; +} + +sub AddForwardDeclarationsForType +{ + my $type = $codeGenerator->StripModule(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 = $codeGenerator->StripModule(shift); + + 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; + } + + if ($type eq "VoidCallback") { + $implIncludes{"WebDOMCustomVoidCallback.h"} = 1; + return; + } + + $implIncludes{"Node.h"} = 1 if $type eq "NodeList"; + $implIncludes{"CSSMutableStyleDeclaration.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 GenerateConditionalStringFromAttributeValue +{ + my $conditional = shift; + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } +} + +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return GenerateConditionalStringFromAttributeValue($conditional); + } else { + return ""; + } +} + +sub GenerateHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = GetClassName($interfaceName); + my $implClassName = GetImplClassName($interfaceName); + my $implClassNameWithNamespace = "WebCore::" . $implClassName; + + my $parentName = ""; + $parentName = GetParent($dataNode); + + my $numConstants = @{$dataNode->constants}; + my $numAttributes = @{$dataNode->attributes}; + my $numFunctions = @{$dataNode->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 = GenerateConditionalString($dataNode); + 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 = (); + + # FIXME: we need a way to include multiple enums. + foreach my $constant (@{$dataNode->constants}) { + my $constantName = $constant->name; + my $constantValue = $constant->value; + + my $output = "WEBDOM_" . $constantName . " = " . $constantValue; + push(@headerConstants, " " . $output); + } + + my $combinedConstants = join(",\n", @headerConstants); + + 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 (@{$dataNode->attributes}) { + next if ShouldSkipTypeInHeader($attribute); + + my $attributeConditionalString = 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 (@{$dataNode->functions}) { + next if ShouldSkipTypeInHeader($function); + my $functionName = $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 ($dataNode->extendedAttributes->{"PureInterface"}) { + 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); + } + + push(@headerFunctions, " "); + push(@headerFunctions, $functionDeclaration); + } + + 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 PureInterface classes also add the interface that the client code needs to + # implement + if ($dataNode->extendedAttributes->{"PureInterface"}) { + 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"); + } + + push(@headerContent, "WebCore::$implClassName* toWebCore(const $className&);\n"); + push(@headerContent, "$className toWebKit(WebCore::$implClassName*);\n"); + if ($dataNode->extendedAttributes->{"PureInterface"}) { + 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 $dataNode = shift; + + my @ancestorInterfaceNames = (); + + if (@{$dataNode->parents} > 1) { + $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@ancestorInterfaceNames); + } + + my $interfaceName = $dataNode->name; + my $className = GetClassName($interfaceName); + my $implClassName = GetImplClassName($interfaceName); + my $parentImplClassName = GetParentImplClassName($dataNode); + my $implClassNameWithNamespace = "WebCore::" . $implClassName; + my $baseClass = "WebDOM$parentImplClassName"; + my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + + my $numAttributes = @{$dataNode->attributes}; + my $numFunctions = @{$dataNode->functions}; + + # - Add default header template. + @implContentHeader = split("\r", $implementationLicenseTemplate); + + # - INCLUDES - + push(@implContentHeader, "\n#include \"config.h\"\n"); + my $conditionalString = GenerateConditionalString($dataNode); + 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 ? m_impl->impl.get() : 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 (@{$dataNode->attributes}) { + next if ShouldSkipTypeInImplementation($attribute); + AddIncludesForType($attribute->signature->type); + + my $idlType = $codeGenerator->StripModule($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 $getterContentHead = "impl()->" . $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + my $getterContentTail = ")"; + + # Special cases + my @customGetterContent = (); + if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { + $getterContentHead = "WTF::String::number(" . $getterContentHead; + $getterContentTail .= ")"; + } elsif ($attribute->signature->type eq "SerializedScriptValue") { + $getterContentHead = "$getterContentHead"; + $getterContentTail .= "->toString()"; + } elsif (ConversionNeeded($attribute->signature->type)) { + $getterContentHead = "toWebKit(WTF::getPtr($getterContentHead"; + $getterContentTail .= "))"; + } + + my $getterContent; + if ($hasGetterException) { + $getterContent = $getterContentHead . "ec" . $getterContentTail; + } else { + $getterContent = $getterContentHead . $getterContentTail; + } + + my $attributeConditionalString = 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); + + # The definition of ConvertToString is flipped for the setter + if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { + $arg = "WTF::String($arg).toInt()"; + } + + 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 $ec = $hasSetterException ? ", ec" : ""; + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + push(@implContent, " impl()->$setterExpressionPrefix$arg$ec);\n"); + push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException; + push(@implContent, "}\n\n"); + } + + push(@implContent, "#endif\n") if $attributeConditionalString; + } + } + + # - Functions + if ($numFunctions > 0) { + foreach my $function (@{$dataNode->functions}) { + # Treat PureInterface as Custom as well, since the WebCore versions will take a script context as well + next if ShouldSkipTypeInImplementation($function) || $dataNode->extendedAttributes->{"PureInterface"}; + 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 = $codeGenerator->StripModule($param->type); + my $implGetter = GetCPPTypeGetter($paramName, $idlType); + + push(@parameterNames, $implGetter); + $needsCustom{"NodeToReturn"} = $paramName if $param->extendedAttributes->{"Return"}; + + 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 = "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"); + } + } + + push(@implContent, "$functionSig\n"); + push(@implContent, "{\n"); + push(@implContent, AddEarlyReturnStatement($returnType)); + push(@implContent, @functionContent); + push(@implContent, "}\n\n"); + + # Clear the hash + %needsCustom = (); + } + } + + # END implementation + + # Generate internal interfaces + push(@implContent, "WebCore::$implClassName* toWebCore(const $className& wrapper)\n"); + push(@implContent, "{\n"); + push(@implContent, " return wrapper.impl();\n"); + push(@implContent, "}\n\n"); + + push(@implContent, "$className toWebKit(WebCore::$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; +} + +# Internal helper +sub WriteData +{ + my $object = shift; + my $name = shift; + + # Open files for writing... + my $headerFileName = "$outputDir/" . $name . ".h"; + my $implFileName = "$outputDir/" . $name . ".cpp"; + + # Remove old files. + unlink($headerFileName); + unlink($implFileName); + + # Write public header. + open(HEADER, ">$headerFileName") or die "Couldn't open file $headerFileName"; + + print HEADER @headerContentHeader; + print HEADER "\n"; + foreach my $class (sort keys(%headerForwardDeclarations)) { + if ($class =~ /::/) { + my $namespacePart = $class; + $namespacePart =~ s/::.*//; + + my $classPart = $class; + $classPart =~ s/${namespacePart}:://; + + print HEADER "namespace $namespacePart {\nclass $classPart;\n};\n\n"; + } else { + print HEADER "class $class;\n" + } + } + + my $hasForwardDeclarations = keys(%headerForwardDeclarations); + print HEADER "\n" if $hasForwardDeclarations; + print HEADER @headerContent; + close(HEADER); + + @headerContentHeader = (); + @headerContent = (); + %headerForwardDeclarations = (); + + # Write implementation file. + open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName"; + + print IMPL @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"; + print IMPL "#include \"$include\"\n"; + } + + print IMPL @implContent; + close(IMPL); + + @implContentHeader = (); + @implContent = (); + %implIncludes = (); +} + +1; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm new file mode 100644 index 0000000..1863d8f --- /dev/null +++ b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -0,0 +1,1441 @@ +# 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; + +# Global Variables +my %implIncludes = (); +my %hdrIncludes = (); + +my $defineTypeMacro = "G_DEFINE_TYPE"; +my $defineTypeInterfaceImplementation = ")"; +my @txtEventListeners = (); +my @txtInstallEventListeners = (); +my @txtInstallSignals = (); +my @txtInstallProps = (); +my @txtSetProps = (); +my @txtGetProps = (); + +my $className = ""; + +# Default constructor +sub new { + my $object = shift; + my $reference = { }; + + $codeGenerator = shift; + $outputDir = shift; + mkdir $outputDir; + + bless($reference, $object); +} + +sub finish { +} + +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 GenerateModule { +} + +sub GetParentClassName { + my $dataNode = shift; + + return "WebKitDOMObject" if @{$dataNode->parents} eq 0; + return "WebKitDOM" . $codeGenerator->StripModule($dataNode->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 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 $dataNode = shift; + + return "WEBKIT_TYPE_DOM_OBJECT" if @{$dataNode->parents} eq 0; + return "WEBKIT_TYPE_DOM_" . ClassNameToGObjectType($codeGenerator->StripModule($dataNode->parents(0))); +} + +sub GetClassName { + my $name = $codeGenerator->StripModule(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->{"CustomGetter"} || + $attribute->signature->extendedAttributes->{"CustomSetter"} || + $attribute->signature->extendedAttributes->{"Replaceable"}) { + return 1; + } + + my $propType = $attribute->signature->type; + if ($propType =~ /Constructor$/) { + 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; + } + + return 0; +} + +sub SkipFunction { + my $function = shift; + my $decamelize = shift; + my $prefix = shift; + + my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name); + my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"} || + $function->signature->extendedAttributes->{"CustomArgumentHandling"}; + + if ($isCustomFunction && + $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; + } + + # Skip functions that have ["Callback"] parameters, because this + # code generator doesn't know how to auto-generate callbacks. + # Skip functions that have "MediaQueryListListener" parameters, because this + # code generator doesn't know how to auto-generate MediaQueryListListener. + foreach my $param (@{$function->parameters}) { + if ($param->extendedAttributes->{"Callback"} || + $param->type eq "MediaQueryListListener") { + 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", "ushort"); + + 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"); + if ($writeable && $hasGtypeSignature) { + push(@result, $property); + } + } + + return @result; +} + +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } + } else { + return ""; + } +} + +sub GenerateProperty { + my $attribute = shift; + my $interfaceName = shift; + my @writeableProperties = @{shift @_}; + + my $conditionalString = GenerateConditionalString($attribute->signature); + 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(@cBodyPriv, "#if ${conditionalString}\n") if $conditionalString; + push(@cBodyPriv, " ${propEnum},\n"); + push(@cBodyPriv, "#endif /* ${conditionalString} */\n") if $conditionalString; + + 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 $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + + my $getterContentHead = "coreSelf->$getterExpressionPrefix"; + my $setterContentHead = "coreSelf->$setterExpressionPrefix${convertFunction}(g_value_get_$gtype(value))"; + + if (grep {$_ eq $attribute} @writeableProperties) { + push(@txtSetProps, "#if ${conditionalString}\n") if $conditionalString; + push(@txtSetProps, " case ${propEnum}:\n {\n"); + push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; + push(@txtSetProps, " ${setterContentHead}"); + push(@txtSetProps, ", ec") if @{$attribute->setterExceptions}; + push(@txtSetProps, ");\n"); + push(@txtSetProps, " break;\n }\n"); + push(@txtSetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; + } + + push(@txtGetProps, "#if ${conditionalString}\n") if $conditionalString; + push(@txtGetProps, " case ${propEnum}:\n {\n"); + + my $exception = ""; + if (@{$attribute->getterExceptions}) { + $exception = "ec"; + push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n"); + } + + my $postConvertFunction = ""; + my $done = 0; + if ($gtype eq "string") { + push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(${getterContentHead}${exception})));\n"); + $done = 1; + } elsif ($gtype eq "object") { + $txtGetProp = << "EOF"; + RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception}); + g_value_set_object(value, WebKit::kit(ptr.get())); +EOF + push(@txtGetProps, $txtGetProp); + $done = 1; + } + + # FIXME: get rid of this glitch? + my $_gtype = $gtype; + if ($gtype eq "ushort") { + $_gtype = "uint"; + } + + if (!$done) { + push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getterExpressionPrefix}${exception})${postConvertFunction});\n"); + } + + push(@txtGetProps, " break;\n }\n"); + push(@txtGetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; + + 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, "#if ${conditionalString}\n") if $conditionalString; + push(@txtInstallProps, $txtInstallProp); + push(@txtInstallProps, "#endif /* ${conditionalString} */\n") if $conditionalString; +} + +my %breakWords = ("before" => 1, "can" => 1, "context" => 1, "dbl" => 1, "drag" => 1, + "drag" => 1, "duration" => 1, "has" => 1, "key" => 1, "loaded" => 1, + "mouse" => 1, "page" => 1, "pop" => 1, "rate" => 1, "select" => 1, + "time" => 1, "touch" => 1, "volume" => 1); + +sub SplitEventListenerAttrName { + my $attrName = shift; + + my @matches = grep { $attrName =~ /^$_/ } keys (%breakWords); + + if (@matches && (length $matches[0] < length $attrName)) { + $attrName = $matches[0] . "-" . substr($attrName, length $matches[0]); + } + + return $attrName; +} + +sub EventSignalName { + my $attrName = shift; + my $name = SplitEventListenerAttrName($attrName) . "-event"; + + return $name; +} + +sub GenerateEventListener { + my $name = shift; + my $object = shift; + my $interfaceName = shift; + + my $gobjectSignalName = EventSignalName($name); + + my $txtInstallSignal = << "EOF"; + g_signal_new("${gobjectSignalName}", + G_TYPE_FROM_CLASS(gobjectClass), + G_SIGNAL_RUN_LAST, + 0, + g_signal_accumulator_true_handled, 0, + webkit_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, 1, + WEBKIT_TYPE_DOM_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + +EOF + push(@txtInstallSignals, $txtInstallSignal); + + my ${listenerName} = $name . "Listener"; + + my $txtInstallEventListener = << "EOF"; + WebCore::GObjectEventListener::addEventListener(object, coreObject, "${name}", "${gobjectSignalName}"); +EOF + push(@txtInstallEventListeners, $txtInstallEventListener); + + $implIncludes{"webkit/WebKitDOMEvent.h"} = 1; + $implIncludes{"GObjectEventListener.h"} = 1; +} + +my @eventSignalNames = ( + # User Interface Event types + "focus", "blur", + # Basic Event types + "load", "unload", "abort", "error", "select", "change", "submit", "reset", + "resize", "scroll", + # Mouse Event types + "click", "dblclick", "mousedown", "mouseup", + "mousemove", "mouseover", "mouseout", + # Mouse Wheel Event types + "mousewheel", + # Keyboard Event types + "keydown", "keypress", "keyup", + # -- Events not in the spec but defined in WebKit + # Media Event types, + "loadstart", "progress", "suspend", "emptied", "stalled", "play", + "loadedmetadata", "loadeddata", "waiting", "playing", "canplay", + "canplaythrough", "seeking", "seeked", "timeupdate", "ended", + "ratechange", "durationchange", "volumechange", + # Drag and Drop Event types + "drag", "dragend", "dragenter", "dragleave", "dragover", "dragstart", "drop", + # Cut and Paste Event types + "beforecut", "cut", "beforecopy", "copy", "beforepaste", "paste", + # Animations + "webkitanimationend", "webkitanimationstart", "webkitanimationiteration", + # Other + "contextmenu", "input", "invalid", "search", "selectstart"); + +sub GenerateProperties { + my ($object, $interfaceName, $dataNode) = @_; + + my $clsCaps = substr(ClassNameToGObjectType($className), 12); + my $lowerCaseIfaceName = "webkit_dom_" . (FixUpDecamelizedName(decamelize($interfaceName))); + + # Properties + my $implContent = ""; + + # Properties + $implContent = << "EOF"; +enum { + PROP_0, +EOF + push(@cBodyPriv, $implContent); + + my @readableProperties = GetReadableProperties($dataNode->attributes); + + my $privFunction = GetCoreObject($interfaceName, "coreSelf", "self"); + + my $txtGetProp = << "EOF"; +static void ${lowerCaseIfaceName}_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; +EOF + push(@txtGetProps, $txtGetProp); + if (scalar @readableProperties > 0) { + $txtGetProp = << "EOF"; + ${className}* self = WEBKIT_DOM_${clsCaps}(object); + $privFunction +EOF + push(@txtGetProps, $txtGetProp); + } + + $txtGetProp = << "EOF"; + switch (prop_id) { +EOF + push(@txtGetProps, $txtGetProp); + + my @writeableProperties = GetWriteableProperties(\@readableProperties); + + my $txtSetProps = << "EOF"; +static void ${lowerCaseIfaceName}_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; +EOF + push(@txtSetProps, $txtSetProps); + + if (scalar @writeableProperties > 0) { + $txtSetProps = << "EOF"; + ${className}* self = WEBKIT_DOM_${clsCaps}(object); + $privFunction +EOF + push(@txtSetProps, $txtSetProps); + } + + $txtSetProps = << "EOF"; + switch (prop_id) { +EOF + push(@txtSetProps, $txtSetProps); + + foreach my $attribute (@readableProperties) { + if ($attribute->signature->type ne "EventListener" && + $attribute->signature->type ne "MediaQueryListListener") { + GenerateProperty($attribute, $interfaceName, \@writeableProperties); + } + } + + # We need to define all the events there are in all base classes + # that implement EventTarget. For now we only care about these + # two. + if ($interfaceName eq "Node" || $interfaceName eq "DOMWindow") { + foreach my $signalName (@eventSignalNames) { + GenerateEventListener($signalName, $object, $interfaceName); + } + } + + push(@cBodyPriv, "};\n\n"); + + $txtGetProp = << "EOF"; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} +EOF + push(@txtGetProps, $txtGetProp); + + $txtSetProps = << "EOF"; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} +EOF + push(@txtSetProps, $txtSetProps); + + # Do not insert extra spaces when interpolating array variables + $" = ""; + + $implContent = << "EOF"; + +static void ${lowerCaseIfaceName}_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject) { + WebCore::${interfaceName}* coreObject = static_cast<WebCore::${interfaceName} *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->finalize(object); +} + +@txtSetProps + +@txtGetProps + +static void ${lowerCaseIfaceName}_constructed(GObject* object) +{ +EOF + push(@cBodyPriv, $implContent); + + if (scalar @txtInstallEventListeners > 0) { + $implContent = << "EOF"; + WebCore::${interfaceName}* coreObject = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(object)->coreObject); +EOF + push(@cBodyPriv, $implContent); + } + + $implContent = << "EOF"; +@txtInstallEventListeners + if (G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->constructed) + G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->constructed(object); +} + +static void ${lowerCaseIfaceName}_class_init(${className}Class* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = ${lowerCaseIfaceName}_finalize; + gobjectClass->set_property = ${lowerCaseIfaceName}_set_property; + gobjectClass->get_property = ${lowerCaseIfaceName}_get_property; + gobjectClass->constructed = ${lowerCaseIfaceName}_constructed; + +@txtInstallProps +@txtInstallSignals +} + +static void ${lowerCaseIfaceName}_init(${className}* request) +{ +} + +EOF + push(@cBodyPriv, $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 getIncludeHeader { + my $type = shift; + my $name = GetClassName($type); + + return "" if $type eq "int"; + return "" if $type eq "long"; + return "" if $type eq "long long"; + return "" if $type eq "short"; + return "" if $type eq "char"; + return "" if $type eq "float"; + return "" if $type eq "double"; + return "" if $type eq "unsigned"; + return "" if $type eq "unsigned int"; + return "" if $type eq "unsigned long"; + return "" if $type eq "unsigned long long"; + return "" if $type eq "unsigned short"; + return "" if $type eq "DOMTimeStamp"; + return "" if $type eq "EventListener"; + return "" if $type eq "MediaQueryListListener"; + return "" if $type eq "unsigned char"; + return "" if $type eq "DOMString"; + return "" if $type eq "float"; + return "" if $type eq "boolean"; + return "" if $type eq "void"; + return "" if $type eq "CompareHow"; + + return "$name.h"; +} + +sub addIncludeInBody { + my $type = shift; + + if ($type eq "DOMObject") { + return; + } + + my $header = getIncludeHeader($type); + if ($header eq "") { + return; + } + + if (IsGDOMClassType($type)) { + $implIncludes{"webkit/$header"} = 1; + } else { + $implIncludes{$header} = 1 + } +} + +sub GenerateFunction { + my ($object, $interfaceName, $function, $prefix) = @_; + + my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); + + if ($object eq "MediaQueryListListener") { + return; + } + + if (SkipFunction($function, $decamelize, $prefix)) { + return; + } + + my $functionSigName = $function->signature->name; + my $functionSigType = $prefix eq "set_" ? "void" : $function->signature->type; + my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($functionSigName); + my $returnType = GetGlibTypeName($functionSigType); + my $returnValueIsGDOMType = IsGDOMClassType($functionSigType); + my $conditionalString = GenerateConditionalString($function->signature); + + my $functionSig = "${className}* self"; + + my $callImplParams = ""; + + # skip some custom functions for now + my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"} || + $function->signature->extendedAttributes->{"CustomArgumentHandling"}; + + foreach my $param (@{$function->parameters}) { + my $paramIDLType = $param->type; + if ($paramIDLType eq "EventListener" || $paramIDLType eq "MediaQueryListListener") { + push(@hBody, "\n/* TODO: event function ${functionName} */\n\n"); + push(@cBody, "\n/* TODO: event function ${functionName} */\n\n"); + return; + } + addIncludeInBody($paramIDLType); + my $paramType = GetGlibTypeName($paramIDLType); + my $const = $paramType eq "gchar*" ? "const " : ""; + my $paramName = decamelize($param->name); + + $functionSig .= ", ${const}$paramType $paramName"; + + my $paramIsGDOMType = IsGDOMClassType($paramIDLType); + if ($paramIsGDOMType) { + if ($paramIDLType ne "DOMObject") { + $implIncludes{"webkit/WebKitDOM${paramIDLType}Private.h"} = 1; + } + } + if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) { + $paramName = "converted_" . $paramName; + } + if ($callImplParams) { + $callImplParams .= ", $paramName"; + } else { + $callImplParams = "$paramName"; + } + } + + # Not quite sure what to do with this yet, but we need to take into + # account the difference in parameters between the IDL file and the + # actual implementation. + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionSig .= ", gboolean isUserGesture"; + $callImplParams .= ", " if $callImplParams; + $callImplParams .= "false"; + } + + if ($returnType ne "void" && $returnValueIsGDOMType && $functionSigType ne "DOMObject") { + if ($functionSigType ne "EventTarget") { + $implIncludes{"webkit/WebKitDOM${functionSigType}Private.h"} = 1; + $implIncludes{"webkit/WebKitDOM${functionSigType}.h"} = 1; + } else { + $implIncludes{"WebKitDOM${functionSigType}.h"} = 1; + } + + $implIncludes{"${functionSigType}.h"} = 1; + } + + if(@{$function->raisesExceptions}) { + $functionSig .= ", GError **error"; + } + + push(@hBody, "WEBKIT_API $returnType\n$functionName($functionSig);\n"); + push(@hBody, "\n"); + + push(@cBody, "$returnType\n$functionName($functionSig)\n{\n"); + push(@cBody, "#if ${conditionalString}\n") if $conditionalString; + + if ($returnType ne "void") { + # TODO: return proper default result + push(@cBody, " g_return_val_if_fail(self, 0);\n"); + } else { + push(@cBody, " g_return_if_fail(self);\n"); + } + + push(@cBody, " WebCore::JSMainThreadNullState state;\n"); + + # The WebKit::core implementations check for NULL already; no need to + # duplicate effort. + push(@cBody, " WebCore::${interfaceName} * item = WebKit::core(self);\n"); + + foreach my $param (@{$function->parameters}) { + my $paramName = decamelize($param->name); + my $paramIDLType = $param->type; + my $paramTypeIsPrimitive = $codeGenerator->IsPrimitiveType($paramIDLType); + my $paramIsGDOMType = IsGDOMClassType($paramIDLType); + if (!$paramTypeIsPrimitive) { + if ($returnType ne "void") { + # TODO: return proper default result + # 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"))) { + push(@cBody, " g_return_val_if_fail($paramName, 0);\n"); + } + } else { + push(@cBody, " g_return_if_fail($paramName);\n"); + } + } + } + + $returnParamName = ""; + foreach my $param (@{$function->parameters}) { + my $paramIDLType = $param->type; + my $paramName = decamelize($param->name); + + my $paramIsGDOMType = IsGDOMClassType($paramIDLType); + if ($paramIDLType eq "DOMString") { + push(@cBody, " WTF::String converted_${paramName} = WTF::String::fromUTF8($paramName);\n"); + } elsif ($paramIDLType eq "CompareHow") { + push(@cBody, " WebCore::Range::CompareHow converted_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); + } elsif ($paramIsGDOMType) { + push(@cBody, " WebCore::${paramIDLType} * converted_${paramName} = NULL;\n"); + push(@cBody, " if (${paramName} != NULL) {\n"); + push(@cBody, " converted_${paramName} = WebKit::core($paramName);\n"); + + if ($returnType ne "void") { + # TODO: return proper default result + push(@cBody, " g_return_val_if_fail(converted_${paramName}, 0);\n"); + } else { + push(@cBody, " g_return_if_fail(converted_${paramName});\n"); + } + + push(@cBody, " }\n"); + } + $returnParamName = "converted_".$paramName if $param->extendedAttributes->{"Return"}; + } + + 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 = "PassRefPtr<WebCore::${functionSigType}> g_res = "; + $assignPre = "WTF::getPtr("; + $assignPost = ")"; + } else { + $assign = "${returnType} res = "; + } + } + my $exceptions = ""; + if (@{$function->raisesExceptions}) { + push(@cBody, " WebCore::ExceptionCode ec = 0;\n"); + if (${callImplParams} ne "") { + $exceptions = ", ec"; + } else { + $exceptions = "ec"; + } + } + + if ($functionHasCustomReturn) { + my $customNodeAppendChild = << "EOF"; + bool ok = item->${functionSigName}(${callImplParams}${exceptions}); + if (ok) + { + ${returnType} res = WebKit::kit($returnParamName); + return res; + } +EOF + push(@cBody, $customNodeAppendChild); + + if(@{$function->raisesExceptions}) { + my $exceptionHandling = << "EOF"; + + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); +EOF + push(@cBody, $exceptionHandling); + } + push(@cBody, "return NULL;"); + push(@cBody, "}\n\n"); + return; + } elsif ($functionSigType eq "DOMString") { + my $getterContentHead; + if ($prefix) { + my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $function); + $getterContentHead = "${assign}convertToUTF8String(item->$getterExpressionPrefix${exceptions}));\n"; + } else { + $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n"; + } + push(@cBody, " ${getterContentHead}"); + } else { + my $contentHead; + if ($prefix eq "get_") { + my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $function); + $contentHead = "${assign}${assignPre}item->$getterExpressionPrefix${callImplParams}${exceptions}${assignPost});\n"; + } elsif ($prefix eq "set_") { + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $function); + $contentHead = "${assign}${assignPre}item->$setterExpressionPrefix${callImplParams}${exceptions}${assignPost});\n"; + } else { + $contentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n"; + } + push(@cBody, " ${contentHead}"); + + if(@{$function->raisesExceptions}) { + my $exceptionHandling = << "EOF"; + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + 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, " ${returnType} res = WebKit::kit(g_res.get());\n"); + } + } + if ($functionSigType eq "DOMObject") { + push(@cBody, " return NULL; /* TODO: return canvas object */\n"); + } else { + push(@cBody, " return res;\n"); + } + } + + if ($conditionalString) { + if ($returnType ne "void") { + push(@cBody, "#else\n"); + if ($codeGenerator->IsNonPointerType($functionSigType)) { + push(@cBody, " return static_cast<${returnType}>(0);\n"); + } else { + push(@cBody, " return NULL;\n"); + } + } + push(@cBody, "#endif /* ${conditionalString} */\n") if $conditionalString; + } + + 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, $dataNode) = @_; + + foreach my $function (@{$dataNode->functions}) { + $object->GenerateFunction($interfaceName, $function, ""); + } + + TOP: + foreach my $attribute (@{$dataNode->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($dataNode, $getname) || ClassHasFunction($dataNode, $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_"); + + if ($attribute->type =~ /^readonly/) { + 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_"); + } +} + +sub GenerateCFile { + my ($object, $interfaceName, $parentClassName, $parentGObjType, $dataNode) = @_; + + if ($dataNode->extendedAttributes->{"EventTarget"}) { + $object->GenerateEventTargetIface($dataNode); + } + + my $implContent = ""; + + my $clsCaps = uc(FixUpDecamelizedName(decamelize($interfaceName))); + my $lowerCaseIfaceName = "webkit_dom_" . FixUpDecamelizedName(decamelize($interfaceName)); + + $implContent = << "EOF"; +${defineTypeMacro}(${className}, ${lowerCaseIfaceName}, ${parentGObjType}${defineTypeInterfaceImplementation} + +namespace WebKit { + +WebCore::${interfaceName}* core(${className}* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::${interfaceName}* coreObject = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +} // namespace WebKit +EOF + + push(@cBodyPriv, $implContent); + $object->GenerateProperties($interfaceName, $dataNode); + $object->GenerateFunctions($interfaceName, $dataNode); + + my $wrapMethod = << "EOF"; +namespace WebKit { +${className}* wrap${interfaceName}(WebCore::${interfaceName}* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + coreObject->ref(); + + return WEBKIT_DOM_${clsCaps}(g_object_new(WEBKIT_TYPE_DOM_${clsCaps}, + "core-object", coreObject, NULL)); +} +} // namespace WebKit +EOF + push(@cBodyPriv, $wrapMethod); +} + +sub GenerateEndHeader { + my ($object) = @_; + + #Header guard + my $guard = $className . "_h"; + + push(@hBody, "G_END_DECLS\n\n"); + push(@hPrefixGuardEnd, "#endif /* $guard */\n"); +} + +sub GeneratePrivateHeader { + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $filename = "$outputDir/" . $className . "Private.h"; + my $guard = uc(decamelize($className)) . "_PRIVATE_H"; + my $parentClassName = GetParentClassName($dataNode); + my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; + my $hasRealParent = @{$dataNode->parents} > 0; + my $hasParent = $hasLegacyParent || $hasRealParent; + + 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 <glib-object.h> +#include <webkit/${parentClassName}.h> +#include "${interfaceName}.h" +EOF + + print PRIVHEADER $text; + + print PRIVHEADER map { "#include \"$_\"\n" } sort keys(%hdrPropIncludes); + print PRIVHEADER "\n" if keys(%hdrPropIncludes); + + $text = << "EOF"; +namespace WebKit { + ${className} * + wrap${interfaceName}(WebCore::${interfaceName} *coreObject); + + WebCore::${interfaceName} * + core(${className} *request); + +EOF + + print PRIVHEADER $text; + + if ($className ne "WebKitDOMNode") { + $text = << "EOF"; + ${className}* + kit(WebCore::${interfaceName}* node); + +EOF + print PRIVHEADER $text; + } + + $text = << "EOF"; +} // namespace WebKit + +#endif /* ${guard} */ +EOF + print PRIVHEADER $text; + + close(PRIVHEADER); +} + +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 $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); + + $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; + WebCore::getExceptionCodeDescription(ec, description); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name); + } +} + +static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface) +{ + iface->dispatch_event = webkit_dom_${decamelize}_dispatch_event; +} + +EOF + + push(@cBody, $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, $dataNode) = @_; + + my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; + my $hasRealParent = @{$dataNode->parents} > 0; + my $hasParent = $hasLegacyParent || $hasRealParent; + my $parentClassName = GetParentClassName($dataNode); + my $parentGObjType = GetParentGObjType($dataNode); + my $interfaceName = $dataNode->name; + + # Add the guard if the 'Conditional' extended attribute exists + my $conditionalString = GenerateConditionalString($dataNode); + push(@conditionGuardStart, "#if ${conditionalString}\n\n") if $conditionalString; + push(@conditionGuardEnd, "#endif /* ${conditionalString} */\n") if $conditionalString; + + # Add the default impl header template + @cPrefix = split("\r", $licenceTemplate); + push(@cPrefix, "\n"); + + $implIncludes{"webkitdefines.h"} = 1; + $implIncludes{"webkitglobalsprivate.h"} = 1; + $implIncludes{"webkitmarshal.h"} = 1; + $implIncludes{"DOMObjectCache.h"} = 1; + $implIncludes{"WebKitDOMBinding.h"} = 1; + $implIncludes{"gobject/ConvertToUTF8String.h"} = 1; + $implIncludes{"webkit/$className.h"} = 1; + $implIncludes{"webkit/${className}Private.h"} = 1; + $implIncludes{"${interfaceName}.h"} = 1; + $implIncludes{"JSMainThreadExecState.h"} = 1; + $implIncludes{"ExceptionCode.h"} = 1; + + $hdrIncludes{"webkit/${parentClassName}.h"} = 1; + + if (!UsesManualKitImplementation($interfaceName)) { + my $converter = << "EOF"; +namespace WebKit { + +${className}* kit(WebCore::$interfaceName* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<${className}*>(ret); + + return static_cast<${className}*>(DOMObjectCache::put(obj, WebKit::wrap${interfaceName}(obj))); +} + +} // namespace WebKit // + +EOF + push(@cBody, $converter); + } + + $object->GenerateHeader($interfaceName, $parentClassName); + $object->GenerateCFile($interfaceName, $parentClassName, $parentGObjType, $dataNode); + $object->GenerateEndHeader(); + $object->GeneratePrivateHeader($dataNode); + +} + +# Internal helper +sub WriteData { + my ($object, $name) = @_; + + # Write public header. + my $hdrFName = "$outputDir/" . $name . ".h"; + open(HEADER, ">$hdrFName") or die "Couldn't open file $hdrFName"; + + print HEADER @hPrefix; + print HEADER @hPrefixGuard; + print HEADER "#include \"webkit/webkitdomdefines.h\"\n"; + print HEADER "#include <glib-object.h>\n"; + print HEADER "#include <webkit/webkitdefines.h>\n"; + print HEADER map { "#include \"$_\"\n" } sort keys(%hdrIncludes); + print HEADER "\n" if keys(%hdrIncludes); + print HEADER "\n"; + print HEADER @hBodyPre; + print HEADER @hBody; + print HEADER @hPrefixGuardEnd; + + close(HEADER); + + # Write the implementation sources + my $implFileName = "$outputDir/" . $name . ".cpp"; + open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName"; + + print IMPL @cPrefix; + print IMPL "#include <glib-object.h>\n"; + print IMPL "#include \"config.h\"\n\n"; + print IMPL @conditionGuardStart; + print IMPL "#include <wtf/GetPtr.h>\n"; + print IMPL "#include <wtf/RefPtr.h>\n"; + print IMPL map { "#include \"$_\"\n" } sort keys(%implIncludes); + print IMPL "\n" if keys(%implIncludes); + print IMPL @cBody; + + print IMPL "\n"; + print IMPL @cBodyPriv; + print IMPL @conditionGuardEnd; + + close(IMPL); + + %implIncludes = (); + %hdrIncludes = (); + @hPrefix = (); + @hBody = (); + + @cPrefix = (); + @cBody = (); + @cBodyPriv = (); +} + +sub GenerateInterface { + my ($object, $dataNode, $defines) = @_; + my $name = $dataNode->name; + + # Set up some global variables + $className = GetClassName($dataNode->name); + $object->Generate($dataNode); + + # Write changes + my $fname = "WebKitDOM_" . $name; + $fname =~ s/_//g; + $object->WriteData($fname); +} diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm new file mode 100644 index 0000000..cff51e9 --- /dev/null +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -0,0 +1,2985 @@ +# +# 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) +# +# 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; + +my $module = ""; +my $outputDir = ""; +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; + $outputDir = shift; + shift; # $outputHeadersDir + shift; # $useLayerOnTop + shift; # $preprocessor + $writeDependencies = shift; + + bless($reference, $object); + return $reference; +} + +sub finish +{ + my $object = shift; + + # Commit changes! + $object->WriteData(); +} + +sub leftShift($$) { + my ($value, $distance) = @_; + return (($value << $distance) & 0xFFFFFFFF); +} + +# Params: 'domClass' struct +sub GenerateInterface +{ + my $object = shift; + my $dataNode = shift; + my $defines = shift; + + $codeGenerator->LinkOverloadedFunctions($dataNode); + + # Start actual generation + if ($dataNode->extendedAttributes->{"Callback"}) { + $object->GenerateCallbackHeader($dataNode); + $object->GenerateCallbackImplementation($dataNode); + } else { + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + } + + my $name = $dataNode->name; + + # Open files for writing + my $headerFileName = "$outputDir/JS$name.h"; + my $implFileName = "$outputDir/JS$name.cpp"; + my $depsFileName = "$outputDir/JS$name.dep"; + + # Remove old dependency file. + unlink($depsFileName); + + open($IMPL, ">$implFileName") || die "Couldn't open file $implFileName"; + open($HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName"; + if (@depsContent) { + open($DEPS, ">$depsFileName") || die "Couldn't open file $depsFileName"; + } +} + +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, imp->correspondingElement()); + if (correspondingElementWrapper.isObject()) +END + + # Add leading whitespace to format the imp->set... line correctly + push(@GenerateEventListenerImpl, " "); + } + + push(@GenerateEventListenerImpl, " imp->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, imp->correspondingElement()); + if (!correspondingElementWrapper.isObject()) + return JSValue::encode(jsUndefined()); +END + } + + push(@GenerateEventListenerImpl, <<END); + JSValue listener = exec->argument(1); + if (!listener.isObject()) + return JSValue::encode(jsUndefined()); + imp->${functionName}EventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), $wrapperObject, false, currentWorld(exec))$passRefPtrHandling, exec->argument(2).toBoolean(exec)); + return JSValue::encode(jsUndefined()); +END + return @GenerateEventListenerImpl; +} + +# Params: 'idlDocument' struct +sub GenerateModule +{ + my $object = shift; + my $dataNode = shift; + + $module = $dataNode->module; +} + +sub GetParentClassName +{ + my $dataNode = shift; + + return $dataNode->extendedAttributes->{"LegacyParent"} if $dataNode->extendedAttributes->{"LegacyParent"}; + return "DOMObjectWithGlobalPointer" if (@{$dataNode->parents} eq 0); + return "JS" . $codeGenerator->StripModule($dataNode->parents(0)); +} + +sub GetVisibleClassName +{ + my $className = shift; + + return "DOMException" if $className eq "DOMCoreException"; + return "FormData" if $className eq "DOMFormData"; + return "MimeType" if $className eq "DOMMimeType"; + return "MimeTypeArray" if $className eq "DOMMimeTypeArray"; + return "Plugin" if $className eq "DOMPlugin"; + return "PluginArray" if $className eq "DOMPluginArray"; + + return $className; +} + +sub GetCallbackClassName +{ + my $className = shift; + + return "JSCustomVoidCallback" if $className eq "VoidCallback"; + 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 "DOMTokenList" or $type eq "DOMSettableTokenList"; + return 0; +} + +sub AddIncludesForType +{ + my $type = $codeGenerator->StripModule(shift); + my $isCallback = @_ ? shift : 0; + + # When we're finished with the one-file-per-class + # reorganization, we won't need these special cases. + if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->AvoidInclusionOfType($type) + or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") { + } elsif ($type =~ /SVGPathSeg/) { + $joinedName = $type; + $joinedName =~ s/Abs|Rel//; + $implIncludes{"${joinedName}.h"} = 1; + } elsif ($type eq "XPathNSResolver") { + $implIncludes{"JSXPathNSResolver.h"} = 1; + $implIncludes{"JSCustomXPathNSResolver.h"} = 1; + } elsif ($isCallback) { + $implIncludes{"JS${type}.h"} = 1; + } else { + # default, include the same named file + $implIncludes{"${type}.h"} = 1; + } + + # 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{"PlatformString.h"} = 1; + } + + if ($type eq "Document") { + $implIncludes{"NodeFilter.h"} = 1; + } + + if ($type eq "MediaQueryListListener") { + $implIncludes{"MediaQueryListListener.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{"PlatformString.h"} = 1; + } +} + +sub IsScriptProfileType +{ + my $type = shift; + return 1 if ($type eq "ScriptProfileNode"); + return 0; +} + +sub AddTypedefForScriptProfileType +{ + my $type = shift; + (my $jscType = $type) =~ s/Script//; + + push(@headerContent, "typedef JSC::$jscType $type;\n\n"); +} + +sub AddClassForwardIfNeeded +{ + my $implClassName = shift; + + # SVGAnimatedLength/Number/etc. are typedefs to SVGAnimatedTemplate, so don't use class forwards for them! + unless ($codeGenerator->IsSVGAnimatedType($implClassName) or IsScriptProfileType($implClassName)) { + push(@headerContent, "class $implClassName;\n\n"); + # ScriptProfile and ScriptProfileNode are typedefs to JSC::Profile and JSC::ProfileNode. + } elsif (IsScriptProfileType($implClassName)) { + AddTypedefForScriptProfileType($implClassName); + } +} + +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 GenerateConditionalStringFromAttributeValue +{ + my $conditional = shift; + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } +} + +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return GenerateConditionalStringFromAttributeValue($conditional); + } else { + return ""; + } +} + +sub GenerateGetOwnPropertySlotBody +{ + my ($dataNode, $interfaceName, $className, $implClassName, $hasAttributes, $inlined) = @_; + + my $namespaceMaybe = ($inlined ? "JSC::" : ""); + + my @getOwnPropertySlotImpl = (); + + if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { + push(@getOwnPropertySlotImpl, " ${namespaceMaybe}JSValue proto = prototype();\n"); + push(@getOwnPropertySlotImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); + push(@getOwnPropertySlotImpl, " return false;\n\n"); + } + + my $manualLookupGetterGeneration = sub { + my $requiresManualLookup = $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasNameGetter"}; + if ($requiresManualLookup) { + push(@getOwnPropertySlotImpl, " const ${namespaceMaybe}HashEntry* entry = ${className}Table.entry(exec, propertyName);\n"); + push(@getOwnPropertySlotImpl, " if (entry) {\n"); + push(@getOwnPropertySlotImpl, " slot.setCustom(this, entry->propertyGetter());\n"); + push(@getOwnPropertySlotImpl, " return true;\n"); + push(@getOwnPropertySlotImpl, " }\n"); + } + }; + + if (!$dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + &$manualLookupGetterGeneration(); + } + + if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@getOwnPropertySlotImpl, " bool ok;\n"); + push(@getOwnPropertySlotImpl, " unsigned index = propertyName.toUInt32(ok);\n"); + + # If the item function returns a string then we let the ConvertNullStringTo handle the cases + # where the index is out of range. + if (IndexGetterReturnsStrings($implClassName)) { + push(@getOwnPropertySlotImpl, " if (ok) {\n"); + } else { + push(@getOwnPropertySlotImpl, " if (ok && index < static_cast<$implClassName*>(impl())->length()) {\n"); + } + if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@getOwnPropertySlotImpl, " slot.setValue(getByIndex(exec, index));\n"); + } else { + push(@getOwnPropertySlotImpl, " slot.setCustomIndex(this, index, indexGetter);\n"); + } + push(@getOwnPropertySlotImpl, " return true;\n"); + push(@getOwnPropertySlotImpl, " }\n"); + } + + if ($dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + push(@getOwnPropertySlotImpl, " if (canGetItemsForName(exec, static_cast<$implClassName*>(impl()), propertyName)) {\n"); + push(@getOwnPropertySlotImpl, " slot.setCustom(this, 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 ($dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + &$manualLookupGetterGeneration(); + } + + if ($dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"}) { + push(@getOwnPropertySlotImpl, " if (getOwnPropertySlotDelegate(exec, propertyName, slot))\n"); + push(@getOwnPropertySlotImpl, " return true;\n"); + } + + if ($hasAttributes) { + if ($inlined) { + die "Cannot inline if NoStaticTables is set." if ($dataNode->extendedAttributes->{"NoStaticTables"}); + push(@getOwnPropertySlotImpl, " return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, s_info.staticPropHashTable, this, propertyName, slot);\n"); + } else { + push(@getOwnPropertySlotImpl, " return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, " . hashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, slot);\n"); + } + } else { + push(@getOwnPropertySlotImpl, " return Base::getOwnPropertySlot(exec, propertyName, slot);\n"); + } + + return @getOwnPropertySlotImpl; +} + +sub GenerateGetOwnPropertyDescriptorBody +{ + my ($dataNode, $interfaceName, $className, $implClassName, $hasAttributes, $inlined) = @_; + + my $namespaceMaybe = ($inlined ? "JSC::" : ""); + + my @getOwnPropertyDescriptorImpl = (); + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"}) { + if ($interfaceName eq "DOMWindow") { + push(@implContent, " if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); + } else { + push(@implContent, " if (!allowsAccessFromFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n"); + } + push(@implContent, " return false;\n"); + } + + if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { + push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}JSValue proto = prototype();\n"); + push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); + push(@getOwnPropertyDescriptorImpl, " return false;\n\n"); + } + + my $manualLookupGetterGeneration = sub { + my $requiresManualLookup = $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasNameGetter"}; + 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(this, entry->propertyGetter());\n"); + push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());\n"); + push(@getOwnPropertyDescriptorImpl, " return true;\n"); + push(@getOwnPropertyDescriptorImpl, " }\n"); + } + }; + + if (!$dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + &$manualLookupGetterGeneration(); + } + + if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@getOwnPropertyDescriptorImpl, " bool ok;\n"); + push(@getOwnPropertyDescriptorImpl, " unsigned index = propertyName.toUInt32(ok);\n"); + push(@getOwnPropertyDescriptorImpl, " if (ok && index < static_cast<$implClassName*>(impl())->length()) {\n"); + if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + # Assume that if there's a setter, the index will be writable + if ($dataNode->extendedAttributes->{"HasIndexSetter"} || $dataNode->extendedAttributes->{"HasCustomIndexSetter"}) { + push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(getByIndex(exec, index), ${namespaceMaybe}DontDelete);\n"); + } else { + push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(getByIndex(exec, index), ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly);\n"); + } + } else { + push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}PropertySlot slot;\n"); + push(@getOwnPropertyDescriptorImpl, " slot.setCustomIndex(this, index, indexGetter);\n"); + # Assume that if there's a setter, the index will be writable + if ($dataNode->extendedAttributes->{"HasIndexSetter"} || $dataNode->extendedAttributes->{"HasCustomIndexSetter"}) { + 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 ($dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + push(@getOwnPropertyDescriptorImpl, " if (canGetItemsForName(exec, static_cast<$implClassName*>(impl()), propertyName)) {\n"); + push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}PropertySlot slot;\n"); + push(@getOwnPropertyDescriptorImpl, " slot.setCustom(this, 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 ($dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + &$manualLookupGetterGeneration(); + } + + if ($dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"}) { + push(@getOwnPropertyDescriptorImpl, " if (getOwnPropertyDescriptorDelegate(exec, propertyName, descriptor))\n"); + push(@getOwnPropertyDescriptorImpl, " return true;\n"); + } + + if ($hasAttributes) { + if ($inlined) { + die "Cannot inline if NoStaticTables is set." if ($dataNode->extendedAttributes->{"NoStaticTables"}); + push(@getOwnPropertyDescriptorImpl, " return ${namespaceMaybe}getStaticValueDescriptor<$className, Base>(exec, s_info.staticPropHashTable, this, propertyName, descriptor);\n"); + } else { + push(@getOwnPropertyDescriptorImpl, " return ${namespaceMaybe}getStaticValueDescriptor<$className, Base>(exec, " . hashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, descriptor);\n"); + } + } else { + push(@getOwnPropertyDescriptorImpl, " return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor);\n"); + } + + return @getOwnPropertyDescriptorImpl; +} + +sub GenerateHeaderContentHeader +{ + my $dataNode = shift; + my $className = "JS" . $dataNode->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 = GenerateConditionalString($dataNode); + push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; + return @headerContentHeader; +} + +sub GenerateImplementationContentHeader +{ + my $dataNode = shift; + my $className = "JS" . $dataNode->name; + + my @implContentHeader = split("\r", $headerTemplate); + + push(@implContentHeader, "\n#include \"config.h\"\n"); + my $conditionalString = GenerateConditionalString($dataNode); + 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 GenerateHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + my $implClassName = $interfaceName; + my @ancestorInterfaceNames = (); + my %structureFlags = (); + + # We only support multiple parents with SVG (for now). + if (@{$dataNode->parents} > 1) { + die "A class can't have more than one parent" unless $interfaceName =~ /SVG/; + $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@ancestorInterfaceNames); + } + + my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; + my $hasRealParent = @{$dataNode->parents} > 0; + my $hasParent = $hasLegacyParent || $hasRealParent; + my $parentClassName = GetParentClassName($dataNode); + my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"}; + my $needsMarkChildren = $dataNode->extendedAttributes->{"CustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"}; + + # - Add default header template and header protection + push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); + + if ($hasParent) { + $headerIncludes{"$parentClassName.h"} = 1; + } else { + $headerIncludes{"JSDOMBinding.h"} = 1; + $headerIncludes{"<runtime/JSGlobalObject.h>"} = 1; + $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1; + } + + if ($dataNode->extendedAttributes->{"CustomCall"}) { + $headerIncludes{"<runtime/CallData.h>"} = 1; + } + + if ($dataNode->extendedAttributes->{"InlineGetOwnPropertySlot"}) { + $headerIncludes{"<runtime/Lookup.h>"} = 1; + $headerIncludes{"<wtf/AlwaysInline.h>"} = 1; + } + + if ($hasParent && $dataNode->extendedAttributes->{"GenerateNativeConverter"}) { + $headerIncludes{"$implClassName.h"} = 1; + } + + $headerIncludes{"<runtime/JSObjectWithGlobalObject.h>"} = 1; + $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/; + + my $implType = $implClassName; + my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implType); + $implType = $svgNativeType if $svgNativeType; + + my $svgPropertyOrListPropertyType; + $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType; + $svgPropertyOrListPropertyType = $svgListPropertyType if $svgListPropertyType; + + my $numConstants = @{$dataNode->constants}; + my $numAttributes = @{$dataNode->attributes}; + my $numFunctions = @{$dataNode->functions}; + + push(@headerContent, "\nnamespace WebCore {\n\n"); + + if ($codeGenerator->IsSVGAnimatedType($implClassName)) { + $headerIncludes{"$implClassName.h"} = 1; + } else { + # Implementation class forward declaration + AddClassForwardIfNeeded($implClassName) unless $svgPropertyOrListPropertyType; + } + + AddClassForwardIfNeeded("JSDOMWindowShell") if $interfaceName eq "DOMWindow"; + + # Class declaration + push(@headerContent, "class $className : public $parentClassName {\n"); + push(@headerContent, " typedef $parentClassName Base;\n"); + push(@headerContent, "public:\n"); + + # Constructor + if ($interfaceName eq "DOMWindow") { + push(@headerContent, " $className(NonNullPassRefPtr<JSC::Structure>, PassRefPtr<$implType>, JSDOMWindowShell*);\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@headerContent, " $className(NonNullPassRefPtr<JSC::Structure>, PassRefPtr<$implType>);\n"); + } else { + push(@headerContent, " $className(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<$implType>);\n"); + } + + # Destructor + push(@headerContent, " virtual ~$className();\n") if (!$hasParent or $eventTarget or $interfaceName eq "DOMWindow"); + + # Prototype + push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}); + + $headerTrailingIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"}; + + $implIncludes{"${className}Custom.h"} = 1 if !$dataNode->extendedAttributes->{"CustomHeader"} && ($dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"}); + + my $hasGetter = $numAttributes > 0 + || !($dataNode->extendedAttributes->{"OmitConstructor"} + || $dataNode->extendedAttributes->{"CustomConstructor"}) + || $dataNode->extendedAttributes->{"HasIndexGetter"} + || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} + || $dataNode->extendedAttributes->{"HasNumericIndexGetter"} + || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"} + || $dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"} + || $dataNode->extendedAttributes->{"HasNameGetter"} + || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}; + + # Getters + if ($hasGetter) { + push(@headerContent, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);\n"); + push(@headerContent, " virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);\n"); + push(@headerContent, " virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);\n") if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"}; + push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"}; + push(@headerContent, " bool getOwnPropertyDescriptorDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n") if $dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"}; + $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1; + } + + # Check if we have any writable properties + my $hasReadWriteProperties = 0; + foreach (@{$dataNode->attributes}) { + if ($_->type !~ /^readonly\ attribute$/) { + $hasReadWriteProperties = 1; + } + } + + my $hasSetter = $hasReadWriteProperties + || $dataNode->extendedAttributes->{"CustomPutFunction"} + || $dataNode->extendedAttributes->{"DelegatingPutFunction"} + || $dataNode->extendedAttributes->{"HasCustomIndexSetter"}; + + # Getters + if ($hasSetter) { + push(@headerContent, " virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);\n"); + push(@headerContent, " virtual void put(JSC::ExecState*, unsigned propertyName, JSC::JSValue);\n") if $dataNode->extendedAttributes->{"HasCustomIndexSetter"}; + push(@headerContent, " bool putDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, JSC::PutPropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingPutFunction"}; + } + + # Class info + push(@headerContent, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); + push(@headerContent, " static const JSC::ClassInfo s_info;\n\n"); + + # Structure ID + if ($interfaceName eq "DOMWindow") { + $structureFlags{"JSC::ImplementsHasInstance"} = 1; + $structureFlags{"JSC::NeedsThisConversion"} = 1; + } + push(@headerContent, + " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . + " {\n" . + " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n" . + " }\n\n"); + + # markChildren function + if ($needsMarkChildren) { + push(@headerContent, " virtual void markChildren(JSC::MarkStack&);\n\n"); + $structureFlags{"JSC::OverridesMarkChildren"} = 1; + } + + # Custom pushEventHandlerScope function + push(@headerContent, " virtual void pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"}; + + # Custom call functions + push(@headerContent, " virtual JSC::CallType getCallData(JSC::CallData&);\n\n") if $dataNode->extendedAttributes->{"CustomCall"}; + + # Custom deleteProperty function + push(@headerContent, " virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier&);\n") if $dataNode->extendedAttributes->{"CustomDeleteProperty"}; + + # Custom getPropertyNames function exists on DOMWindow + if ($interfaceName eq "DOMWindow") { + push(@headerContent, " virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n"); + $structureFlags{"JSC::OverridesGetPropertyNames"} = 1; + } + + # Custom defineProperty function exists on DOMWindow + push(@headerContent, " virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interfaceName eq "DOMWindow"; + + # Custom getOwnPropertyNames function + if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@headerContent, " virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n"); + $structureFlags{"JSC::OverridesGetPropertyNames"} = 1; + } + + # Custom defineGetter function + push(@headerContent, " virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomDefineGetter"}; + + # Custom defineSetter function + push(@headerContent, " virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomDefineSetter"}; + + # Custom lookupGetter function + push(@headerContent, " virtual JSC::JSValue lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName);\n") if $dataNode->extendedAttributes->{"CustomLookupGetter"}; + + # Custom lookupSetter function + push(@headerContent, " virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);\n") if $dataNode->extendedAttributes->{"CustomLookupSetter"}; + + # Override toBoolean to return false for objects that want to 'MasqueradesAsUndefined'. + if ($dataNode->extendedAttributes->{"MasqueradesAsUndefined"}) { + push(@headerContent, " virtual bool toBoolean(JSC::ExecState*) const { return false; };\n"); + $structureFlags{"JSC::MasqueradesAsUndefined"} = 1; + } + + # Constructor object getter + push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); + + my $numCustomFunctions = 0; + my $numCustomAttributes = 0; + + # Attribute and function enums + if ($numAttributes > 0) { + foreach (@{$dataNode->attributes}) { + my $attribute = $_; + $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"}; + $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}; + $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}; + if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { + push(@headerContent, " static const unsigned " . $attribute->signature->name . "Slot = $numCachedAttributes + Base::AnonymousSlotCount;\n"); + $numCachedAttributes++; + } + } + } + + if ($numCachedAttributes > 0) { + push(@headerContent, " using $parentClassName" . "::putAnonymousValue;\n"); + push(@headerContent, " using $parentClassName" . "::getAnonymousValue;\n"); + } + if ($numCustomAttributes > 0) { + push(@headerContent, "\n // Custom attributes\n"); + + foreach my $attribute (@{$dataNode->attributes}) { + if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"}) { + push(@headerContent, " JSC::JSValue " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(JSC::ExecState*) const;\n"); + if ($attribute->type !~ /^readonly/) { + push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n"); + } + } elsif ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) { + push(@headerContent, " JSC::JSValue " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(JSC::ExecState*) const;\n"); + } elsif ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) { + if ($attribute->type !~ /^readonly/) { + push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n"); + } + } + } + } + + foreach my $function (@{$dataNode->functions}) { + $numCustomFunctions++ if $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}; + } + + if ($numCustomFunctions > 0) { + push(@headerContent, "\n // Custom functions\n"); + foreach my $function (@{$dataNode->functions}) { + if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) { + my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name); + push(@headerContent, " JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n"); + } + } + } + + if (!$hasParent) { + push(@headerContent, " $implType* impl() const { return m_impl.get(); }\n\n"); + push(@headerContent, "private:\n"); + push(@headerContent, " RefPtr<$implType> m_impl;\n"); + } elsif ($dataNode->extendedAttributes->{"GenerateNativeConverter"}) { + push(@headerContent, " $implClassName* impl() const\n"); + push(@headerContent, " {\n"); + push(@headerContent, " return static_cast<$implClassName*>(Base::impl());\n"); + push(@headerContent, " }\n"); + } + + # anonymous slots + if ($numCachedAttributes) { + push(@headerContent, "public:\n"); + push(@headerContent, " static const unsigned AnonymousSlotCount = $numCachedAttributes + Base::AnonymousSlotCount;\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"); + + # Index getter + if ($dataNode->extendedAttributes->{"HasIndexGetter"}) { + push(@headerContent, " static JSC::JSValue indexGetter(JSC::ExecState*, JSC::JSValue, unsigned);\n"); + } + if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@headerContent, " JSC::JSValue getByIndex(JSC::ExecState*, unsigned index);\n"); + + } + + # Index setter + if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) { + push(@headerContent, " void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue);\n"); + } + # Name getter + if ($dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + push(@headerContent, "private:\n"); + push(@headerContent, " static bool canGetItemsForName(JSC::ExecState*, $implClassName*, const JSC::Identifier&);\n"); + push(@headerContent, " static JSC::JSValue nameGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);\n"); + } + + push(@headerContent, "};\n\n"); + + if ($dataNode->extendedAttributes->{"InlineGetOwnPropertySlot"} && !$dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}) { + push(@headerContent, "ALWAYS_INLINE bool ${className}::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot)\n"); + push(@headerContent, "{\n"); + push(@headerContent, GenerateGetOwnPropertySlotBody($dataNode, $interfaceName, $className, $implClassName, $numAttributes > 0, 1)); + push(@headerContent, "}\n\n"); + push(@headerContent, "ALWAYS_INLINE bool ${className}::getOwnPropertyDescriptor(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor)\n"); + push(@headerContent, "{\n"); + push(@headerContent, GenerateGetOwnPropertyDescriptorBody($dataNode, $interfaceName, $className, $implClassName, $numAttributes > 0, 1)); + push(@headerContent, "}\n\n"); + } + + if (!$hasParent || $dataNode->extendedAttributes->{"GenerateToJS"} || $dataNode->extendedAttributes->{"CustomToJS"}) { + if ($svgPropertyType) { + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*);\n"); + } else { + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*);\n"); + } + } + if (!$hasParent || $dataNode->extendedAttributes->{"GenerateNativeConverter"}) { + if ($interfaceName eq "NodeFilter") { + push(@headerContent, "PassRefPtr<NodeFilter> toNodeFilter(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::JSObjectWithGlobalObject {\n"); + push(@headerContent, " typedef JSC::JSObjectWithGlobalObject Base;\n"); + push(@headerContent, "public:\n"); + if ($interfaceName eq "DOMWindow") { + push(@headerContent, " void* operator new(size_t);\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@headerContent, " void* operator new(size_t, JSC::JSGlobalData*);\n"); + } else { + push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n"); + } + push(@headerContent, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); + push(@headerContent, " static const JSC::ClassInfo s_info;\n"); + if ($numFunctions > 0 || $numConstants > 0 || $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}) { + push(@headerContent, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n"); + push(@headerContent, " virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n"); + push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}; + push(@headerContent, " bool getOwnPropertyDescriptorDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n") if $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}; + $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1; + } + if ($dataNode->extendedAttributes->{"CustomMarkFunction"} or $needsMarkChildren) { + $structureFlags{"JSC::OverridesMarkChildren"} = 1; + } + push(@headerContent, + " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . + " {\n" . + " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n" . + " }\n"); + if ($dataNode->extendedAttributes->{"DelegatingPrototypePutFunction"}) { + push(@headerContent, " virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);\n"); + push(@headerContent, " bool putDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, JSC::PutPropertySlot&);\n"); + } + + # Custom defineGetter function + push(@headerContent, " virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomPrototypeDefineGetter"}; + + push(@headerContent, " ${className}Prototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, 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"); + + # Conditionally emit the constructor object's declaration + if ($dataNode->extendedAttributes->{"CustomConstructFunction"}) { + GenerateConstructorDeclaration(\@headerContent, $className, $dataNode); + } + + + if ($numFunctions > 0) { + push(@headerContent,"// Functions\n\n"); + foreach my $function (@{$dataNode->functions}) { + next if $function->{overloadIndex} && $function->{overloadIndex} > 1; + my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); + push(@headerContent, "JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState*);\n"); + } + } + + if ($numAttributes > 0 || !($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + push(@headerContent,"// Attributes\n\n"); + foreach my $attribute (@{$dataNode->attributes}) { + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);\n"); + unless ($attribute->type =~ /readonly/) { + my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@headerContent, "void ${setter}(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);\n"); + } + } + + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + my $getter = "js" . $interfaceName . "Constructor"; + push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);\n"); + } + + if ($dataNode->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 (@{$dataNode->constants}) { + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); + push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);\n"); + } + } + + my $conditionalString = GenerateConditionalString($dataNode); + 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, $dataNode) = @_; + + # FIXME: These should be functions on $dataNode. + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add all attributes in a hashtable definition + my $numAttributes = @{$dataNode->attributes}; + $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); + + 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 (@{$dataNode->attributes}) { + 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->{"DontEnum"}; + push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; + my $special = (@specials > 0) ? join(" | ", @specials) : "0"; + push(@hashSpecials, $special); + + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@hashValue1, $getter); + + if ($attribute->type =~ /readonly/) { + push(@hashValue2, "0"); + } else { + my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@hashValue2, $setter); + } + + my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; + if ($conditional) { + $conditionals{$name} = $conditional; + } + } + + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + push(@hashKeys, "constructor"); + my $getter = "js" . $interfaceName . "Constructor"; + push(@hashValue1, $getter); + if ($dataNode->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, "exec->argumentCount() == $numParameters"); + my $parameterIndex = 0; + foreach $parameter (@{$function->parameters}) { + last if $parameterIndex >= $numParameters; + my $value = "exec->argument($parameterIndex)"; + my $type = $codeGenerator->StripModule($parameter->type); + + # Only DOMString or wrapper types are checked. + # For DOMString, Null, Undefined and any Object are accepted too, as + # these are acceptable values for a DOMString argument (any Object can + # be converted to a string via .toString). + if ($codeGenerator->IsStringType($type)) { + 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}.isObject())"); + } elsif (!IsNativeType($type)) { + push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(&JS${type}::s_info)))"); + } + $parameterIndex++; + } + my $res = join(" && ", @andExpression); + $res = "($res)" if @andExpression > 1; + return $res; +} + +sub GenerateFunctionParametersCheck +{ + my $function = shift; + + my @orExpression = (); + my $numParameters = 0; + foreach $parameter (@{$function->parameters}) { + if ($parameter->extendedAttributes->{"Optional"}) { + push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); + } + $numParameters++; + } + push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); + return join(" || ", @orExpression); +} + +sub GenerateOverloadedPrototypeFunction +{ + my $function = shift; + my $dataNode = shift; + my $implClassName = 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 $functionName = "js${implClassName}PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); + + push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)\n"); + push(@implContent, <<END); +{ +END + foreach my $overload (@{$function->{overloads}}) { + my $parametersCheck = GenerateFunctionParametersCheck($overload); + push(@implContent, " if ($parametersCheck)\n"); + push(@implContent, " return ${functionName}$overload->{overloadIndex}(exec);\n"); + } + push(@implContent, <<END); + return throwVMTypeError(exec); +} + +END +} + +sub GenerateImplementation +{ + my ($object, $dataNode) = @_; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + my $implClassName = $interfaceName; + + my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; + my $hasRealParent = @{$dataNode->parents} > 0; + my $hasParent = $hasLegacyParent || $hasRealParent; + my $parentClassName = GetParentClassName($dataNode); + my $visibleClassName = GetVisibleClassName($interfaceName); + my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"}; + my $needsMarkChildren = $dataNode->extendedAttributes->{"CustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"}; + + # - Add default header template + push(@implContentHeader, GenerateImplementationContentHeader($dataNode)); + + AddIncludesForSVGAnimatedType($interfaceName) if $className =~ /^JSSVGAnimated/; + + $implIncludes{"<wtf/GetPtr.h>"} = 1; + $implIncludes{"<runtime/PropertyNameArray.h>"} = 1 if $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}; + + AddIncludesForType($interfaceName); + + @implContent = (); + + push(@implContent, "\nusing namespace JSC;\n\n"); + push(@implContent, "namespace WebCore {\n\n"); + + push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className);\n\n"); + + my $numAttributes = GenerateAttributesHashTable($object, $dataNode); + + my $numConstants = @{$dataNode->constants}; + my $numFunctions = @{$dataNode->functions}; + + # - Add all constants + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + $hashSize = $numConstants; + $hashName = $className . "ConstructorTable"; + + @hashKeys = (); + @hashValue1 = (); + @hashValue2 = (); + @hashSpecials = (); + + # FIXME: we should not need a function for every constant. + foreach my $constant (@{$dataNode->constants}) { + push(@hashKeys, $constant->name); + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); + push(@hashValue1, $getter); + push(@hashValue2, "0"); + push(@hashSpecials, "DontDelete | ReadOnly"); + } + + $object->GenerateHashTable($hashName, $hashSize, + \@hashKeys, \@hashSpecials, + \@hashValue1, \@hashValue2); + + push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNeeded($dataNode)); + + my $protoClassName = "${className}Prototype"; + + GenerateConstructorDeclaration(\@implContent, $className, $dataNode) unless $dataNode->extendedAttributes->{"CustomConstructFunction"}; + GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $visibleClassName, $dataNode); + } + + # - Add functions and constants to a hashtable definition + $hashSize = $numFunctions + $numConstants; + $hashName = $className . "PrototypeTable"; + + @hashKeys = (); + @hashValue1 = (); + @hashValue2 = (); + @hashSpecials = (); + + # FIXME: we should not need a function for every constant. + foreach my $constant (@{$dataNode->constants}) { + push(@hashKeys, $constant->name); + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); + push(@hashValue1, $getter); + push(@hashValue2, "0"); + push(@hashSpecials, "DontDelete | ReadOnly"); + } + + foreach my $function (@{$dataNode->functions}) { + next if $function->{overloadIndex} && $function->{overloadIndex} > 1; + my $name = $function->signature->name; + push(@hashKeys, $name); + + my $value = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($name); + push(@hashValue1, $value); + + my $numParameters = @{$function->parameters}; + push(@hashValue2, $numParameters); + + my @specials = (); + push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"}; + push(@specials, "DontEnum") if $function->signature->extendedAttributes->{"DontEnum"}; + push(@specials, "Function"); + my $special = (@specials > 0) ? join(" | ", @specials) : "0"; + push(@hashSpecials, $special); + } + + $object->GenerateHashTable($hashName, $hashSize, + \@hashKeys, \@hashSpecials, + \@hashValue1, \@hashValue2); + + if ($dataNode->extendedAttributes->{"NoStaticTables"}) { + 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"); + push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", 0, 0, get${className}PrototypeTable };\n\n"); + } else { + push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", 0, &${className}PrototypeTable, 0 };\n\n"); + } + if ($interfaceName eq "DOMWindow") { + push(@implContent, "void* ${className}Prototype::operator new(size_t size)\n"); + push(@implContent, "{\n"); + push(@implContent, " return JSDOMWindow::commonJSGlobalData()->heap.allocate(size);\n"); + push(@implContent, "}\n\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@implContent, "void* ${className}Prototype::operator new(size_t size, JSGlobalData* globalData)\n"); + push(@implContent, "{\n"); + push(@implContent, " return globalData->heap.allocate(size);\n"); + push(@implContent, "}\n\n"); + } else { + 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 || $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}) { + push(@implContent, "bool ${className}Prototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n"); + push(@implContent, "{\n"); + + if ($dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}) { + push(@implContent, " if (getOwnPropertySlotDelegate(exec, propertyName, slot))\n"); + push(@implContent, " return true;\n"); + } + + if ($numConstants eq 0 && $numFunctions eq 0) { + push(@implContent, " return Base::getOwnPropertySlot(exec, propertyName, slot);\n"); + } elsif ($numConstants eq 0) { + push(@implContent, " return getStaticFunctionSlot<JSObject>(exec, " . prototypeHashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, slot);\n"); + } elsif ($numFunctions eq 0) { + push(@implContent, " return getStaticValueSlot<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, slot);\n"); + } else { + push(@implContent, " return getStaticPropertySlot<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, slot);\n"); + } + push(@implContent, "}\n\n"); + + push(@implContent, "bool ${className}Prototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)\n"); + push(@implContent, "{\n"); + + if ($dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}) { + push(@implContent, " if (getOwnPropertyDescriptorDelegate(exec, propertyName, descriptor))\n"); + push(@implContent, " return true;\n"); + } + + if ($numConstants eq 0 && $numFunctions eq 0) { + push(@implContent, " return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor);\n"); + } elsif ($numConstants eq 0) { + push(@implContent, " return getStaticFunctionDescriptor<JSObject>(exec, " . prototypeHashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, descriptor);\n"); + } elsif ($numFunctions eq 0) { + push(@implContent, " return getStaticValueDescriptor<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, descriptor);\n"); + } else { + push(@implContent, " return getStaticPropertyDescriptor<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, propertyName, descriptor);\n"); + } + push(@implContent, "}\n\n"); + } + + if ($dataNode->extendedAttributes->{"DelegatingPrototypePutFunction"}) { + push(@implContent, "void ${className}Prototype::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)\n"); + push(@implContent, "{\n"); + push(@implContent, " if (putDelegate(exec, propertyName, value, slot))\n"); + push(@implContent, " return;\n"); + push(@implContent, " Base::put(exec, propertyName, value, slot);\n"); + push(@implContent, "}\n\n"); + } + + # - Initialize static ClassInfo object + if ($numAttributes > 0 && $dataNode->extendedAttributes->{"NoStaticTables"}) { + 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"); + } + push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleClassName}\", "); + if ($hasParent) { + push(@implContent, "&" . $parentClassName . "::s_info, "); + } else { + push(@implContent, "0, "); + } + + if ($numAttributes > 0 && !$dataNode->extendedAttributes->{"NoStaticTables"}) { + push(@implContent, "&${className}Table"); + } else { + push(@implContent, "0"); + } + if ($numAttributes > 0 && $dataNode->extendedAttributes->{"NoStaticTables"}) { + push(@implContent, ", get${className}Table "); + } else { + push(@implContent, ", 0 "); + } + push(@implContent, "};\n\n"); + + my $implType = $implClassName; + 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") { + AddIncludesForType("JSDOMWindowShell"); + push(@implContent, "${className}::$className(NonNullPassRefPtr<Structure> structure, PassRefPtr<$implType> impl, JSDOMWindowShell* shell)\n"); + push(@implContent, " : $parentClassName(structure, impl, shell)\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + AddIncludesForType($interfaceName); + push(@implContent, "${className}::$className(NonNullPassRefPtr<Structure> structure, PassRefPtr<$implType> impl)\n"); + push(@implContent, " : $parentClassName(structure, impl)\n"); + } else { + push(@implContent, "${className}::$className(NonNullPassRefPtr<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)\n"); + } + } + push(@implContent, "{\n"); + if ($numCachedAttributes > 0) { + push(@implContent, " for (unsigned i = Base::AnonymousSlotCount; i < AnonymousSlotCount; i++)\n"); + push(@implContent, " putAnonymousValue(i, JSValue());\n"); + } + push(@implContent, "}\n\n"); + + # Destructor + if (!$hasParent || $eventTarget) { + push(@implContent, "${className}::~$className()\n"); + push(@implContent, "{\n"); + + if ($eventTarget) { + $implIncludes{"RegisteredEventListener.h"} = 1; + push(@implContent, " impl()->invalidateJSEventListeners(this);\n"); + } + + if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) { + if ($interfaceName eq "Node") { + push(@implContent, " forgetDOMNode(this, impl(), impl()->document());\n"); + } else { + push(@implContent, " forgetDOMObject(this, impl());\n"); + } + } + + push(@implContent, "}\n\n"); + } + + if ($needsMarkChildren && !$dataNode->extendedAttributes->{"CustomMarkFunction"}) { + push(@implContent, "void ${className}::markChildren(MarkStack& markStack)\n"); + push(@implContent, "{\n"); + push(@implContent, " Base::markChildren(markStack);\n"); + push(@implContent, " impl()->markJSEventListeners(markStack);\n"); + push(@implContent, "}\n\n"); + } + + if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) { + push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec, JSGlobalObject* globalObject)\n"); + push(@implContent, "{\n"); + if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") { + push(@implContent, " return new (exec) ${className}Prototype(globalObject, ${className}Prototype::createStructure(${parentClassName}Prototype::self(exec, globalObject)));\n"); + } else { + push(@implContent, " return new (exec) ${className}Prototype(globalObject, ${className}Prototype::createStructure(globalObject->objectPrototype()));\n"); + } + push(@implContent, "}\n\n"); + } + + my $hasGetter = $numAttributes > 0 + || !($dataNode->extendedAttributes->{"OmitConstructor"} + || $dataNode->extendedAttributes->{"CustomConstructor"}) + || $dataNode->extendedAttributes->{"HasIndexGetter"} + || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} + || $dataNode->extendedAttributes->{"HasNumericIndexGetter"} + || $dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"} + || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"} + || $dataNode->extendedAttributes->{"HasNameGetter"} + || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}; + + # Attributes + if ($hasGetter) { + if (!$dataNode->extendedAttributes->{"InlineGetOwnPropertySlot"} && !$dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}) { + push(@implContent, "bool ${className}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n"); + push(@implContent, "{\n"); + push(@implContent, GenerateGetOwnPropertySlotBody($dataNode, $interfaceName, $className, $implClassName, $numAttributes > 0, 0)); + push(@implContent, "}\n\n"); + push(@implContent, "bool ${className}::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)\n"); + push(@implContent, "{\n"); + push(@implContent, GenerateGetOwnPropertyDescriptorBody($dataNode, $interfaceName, $className, $implClassName, $numAttributes > 0, 0)); + push(@implContent, "}\n\n"); + } + + if (($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) + && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"}) { + push(@implContent, "bool ${className}::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)\n"); + push(@implContent, "{\n"); + push(@implContent, " if (propertyName < static_cast<$implClassName*>(impl())->length()) {\n"); + if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@implContent, " slot.setValue(getByIndex(exec, propertyName));\n"); + } else { + push(@implContent, " slot.setCustomIndex(this, propertyName, indexGetter);\n"); + } + push(@implContent, " return true;\n"); + push(@implContent, " }\n"); + push(@implContent, " return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);\n"); + push(@implContent, "}\n\n"); + } + + if ($numAttributes > 0) { + foreach my $attribute (@{$dataNode->attributes}) { + my $name = $attribute->signature->name; + my $type = $codeGenerator->StripModule($attribute->signature->type); + my $getFunctionName = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name); + + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; + + push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, const Identifier&)\n"); + push(@implContent, "{\n"); + push(@implContent, " ${className}* castedThis = static_cast<$className*>(asObject(slotBase));\n"); + + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && + !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"} && + !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurityOnGet"}) { + push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n"); + push(@implContent, " return jsUndefined();\n"); + } + + if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) { + push(@implContent, " return castedThis->$implGetterFunctionName(exec);\n"); + } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { + $implIncludes{"JSDOMBinding.h"} = 1; + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); + } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { + $implIncludes{"Document.h"} = 1; + $implIncludes{"JSDOMBinding.h"} = 1; + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); + } elsif ($type eq "EventListener") { + $implIncludes{"EventListener.h"} = 1; + push(@implContent, " UNUSED_PARAM(exec);\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " if (EventListener* listener = imp->$implGetterFunctionName()) {\n"); + push(@implContent, " if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n"); + if ($implClassName eq "Document" || $implClassName eq "WorkerContext" || $implClassName eq "SharedWorkerContext" || $implClassName eq "DedicatedWorkerContext") { + push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(imp))\n"); + } else { + push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(imp->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 = $codeGenerator->StripModule($attribute->signature->type); + $constructorType =~ s/Constructor$//; + # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object + # Once DOMObjects have a back-pointer to the globalObject we can pass castedThis->globalObject() + push(@implContent, " return JS" . $constructorType . "::getConstructor(exec, castedThis);\n"); + } elsif (!@{$attribute->getterExceptions}) { + push(@implContent, " UNUSED_PARAM(exec);\n"); + my $cacheIndex = 0; + if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { + $cacheIndex = $currentCachedAttribute; + $currentCachedAttribute++; + push(@implContent, " if (JSValue cachedValue = castedThis->getAnonymousValue(" . $className . "::" . $attribute->signature->name . "Slot))\n"); + push(@implContent, " return cachedValue;\n"); + } + + if ($svgListPropertyType) { + push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "castedThis->impl()->$implGetterFunctionName()", "castedThis") . ";\n"); + } elsif ($svgPropertyOrListPropertyType) { + push(@implContent, " $svgPropertyOrListPropertyType& imp = castedThis->impl()->propertyReference();\n"); + if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber + push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp", "castedThis") . ";\n"); + } else { + push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp.$implGetterFunctionName()", "castedThis") . ";\n"); + } + } else { + my $getterExpression = "imp->" . $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute) . ")"; + my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $getterExpression, "castedThis"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + 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->putAnonymousValue(" . $className . "::" . $attribute->signature->name . "Slot, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"}); + push(@implContent, " return result;\n"); + + } else { + push(@implContent, " ExceptionCode ec = 0;\n"); + if ($svgPropertyOrListPropertyType) { + push(@implContent, " $svgPropertyOrListPropertyType imp(*castedThis->impl());\n"); + push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp.$implGetterFunctionName(ec)", "castedThis") . ";\n"); + } else { + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp->$implGetterFunctionName(ec)", "castedThis") . ";\n"); + } + + push(@implContent, " setDOMException(exec, ec);\n"); + push(@implContent, " return result;\n"); + } + + push(@implContent, "}\n"); + + push(@implContent, "#endif\n") if $attributeConditionalString; + + push(@implContent, "\n"); + } + + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + my $constructorFunctionName = "js" . $interfaceName . "Constructor"; + + push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, JSValue slotBase, const Identifier&)\n"); + push(@implContent, "{\n"); + push(@implContent, " ${className}* domObject = static_cast<$className*>(asObject(slotBase));\n"); + + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"}) { + push(@implContent, " if (!domObject->allowsAccessFrom(exec))\n"); + push(@implContent, " return jsUndefined();\n"); + } + + push(@implContent, " return ${className}::getConstructor(exec, domObject->globalObject());\n"); + push(@implContent, "}\n"); + push(@implContent, "\n"); + } + } + + # Check if we have any writable attributes + my $hasReadWriteProperties = 0; + foreach my $attribute (@{$dataNode->attributes}) { + $hasReadWriteProperties = 1 if $attribute->type !~ /^readonly/; + } + + my $hasSetter = $hasReadWriteProperties + || $dataNode->extendedAttributes->{"DelegatingPutFunction"} + || $dataNode->extendedAttributes->{"HasCustomIndexSetter"}; + + if ($hasSetter) { + if (!$dataNode->extendedAttributes->{"CustomPutFunction"}) { + push(@implContent, "void ${className}::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)\n"); + push(@implContent, "{\n"); + if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) { + push(@implContent, " bool ok;\n"); + push(@implContent, " unsigned index = propertyName.toUInt32(ok);\n"); + push(@implContent, " if (ok) {\n"); + push(@implContent, " indexSetter(exec, index, value);\n"); + push(@implContent, " return;\n"); + push(@implContent, " }\n"); + } + if ($dataNode->extendedAttributes->{"DelegatingPutFunction"}) { + push(@implContent, " if (putDelegate(exec, propertyName, value, slot))\n"); + push(@implContent, " return;\n"); + } + + if ($hasReadWriteProperties) { + push(@implContent, " lookupPut<$className, Base>(exec, propertyName, value, " . hashTableAccessor($dataNode->extendedAttributes->{"NoStaticTables"}, $className) . ", this, slot);\n"); + } else { + push(@implContent, " Base::put(exec, propertyName, value, slot);\n"); + } + push(@implContent, "}\n\n"); + } + + if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) { + push(@implContent, "void ${className}::put(ExecState* exec, unsigned propertyName, JSValue value)\n"); + push(@implContent, "{\n"); + push(@implContent, " indexSetter(exec, propertyName, value);\n"); + push(@implContent, " return;\n"); + push(@implContent, "}\n\n"); + } + + if ($hasReadWriteProperties) { + foreach my $attribute (@{$dataNode->attributes}) { + if ($attribute->type !~ /^readonly/) { + my $name = $attribute->signature->name; + my $type = $codeGenerator->StripModule($attribute->signature->type); + my $putFunctionName = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name); + + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; + + push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n"); + push(@implContent, "{\n"); + + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { + if ($interfaceName eq "DOMWindow") { + push(@implContent, " if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); + } else { + push(@implContent, " if (!allowsAccessFromFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n"); + } + push(@implContent, " return;\n"); + } + + if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) { + push(@implContent, " static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n"); + } elsif ($type eq "EventListener") { + $implIncludes{"JSEventListener.h"} = 1; + push(@implContent, " UNUSED_PARAM(exec);\n"); + my $windowEventListener = $attribute->signature->extendedAttributes->{"WindowEventListener"}; + if ($windowEventListener) { + push(@implContent, " ${className}* castedThis = static_cast<${className}*>(thisObject);\n"); + push(@implContent, " JSDOMGlobalObject* globalObject = castedThis->globalObject();\n"); + } + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n"); + if ($interfaceName eq "WorkerContext" and $name eq "onerror") { + $implIncludes{"JSWorkerContextErrorHandler.h"} = 1; + push(@implContent, " imp->set$implSetterFunctionName(createJSWorkerContextErrorHandler(exec, value, thisObject));\n"); + } else { + push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener)); + } + } elsif ($attribute->signature->type =~ /Constructor$/) { + my $constructorType = $attribute->signature->type; + $constructorType =~ s/Constructor$//; + if ($constructorType ne "DOMObject") { + $implIncludes{"JS" . $constructorType . ".h"} = 1; + } + push(@implContent, " // Shadowing a built-in constructor\n"); + if ($interfaceName eq "DOMWindow" && $className eq "JSblah") { + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->propertyNames().constructor, value);\n"); + } else { + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); + } + } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) { + push(@implContent, " // Shadowing a built-in object\n"); + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); + } else { + push(@implContent, " $className* castedThis = static_cast<$className*>(thisObject);\n"); + push(@implContent, " $implType* imp = 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 (imp->role() == AnimValRole) {\n"); + push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n"); + push(@implContent, " return;\n"); + push(@implContent, " }\n"); + } + push(@implContent, " $svgPropertyOrListPropertyType& podImp = imp->propertyReference();\n"); + if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber + push(@implContent, " podImp = $nativeValue;\n"); + } else { + push(@implContent, " podImp.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, " imp->commitChange();\n"); + } else { + push(@implContent, " imp->commitChange();\n"); + } + } + } else { + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + push(@implContent, " imp->$setterExpressionPrefix$nativeValue"); + push(@implContent, ", ec") if @{$attribute->setterExceptions}; + push(@implContent, ");\n"); + push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; + } + } + + push(@implContent, "}\n"); + + push(@implContent, "#endif\n") if $attributeConditionalString; + + push(@implContent, "\n"); + } + } + } + + if ($dataNode->extendedAttributes->{"ReplaceableConstructor"}) { + my $constructorFunctionName = "setJS" . $interfaceName . "Constructor"; + + push(@implContent, "void ${constructorFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n"); + push(@implContent, "{\n"); + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"}) { + if ($interfaceName eq "DOMWindow") { + push(@implContent, " if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); + } else { + push(@implContent, " if (!allowsAccessFromFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n"); + } + push(@implContent, " return;\n"); + } + + push(@implContent, " // Shadowing a built-in constructor\n"); + + if ($interfaceName eq "DOMWindow") { + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->propertyNames().constructor, value);\n"); + } else { + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); + } + push(@implContent, "}\n"); + push(@implContent, "\n"); + } + } + } + + if (($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) && !$dataNode->extendedAttributes->{"CustomGetPropertyNames"}) { + push(@implContent, "void ${className}::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)\n"); + push(@implContent, "{\n"); + if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@implContent, " for (unsigned i = 0; i < static_cast<${implClassName}*>(impl())->length(); ++i)\n"); + push(@implContent, " propertyNames.add(Identifier::from(exec, i));\n"); + } + push(@implContent, " Base::getOwnPropertyNames(exec, propertyNames, mode);\n"); + push(@implContent, "}\n\n"); + } + + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n"); + push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));\n"); + push(@implContent, "}\n\n"); + } + + # Functions + if ($numFunctions > 0) { + foreach my $function (@{$dataNode->functions}) { + AddIncludesForType($function->signature->type); + + my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); + + if ($function->{overloads} && @{$function->{overloads}} > 1) { + # 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->{"ImplementationFunction"} || $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 ($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 ($dataNode->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 = static_cast<$className*>(asObject(thisValue));\n"); + } + + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && + !$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { + push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + } + + if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) { + push(@implContent, " return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n"); + } else { + push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); + if ($svgPropertyType) { + push(@implContent, " if (imp->role() == AnimValRole) {\n"); + push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + push(@implContent, " $svgPropertyType& podImp = imp->propertyReference();\n"); + } + + my $numParameters = @{$function->parameters}; + + my $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"}; + if ($requiresAllArguments) { + my $numMandatoryParams = @{$function->parameters}; + foreach my $param (reverse(@{$function->parameters})) { + if ($param->extendedAttributes->{"Optional"}) { + $numMandatoryParams--; + } else { + last; + } + } + push(@implContent, " if (exec->argumentCount() < $numMandatoryParams)\n"); + if ($requiresAllArguments eq "Raise") { + push(@implContent, " return throwVMError(exec, createSyntaxError(exec, \"Not enough arguments\"));\n"); + } else { + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + } + } + + if (@{$function->raisesExceptions}) { + push(@implContent, " ExceptionCode ec = 0;\n"); + } + + if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) { + push(@implContent, " if (!checkNodeSecurity(exec, imp->getSVGDocument(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + $implIncludes{"JSDOMBinding.h"} = 1; + } + + if ($function->signature->name eq "addEventListener") { + push(@implContent, GenerateEventListenerCall($className, "add")); + } elsif ($function->signature->name eq "removeEventListener") { + push(@implContent, GenerateEventListenerCall($className, "remove")); + } else { + my $argsIndex = 0; + my $paramIndex = 0; + my $functionString = (($svgPropertyOrListPropertyType and !$svgListPropertyType) ? "podImp." : "imp->") . $functionImplementationName . "("; + my $hasOptionalArguments = 0; + + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + push(@implContent, " RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n"); + push(@implContent, " size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n"); + push(@implContent, " RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n"); + $implIncludes{"ScriptArguments.h"} = 1; + $implIncludes{"ScriptCallStack.h"} = 1; + $implIncludes{"ScriptCallStackFactory.h"} = 1; + } + + my $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith) { + my $callWithArg = "COMPILE_ASSERT(false)"; + if ($callWith eq "DynamicFrame") { + push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n"); + push(@implContent, " if (!dynamicFrame)\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + $callWithArg = "dynamicFrame"; + } elsif ($callWith eq "ScriptState") { + $callWithArg = "exec"; + } elsif ($callWith eq "ScriptExecutionContext") { + push(@implContent, " ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n"); + push(@implContent, " if (!scriptContext)\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + $callWithArg = "scriptContext"; + } + $functionString .= ", " if $paramIndex; + $functionString .= $callWithArg; + $paramIndex++; + } + + $implIncludes{"ExceptionCode.h"} = 1; + $implIncludes{"JSDOMBinding.h"} = 1; + foreach my $parameter (@{$function->parameters}) { + # Optional callbacks should be treated differently, because they always have a default value (0), + # and we can reduce the number of overloaded functions that take a different number of parameters. + if ($parameter->extendedAttributes->{"Optional"} && !$parameter->extendedAttributes->{"Callback"}) { + # Generate early call if there are enough parameters. + if (!$hasOptionalArguments) { + push(@implContent, "\n int argsCount = exec->argumentCount();\n"); + $hasOptionalArguments = 1; + } + push(@implContent, " if (argsCount <= $argsIndex) {\n"); + GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $svgPropertyType, $implClassName); + push(@implContent, " }\n\n"); + } + + my $name = $parameter->name; + my $argType = $codeGenerator->StripModule($parameter->type); + + if ($argType eq "XPathNSResolver") { + push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); + push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(exec->argument($argsIndex));\n"); + push(@implContent, " if (!resolver) {\n"); + push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, exec->argument($argsIndex));\n"); + push(@implContent, " if (exec->hadException())\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " resolver = customResolver.get();\n"); + push(@implContent, " }\n"); + } elsif ($parameter->extendedAttributes->{"Callback"}) { + my $callbackClassName = GetCallbackClassName($argType); + $implIncludes{"$callbackClassName.h"} = 1; + if ($parameter->extendedAttributes->{"Optional"}) { + push(@implContent, " RefPtr<$argType> $name;\n"); + push(@implContent, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isNull() && !exec->argument($argsIndex).isUndefined()) {\n"); + push(@implContent, " if (!exec->argument($argsIndex).isObject()) {\n"); + push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + push(@implContent, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); + push(@implContent, " }\n"); + } else { + push(@implContent, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n"); + push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + push(@implContent, " RefPtr<$argType> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\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(@implContent, " if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(&JS${argType}::s_info))\n"); + push(@implContent, " return throwVMTypeError(exec);\n"); + } + } + + push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\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(@implContent, " if ($name < 0) {\n"); + push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + } + + # Check if the type conversion succeeded. + push(@implContent, " if (exec->hadException())\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + + if ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $implClassName =~ /List$/) { + push(@implContent, " if (!$name) {\n"); + push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + } + } + + $functionString .= ", " if $paramIndex; + + if ($argType eq "NodeFilter") { + $functionString .= "$name.get()"; + } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $implClassName =~ /List$/) { + $functionString .= "$name->propertyReference()"; + } else { + $functionString .= $name; + } + $argsIndex++; + $paramIndex++; + } + + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionString .= ", " if $paramIndex; + $functionString .= "processingUserGesture()"; + $paramIndex++; + } + + push(@implContent, "\n"); + GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $svgPropertyType, $implClassName); + } + } + push(@implContent, "}\n\n"); + + if ($function->{overloads} && @{$function->{overloads}} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) { + # Generate a function dispatching call to the rest of the overloads. + GenerateOverloadedPrototypeFunction($function, $dataNode, $implClassName); + } + } + } + + if ($numConstants > 0) { + push(@implContent, "// Constant getters\n\n"); + + foreach my $constant (@{$dataNode->constants}) { + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); + + # 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, const Identifier&)\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"); + } + } + + if ($dataNode->extendedAttributes->{"HasIndexGetter"}) { + push(@implContent, "\nJSValue ${className}::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)\n"); + push(@implContent, "{\n"); + push(@implContent, " ${className}* thisObj = static_cast<$className*>(asObject(slotBase));\n"); + if (IndexGetterReturnsStrings($implClassName)) { + $implIncludes{"KURL.h"} = 1; + push(@implContent, " return jsStringOrNull(exec, thisObj->impl()->item(index));\n"); + } else { + push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(index));\n"); + } + push(@implContent, "}\n"); + if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { + $implIncludes{"JSNode.h"} = 1; + $implIncludes{"Node.h"} = 1; + } + } + + if ($dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { + push(@implContent, "\nJSValue ${className}::getByIndex(ExecState*, unsigned index)\n"); + push(@implContent, "{\n"); + push(@implContent, " return jsNumber(static_cast<$implClassName*>(impl())->item(index));\n"); + push(@implContent, "}\n"); + if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { + $implIncludes{"JSNode.h"} = 1; + $implIncludes{"Node.h"} = 1; + } + } + + if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateToJS"}) and !$dataNode->extendedAttributes->{"CustomToJS"}) { + if ($svgPropertyType) { + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object)\n"); + } else { + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object)\n"); + } + push(@implContent, "{\n"); + if ($svgPropertyType) { + push(@implContent, " return getDOMObjectWrapper<$className, $implType>(exec, globalObject, object);\n"); + } else { + push(@implContent, " return getDOMObjectWrapper<$className>(exec, globalObject, object);\n"); + } + push(@implContent, "}\n"); + } + + if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateNativeConverter"}) and !$dataNode->extendedAttributes->{"CustomNativeConverter"}) { + push(@implContent, "$implType* to${interfaceName}(JSC::JSValue value)\n"); + push(@implContent, "{\n"); + push(@implContent, " return value.inherits(&${className}::s_info) ? static_cast<$className*>(asObject(value))->impl() : 0"); + push(@implContent, ";\n}\n"); + } + + push(@implContent, "\n}\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateCallbackHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add default header template and header protection + push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); + + $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 = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@headerContent, "\n // Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if (!$function->signature->extendedAttributes->{"Custom"} && + !(GetNativeType($function->signature->type) eq "bool")) { + push(@headerContent, " COMPILE_ASSERT(false)"); + } + + push(@headerContent, " virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "("); + + my @args = (); + foreach my $param (@params) { + push(@args, GetNativeType($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 = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; + push(@headerContent, "#endif\n"); +} + +sub GenerateCallbackImplementation +{ + my ($object, $dataNode) = @_; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add default header template + push(@implContentHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"ScriptExecutionContext.h"} = 1; + $implIncludes{"<runtime/JSLock.h>"} = 1; + $implIncludes{"<wtf/MainThread.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 = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@implContent, "\n// Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if ($function->signature->extendedAttributes->{"Custom"} || + !(GetNativeType($function->signature->type) eq "bool")) { + next; + } + + AddIncludesForType($function->signature->type); + push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "("); + + my @args = (); + foreach my $param (@params) { + AddIncludesForType($param->type, 1); + push(@args, GetNativeType($param->type) . " " . $param->name); + } + push(@implContent, join(", ", @args)); + push(@implContent, ")\n"); + + push(@implContent, "{\n"); + push(@implContent, " if (!canInvokeCallback())\n"); + push(@implContent, " return true;\n\n"); + push(@implContent, " RefPtr<$className> protect(this);\n\n"); + push(@implContent, " JSLock lock(SilenceAssertionsOnly);\n\n"); + 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(jsString(exec, ${paramName}));\n"); + } else { + push(@implContent, " args.append(toJS(exec, ${paramName}));\n"); + } + } + + push(@implContent, "\n bool raisedException = false;\n"); + push(@implContent, " m_data->invokeCallback(args, &raisedException);\n"); + push(@implContent, " return !raisedException;\n"); + push(@implContent, "}\n"); + } + } + + push(@implContent, "\n}\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateImplementationFunctionCall() +{ + my $function = shift; + my $functionString = shift; + my $paramIndex = shift; + my $indent = shift; + my $svgPropertyType = shift; + my $implClassName = shift; + + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + $functionString .= ", " if $paramIndex; + $paramIndex += 2; + $functionString .= "scriptArguments, callStack"; + } + + if (@{$function->raisesExceptions}) { + $functionString .= ", " if $paramIndex; + $functionString .= "ec"; + } + $functionString .= ")"; + + if ($function->signature->type eq "void") { + push(@implContent, $indent . "$functionString;\n"); + push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; + + if ($svgPropertyType) { + if (@{$function->raisesExceptions}) { + push(@implContent, $indent . "if (!ec)\n"); + push(@implContent, $indent . " imp->commitChange();\n"); + } else { + push(@implContent, $indent . "imp->commitChange();\n"); + } + } + + push(@implContent, $indent . "return JSValue::encode(jsUndefined());\n"); + } else { + push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, $functionString, "castedThis") . ";\n"); + push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; + + $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith and $callWith eq "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 = $codeGenerator->StripModule($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&", + "DOMObject" => "ScriptValue", + "NodeFilter" => "RefPtr<NodeFilter>", + "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", + "IDBKey" => "RefPtr<IDBKey>", + "SVGPaintType" => "SVGPaint::SVGPaintType", + "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>" +); + +sub GetNativeType +{ + my $type = shift; + + my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($type); + return "${svgNativeType}*" if $svgNativeType; + return $nativeType{$type} if exists $nativeType{$type}; + + # For all other types, the native type is a pointer with same type name as the IDL type. + return "${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 $type = $codeGenerator->StripModule($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"; + return "static_cast<SVGPaint::SVGPaintType>($value.toInt32(exec))" if $type eq "SVGPaintType"; + + if ($type eq "DOMString") { + return "valueToStringWithNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertNullToNullString"} || $signature->extendedAttributes->{"Reflect"}; + return "valueToStringWithUndefinedOrNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"}; + return "ustringToString($value.toString(exec))"; + } + + if ($type eq "DOMObject") { + return "$value"; + } + + if ($type eq "MediaQueryListListener") { + $implIncludes{"MediaQueryListListener.h"} = 1; + return "MediaQueryListListener::create(" . $value .")"; + } + + if ($type eq "SerializedScriptValue" or $type eq "any") { + $implIncludes{"SerializedScriptValue.h"} = 1; + return "SerializedScriptValue::create(exec, $value)"; + } + + if ($type eq "IDBKey") { + $implIncludes{"IDBBindingUtilities.h"} = 1; + $implIncludes{"IDBKey.h"} = 1; + return "createIDBKeyFromValue(exec, $value)"; + } + + $implIncludes{"HTMLOptionElement.h"} = 1 if $type eq "HTMLOptionElement"; + $implIncludes{"JSCustomVoidCallback.h"} = 1 if $type eq "VoidCallback"; + $implIncludes{"Event.h"} = 1 if $type eq "Event"; + + # Default, assume autogenerated type conversion routines + $implIncludes{"JS$type.h"} = 1; + return "to$type($value)"; +} + +sub NativeToJSValue +{ + my $signature = shift; + my $inFunctionCall = shift; + my $implClassName = shift; + my $value = shift; + my $thisValue = shift; + + my $type = $codeGenerator->StripModule($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 "SVGPaintType" or $type eq "DOMTimeStamp") { + $implIncludes{"<runtime/JSNumberCell.h>"} = 1; + return "jsNumber($value)"; + } + + if ($codeGenerator->IsStringType($type)) { + $implIncludes{"KURL.h"} = 1; + my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"}; + if (defined $conv) { + return "jsStringOrNull(exec, $value)" if $conv eq "Null"; + return "jsStringOrUndefined(exec, $value)" if $conv eq "Undefined"; + return "jsStringOrFalse(exec, $value)" if $conv eq "False"; + + die "Unknown value for ConvertNullStringTo extended attribute"; + } + $conv = $signature->extendedAttributes->{"ConvertScriptString"}; + return "jsOwnedStringOrNull(exec, $value)" if $conv; + $implIncludes{"<runtime/JSString.h>"} = 1; + return "jsString(exec, $value)"; + } + + my $globalObject = "$thisValue->globalObject()"; + + if ($type eq "CSSStyleDeclaration") { + $implIncludes{"CSSMutableStyleDeclaration.h"} = 1; + } + + if ($type eq "NodeList") { + $implIncludes{"NameNodeList.h"} = 1; + } + + if ($type eq "DOMObject") { + if ($implClassName eq "Document") { + $implIncludes{"JSCanvasRenderingContext2D.h"} = 1; + } else { + return "$value.jsValue();"; + } + } elsif ($type =~ /SVGPathSeg/) { + $implIncludes{"JS$type.h"} = 1; + $joinedName = $type; + $joinedName =~ s/Abs|Rel//; + $implIncludes{"$joinedName.h"} = 1; + } elsif ($type eq "SerializedScriptValue" or $type eq "any") { + $implIncludes{"SerializedScriptValue.h"} = 1; + return "$value ? $value->deserialize(exec, castedThis->globalObject()) : jsNull()"; + } else { + # Default, include header with same name. + $implIncludes{"JS$type.h"} = 1; + $implIncludes{"$type.h"} = 1 if not $codeGenerator->AvoidInclusionOfType($type); + } + + return $value if $codeGenerator->IsSVGAnimatedType($type); + + if ($signature->extendedAttributes->{"ReturnsNew"}) { + return "toJSNewlyCreated(exec, $globalObject, WTF::getPtr($value))"; + } + + if ($codeGenerator->IsSVGAnimatedType($implClassName)) { + # 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 $implClassName =~ /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/imp\.//; + $getter =~ s/imp->//; + $getter =~ s/\(\)//; + my $updateMethod = "&${implClassName}::update" . $codeGenerator->WK_ucfirst($getter); + + my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($implClassName); + if ($selfIsTearOffType) { + $implIncludes{"SVGStaticPropertyWithParentTearOff.h"} = 1; + $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParentTearOff<$implClassName, /; + + if ($value =~ /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. + $value =~ s/matrix/svgMatrix/; + } + + $value = "${tearOffType}::create(castedThis->impl(), $value, $updateMethod)"; + } else { + $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; + $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassName, /; + $value = "${tearOffType}::create(imp, $value, $updateMethod)"; + } + } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { + my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), "; + $value = "${tearOffType}::create($extraImp$value)"; + } elsif (not $tearOffType =~ /SVG(Point|PathSeg)List/) { + $value = "${tearOffType}::create($value)"; + } + } + + return "toJS(exec, $globalObject, 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 + my $count = scalar @{$keys} + 1; + push(@implContent, "#if ENABLE(JIT)\n"); + push(@implContent, "#define THUNK_GENERATOR(generator) , generator\n"); + push(@implContent, "#else\n"); + push(@implContent, "#define THUNK_GENERATOR(generator)\n"); + push(@implContent, "#endif\n"); + push(@implContent, "\nstatic const HashTableValue $nameEntries\[$count\] =\n\{\n"); + $i = 0; + foreach my $key (@{$keys}) { + my $conditional; + my $targetType; + + if ($conditionals) { + $conditional = $conditionals->{$key}; + } + if ($conditional) { + my $conditionalString = 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] THUNK_GENERATOR(0) },\n"); + if ($conditional) { + push(@implContent, "#endif\n"); + } + ++$i; + } + push(@implContent, " { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n"); + push(@implContent, "};\n\n"); + push(@implContent, "#undef THUNK_GENERATOR\n"); + my $compactSizeMask = $numEntries - 1; + push(@implContent, "static JSC_CONST_HASHTABLE HashTable $name = { $compactSize, $compactSizeMask, $nameEntries, 0 };\n"); +} + +# Internal helper +sub GenerateHashValue +{ + my $object = shift; + + @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); + + # this avoids ever returning a hash code of 0, since that is used to + # signal "hash not computed yet", using a value that is likely to be + # effectively the same as 0 when the low bits are masked + $hash = 0x80000000 if ($hash == 0); + + return $hash; +} + +# Internal helper +sub WriteData +{ + if (defined($IMPL)) { + # Write content to file. + print $IMPL @implContentHeader; + + my @includes = (); + foreach my $include (keys %implIncludes) { + my $checkType = $include; + $checkType =~ s/\.h//; + next if $codeGenerator->IsSVGAnimatedType($checkType); + + $include = "\"$include\"" unless $include =~ /^["<]/; # " + push @includes, $include; + } + foreach my $include (sort @includes) { + print $IMPL "#include $include\n"; + } + + print $IMPL @implContent; + close($IMPL); + undef($IMPL); + + @implContentHeader = (); + @implContent = (); + %implIncludes = (); + } + + if (defined($HEADER)) { + # Write content to file. + print $HEADER @headerContentHeader; + + my @includes = (); + foreach my $include (keys %headerIncludes) { + $include = "\"$include\"" unless $include =~ /^["<]/; # " + push @includes, $include; + } + foreach my $include (sort @includes) { + print $HEADER "#include $include\n"; + } + + print $HEADER @headerContent; + + @includes = (); + foreach my $include (keys %headerTrailingIncludes) { + $include = "\"$include\"" unless $include =~ /^["<]/; # " + push @includes, $include; + } + foreach my $include (sort @includes) { + print $HEADER "#include $include\n"; + } + + close($HEADER); + undef($HEADER); + + @headerContentHeader = (); + @headerContent = (); + %headerIncludes = (); + %headerTrailingIncludes = (); + } + + if (defined($DEPS)) { + # Write dependency file. + print $DEPS @depsContent; + close($DEPS); + undef($DEPS); + + @depsContent = (); + } +} + +sub GenerateConstructorDeclaration +{ + my $outputArray = shift; + my $className = shift; + my $dataNode = shift; + + my $constructorClassName = "${className}Constructor"; + my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"}; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; + + push(@$outputArray, "class ${constructorClassName} : public DOMConstructorObject {\n"); + push(@$outputArray, "public:\n"); + push(@$outputArray, " ${constructorClassName}(JSC::ExecState*, JSDOMGlobalObject*);\n\n"); + + push(@$outputArray, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n"); + push(@$outputArray, " virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n"); + push(@$outputArray, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); + push(@$outputArray, " static const JSC::ClassInfo s_info;\n"); + + push(@$outputArray, " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n"); + push(@$outputArray, " {\n"); + push(@$outputArray, " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n"); + push(@$outputArray, " }\n"); + + push(@$outputArray, "protected:\n"); + push(@$outputArray, " static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;\n"); + + if ($canConstruct) { + push(@$outputArray, " static JSC::EncodedJSValue JSC_HOST_CALL construct${className}(JSC::ExecState*);\n"); + push(@$outputArray, " virtual JSC::ConstructType getConstructData(JSC::ConstructData&);\n"); + } + push(@$outputArray, "};\n\n"); +} + +sub GenerateConstructorDefinition +{ + my $outputArray = shift; + + my $className = shift; + my $protoClassName = shift; + my $interfaceName = shift; + my $visibleClassName = shift; + my $dataNode = shift; + + my $constructorClassName = "${className}Constructor"; + my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"}; + my $customConstructFunction = $dataNode->extendedAttributes->{"CustomConstructFunction"}; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; + my $numberOfconstructParameters = $dataNode->extendedAttributes->{"ConstructorParameters"}; + + push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleClassName}Constructor\", 0, &${constructorClassName}Table, 0 };\n\n"); + + push(@$outputArray, "${constructorClassName}::${constructorClassName}(ExecState* exec, JSDOMGlobalObject* globalObject)\n"); + push(@$outputArray, " : DOMConstructorObject(${constructorClassName}::createStructure(globalObject->objectPrototype()), globalObject)\n"); + push(@$outputArray, "{\n"); + if ($interfaceName eq "DOMWindow") { + push(@$outputArray, " putDirect(exec->propertyNames().prototype, globalObject->prototype(), DontDelete | ReadOnly);\n"); + } else { + push(@$outputArray, " putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), DontDelete | ReadOnly);\n"); + } + push(@$outputArray, " putDirect(exec->propertyNames().length, jsNumber(${numberOfconstructParameters}), ReadOnly | DontDelete | DontEnum);\n") if $numberOfconstructParameters; + push(@$outputArray, "}\n\n"); + + push(@$outputArray, "bool ${constructorClassName}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n"); + push(@$outputArray, "{\n"); + push(@$outputArray, " return getStaticValueSlot<${constructorClassName}, DOMObject>(exec, &${constructorClassName}Table, this, propertyName, slot);\n"); + push(@$outputArray, "}\n\n"); + + push(@$outputArray, "bool ${constructorClassName}::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)\n"); + push(@$outputArray, "{\n"); + push(@$outputArray, " return getStaticValueDescriptor<${constructorClassName}, DOMObject>(exec, &${constructorClassName}Table, this, propertyName, descriptor);\n"); + push(@$outputArray, "}\n\n"); + + if ($canConstruct) { + if (!$customConstructFunction) { + push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n"); + push(@$outputArray, "{\n"); + my $constructorArg = ""; + if ($callWith and $callWith eq "ScriptExecutionContext") { + $constructorArg = "context"; + push(@$outputArray, " ScriptExecutionContext* context = static_cast<${constructorClassName}*>(exec->callee())->scriptExecutionContext();\n"); + push(@$outputArray, " if (!context)\n"); + push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"Reference error\"));\n"); + } + push(@$outputArray, " return JSValue::encode(asObject(toJS(exec, static_cast<${constructorClassName}*>(exec->callee())->globalObject(), ${interfaceName}::create(${constructorArg}))));\n"); + push(@$outputArray, "}\n\n"); + } + + push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(ConstructData& constructData)\n"); + push(@$outputArray, "{\n"); + push(@$outputArray, " constructData.native.function = construct${className};\n"); + push(@$outputArray, " return ConstructTypeHost;\n"); + push(@$outputArray, "}\n\n"); + } +} + +1; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm new file mode 100644 index 0000000..6ccebf9 --- /dev/null +++ b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -0,0 +1,1816 @@ +# +# 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; + +# Global Variables +my $module = ""; +my $outputDir = ""; +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 $buildingForTigerOrEarlier = 1 if $ENV{"MACOSX_DEPLOYMENT_TARGET"} and $ENV{"MACOSX_DEPLOYMENT_TARGET"} <= 10.4; +my $buildingForLeopardOrLater = 1 if $ENV{"MACOSX_DEPLOYMENT_TARGET"} and $ENV{"MACOSX_DEPLOYMENT_TARGET"} >= 10.5; +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; + $outputDir = shift; + shift; # $outputHeadersDir + shift; # $useLayerOnTop + shift; # $preprocessor + $writeDependencies = shift; + + bless($reference, $object); + return $reference; +} + +sub finish +{ + my $object = shift; +} + +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 GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } + } else { + return ""; + } +} + +# Params: 'domClass' struct +sub GenerateInterface +{ + my $object = shift; + my $dataNode = shift; + my $defines = shift; + + $fatalError = 0; + + my $name = $dataNode->name; + my $className = GetClassName($name); + my $parentClassName = "DOM" . GetParentImplClassName($dataNode); + $isProtocol = $dataNode->extendedAttributes->{ObjCProtocol}; + $noImpl = $dataNode->extendedAttributes->{ObjCCustomImplementation} || $isProtocol; + + ReadPublicInterfaces($className, $parentClassName, $defines, $isProtocol); + + # Start actual generation.. + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode) unless $noImpl; + + # Write changes. + $object->WriteData("DOM" . $name); + + # 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; +} + +# Params: 'idlDocument' struct +sub GenerateModule +{ + my $object = shift; + my $dataNode = shift; + + $module = $dataNode->module; +} + +sub GetClassName +{ + my $name = $codeGenerator->StripModule(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 = $codeGenerator->StripModule(shift); + + return "DOMImplementationFront" if $name eq "DOMImplementation"; + return "DOMWindow" if $name eq "AbstractView"; + return $name; +} + +sub GetParentImplClassName +{ + my $dataNode = shift; + + return "Object" if @{$dataNode->parents} eq 0; + + my $parent = $codeGenerator->StripModule($dataNode->parents(0)); + + # special cases + return "Object" if $parent eq "HTMLCollection"; + + return $parent; +} + +sub GetParentAndProtocols +{ + my $dataNode = shift; + my $numParents = @{$dataNode->parents}; + + my $parent = ""; + my @protocols = (); + if ($numParents eq 0) { + if ($isProtocol) { + push(@protocols, "NSObject"); + push(@protocols, "NSCopying") if $dataNode->name eq "EventTarget"; + } else { + $parent = "DOMObject"; + } + } elsif ($numParents eq 1) { + my $parentName = $codeGenerator->StripModule($dataNode->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 = @{$dataNode->parents}; + my $firstParent = $codeGenerator->StripModule(shift(@parents)); + if (IsProtocolType($firstParent)) { + push(@protocols, "DOM" . $firstParent); + if (!$isProtocol) { + $parent = "DOMObject"; + } + } else { + $parent = "DOM" . $firstParent; + } + + foreach my $parentName (@parents) { + $parentName = $codeGenerator->StripModule($parentName); + 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"; + 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 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" or $type eq "SVGPaintType"; + return "$name *"; +} + +sub GetPropertyAttributes +{ + my $type = $codeGenerator->StripModule(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" && $type ne "SVGPaintType") { + push(@attributes, "retain"); + } + + return "" unless @attributes > 0; + return "(" . join(", ", @attributes) . ")"; +} + +sub ConversionNeeded +{ + my $type = $codeGenerator->StripModule(shift); + + return !$codeGenerator->IsNonPointerType($type) && !$codeGenerator->IsStringType($type) && !IsNativeObjCType($type); +} + +sub GetObjCTypeGetter +{ + my $argName = shift; + my $type = $codeGenerator->StripModule(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 "static_cast<WebCore::SVGPaint::SVGPaintType>($argName)" if $type eq "SVGPaintType"; + 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 = $codeGenerator->StripModule(shift); + my $public = shift; + + return if $codeGenerator->IsNonPointerType($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 = $codeGenerator->StripModule(shift); + + return if $codeGenerator->IsNonPointerType($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{"CSSMutableStyleDeclaration.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->AvoidInclusionOfType($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 $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = GetClassName($interfaceName); + + my $parentName = ""; + my @protocolsToImplement = (); + ($parentName, @protocolsToImplement) = GetParentAndProtocols($dataNode); + + my $numConstants = @{$dataNode->constants}; + my $numAttributes = @{$dataNode->attributes}; + my $numFunctions = @{$dataNode->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 = (); + + # FIXME: we need a way to include multiple enums. + foreach my $constant (@{$dataNode->constants}) { + my $constantName = $constant->name; + my $constantValue = $constant->value; + + my $output = " DOM_" . $constantName . " = " . $constantValue; + push(@headerConstants, $output); + } + + my $combinedConstants = join(",\n", @headerConstants); + + # 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 (@{$dataNode->attributes}) { + 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}; + } + + $availabilityMacro = "WEBKIT_OBJC_METHOD_ANNOTATION($availabilityMacro)" if length $availabilityMacro and $buildingForTigerOrEarlier; + + 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; + } + + if ($buildingForLeopardOrLater) { + $property .= $declarationSuffix; + push(@headerAttributes, $property) if $public; + push(@privateHeaderAttributes, $property) unless $public; + } else { + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + if ($attributeConditionalString) { + push(@headerAttributes, "#if ${attributeConditionalString}\n") if $public; + push(@privateHeaderAttributes, "#if ${attributeConditionalString}\n") unless $public; + } + + # - GETTER + my $getter = "- (" . $attributeType . ")" . $attributeName . $declarationSuffix; + push(@headerAttributes, $getter) if $public; + push(@privateHeaderAttributes, $getter) unless $public; + + # - SETTER + if (!$attributeIsReadonly) { + my $setter = "- (void)$setterName(" . $attributeType . ")new" . ucfirst($attributeName) . $declarationSuffix; + push(@headerAttributes, $setter) if $public; + push(@privateHeaderAttributes, $setter) unless $public; + } + + if ($attributeConditionalString) { + push(@headerAttributes, "#endif\n") if $public; + push(@privateHeaderAttributes, "#endif\n") unless $public; + } + } + } + + push(@headerContent, @headerAttributes) if @headerAttributes > 0; + } + + my @headerFunctions = (); + my @privateHeaderFunctions = (); + my @deprecatedHeaderFunctions = (); + + # - Add functions. + if ($numFunctions > 0) { + foreach my $function (@{$dataNode->functions}) { + my $functionName = $function->signature->name; + + my $returnType = GetObjCType($function->signature->type); + my $needsDeprecatedVersion = (@{$function->parameters} > 1 and $function->signature->extendedAttributes->{"OldStyleObjC"}); + 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) { + my $paramPrefix = $param->extendedAttributes->{"ObjCPrefix"}; + $paramPrefix = $paramName unless defined($paramPrefix); + $functionSig .= " $paramPrefix"; + $methodName .= $paramPrefix; + } + + $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}; + } + + $availabilityMacro = "WEBKIT_OBJC_METHOD_ANNOTATION($availabilityMacro)" if length $availabilityMacro and $buildingForTigerOrEarlier; + + 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; + } + + 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}; + } + + $availabilityMacro = "WEBKIT_OBJC_METHOD_ANNOTATION($availabilityMacro)" if $buildingForTigerOrEarlier; + + $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 OldStyleObjC IDL attribute removed"; + $fatalError = 1; + } + + delete $publicInterfaces{$publicInterfaceKey}; + } + } + + if (@headerFunctions > 0) { + push(@headerContent, "\n") if $buildingForLeopardOrLater and @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 $buildingForLeopardOrLater and @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 ($dataNode->extendedAttributes->{Polymorphic}) { + 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 $dataNode = shift; + + my @ancestorInterfaceNames = (); + + if (@{$dataNode->parents} > 1) { + $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@ancestorInterfaceNames); + } + + my $interfaceName = $dataNode->name; + my $className = GetClassName($interfaceName); + my $implClassName = GetImplClassName($interfaceName); + my $parentImplClassName = GetParentImplClassName($dataNode); + my $implClassNameWithNamespace = "WebCore::" . $implClassName; + my $baseClass = GetBaseClass($parentImplClassName); + my $classHeaderName = GetClassHeaderName($className); + + my $numAttributes = @{$dataNode->attributes}; + my $numFunctions = @{$dataNode->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 = GenerateConditionalString($dataNode); + 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->AvoidInclusionOfType($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 (@{$dataNode->attributes}) { + AddIncludesForType($attribute->signature->type); + + my $idlType = $codeGenerator->StripModule($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 $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + + # 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 = "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(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->{"ConvertToString"}) { + $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) 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->AvoidInclusionOfType($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/) { + my $extraImp = "WebCore::GetOwnerElementForType<$implClassNameWithNamespace, WebCore::IsDerivedFromSVGElement<$implClassNameWithNamespace>::value>::ownerElement(IMPL), "; + $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($extraImp$getterContentHead"; + $getterContentTail .= ")))"; + } else { + $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($getterContentHead"; + $getterContentTail .= ")))"; + } + } else { + $getterContentHead = "kit(WTF::getPtr($getterContentHead"; + $getterContentTail .= "))"; + } + } + + my $getterContent; + if ($hasGetterException) { + $getterContent = $getterContentHead . "ec" . $getterContentTail; + } else { + $getterContent = $getterContentHead . $getterContentTail; + } + + my $attributeConditionalString = 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 ConvertToString is flipped for the setter + if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { + $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) { + $getterContentHead = "$getterExpressionPrefix"; + push(@implContent, " if (IMPL->role() == WebCore::AnimValRole) {\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, 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 $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + my $ec = $hasSetterException ? ", ec" : ""; + push(@implContent, " $exceptionInit\n") if $hasSetterException; + push(@implContent, " IMPL->$setterExpressionPrefix$arg$ec);\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 (@{$dataNode->functions}) { + 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 = $codeGenerator->StripModule($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->{"Return"}; + + unless ($codeGenerator->IsPrimitiveType($idlType) or $codeGenerator->IsStringType($idlType)) { + push(@needsAssert, " ASSERT($paramName);\n"); + } + + if ($parameterIndex >= 1) { + my $paramPrefix = $param->extendedAttributes->{"ObjCPrefix"}; + $paramPrefix = $param->name unless defined($paramPrefix); + $functionSig .= " $paramPrefix"; + } + + $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->{"UsesView"}) { + 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, "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 = $codeGenerator->StripModule($param->type); + next if not $codeGenerator->IsSVGTypeNeedingTearOff($idlType) or $implClassName =~ /List$/; + + my $implGetter = GetObjCTypeGetter($paramName, $idlType); + my $idlTypeWithNamespace = GetSVGTypeWithNamespace($idlType); + + 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 = $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; + + if ($svgPropertyType) { + push(@functionContent, " if (IMPL->role() == WebCore::AnimValRole) {\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.$content"; + } else { + $content = $caller . "->$content"; + } + + 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"); + } + } + + push(@implContent, "$functionSig\n"); + push(@implContent, "{\n"); + push(@implContent, " $jsContextSetter\n"); + push(@implContent, @functionContent); + push(@implContent, "}\n\n"); + + # generate the old style method names with un-named parameters, these methods are deprecated + if (@{$function->parameters} > 1 and $function->signature->extendedAttributes->{"OldStyleObjC"}) { + 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 ($dataNode->extendedAttributes->{Polymorphic}) { + 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 $name = shift; + + # Open files for writing... + my $headerFileName = "$outputDir/" . $name . ".h"; + my $privateHeaderFileName = "$outputDir/" . $name . "Private.h"; + my $implFileName = "$outputDir/" . $name . ".mm"; + my $internalHeaderFileName = "$outputDir/" . $name . "Internal.h"; + my $depsFileName = "$outputDir/" . $name . ".dep"; + + # Remove old files. + unlink($headerFileName); + unlink($privateHeaderFileName); + unlink($implFileName); + unlink($internalHeaderFileName); + unlink($depsFileName); + + # Write public header. + open(HEADER, ">$headerFileName") or die "Couldn't open file $headerFileName"; + + print HEADER @headerContentHeader; + print HEADER map { "\@class $_;\n" } sort keys(%headerForwardDeclarations); + print HEADER map { "\@protocol $_;\n" } sort keys(%headerForwardDeclarationsForProtocols); + + my $hasForwardDeclarations = keys(%headerForwardDeclarations) + keys(%headerForwardDeclarationsForProtocols); + print HEADER "\n" if $hasForwardDeclarations; + print HEADER @headerContent; + + close(HEADER); + + @headerContentHeader = (); + @headerContent = (); + %headerForwardDeclarations = (); + %headerForwardDeclarationsForProtocols = (); + + if (@privateHeaderContent > 0) { + open(PRIVATE_HEADER, ">$privateHeaderFileName") or die "Couldn't open file $privateHeaderFileName"; + + print PRIVATE_HEADER @privateHeaderContentHeader; + print PRIVATE_HEADER map { "\@class $_;\n" } sort keys(%privateHeaderForwardDeclarations); + print PRIVATE_HEADER map { "\@protocol $_;\n" } sort keys(%privateHeaderForwardDeclarationsForProtocols); + + $hasForwardDeclarations = keys(%privateHeaderForwardDeclarations) + keys(%privateHeaderForwardDeclarationsForProtocols); + print PRIVATE_HEADER "\n" if $hasForwardDeclarations; + print PRIVATE_HEADER @privateHeaderContent; + + close(PRIVATE_HEADER); + + @privateHeaderContentHeader = (); + @privateHeaderContent = (); + %privateHeaderForwardDeclarations = (); + %privateHeaderForwardDeclarationsForProtocols = (); + } + + # Write implementation file. + unless ($noImpl) { + open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName"; + + print IMPL @implContentHeader; + print IMPL map { "#import \"$_\"\n" } sort keys(%implIncludes); + print IMPL @implContent; + + close(IMPL); + + @implContentHeader = (); + @implContent = (); + %implIncludes = (); + } + + if (@internalHeaderContent > 0) { + open(INTERNAL_HEADER, ">$internalHeaderFileName") or die "Couldn't open file $internalHeaderFileName"; + + print INTERNAL_HEADER @internalHeaderContent; + + close(INTERNAL_HEADER); + + @internalHeaderContent = (); + } + + # Write dependency file. + if (@depsContent) { + open(DEPS, ">$depsFileName") or die "Couldn't open file $depsFileName"; + print DEPS @depsContent; + close(DEPS); + @depsContent = (); + } +} + +1; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm new file mode 100644 index 0000000..f50e74a --- /dev/null +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -0,0 +1,3251 @@ +# 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 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) +# +# 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 Digest::MD5; + +my $module = ""; +my $outputDir = ""; +my $outputHeadersDir = ""; + +my @headerContent = (); +my @implContentHeader = (); +my @implFixedHeader = (); +my @implContent = (); +my @implContentDecls = (); +my %implIncludes = (); +my %headerIncludes = (); + +my @allParents = (); + +# 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; + $outputDir = shift; + $outputHeadersDir = shift; + + bless($reference, $object); + return $reference; +} + +sub finish +{ + my $object = shift; + + # Commit changes! + $object->WriteData(); +} + +# Params: 'domClass' struct +sub GenerateInterface +{ + my $object = shift; + my $dataNode = shift; + my $defines = shift; + + # Start actual generation + if ($dataNode->extendedAttributes->{"Callback"}) { + $object->GenerateCallbackHeader($dataNode); + $object->GenerateCallbackImplementation($dataNode); + } else { + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + } + + my $name = $dataNode->name; + + # Open files for writing + my $headerFileName = "$outputHeadersDir/V8$name.h"; + my $implFileName = "$outputDir/V8$name.cpp"; + + open($IMPL, ">$implFileName") || die "Couldn't open file $implFileName"; + open($HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName"; +} + +# Params: 'idlDocument' struct +sub GenerateModule +{ + my $object = shift; + my $dataNode = shift; + + $module = $dataNode->module; +} + +sub AddIncludesForType +{ + my $type = $codeGenerator->StripModule(shift); + + # When we're finished with the one-file-per-class + # reorganization, we won't need these special cases. + if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->AvoidInclusionOfType($type) and $type ne "Date") { + # default, include the same named file + $implIncludes{GetV8HeaderName(${type})} = 1; + + if ($type =~ /SVGPathSeg/) { + $joinedName = $type; + $joinedName =~ s/Abs|Rel//; + $implIncludes{"${joinedName}.h"} = 1; + } + } + + # 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") { + $implIncludes{"PlatformString.h"} = 1; + } + + if ($type eq "CSSStyleDeclaration") { + $implIncludes{"CSSMutableStyleDeclaration.h"} = 1; + } + + if ($type eq "Plugin" or $type eq "PluginArray" or $type eq "MimeTypeArray") { + # So we can get String -> AtomicString conversion for namedItem(). + $implIncludes{"wtf/text/AtomicString.h"} = 1; + } +} + +# If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if. +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } + } else { + return ""; + } +} + +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; + $implIncludes{"SVGAnimatedPropertyTearOff.h"} = 1; + } 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 $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + my $implClassName = $interfaceName; + + # Copy contents of parent classes except the first parent or if it is + # EventTarget. + $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 1); + + my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; + + # - Add default header template + push(@headerContent, GenerateHeaderContentHeader($dataNode)); + + $headerIncludes{"wtf/text/StringHash.h"} = 1; + $headerIncludes{"WrapperTypeInfo.h"} = 1; + $headerIncludes{"V8DOMWrapper.h"} = 1; + + my $headerClassInclude = GetHeaderClassInclude($implClassName); + $headerIncludes{$headerClassInclude} = 1 if $headerClassInclude ne ""; + + my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implClassName); + + foreach my $headerInclude (sort keys(%headerIncludes)) { + push(@headerContent, "#include \"${headerInclude}\"\n"); + } + + push(@headerContent, "#include <v8.h>\n"); + push(@headerContent, "#include <wtf/HashMap.h>\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, "\nclass FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect"; + push(@headerContent, "\nclass $className {\n"); + + my $nativeType = GetNativeTypeForConversions($dataNode, $interfaceName); + my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName); + my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : ""; + my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : ""; + my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : ""; + + push(@headerContent, <<END); + +public: + static bool HasInstance(v8::Handle<v8::Value> 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->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(${nativeType}*${forceNewObjectParameter}); + static void derefObject(void*); + static WrapperTypeInfo info; +END + if (IsActiveDomType($implClassName)) { + push(@headerContent, " static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);\n"); + } + + if ($implClassName eq "DOMWindow") { + push(@headerContent, <<END); + static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(); +END + } + + if ($implClassName 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); +END + } + + my @enabledAtRuntime; + foreach my $function (@{$dataNode->functions}) { + my $name = $function->signature->name; + my $attrExt = $function->signature->extendedAttributes; + + if ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { + push(@headerContent, <<END); + static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments&); +END + } + + if ($attrExt->{"EnabledAtRuntime"}) { + push(@enabledAtRuntime, $function); + } + } + + if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"}) { + push(@headerContent, <<END); + static v8::Handle<v8::Value> constructorCallback(const v8::Arguments& args); +END + } + + foreach my $attribute (@{$dataNode->attributes}) { + my $name = $attribute->signature->name; + my $attrExt = $attribute->signature->extendedAttributes; + if ($attrExt->{"V8CustomGetter"} || $attrExt->{"CustomGetter"} + || $attrExt->{"V8Custom"} || $attrExt->{"Custom"}) { + push(@headerContent, <<END); + static v8::Handle<v8::Value> ${name}AccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info); +END + } + if ($attrExt->{"V8CustomSetter"} || $attrExt->{"CustomSetter"} + || $attrExt->{"V8Custom"} || $attrExt->{"Custom"}) { + push(@headerContent, <<END); + static void ${name}AccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info); +END + } + if ($attrExt->{"EnabledAtRuntime"}) { + push(@enabledAtRuntime, $attribute); + } + } + + GenerateHeaderNamedAndIndexedPropertyAccessors($dataNode); + GenerateHeaderCustomCall($dataNode); + GenerateHeaderCustomInternalFieldIndices($dataNode); + + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"}) { + 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 + } + + push(@headerContent, <<END); +private: + static v8::Handle<v8::Object> wrapSlow(${nativeType}*); +}; + +END + + push(@headerContent, <<END); + +v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) +{ +END + if ($domMapFunction) { + push(@headerContent, " if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName); + my $getWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getWrapper(impl)" : "${domMapFunction}.get(impl)"; + push(@headerContent, <<END); + v8::Handle<v8::Object> wrapper = ${getWrapper}; + if (!wrapper.IsEmpty()) + return wrapper; +END + push(@headerContent, " }\n") if IsDOMNodeType($interfaceName); + } + push(@headerContent, <<END); + return ${className}::wrapSlow(impl); +} +END + + if (!HasCustomToV8Implementation($dataNode, $interfaceName)) { + push(@headerContent, <<END); + +inline v8::Handle<v8::Value> toV8(${nativeType}* impl${forceNewObjectParameter}) +{ + if (!impl) + return v8::Null(); + return ${className}::wrap(impl${forceNewObjectCall}); +} +END + } elsif ($interfaceName ne 'Node') { + push(@headerContent, <<END); + +v8::Handle<v8::Value> toV8(${nativeType}*${forceNewObjectParameter}); +END + } else { + push(@headerContent, <<END); + +v8::Handle<v8::Value> toV8Slow(Node*, bool); + +inline v8::Handle<v8::Value> toV8(Node* impl, bool forceNewObject = false) +{ + if (!impl) + return v8::Null(); + if (!forceNewObject) { + v8::Handle<v8::Value> wrapper = V8DOMWrapper::getWrapper(impl); + if (!wrapper.IsEmpty()) + return wrapper; + } + return toV8Slow(impl, forceNewObject); +} +END + } + + if (IsRefPtrType($implClassName)) { + push(@headerContent, <<END); +inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl${forceNewObjectParameter}) +{ + return toV8(impl.get()${forceNewObjectCall}); +} +END + } + + push(@headerContent, "}\n\n"); + push(@headerContent, "#endif // $className" . "_h\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; +} + +sub GetInternalFields +{ + my $dataNode = shift; + my $name = $dataNode->name; + + my @customInternalFields = (); + + # We can't ask whether a parent type has a given extendedAttribute, so special-case Node, AbstractWorker and WorkerContext to include all sub-types. + # FIXME: SVGElementInstance should probably have the EventTarget extended attribute, but doesn't. + if ($dataNode->extendedAttributes->{"EventTarget"} || IsNodeSubType($dataNode) || IsSubType($dataNode, "AbstractWorker") || IsSubType($dataNode, "WorkerContext") + || $name eq "SVGElementInstance") { + push(@customInternalFields, "eventListenerCacheIndex"); + } + + if (IsSubType($dataNode, "Document")) { + push(@customInternalFields, "implementationIndex"); + } elsif ($name eq "DOMWindow") { + push(@customInternalFields, "enteredIsolatedWorldIndex"); + } + return @customInternalFields; +} + +sub GetHeaderClassInclude +{ + my $className = shift; + if ($className =~ /SVGPathSeg/) { + $className =~ s/Abs|Rel//; + } + return "" if ($codeGenerator->AvoidInclusionOfType($className)); + return "${className}.h"; +} + +sub GenerateHeaderCustomInternalFieldIndices +{ + my $dataNode = shift; + my @customInternalFields = GetInternalFields($dataNode); + 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 $dataNode = shift; + my $interfaceName = $dataNode->name; + my $hasCustomIndexedGetter = $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}; + my $hasCustomIndexedSetter = $dataNode->extendedAttributes->{"HasCustomIndexSetter"} && !$dataNode->extendedAttributes->{"HasNumericIndexGetter"}; + my $hasCustomNamedGetter = $dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasOverridingNameGetter"} || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}; + my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"DelegatingPutFunction"}; + my $hasCustomDeleters = $dataNode->extendedAttributes->{"CustomDeleteProperty"}; + my $hasCustomEnumerator = $dataNode->extendedAttributes->{"CustomGetPropertyNames"}; + if ($interfaceName eq "HTMLOptionsCollection") { + $interfaceName = "HTMLCollection"; + $hasCustomIndexedGetter = 1; + $hasCustomNamedGetter = 1; + } + if ($interfaceName eq "DOMWindow") { + $hasCustomDeleterr = 0; + $hasEnumerator = 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 $dataNode = shift; + + if ($dataNode->extendedAttributes->{"CustomCall"}) { + push(@headerContent, " static v8::Handle<v8::Value> callAsFunctionCallback(const v8::Arguments&);\n"); + } + if ($dataNode->name eq "Event") { + push(@headerContent, " static v8::Handle<v8::Value> dataTransferAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info);\n"); + push(@headerContent, " static void valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info);\n"); + } + if ($dataNode->name eq "Location") { + push(@headerContent, " static v8::Handle<v8::Value> assignAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info);\n"); + push(@headerContent, " static v8::Handle<v8::Value> reloadAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info);\n"); + push(@headerContent, " static v8::Handle<v8::Value> replaceAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info);\n"); + } +} + +sub GenerateSetDOMException +{ + my $indent = shift; + my $result = ""; + + $result .= $indent . "if (UNLIKELY(ec)) {\n"; + $result .= $indent . " V8Proxy::setDOMException(ec);\n"; + $result .= $indent . " return v8::Handle<v8::Value>();\n"; + $result .= $indent . "}\n"; + + return $result; +} + +sub IsSubType +{ + my $dataNode = shift; + my $parentType = shift; + return 1 if ($dataNode->name eq $parentType); + foreach (@allParents) { + my $parent = $codeGenerator->StripModule($_); + return 1 if $parent eq $parentType; + } + return 0; +} + +sub IsNodeSubType +{ + my $dataNode = shift; + return IsSubType($dataNode, "Node"); +} + +sub GenerateDomainSafeFunctionGetter +{ + my $function = shift; + my $implClassName = shift; + + my $className = "V8" . $implClassName; + my $funcName = $function->signature->name; + + my $signature = "v8::Signature::New(" . $className . "::GetRawTemplate())"; + if ($function->signature->extendedAttributes->{"V8DoNotCheckSignature"}) { + $signature = "v8::Local<v8::Signature>()"; + } + + my $newTemplateString = GenerateNewFunctionTemplate($function, $implClassName, $signature); + + push(@implContentDecls, <<END); +static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS(\"DOM.$implClassName.$funcName._get\"); + static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(${className}::GetTemplate(), info.This()); + if (holder.IsEmpty()) { + // can only reach here by 'object.__proto__.func', and it should passed + // domain security check already + return privateTemplate->GetFunction(); + } + ${implClassName}* imp = ${className}::toNative(holder); + if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false)) { + static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New($newTemplateString); + return sharedTemplate->GetFunction(); + } + return privateTemplate->GetFunction(); +} + +END +} + +sub GenerateConstructorGetter +{ + my $implClassName = shift; + + push(@implContentDecls, <<END); +static v8::Handle<v8::Value> ${implClassName}ConstructorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS(\"DOM.$implClassName.constructors._get\"); + v8::Handle<v8::Value> data = info.Data(); + ASSERT(data->IsExternal() || data->IsNumber()); + WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); +END + + if ($implClassName eq "DOMWindow") { + push(@implContentDecls, <<END); + // Get the proxy corresponding to the DOMWindow if possible to + // make sure that the constructor function is constructed in the + // context of the DOMWindow and not in the context of the caller. + return V8DOMWrapper::getConstructor(type, V8DOMWindow::toNative(info.Holder())); +END + } elsif ($implClassName eq "DedicatedWorkerContext" or $implClassName eq "WorkerContext" or $implClassName eq "SharedWorkerContext") { + push(@implContentDecls, <<END); + return V8DOMWrapper::getConstructor(type, V8WorkerContext::toNative(info.Holder())); +END + } else { + push(@implContentDecls, " return v8::Handle<v8::Value>();"); + } + + push(@implContentDecls, <<END); +} + +END +} + +sub GenerateNormalAttrGetter +{ + my $attribute = shift; + my $dataNode = shift; + my $implClassName = shift; + my $interfaceName = shift; + + my $attrExt = $attribute->signature->extendedAttributes; + my $attrName = $attribute->signature->name; + my $attrType = GetTypeFromSignature($attribute->signature); + my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); + + my $getterStringUsesImp = $implClassName ne "SVGNumber"; + my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implClassName); + + # Getter + my $conditionalString = 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) +{ + INC_STATS(\"DOM.$implClassName.$attrName._get\"); +END + + if ($svgNativeType) { + my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); + if ($svgWrappedNativeType =~ /List/) { + push(@implContentDecls, <<END); + $svgNativeType* imp = V8${implClassName}::toNative(info.Holder()); +END + } else { + push(@implContentDecls, <<END); + $svgNativeType* wrapper = V8${implClassName}::toNative(info.Holder()); + $svgWrappedNativeType& impInstance = wrapper->propertyReference(); +END + if ($getterStringUsesImp) { + push(@implContentDecls, <<END); + $svgWrappedNativeType* imp = &impInstance; +END + } + } + } elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) { + 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 = V8DOMWrapper::lookupDOMWrapper(V8${interfaceName}::GetTemplate(), info.This()); + if (holder.IsEmpty()) + return v8::Handle<v8::Value>(); +END + } + push(@implContentDecls, <<END); + ${implClassName}* imp = V8${implClassName}::toNative(holder); +END + } else { + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $url = $attribute->signature->extendedAttributes->{"URL"}; + if ($getterStringUsesImp && $reflect && !$url && IsNodeSubType($dataNode) && $codeGenerator->IsStringType($attrType)) { + # Generate super-compact call for regular attribute getter: + my $contentAttributeName = $reflect eq "1" ? lc $attrName : $reflect; + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + push(@implContentDecls, " return getElementStringAttr(info, ${namespace}::${contentAttributeName}Attr);\n"); + push(@implContentDecls, "}\n\n"); + push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; + return; + # Skip the rest of the function! + } + push(@implContentDecls, <<END); + ${implClassName}* imp = V8${implClassName}::toNative(info.Holder()); +END + } + + # Generate security checks if necessary + if ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { + push(@implContentDecls, " if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->$attrName()))\n return v8::Handle<v8::Value>();\n\n"); + } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { + push(@implContentDecls, " if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->contentDocument()))\n return v8::Handle<v8::Value>();\n\n"); + } + + my $useExceptions = 1 if @{$attribute->getterExceptions}; + if ($useExceptions) { + $implIncludes{"ExceptionCode.h"} = 1; + push(@implContentDecls, " ExceptionCode ec = 0;\n"); + } + + if ($attribute->signature->extendedAttributes->{"v8referenceattr"}) { + $attrName = $attribute->signature->extendedAttributes->{"v8referenceattr"}; + } + + my $returnType = GetTypeFromSignature($attribute->signature); + + my $getterString; + if ($getterStringUsesImp) { + $getterString = "imp->" . $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + $getterString .= "ec" if $useExceptions; + $getterString .= ")"; + } else { + $getterString = "impInstance"; + } + + my $result; + my $wrapper; + + if ($attribute->signature->type eq "EventListener" && $dataNode->name eq "DOMWindow") { + push(@implContentDecls, " if (!imp->document())\n"); + push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); + } + + if ($useExceptions) { + if ($nativeType =~ /^V8Parameter/) { + push(@implContentDecls, " " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $getterString) . ";\n"); + } else { + push(@implContentDecls, " $nativeType v = $getterString;\n"); + } + push(@implContentDecls, GenerateSetDOMException(" ")); + $result = "v"; + $result .= ".release()" if (IsRefPtrType($returnType)); + } else { + # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary + $result = $getterString; + } + + # 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 (!IsNodeSubType($dataNode) && $attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"}) + && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow" + && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType))) { + AddIncludesForType($returnType); + my $domMapFunction = GetDomMapFunction(0, $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() ? ${domMapFunction}.get(result.get()) : v8::Handle<v8::Value>();\n"); + push(@implContentDecls, " if (wrapper.IsEmpty()) {\n"); + push(@implContentDecls, " wrapper = toV8(result.get());\n"); + push(@implContentDecls, " if (!wrapper.IsEmpty())\n"); + if ($dataNode->name eq "DOMWindow") { + push(@implContentDecls, " V8DOMWrapper::setHiddenWindowReference(imp->frame(), wrapper);\n"); + } else { + push(@implContentDecls, " V8DOMWrapper::setHiddenReference(info.Holder(), 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($implClassName) and $codeGenerator->IsSVGTypeNeedingTearOff($attrType)) { + $implIncludes{"V8$attrType.h"} = 1; + my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); + # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked. + push(@implContentDecls, " return toV8(static_cast<$svgNativeType*>($result));\n"); + } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $implClassName =~ /List$/) { + $implIncludes{"V8$attrType.h"} = 1; + $implIncludes{"SVGPropertyTearOff.h"} = 1; + my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); + if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { + my $getter = $result; + $getter =~ s/imp->//; + $getter =~ s/\(\)//; + + my $updateMethod = "&${implClassName}::update" . $codeGenerator->WK_ucfirst($getter); + + my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($implClassName); + if ($selfIsTearOffType) { + $implIncludes{"SVGStaticPropertyWithParentTearOff.h"} = 1; + $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParentTearOff<$implClassName, /; + + if ($result =~ /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. + $result =~ s/matrix/svgMatrix/; + } + + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(wrapper, $result, $updateMethod)));\n"); + } else { + $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; + $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassName, /; + + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(imp, $result, $updateMethod)));\n"); + } + } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { + my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), "; + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($extraImp$result)));\n"); + } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { + push(@implContentDecls, " return toV8(WTF::getPtr($result));\n"); + } else { + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($result)));\n"); + } + } else { + push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n"); + } + + push(@implContentDecls, "}\n\n"); # end of getter + push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; +} + +sub GenerateNormalAttrSetter +{ + my $attribute = shift; + my $dataNode = shift; + my $implClassName = shift; + my $interfaceName = shift; + + $implIncludes{"V8BindingMacros.h"} = 1; + + my $attrExt = $attribute->signature->extendedAttributes; + + my $conditionalString = 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, " INC_STATS(\"DOM.$implClassName.$attrName._set\");\n"); + + # 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 = GetTypeFromSignature($attribute->signature); + if (IsWrapperType($argType)) { + push(@implContentDecls, " if (!isUndefinedOrNull(value) && !V8${argType}::HasInstance(value)) {\n"); + push(@implContentDecls, " V8Proxy::throwTypeError();\n"); + push(@implContentDecls, " return;\n"); + push(@implContentDecls, " }\n"); + } + } + + my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implClassName); + if ($svgNativeType) { + my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); + if ($svgWrappedNativeType =~ /List$/) { + push(@implContentDecls, <<END); + $svgNativeType* imp = V8${implClassName}::toNative(info.Holder()); +END + } else { + push(@implContentDecls, " $svgNativeType* wrapper = V8${implClassName}::toNative(info.Holder());\n"); + push(@implContentDecls, " if (wrapper->role() == AnimValRole) {\n"); + push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR);\n"); + push(@implContentDecls, " return;\n"); + push(@implContentDecls, " }\n"); + push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); + push(@implContentDecls, " $svgWrappedNativeType* imp = &impInstance;\n"); + } + } elsif ($attrExt->{"v8OnProto"}) { + 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 = V8DOMWrapper::lookupDOMWrapper(V8${interfaceName}::GetTemplate(), info.This()); + if (holder.IsEmpty()) + return; +END + } + push(@implContentDecls, <<END); + ${implClassName}* imp = V8${implClassName}::toNative(holder); +END + } else { + my $attrType = GetTypeFromSignature($attribute->signature); + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + if ($reflect && IsNodeSubType($dataNode) && $codeGenerator->IsStringType($attrType)) { + # Generate super-compact call for regular attribute setter: + my $contentAttributeName = $reflect eq "1" ? lc $attrName : $reflect; + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + push(@implContentDecls, " setElementStringAttr(info, ${namespace}::${contentAttributeName}Attr, value);\n"); + push(@implContentDecls, "}\n\n"); + push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; + return; + # Skip the rest of the function! + } + + push(@implContentDecls, <<END); + ${implClassName}* imp = V8${implClassName}::toNative(info.Holder()); +END + } + + my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); + if ($attribute->signature->type eq "EventListener") { + if ($dataNode->name eq "DOMWindow") { + push(@implContentDecls, " if (!imp->document())\n"); + push(@implContentDecls, " return;\n"); + } + } else { + my $value = JSValueToNative($attribute->signature, "value"); + if ($nativeType =~ /^V8Parameter/) { + push(@implContentDecls, " " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n"); + } else { + push(@implContentDecls, " $nativeType v = $value;\n"); + } + } + + my $result = "v"; + my $returnType = GetTypeFromSignature($attribute->signature); + if (IsRefPtrType($returnType)) { + $result = "WTF::getPtr(" . $result . ")"; + } + + my $useExceptions = 1 if @{$attribute->setterExceptions}; + + if ($useExceptions) { + $implIncludes{"ExceptionCode.h"} = 1; + push(@implContentDecls, " ExceptionCode ec = 0;\n"); + } + + if ($implClassName eq "SVGNumber") { + push(@implContentDecls, " *imp = $result;\n"); + } else { + if ($attribute->signature->type eq "EventListener") { + my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); + $implIncludes{"V8AbstractEventListener.h"} = 1; + push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, V8${interfaceName}::eventListenerCacheIndex);\n"); + if ($interfaceName eq "WorkerContext" and $attribute->signature->name eq "onerror") { + $implIncludes{"V8EventListenerList.h"} = 1; + $implIncludes{"V8WorkerContextErrorHandler.h"} = 1; + push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"); + } else { + push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)"); + } + } else { + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + push(@implContentDecls, " imp->$setterExpressionPrefix$result"); + } + push(@implContentDecls, ", ec") if $useExceptions; + push(@implContentDecls, ");\n"); + } + + if ($useExceptions) { + push(@implContentDecls, " if (UNLIKELY(ec))\n"); + push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); + } + + if ($svgNativeType) { + if ($useExceptions) { + push(@implContentDecls, " if (!ec)\n"); + push(@implContentDecls, " wrapper->commitChange();\n"); + } else { + push(@implContentDecls, " wrapper->commitChange();\n"); + } + } + + push(@implContentDecls, " return;\n"); + push(@implContentDecls, "}\n\n"); # end of setter + push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString; +} + +sub GetFunctionTemplateCallbackName +{ + $function = shift; + $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}Internal::${name}Callback"; + } +} + +sub GenerateNewFunctionTemplate +{ + $function = shift; + $interfaceName = shift; + $signature = shift; + + my $callback = GetFunctionTemplateCallbackName($function, $interfaceName); + return "v8::FunctionTemplate::New($callback, v8::Handle<v8::Value>(), $signature)"; +} + +sub GenerateEventListenerCallback +{ + my $implClassName = 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) +{ + INC_STATS("DOM.${implClassName}.${functionName}EventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFind${lookupType}); + if (listener) { + V8${implClassName}::toNative(args.Holder())->${functionName}EventListener(v8ValueToAtomicWebCoreString(args[0]), listener${passRefPtrHandling}, args[2]->BooleanValue()); + ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], V8${implClassName}::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +END +} + +sub GenerateParametersCheckExpression +{ + my $numParameters = shift; + my $function = shift; + + my @andExpression = (); + push(@andExpression, "args.Length() == $numParameters"); + my $parameterIndex = 0; + foreach $parameter (@{$function->parameters}) { + last if $parameterIndex >= $numParameters; + my $value = "args[$parameterIndex]"; + my $type = GetTypeFromSignature($parameter); + + # Only DOMString or wrapper types are checked. + # For DOMString, Null, Undefined and any Object are accepted too, as + # these are acceptable values for a DOMString argument (any Object can + # be converted to a string via .toString). + if ($codeGenerator->IsStringType($type)) { + 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}->IsObject())"); + } elsif (IsWrapperType($type)) { + push(@andExpression, "(${value}->IsNull() || 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; + foreach $parameter (@{$function->parameters}) { + if ($parameter->extendedAttributes->{"Optional"}) { + push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); + } + $numParameters++; + } + push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); + return join(" || ", @orExpression); +} + +sub GenerateOverloadedFunctionCallback +{ + my $function = shift; + my $dataNode = shift; + my $implClassName = 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 $name = $function->signature->name; + push(@implContentDecls, <<END); +static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments& args) +{ + INC_STATS(\"DOM.$implClassName.$name\"); +END + + foreach my $overload (@{$function->{overloads}}) { + my $parametersCheck = GenerateFunctionParametersCheck($overload); + push(@implContentDecls, " if ($parametersCheck)\n"); + push(@implContentDecls, " return ${name}$overload->{overloadIndex}Callback(args);\n"); + } + push(@implContentDecls, <<END); + V8Proxy::throwTypeError(); + return notHandledByInterceptor(); +END + push(@implContentDecls, "}\n\n"); +} + +sub GenerateFunctionCallback +{ + my $function = shift; + my $dataNode = shift; + my $implClassName = shift; + + my $interfaceName = $dataNode->name; + 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 classes that take event listeners, + # so we can generate them as a "special case". + if ($name eq "addEventListener") { + GenerateEventListenerCallback($implClassName, "add"); + return; + } elsif ($name eq "removeEventListener") { + GenerateEventListenerCallback($implClassName, "remove"); + return; + } + + push(@implContentDecls, <<END); +static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments& args) +{ + INC_STATS(\"DOM.$implClassName.$name\"); +END + + my $numParameters = @{$function->parameters}; + + my $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"}; + if ($requiresAllArguments) { + my $numMandatoryParams = @{$function->parameters}; + foreach my $param (reverse(@{$function->parameters})) { + if ($param->extendedAttributes->{"Optional"}) { + $numMandatoryParams--; + } else { + last; + } + } + push(@implContentDecls, " if (args.Length() < $numMandatoryParams)\n"); + if ($requiresAllArguments eq "Raise") { + push(@implContentDecls, " return throwError(\"Not enough arguments\", V8Proxy::SyntaxError);\n"); + } else { + push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); + } + } + + my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implClassName); + + if ($svgNativeType) { + my $nativeClassName = GetNativeType($implClassName); + if ($implClassName =~ /List$/) { + push(@implContentDecls, " $nativeClassName imp = V8${implClassName}::toNative(args.Holder());\n"); + } else { + push(@implContentDecls, " $nativeClassName wrapper = V8${implClassName}::toNative(args.Holder());\n"); + push(@implContentDecls, " if (wrapper->role() == AnimValRole) {\n"); + push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR);\n"); + push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); + push(@implContentDecls, " }\n"); + my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); + push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); + push(@implContentDecls, " $svgWrappedNativeType* imp = &impInstance;\n"); + } + } elsif (!$function->signature->extendedAttributes->{"ClassMethod"}) { + push(@implContentDecls, <<END); + ${implClassName}* imp = V8${implClassName}::toNative(args.Holder()); +END + } + + # Check domain security if needed + if (($dataNode->extendedAttributes->{"CheckDomainSecurity"} + || $interfaceName eq "DOMWindow") + && !$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { + # We have not find real use cases yet. + push(@implContentDecls, <<END); + if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true)) + return v8::Handle<v8::Value>(); +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) { + $implIncludes{"ExceptionCode.h"} = 1; + 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->{"CustomArgumentHandling"}) { + push(@implContentDecls, <<END); + RefPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters)); + size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; + RefPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); + if (!callStack) + return v8::Undefined(); +END + $implIncludes{"ScriptArguments.h"} = 1; + $implIncludes{"ScriptCallStack.h"} = 1; + $implIncludes{"ScriptCallStackFactory.h"} = 1; + } + if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) { + push(@implContentDecls, <<END); + if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->getSVGDocument(ec))) + return v8::Handle<v8::Value>(); +END + } + + my $paramIndex = 0; + foreach my $parameter (@{$function->parameters}) { + TranslateParameter($parameter); + + my $parameterName = $parameter->name; + + # Optional callbacks should be treated differently, because they always have a default value (0), + # and we can reduce the number of overloaded functions that take a different number of parameters. + if ($parameter->extendedAttributes->{"Optional"} && !$parameter->extendedAttributes->{"Callback"}) { + # Generate early call if there are not enough parameters. + push(@implContentDecls, " if (args.Length() <= $paramIndex) {\n"); + my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $implClassName); + push(@implContentDecls, $functionCall); + push(@implContentDecls, " }\n"); + } + + $implIncludes{"ExceptionCode.h"} = 1; + my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); + if ($parameter->extendedAttributes->{"Callback"}) { + my $className = GetCallbackClassName($parameter->type); + $implIncludes{"$className.h"} = 1; + if ($parameter->extendedAttributes->{"Optional"}) { + push(@implContentDecls, " RefPtr<" . $parameter->type . "> $parameterName;\n"); + push(@implContentDecls, " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"); + push(@implContentDecls, " if (!args[$paramIndex]->IsObject())\n"); + push(@implContentDecls, " return throwError(TYPE_MISMATCH_ERR);\n"); + push(@implContentDecls, " $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"); + push(@implContentDecls, " }\n"); + } else { + push(@implContentDecls, " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n"); + push(@implContentDecls, " return throwError(TYPE_MISMATCH_ERR);\n"); + push(@implContentDecls, " RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"); + } + } elsif ($parameter->type eq "SerializedScriptValue") { + $implIncludes{"SerializedScriptValue.h"} = 1; + push(@implContentDecls, " bool ${parameterName}DidThrow = false;\n"); + push(@implContentDecls, " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n"); + push(@implContentDecls, " if (${parameterName}DidThrow)\n"); + push(@implContentDecls, " return v8::Undefined();\n"); + } elsif (TypeCanFailConversion($parameter)) { + push(@implContentDecls, " $nativeType $parameterName = " . + JSValueToNative($parameter, "args[$paramIndex]") . ";\n"); + push(@implContentDecls, " if (UNLIKELY(!$parameterName)) {\n"); + push(@implContentDecls, " ec = TYPE_MISMATCH_ERR;\n"); + push(@implContentDecls, " goto fail;\n"); + push(@implContentDecls, " }\n"); + } elsif ($nativeType =~ /^V8Parameter/) { + my $value = JSValueToNative($parameter, "args[$paramIndex]"); + push(@implContentDecls, " " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n"); + } else { + $implIncludes{"V8BindingMacros.h"} = 1; + # 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 = GetTypeFromSignature($parameter); + if (IsWrapperType($argType)) { + push(@implContentDecls, " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue)) {\n"); + push(@implContentDecls, " V8Proxy::throwTypeError();\n"); + push(@implContentDecls, " return notHandledByInterceptor();\n"); + push(@implContentDecls, " }\n"); + } + } + push(@implContentDecls, " EXCEPTION_BLOCK($nativeType, $parameterName, " . + JSValueToNative($parameter, "args[$paramIndex]") . ");\n"); + } + + if ($parameter->extendedAttributes->{"IsIndex"}) { + push(@implContentDecls, " if (UNLIKELY($parameterName < 0)) {\n"); + push(@implContentDecls, " ec = INDEX_SIZE_ERR;\n"); + push(@implContentDecls, " goto fail;\n"); + push(@implContentDecls, " }\n"); + } + + $paramIndex++; + } + + # Build the function call string. + my $callString = GenerateFunctionCallString($function, $paramIndex, " ", $implClassName); + push(@implContentDecls, "$callString"); + + if ($raisesExceptions) { + push(@implContentDecls, " }\n"); + push(@implContentDecls, " fail:\n"); + push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); + push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); + } + + push(@implContentDecls, "}\n\n"); +} + +sub GenerateBatchedAttributeData +{ + my $dataNode = shift; + my $interfaceName = $dataNode->name; + my $attributes = shift; + + foreach my $attribute (@$attributes) { + my $conditionalString = 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; + + # Attributes of type SerializedScriptValue are set in the + # constructor and don't require callbacks. + return if ($attribute->signature->type eq "SerializedScriptValue"); + + my $accessControl = "v8::DEFAULT"; + if ($attrExt->{"DoNotCheckDomainSecurityOnGet"}) { + $accessControl = "v8::ALL_CAN_READ"; + } elsif ($attrExt->{"DoNotCheckDomainSecurityOnSet"}) { + $accessControl = "v8::ALL_CAN_WRITE"; + } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) { + $accessControl = "v8::ALL_CAN_READ"; + if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) { + $accessControl .= " | v8::ALL_CAN_WRITE"; + } + } + if ($attrExt->{"V8DisallowShadowing"}) { + $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 1) { + # use the naming convension, interface + (capitalize) attr name + $customAccessor = $interfaceName . "::" . $attrName; + } + + my $getter; + my $setter; + my $propAttr = "v8::None"; + my $hasCustomSetter = 0; + + # Check attributes. + if ($attrExt->{"DontEnum"}) { + $propAttr .= " | v8::DontEnum"; + } + if ($attrExt->{"V8DisallowShadowing"}) { + $propAttr .= " | v8::DontDelete"; + } + + my $on_proto = "0 /* on instance */"; + my $data = "0 /* no data */"; + + # Constructor + if ($attribute->signature->type =~ /Constructor$/) { + my $constructorType = $codeGenerator->StripModule($attribute->signature->type); + $constructorType =~ s/Constructor$//; + $implIncludes{"V8${constructorType}.h"} = 1; + if ($customAccessor) { + $getter = "V8${customAccessor}AccessorGetter"; + } else { + $data = "&V8${constructorType}::info"; + $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter"; + } + $setter = "0"; + $propAttr = "v8::ReadOnly"; + + } else { + # Default Getter and Setter + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; + $setter = "${interfaceName}Internal::${attrName}AttrSetter"; + + # Custom Setter + if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { + $hasCustomSetter = 1; + $setter = "V8${customAccessor}AccessorSetter"; + } + + # Custom Getter + if ($attrExt->{"CustomGetter"} || $attrExt->{"V8CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { + $getter = "V8${customAccessor}AccessorGetter"; + } + } + + # Replaceable + if ($attrExt->{"Replaceable"} && !$hasCustomSetter) { + $setter = "0"; + # Handle the special case of window.top being marked as Replaceable. + # FIXME: Investigate whether we could treat window.top as replaceable + # and allow shadowing without it being a security hole. + if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) { + $propAttr .= " | v8::ReadOnly"; + } + } + + # Read only attributes + if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) { + $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 GenerateImplementationIndexer +{ + my $dataNode = shift; + my $indexer = shift; + my $interfaceName = $dataNode->name; + + # FIXME: Figure out what HasNumericIndexGetter is really supposed to do. Right now, it's only set on WebGL-related files. + my $hasCustomSetter = $dataNode->extendedAttributes->{"HasCustomIndexSetter"} && !$dataNode->extendedAttributes->{"HasNumericIndexGetter"}; + my $hasGetter = $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}; + + # FIXME: Find a way to not have to special-case HTMLOptionsCollection. + if ($interfaceName eq "HTMLOptionsCollection") { + $hasGetter = 1; + } + + # 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 ($dataNode->extendedAttributes->{"DelegatingPutFunction"}) { + $hasCustomSetter = 1; + } + } + + if (!$hasGetter) { + return; + } + + $implIncludes{"V8Collection.h"} = 1; + + 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"; + } + + # FIXME: The item() getter is not inherited from CSSValueList, seemingly due to the way + # the CodeGenerator->AddMethodsConstantsAndAttributesFromParentClasses() method works, + # so we need to set the indexerType manually in this case. + if ($interfaceName eq "WebKitCSSTransformValue") { + $indexerType = "CSSValue"; + } + + if ($indexerType && !$hasCustomSetter) { + if ($indexerType eq "DOMString") { + my $conversion = $indexer->extendedAttributes->{"ConvertNullStringTo"}; + if ($conversion && $conversion eq "Null") { + push(@implContent, <<END); + setCollectionStringOrNullIndexedGetter<${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. + $implIncludes{"V8${indexerType}.h"} = 1; + } + + return; + } + + my $hasDeleter = $dataNode->extendedAttributes->{"CustomDeleteProperty"}; + my $hasEnumerator = !$isSpecialCase && IsNodeSubType($dataNode); + 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(V8${interfaceName}::indexedPropertyGetter"); + push(@implContent, $hasCustomSetter ? ", V8${interfaceName}::indexedPropertySetter" : ", 0"); + push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the moment. + push(@implContent, $hasDeleter ? ", V8${interfaceName}::indexedPropertyDeleter" : ", 0"); + push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceName}>") if $hasEnumerator; + push(@implContent, ");\n"); +} + +sub GenerateImplementationNamedPropertyGetter +{ + my $dataNode = shift; + my $namedPropertyGetter = shift; + my $interfaceName = $dataNode->name; + my $hasCustomGetter = $dataNode->extendedAttributes->{"HasOverridingNameGetter"} || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}; + + # FIXME: Remove hard-coded HTMLOptionsCollection reference by changing HTMLOptionsCollection to not inherit + # from HTMLCollection per W3C spec (http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#HTMLOptionsCollection). + if ($interfaceName eq "HTMLOptionsCollection") { + $interfaceName = "HTMLCollection"; + $hasCustomGetter = 1; + } + + if ($interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedElement" || $interfaceName eq "HTMLObjectElement") { + $hasCustomGetter = 1; + } + + if ($interfaceName eq "HTMLDocument") { + $hasCustomGetter = 0; + } + + my $hasGetter = $dataNode->extendedAttributes->{"HasNameGetter"} || $hasCustomGetter; + if (!$hasGetter) { + return; + } + + if ($namedPropertyGetter && $namedPropertyGetter->type ne "Node" && !$namedPropertyGetter->extendedAttributes->{"Custom"} && !$hasCustomGetter) { + $implIncludes{"V8Collection.h"} = 1; + my $type = $namedPropertyGetter->type; + push(@implContent, <<END); + setCollectionNamedGetter<${interfaceName}, ${type}>(desc); +END + return; + } + + my $hasSetter = $dataNode->extendedAttributes->{"DelegatingPutFunction"}; + my $hasDeleter = $dataNode->extendedAttributes->{"CustomDeleteProperty"}; + my $hasEnumerator = $dataNode->extendedAttributes->{"CustomGetPropertyNames"}; + 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(V8${interfaceName}::namedPropertyGetter, "); + push(@implContent, $hasSetter ? "V8${interfaceName}::namedPropertySetter, " : "0, "); + # If there is a custom enumerator, there MUST be custom query to properly communicate property attributes. + push(@implContent, $hasEnumerator ? "V8${interfaceName}::namedPropertyQuery, " : "0, "); + push(@implContent, $hasDeleter ? "V8${interfaceName}::namedPropertyDeleter, " : "0, "); + push(@implContent, $hasEnumerator ? "V8${interfaceName}::namedPropertyEnumerator" : "0"); + push(@implContent, ");\n"); +} + +sub GenerateImplementationCustomCall +{ + my $dataNode = shift; + my $interfaceName = $dataNode->name; + my $hasCustomCall = $dataNode->extendedAttributes->{"CustomCall"}; + + # FIXME: Remove hard-coded HTMLOptionsCollection reference. + if ($interfaceName eq "HTMLOptionsCollection") { + $interfaceName = "HTMLCollection"; + $hasCustomCall = 1; + } + + if ($hasCustomCall) { + push(@implContent, " desc->InstanceTemplate()->SetCallAsFunctionHandler(V8${interfaceName}::callAsFunctionCallback);\n"); + } +} + +sub GenerateImplementationMasqueradesAsUndefined +{ + my $dataNode = shift; + if ($dataNode->extendedAttributes->{"MasqueradesAsUndefined"}) + { + push(@implContent, " desc->InstanceTemplate()->MarkAsUndetectable();\n"); + } +} + +sub GenerateImplementation +{ + my $object = shift; + my $dataNode = shift; + my $interfaceName = $dataNode->name; + my $visibleInterfaceName = GetVisibleInterfaceName($interfaceName); + my $className = "V8$interfaceName"; + my $implClassName = $interfaceName; + my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; + + # - Add default header template + push(@implFixedHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"RuntimeEnabledFeatures.h"} = 1; + $implIncludes{"V8Proxy.h"} = 1; + $implIncludes{"V8Binding.h"} = 1; + $implIncludes{"V8BindingState.h"} = 1; + $implIncludes{"V8DOMWrapper.h"} = 1; + $implIncludes{"V8IsolatedContext.h"} = 1; + + AddIncludesForType($interfaceName); + + my $toActive = IsActiveDomType($interfaceName) ? "${className}::toActiveDOMObject" : "0"; + + push(@implContentDecls, "namespace WebCore {\n\n"); + push(@implContentDecls, "WrapperTypeInfo ${className}::info = { ${className}::GetTemplate, ${className}::derefObject, ${toActive} };\n\n"); + push(@implContentDecls, "namespace ${interfaceName}Internal {\n\n"); + push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n"); + + my $hasConstructors = 0; + my $serializedAttribute; + # Generate property accessors for attributes. + for ($index = 0; $index < @{$dataNode->attributes}; $index++) { + $attribute = @{$dataNode->attributes}[$index]; + $attrName = $attribute->signature->name; + $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; + } + + # Attributes of type SerializedScriptValue are set in the + # constructor and don't require callbacks. + if ($attrType eq "SerializedScriptValue") { + die "Only one attribute of type SerializedScriptValue supported" if $serializedAttribute; + $implIncludes{"SerializedScriptValue.h"} = 1; + $serializedAttribute = $attribute; + next; + } + + # 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, $dataNode, $implClassName, $interfaceName); + } + if (!$attribute->signature->extendedAttributes->{"CustomSetter"} && + !$attribute->signature->extendedAttributes->{"V8CustomSetter"} && + !$attribute->signature->extendedAttributes->{"Replaceable"} && + $attribute->type !~ /^readonly/ && + !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) { + GenerateNormalAttrSetter($attribute, $dataNode, $implClassName, $interfaceName); + } + } + + if ($hasConstructors) { + GenerateConstructorGetter($implClassName); + } + + $codeGenerator->LinkOverloadedFunctions($dataNode); + + my $indexer; + my $namedPropertyGetter; + # Generate methods for functions. + foreach my $function (@{$dataNode->functions}) { + if (!($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"})) { + GenerateFunctionCallback($function, $dataNode, $implClassName); + if ($function->{overloadIndex} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) { + GenerateOverloadedFunctionCallback($function, $dataNode, $implClassName); + } + } + + if ($function->signature->name eq "item") { + $indexer = $function->signature; + } + + if ($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 (($dataNode->extendedAttributes->{"CheckDomainSecurity"} || ($interfaceName eq "DOMWindow")) && $function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { + GenerateDomainSafeFunctionGetter($function, $implClassName); + } + } + + # Attributes + my $attributes = $dataNode->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 @enabledAtRuntime; + my @normal; + foreach my $attribute (@$attributes) { + + if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttributes->{"V8DisallowShadowing"}) { + push(@disallowsShadowing, $attribute); + } elsif ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) { + push(@enabledAtRuntime, $attribute); + } else { + push(@normal, $attribute); + } + } + $attributes = \@normal; + # Put the attributes that disallow shadowing on the shadow object. + if (@disallowsShadowing) { + push(@implContent, "static const BatchedAttribute shadowAttrs[] = {\n"); + GenerateBatchedAttributeData($dataNode, \@disallowsShadowing); + push(@implContent, "};\n"); + } + + my $has_attributes = 0; + if (@$attributes) { + $has_attributes = 1; + push(@implContent, "static const BatchedAttribute ${interfaceName}Attrs[] = {\n"); + GenerateBatchedAttributeData($dataNode, $attributes); + push(@implContent, "};\n"); + } + + # Setup table of standard callback functions + $num_callbacks = 0; + $has_callbacks = 0; + foreach my $function (@{$dataNode->functions}) { + # Only one table entry is needed for overloaded methods: + next if $function->{overloadIndex} > 1; + + my $attrExt = $function->signature->extendedAttributes; + # Don't put any nonstandard functions into this table: + if ($attrExt->{"V8OnInstance"}) { + next; + } + if ($attrExt->{"ClassMethod"}) { + next; + } + if ($attrExt->{"EnabledAtRuntime"} || RequiresCustomSignature($function) || $attrExt->{"V8DoNotCheckSignature"}) { + next; + } + if ($attrExt->{"DoNotCheckDomainSecurity"} && + ($dataNode->extendedAttributes->{"CheckDomainSecurity"} || $interfaceName eq "DOMWindow")) { + next; + } + if ($attrExt->{"DontEnum"} || $attrExt->{"V8ReadOnly"}) { + next; + } + if (!$has_callbacks) { + $has_callbacks = 1; + push(@implContent, "static const BatchedCallback ${interfaceName}Callbacks[] = {\n"); + } + my $name = $function->signature->name; + my $callback = GetFunctionTemplateCallbackName($function, $interfaceName); + push(@implContent, <<END); + {"$name", $callback}, +END + $num_callbacks++; + } + push(@implContent, "};\n") if $has_callbacks; + + # Setup constants + my $has_constants = 0; + if (@{$dataNode->constants}) { + $has_constants = 1; + push(@implContent, "static const BatchedConstant ${interfaceName}Consts[] = {\n"); + } + foreach my $constant (@{$dataNode->constants}) { + my $name = $constant->name; + my $value = $constant->value; + # 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. + push(@implContent, <<END); + {"${name}", static_cast<signed int>($value)}, +END + } + if ($has_constants) { + push(@implContent, "};\n"); + push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNeeded($dataNode)); + } + + push(@implContentDecls, "} // namespace ${interfaceName}Internal\n\n"); + + # In namespace WebCore, add generated implementation for 'CanBeConstructed'. + if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"} && !$dataNode->extendedAttributes->{"V8CustomConstructor"}) { + my $v8ConstructFunction; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; + if ($callWith and $callWith eq "ScriptExecutionContext") { + $v8ConstructFunction = "constructDOMObjectWithScriptExecutionContext"; + } else { + $v8ConstructFunction = "constructDOMObject"; + } + push(@implContent, <<END); +v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.${interfaceName}.Contructor"); + return V8Proxy::${v8ConstructFunction}<$interfaceName>(args, &info); +} +END + } + + my $access_check = ""; + if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !($interfaceName eq "DOMWindow")) { + $access_check = "instance->SetAccessCheckCallbacks(V8${interfaceName}::namedSecurityCheck, V8${interfaceName}::indexedSecurityCheck, v8::External::Wrap(&V8${interfaceName}::info));"; + } + + # For the DOMWindow interface, generate the shadow object template + # configuration method. + if ($implClassName eq "DOMWindow") { + push(@implContent, <<END); +static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Persistent<v8::ObjectTemplate> templ) +{ + 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::Wrap(&V8DOMWindow::info)); + templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount); + return templ; +} +END + } + + # find the super descriptor + my $parentClassTemplate = ""; + foreach (@{$dataNode->parents}) { + my $parent = $codeGenerator->StripModule($_); + if ($parent eq "EventTarget") { next; } + $implIncludes{"V8${parent}.h"} = 1; + $parentClassTemplate = "V8" . $parent . "::GetTemplate()"; + last; + } + if (!$parentClassTemplate) { + $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()"; + } + + # Generate the template configuration method + push(@implContent, <<END); +static v8::Persistent<v8::FunctionTemplate> Configure${className}Template(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, \"${visibleInterfaceName}\", $parentClassTemplate, V8${interfaceName}::internalFieldCount, +END + # Set up our attributes if we have them + if ($has_attributes) { + push(@implContent, <<END); + ${interfaceName}Attrs, WTF_ARRAY_LENGTH(${interfaceName}Attrs), +END + } else { + push(@implContent, <<END); + 0, 0, +END + } + + if ($has_callbacks) { + push(@implContent, <<END); + ${interfaceName}Callbacks, WTF_ARRAY_LENGTH(${interfaceName}Callbacks)); +END + } else { + push(@implContent, <<END); + 0, 0); +END + } + + if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"}) { + push(@implContent, <<END); + desc->SetCallHandler(V8${interfaceName}::constructorCallback); +END + } + + if ($access_check or @enabledAtRuntime or @{$dataNode->functions} or $has_constants) { + push(@implContent, <<END); + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); +END + } + + push(@implContent, " $access_check\n"); + + # Setup the enable-at-runtime attrs if we have them + foreach my $runtime_attr (@enabledAtRuntime) { + my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signature); + my $conditionalString = GenerateConditionalString($runtime_attr->signature); + push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; + push(@implContent, " if (${enable_function}()) {\n"); + push(@implContent, " static const BatchedAttribute attrData =\\\n"); + GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, ";", " "); + push(@implContent, <<END); + configureAttribute(instance, proto, attrData); + } +END + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; + } + + GenerateImplementationIndexer($dataNode, $indexer); + GenerateImplementationNamedPropertyGetter($dataNode, $namedPropertyGetter); + GenerateImplementationCustomCall($dataNode); + GenerateImplementationMasqueradesAsUndefined($dataNode); + + # Define our functions with Set() or SetAccessor() + $total_functions = 0; + foreach my $function (@{$dataNode->functions}) { + # Only one accessor is needed for overloaded methods: + next if $function->{overloadIndex} > 1; + + $total_functions++; + my $attrExt = $function->signature->extendedAttributes; + my $name = $function->signature->name; + + my $property_attributes = "v8::DontDelete"; + if ($attrExt->{"DontEnum"}) { + $property_attributes .= " | v8::DontEnum"; + } + if ($attrExt->{"V8ReadOnly"}) { + $property_attributes .= " | v8::ReadOnly"; + } + + my $commentInfo = "Function '$name' (ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; + + my $template = "proto"; + if ($attrExt->{"V8OnInstance"}) { + $template = "instance"; + } + if ($attrExt->{"ClassMethod"}) { + $template = "desc"; + } + + my $conditional = ""; + if ($attrExt->{"EnabledAtRuntime"}) { + # Only call Set()/SetAccessor() if this method should be enabled + $enable_function = GetRuntimeEnableFunctionName($function->signature); + $conditional = "if (${enable_function}())\n "; + } + + if ($attrExt->{"DoNotCheckDomainSecurity"} && + ($dataNode->extendedAttributes->{"CheckDomainSecurity"} || $interfaceName eq "DOMWindow")) { + # Mark the accessor as ReadOnly and set it on the proto object so + # it can be shadowed. This is really a hack to make it work. + # There are several sceneria to call into the accessor: + # 1) from the same domain: "window.open": + # the accessor finds the DOM wrapper in the proto chain; + # 2) from the same domain: "window.__proto__.open": + # the accessor will NOT find a DOM wrapper in the prototype chain + # 3) from another domain: "window.open": + # the access find the DOM wrapper in the prototype chain + # "window.__proto__.open" from another domain will fail when + # accessing '__proto__' + # + # The solution is very hacky and fragile, it really needs to be replaced + # by a better solution. + $property_attributes .= " | v8::ReadOnly"; + push(@implContent, <<END); + + // $commentInfo + ${conditional}$template->SetAccessor(v8::String::New("$name"), ${interfaceName}Internal::${name}AttrGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes)); +END + $num_callbacks++; + next; + } + + my $signature = "defaultSignature"; + if ($attrExt->{"V8DoNotCheckSignature"} || $attrExt->{"ClassMethod"}) { + $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 "") { + # Standard type of callback, already created in the batch, so skip it here. + next; + } + + push(@implContent, <<END); + ${conditional}$template->Set(v8::String::New("$name"), v8::FunctionTemplate::New($callback, v8::Handle<v8::Value>(), ${signature})$property_attributes); +END + $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); + batchConfigureConstants(desc, proto, ${interfaceName}Consts, WTF_ARRAY_LENGTH(${interfaceName}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::Wrap(&V8DOMWindow::info), false); +END + } + if ($interfaceName eq "HTMLDocument") { + 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::New("reload"), V8Location::reloadAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); + instance->SetAccessor(v8::String::New("replace"), V8Location::replaceAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); + instance->SetAccessor(v8::String::New("assign"), V8Location::assignAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); +END + } + + my $nativeType = GetNativeTypeForConversions($dataNode, $interfaceName); + push(@implContent, <<END); + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> ${className}::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> ${className}RawCache = createRawTemplate(); + return ${className}RawCache; +} + +v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate()\ +{ + static v8::Persistent<v8::FunctionTemplate> ${className}Cache = Configure${className}Template(GetRawTemplate()); + return ${className}Cache; +} + +bool ${className}::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + +END + + if (IsActiveDomType($interfaceName)) { + # 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* ${className}::toActiveDOMObject(v8::Handle<v8::Object> object) +{ + return ${returnValue}; +} +END + } + + if ($implClassName 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($dataNode, $interfaceName, $className, $nativeType, $serializedAttribute); + + push(@implContent, <<END); + +void ${className}::derefObject(void* object) +{ +END + + if (IsRefPtrType($interfaceName)) { + push(@implContent, <<END); + static_cast<${nativeType}*>(object)->deref(); +END + } + + push(@implContent, <<END); +} + +} // namespace WebCore +END + + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; + + # We've already added the header for this file in implFixedHeader, so remove + # it from implIncludes to ensure we don't #include it twice. + delete $implIncludes{"${className}.h"}; +} + +sub GenerateHeaderContentHeader +{ + my $dataNode = shift; + my $className = "V8" . $dataNode->name; + my $conditionalString = GenerateConditionalString($dataNode); + + my @headerContentHeader = split("\r", $headerTemplate); + + push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString; + push(@headerContentHeader, "\n#ifndef ${className}" . "_h"); + push(@headerContentHeader, "\n#define ${className}" . "_h\n\n"); + return @headerContentHeader; +} + +sub GenerateImplementationContentHeader +{ + my $dataNode = shift; + my $className = "V8" . $dataNode->name; + my $conditionalString = GenerateConditionalString($dataNode); + + my @implContentHeader = split("\r", $headerTemplate); + + push(@implContentHeader, "\n#include \"config.h\"\n"); + push(@implContentHeader, "#include \"${className}.h\"\n\n"); + push(@implContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; + return @implContentHeader; +} + +sub GenerateCallbackHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + + + # - Add default header template + push(@headerContent, GenerateHeaderContentHeader($dataNode)); + + my @unsortedIncludes = (); + push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); + push(@unsortedIncludes, "#include \"$interfaceName.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 $className : public $interfaceName, public ActiveDOMCallback {\n"); + + push(@headerContent, <<END); +public: + static PassRefPtr<${className}> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) + { + ASSERT(value->IsObject()); + ASSERT(context); + return adoptRef(new ${className}(value->ToObject(), context)); + } + + virtual ~${className}(); + +END + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@headerContent, " // Functions\n"); + foreach my $function (@{$dataNode->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: + ${className}(v8::Local<v8::Object>, ScriptExecutionContext*); + + v8::Persistent<v8::Object> m_callback; + WorldContextHandle m_worldContext; +}; + +END + + push(@headerContent, "}\n\n"); + push(@headerContent, "#endif // $className" . "_h\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateCallbackImplementation +{ + my $object = shift; + my $dataNode = shift; + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + + # - Add default header template + push(@implFixedHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"ScriptExecutionContext.h"} = 1; + $implIncludes{"V8CustomVoidCallback.h"} = 1; + $implIncludes{"V8Proxy.h"} = 1; + + push(@implContent, "#include <wtf/Assertions.h>\n\n"); + push(@implContent, "namespace WebCore {\n\n"); + push(@implContent, <<END); +${className}::${className}(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : ActiveDOMCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) + , m_worldContext(UseCurrentWorld) +{ +} + +${className}::~${className}() +{ + m_callback.Dispose(); +} + +END + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@implContent, "// Functions\n"); + foreach my $function (@{$dataNode->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) . " ${className}::" . $function->signature->name . "("); + + my @args = (); + foreach my $param (@params) { + AddIncludesForType($param->type); + push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name); + } + push(@implContent, join(", ", @args)); + + push(@implContent, ")\n"); + push(@implContent, "{\n"); + 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 = toV8(${paramName});\n"); + push(@implContent, " if (${paramName}Handle.IsEmpty()) {\n"); + push(@implContent, " CRASH();\n"); + push(@implContent, " return true;\n"); + push(@implContent, " }\n"); + push(@args, " ${paramName}Handle"); + } + + push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); + push(@implContent, join(",\n", @args)); + push(@implContent, "\n };\n\n"); + push(@implContent, " bool callbackReturnValue = false;\n"); + push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); + push(@implContent, "}\n"); + } + } + + push(@implContent, "\n} // namespace WebCore\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateToV8Converters +{ + my $dataNode = shift; + my $interfaceName = shift; + my $className = shift; + my $nativeType = shift; + my $serializedAttribute = shift; + + my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName); + my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : ""; + my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : ""; + + push(@implContent, <<END); + +v8::Handle<v8::Object> ${className}::wrapSlow(${nativeType}* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; +END + + if (IsNodeSubType($dataNode)) { + push(@implContent, <<END); + if (impl->document()) { + proxy = V8Proxy::retrieve(impl->document()->frame()); + if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) { + if (proxy->windowShell()->initContextIfNeeded()) { + // initContextIfNeeded may have created a wrapper for the object, retry from the start. + return ${className}::wrap(impl); + } + } + } + +END + } + + if (IsNodeSubType($dataNode)) { + push(@implContent, <<END); + + v8::Handle<v8::Context> context; + if (proxy) + context = proxy->context(); + + // Enter the node's context and create the wrapper in that context. + if (!context.IsEmpty()) + context->Enter(); +END + } + + push(@implContent, <<END); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); +END + if (IsNodeSubType($dataNode)) { + push(@implContent, <<END); + // Exit the node's context if it was entered. + if (!context.IsEmpty()) + context->Exit(); +END + } + + push(@implContent, <<END); + if (wrapper.IsEmpty()) + return wrapper; +END + push(@implContent, "\n impl->ref();\n") if IsRefPtrType($interfaceName); + + # Eagerly deserialize attributes of type SerializedScriptValue + # while we're in the right context. + if ($serializedAttribute) { + die "Attribute of type SerializedScriptValue expected" if $serializedAttribute->signature->type ne "SerializedScriptValue"; + my $attrName = $serializedAttribute->signature->name; + my $attrAttr = "v8::DontDelete"; + if ($serializedAttribute->type =~ /^readonly/) { + $attrAttr .= " | v8::ReadOnly"; + } + $attrAttr = "static_cast<v8::PropertyAttribute>($attrAttr)"; + my $getterFunc = $codeGenerator->WK_lcfirst($attrName); + push(@implContent, <<END); + SerializedScriptValue::deserializeAndSetProperty(wrapper, "${attrName}", ${attrAttr}, impl->${getterFunc}()); +END + } + + if ($domMapFunction) { + push(@implContent, <<END); + ${domMapFunction}.set(impl, v8::Persistent<v8::Object>::New(wrapper)); +END + } + + push(@implContent, <<END); + return wrapper; +} +END +} + +sub HasCustomToV8Implementation { + # FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)? + $dataNode = shift; + $interfaceName = shift; + + # We generate a custom converter (but JSC doesn't) for the following: + return 1 if $interfaceName eq "CSSStyleSheet"; + return 1 if $interfaceName eq "CanvasPixelArray"; + return 1 if $interfaceName eq "DOMStringMap"; + return 1 if $interfaceName eq "DOMWindow"; + return 1 if $interfaceName eq "DOMTokenList"; + return 1 if $interfaceName eq "Element"; + return 1 if $interfaceName eq "HTMLDocument"; + return 1 if $interfaceName eq "HTMLElement"; + return 1 if $interfaceName eq "Location"; + return 1 if $interfaceName eq "NamedNodeMap"; + return 1 if $interfaceName eq "SVGDocument"; + return 1 if $interfaceName eq "SVGElement"; + return 1 if $interfaceName eq "ScriptProfile"; + return 1 if $interfaceName eq "ScriptProfileNode"; + return 1 if $interfaceName eq "WorkerContext"; + # We don't generate a custom converter (but JSC does) for the following: + return 0 if $interfaceName eq "AbstractWorker"; + return 0 if $interfaceName eq "CanvasRenderingContext"; + return 0 if $interfaceName eq "SVGElementInstance"; + + # For everything else, do what JSC does. + return $dataNode->extendedAttributes->{"CustomToJS"}; +} + +sub GetDomMapFunction +{ + my $dataNode = shift; + my $type = shift; + return "getDOMSVGElementInstanceMap()" if $type eq "SVGElementInstance"; + return "getDOMNodeMap()" if ($dataNode && IsNodeSubType($dataNode)); + return "" if $type eq "DOMImplementation"; + return "getActiveDOMObjectMap()" if IsActiveDomType($type); + return "getDOMObjectMap()"; +} + +sub IsActiveDomType +{ + # FIXME: Consider making this an .idl attribute. + my $type = shift; + return 1 if $type eq "EventSource"; + return 1 if $type eq "MessagePort"; + return 1 if $type eq "XMLHttpRequest"; + return 1 if $type eq "WebSocket"; + return 1 if $type eq "Worker"; + return 1 if $type eq "SharedWorker"; + return 1 if $type eq "IDBRequest"; + return 1 if $type eq "FileReader"; + return 1 if $type eq "FileWriter"; + return 0; +} + +sub GetNativeTypeForConversions +{ + my $dataNode = shift; + my $type = shift; + + $type = $codeGenerator->GetSVGTypeNeedingTearOff($type) if $codeGenerator->IsSVGTypeNeedingTearOff($type); + return $type; +} + +sub GenerateFunctionCallString() +{ + my $function = shift; + my $numberOfParameters = shift; + my $indent = shift; + my $implClassName = shift; + + my $name = $function->signature->name; + my $returnType = GetTypeFromSignature($function->signature); + my $nativeReturnType = GetNativeType($returnType, 0); + my $result = ""; + + my $isSVGTearOffType = ($codeGenerator->IsSVGTypeNeedingTearOff($returnType) and not $implClassName =~ /List$/); + $nativeReturnType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTearOffType; + + if ($function->signature->extendedAttributes->{"v8implname"}) { + $name = $function->signature->extendedAttributes->{"v8implname"}; + } + + if ($function->signature->extendedAttributes->{"ImplementationFunction"}) { + $name = $function->signature->extendedAttributes->{"ImplementationFunction"}; + } + + my $functionString = "imp->${name}("; + if ($function->signature->extendedAttributes->{"ClassMethod"}) { + $functionString = "${implClassName}::${name}("; + } + + my $index = 0; + my $hasScriptState = 0; + + my $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith) { + my $callWithArg = "COMPILE_ASSERT(false)"; + if ($callWith eq "DynamicFrame") { + $result .= $indent . "Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();\n"; + $result .= $indent . "if (!enteredFrame)\n"; + $result .= $indent . " return v8::Undefined();\n"; + $callWithArg = "enteredFrame"; + } elsif ($callWith eq "ScriptState") { + $result .= $indent . "EmptyScriptState state;\n"; + $callWithArg = "&state"; + $hasScriptState = 1; + } elsif ($callWith eq "ScriptExecutionContext") { + $result .= $indent . "ScriptExecutionContext* scriptContext = getScriptExecutionContext();\n"; + $result .= $indent . "if (!scriptContext)\n"; + $result .= $indent . " return v8::Undefined();\n"; + $callWithArg = "scriptContext"; + } + $functionString .= ", " if $index; + $functionString .= $callWithArg; + $index++; + $numberOfParameters++ + } + + foreach my $parameter (@{$function->parameters}) { + if ($index eq $numberOfParameters) { + last; + } + $functionString .= ", " if $index; + my $paramName = $parameter->name; + my $paramType = $parameter->type; + + if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") { + $functionString .= "$paramName.get()"; + } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) { + $functionString .= "$paramName->propertyReference()"; + $result .= $indent . "if (!$paramName) {\n"; + $result .= $indent . " V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);\n"; + $result .= $indent . " return v8::Handle<v8::Value>();\n"; + $result .= $indent . "}\n"; + } elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") { + $functionString .= "$paramName.get()"; + } else { + $functionString .= $paramName; + } + $index++; + } + + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + $functionString .= ", " if $index; + $functionString .= "scriptArguments, callStack"; + $index += 2; + } + + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionString .= ", " if $index; + # FIXME: We need to pass DOMWrapperWorld as a parameter. + # See http://trac.webkit.org/changeset/54182 + $functionString .= "processingUserGesture()"; + $index++; + } + + if (@{$function->raisesExceptions}) { + $functionString .= ", " if $index; + $functionString .= "ec"; + $index++; + } + $functionString .= ")"; + + my $return = "result"; + my $returnIsRef = IsRefPtrType($returnType); + + if ($returnType eq "void") { + $result .= $indent . "$functionString;\n"; + } elsif ($hasScriptState 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 ($implClassName eq "SVGTransformList" and IsRefPtrType($returnType)) { + $return = "WTF::getPtr(" . $return . ")"; + } + } + + if (@{$function->raisesExceptions}) { + $result .= $indent . "if (UNLIKELY(ec))\n"; + $result .= $indent . " goto fail;\n"; + } + + if ($hasScriptState) { + $result .= $indent . "if (state.hadException())\n"; + $result .= $indent . " return throwError(state.exception());\n" + } + + if ($isSVGTearOffType) { + $implIncludes{"V8$returnType.h"} = 1; + $implIncludes{"SVGPropertyTearOff.h"} = 1; + my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($returnType); + $result .= $indent . "return toV8(WTF::getPtr(${svgNativeType}::create($return)));\n"; + return $result; + } + + # If the implementing class is a POD type, commit changes + if ($codeGenerator->IsSVGTypeNeedingTearOff($implClassName) and not $implClassName =~ /List$/) { + $result .= $indent . "wrapper->commitChange();\n"; + } + + $return .= ".release()" if ($returnIsRef); + $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n"; + + return $result; +} + + +sub GetTypeFromSignature +{ + my $signature = shift; + + return $codeGenerator->StripModule($signature->type); +} + + +sub GetNativeTypeFromSignature +{ + my $signature = shift; + my $parameterIndex = shift; + + my $type = GetTypeFromSignature($signature); + + 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 "V8Parameter") { + my $mode = ""; + if ($signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"}) { + $mode = "WithUndefinedOrNullCheck"; + } elsif ($signature->extendedAttributes->{"ConvertNullToNullString"} || $signature->extendedAttributes->{"Reflect"}) { + $mode = "WithNullCheck"; + } + $type .= "<$mode>"; + } + + return $type; +} + +sub IsRefPtrType +{ + my $type = shift; + + return 0 if $type eq "boolean"; + return 0 if $type eq "float"; + return 0 if $type eq "int"; + return 0 if $type eq "Date"; + return 0 if $type eq "DOMString"; + return 0 if $type eq "double"; + return 0 if $type eq "short"; + return 0 if $type eq "long"; + return 0 if $type eq "unsigned"; + return 0 if $type eq "unsigned long"; + return 0 if $type eq "unsigned short"; + + return 1; +} + +sub GetNativeType +{ + my $type = shift; + my $isParameter = shift; + + my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($type); + if ($svgNativeType) { + if ($svgNativeType =~ /List$/) { + return "${svgNativeType}*"; + } else { + return "RefPtr<${svgNativeType} >"; + } + } + + if ($type eq "float" or $type eq "double") { + return $type; + } + + return "V8Parameter" if ($type eq "DOMString" or $type eq "DOMUserData") and $isParameter; + return "int" if $type eq "int"; + return "int" if $type eq "short" or $type eq "unsigned short"; + return "unsigned" if $type eq "unsigned long"; + return "int" if $type eq "long"; + 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 "String" if $type eq "DOMString"; + return "Range::CompareHow" if $type eq "CompareHow"; + return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; + return "DOMTimeStamp" if $type eq "DOMTimeStamp"; + return "unsigned" if $type eq "unsigned int"; + return "Node*" if $type eq "EventTarget" and $isParameter; + return "double" if $type eq "Date"; + return "ScriptValue" if $type eq "DOMObject"; + return "OptionsObject" if $type eq "OptionsObject"; + + return "String" if $type eq "DOMUserData"; # FIXME: Temporary hack? + + # temporary hack + return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; + + return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; + + return "RefPtr<IDBKey>" if $type eq "IDBKey"; + + # necessary as resolvers could be constructed on fly. + return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; + + return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; + + return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"; + + # 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"; + + # 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 = GetTypeFromSignature($signature); + + $implIncludes{"ExceptionCode.h"} = 1 if $type eq "Attr"; + return 1 if $type eq "Attr"; + return 1 if $type eq "VoidCallback"; + return 1 if $type eq "IDBKey"; + return 0; +} + +sub JSValueToNative +{ + my $signature = shift; + my $value = shift; + + my $type = GetTypeFromSignature($signature); + + 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 "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType"; + return "toWebCoreDate($value)" if $type eq "Date"; + + if ($type eq "DOMString" or $type eq "DOMUserData") { + return $value; + } + + die "Unexpected SerializedScriptValue" if $type eq "SerializedScriptValue"; + + if ($type eq "IDBKey") { + $implIncludes{"IDBBindingUtilities.h"} = 1; + $implIncludes{"IDBKey.h"} = 1; + return "createIDBKeyFromValue($value)"; + } + + if ($type eq "OptionsObject") { + $implIncludes{"OptionsObject.h"} = 1; + return $value; + } + + if ($type eq "DOMObject") { + $implIncludes{"ScriptValue.h"} = 1; + return "ScriptValue($value)"; + } + + if ($type eq "NodeFilter") { + return "V8DOMWrapper::wrapNativeNodeFilter($value)"; + } + + if ($type eq "MediaQueryListListener") { + $implIncludes{"MediaQueryListListener.h"} = 1; + return "MediaQueryListListener::create(" . $value . ")"; + } + + # Default, assume autogenerated type conversion routines + if ($type eq "EventTarget") { + $implIncludes{"V8Node.h"} = 1; + + # 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 "V8DOMWrapper::getXPathNSResolver($value)"; + } + + AddIncludesForType($type); + + if (IsDOMNodeType($type)) { + $implIncludes{"V8${type}.h"} = 1; + + # Perform type checks on the parameter, if it is expected Node type, + # return NULL. + return "V8${type}::HasInstance($value) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; + } else { + $implIncludes{"V8$type.h"} = 1; + + # Perform type checks on the parameter, if it is expected Node type, + # return NULL. + 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 "EventTarget.h" if $type eq "EventTarget"; + return "SerializedScriptValue.h" if $type eq "SerializedScriptValue"; + return "ScriptValue.h" if $type eq "DOMObject"; + 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 $header = GetV8HeaderName($type); + $implIncludes{$header} = 1; + $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; + } + # Type checking is performed in the generated code + if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) { + return 0; + } + foreach my $parameter (@{$function->parameters}) { + if ($parameter->extendedAttributes->{"Optional"} || $parameter->extendedAttributes->{"Callback"}) { + return 0; + } + } + + foreach my $parameter (@{$function->parameters}) { + if (IsWrapperType($parameter->type)) { + return 1; + } + } + return 0; +} + + +# FIXME: Sort this array. +my %non_wrapper_types = ( + 'float' => 1, + 'double' => 1, + 'int' => 1, + 'unsigned int' => 1, + 'short' => 1, + 'unsigned short' => 1, + 'long' => 1, + 'unsigned long' => 1, + 'boolean' => 1, + 'long long' => 1, + 'unsigned long long' => 1, + 'DOMString' => 1, + 'CompareHow' => 1, + 'SerializedScriptValue' => 1, + 'SVGPaintType' => 1, + 'DOMTimeStamp' => 1, + 'JSObject' => 1, + 'DOMObject' => 1, + 'EventTarget' => 1, + 'NodeFilter' => 1, + 'EventListener' => 1, + 'IDBKey' => 1, + 'OptionsObject' => 1, + 'Date' => 1, + 'MediaQueryListListener' => 1 +); + + +sub IsWrapperType +{ + my $type = $codeGenerator->StripModule(shift); + return !($non_wrapper_types{$type}); +} + +sub IsDOMNodeType +{ + my $type = shift; + + return 1 if $type eq 'Attr'; + return 1 if $type eq 'CDATASection'; + 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 'EntityReference'; + return 1 if $type eq 'HTMLCanvasElement'; + return 1 if $type eq 'HTMLDocument'; + return 1 if $type eq 'HTMLElement'; + return 1 if $type eq 'HTMLFormElement'; + return 1 if $type eq 'HTMLTableCaptionElement'; + return 1 if $type eq 'HTMLTableSectionElement'; + return 1 if $type eq 'Node'; + return 1 if $type eq 'ProcessingInstruction'; + return 1 if $type eq 'SVGElement'; + return 1 if $type eq 'SVGDocument'; + return 1 if $type eq 'SVGSVGElement'; + return 1 if $type eq 'SVGUseElement'; + return 1 if $type eq 'Text'; + + return 0; +} + + +sub ReturnNativeToJSValue +{ + my $signature = shift; + my $value = shift; + my $indent = shift; + my $type = GetTypeFromSignature($signature); + + return "return v8Boolean($value)" if $type eq "boolean"; + return "return v8::Handle<v8::Value>()" if $type eq "void"; # equivalent to v8::Undefined() + + # 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 "return v8::Integer::NewFromUnsigned(std::max(0, " . $value . "))"; + } + + # For all the types where we use 'int' as the representation type, + # we use Integer::New which has a fast Smi conversion check. + my $nativeType = GetNativeType($type); + return "return v8::Integer::New($value)" if $nativeType eq "int"; + return "return v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned"; + + return "return v8DateOrNull($value)" if $type eq "Date"; + # long long and unsigned long long are not representable in ECMAScript. + return "return v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp"; + return "return v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType"; + return "return $value.v8Value()" if $nativeType eq "ScriptValue"; + + if ($codeGenerator->IsStringType($type)) { + my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"}; + if (defined $conv) { + return "return v8StringOrNull($value)" if $conv eq "Null"; + return "return v8StringOrUndefined($value)" if $conv eq "Undefined"; + return "return v8StringOrFalse($value)" if $conv eq "False"; + + die "Unknown value for ConvertNullStringTo extended attribute"; + } + $conv = $signature->extendedAttributes->{"ConvertScriptString"}; + return "return v8StringOrNull($value)" if $conv; + return "return v8String($value)"; + } + + AddIncludesForType($type); + + # special case for non-DOM node interfaces + if (IsDOMNodeType($type)) { + return "return toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")"); + } + + if ($type eq "EventTarget") { + return "return V8DOMWrapper::convertEventTargetToV8Object($value)"; + } + + if ($type eq "EventListener") { + $implIncludes{"V8AbstractEventListener.h"} = 1; + return "return ${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())"; + } + + if ($type eq "SerializedScriptValue") { + $implIncludes{"$type.h"} = 1; + return "return $value->deserialize()"; + } + + $implIncludes{"wtf/RefCounted.h"} = 1; + $implIncludes{"wtf/RefPtr.h"} = 1; + $implIncludes{"wtf/GetPtr.h"} = 1; + + return "return toV8($value)"; +} + +# Internal helper +sub WriteData +{ + if (defined($IMPL)) { + # Write content to file. + print $IMPL @implContentHeader; + + print $IMPL @implFixedHeader; + + foreach my $implInclude (sort keys(%implIncludes)) { + my $checkType = $implInclude; + $checkType =~ s/\.h//; + + if ($implInclude =~ /wtf/) { + print $IMPL "#include \<$implInclude\>\n"; + } else { + print $IMPL "#include \"$implInclude\"\n" unless $codeGenerator->IsSVGAnimatedType($checkType); + } + } + + print $IMPL "\n"; + print $IMPL @implContentDecls; + print $IMPL @implContent; + close($IMPL); + undef($IMPL); + + %implIncludes = (); + @implFixedHeader = (); + @implHeaderContent = (); + @implContentDecls = (); + @implContent = (); + } + + if (defined($HEADER)) { + # Write content to file. + print $HEADER @headerContent; + close($HEADER); + undef($HEADER); + + @headerContent = (); + } +} + +sub GetVisibleInterfaceName +{ + my $interfaceName = shift; + + return "DOMException" if $interfaceName eq "DOMCoreException"; + return "FormData" if $interfaceName eq "DOMFormData"; + return $interfaceName; +} + +sub GetCallbackClassName +{ + my $interfaceName = shift; + + return "V8CustomVoidCallback" if $interfaceName eq "VoidCallback"; + return "V8$interfaceName"; +} + +sub ConvertToV8Parameter +{ + my $signature = shift; + my $nativeType = shift; + my $variableName = shift; + my $value = shift; + my $suffix = shift; + + die "Wrong native type passed: $nativeType" unless $nativeType =~ /^V8Parameter/; + if ($signature->type eq "DOMString") { + $implIncludes{"V8BindingMacros.h"} = 1; + my $macro = "STRING_TO_V8PARAMETER_EXCEPTION_BLOCK"; + $macro .= "_$suffix" if $suffix; + return "$macro($nativeType, $variableName, $value);" + } else { + # Don't know how to properly check for conversion exceptions when $parameter->type is "DOMUserData" + 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. "EnabledAtRuntime=FeatureName") return the RuntimeEnabledFeatures::{FeatureName}Enabled() method. + return "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($signature->extendedAttributes->{"EnabledAtRuntime"}) . "Enabled" if ($signature->extendedAttributes->{"EnabledAtRuntime"} && $signature->extendedAttributes->{"EnabledAtRuntime"} ne "1"); + + # Otherwise return a function named RuntimeEnabledFeatures::{methodName}Enabled(). + return "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($signature->name) . "Enabled"; +} + +sub DebugPrint +{ + my $output = shift; + + print $output; + print "\n"; +} diff --git a/Source/WebCore/bindings/scripts/IDLParser.pm b/Source/WebCore/bindings/scripts/IDLParser.pm new file mode 100644 index 0000000..927deb9 --- /dev/null +++ b/Source/WebCore/bindings/scripts/IDLParser.pm @@ -0,0 +1,439 @@ +# +# KDOM IDL parser +# +# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.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. +# + +package IDLParser; + +use strict; + +use IPC::Open2; +use IDLStructure; + +use constant MODE_UNDEF => 0; # Default mode. + +use constant MODE_MODULE => 10; # 'module' section +use constant MODE_INTERFACE => 11; # 'interface' section +use constant MODE_EXCEPTION => 12; # 'exception' section +use constant MODE_ALIAS => 13; # 'alias' section + +# Helper variables +my @temporaryContent = ""; + +my $parseMode = MODE_UNDEF; +my $preservedParseMode = MODE_UNDEF; + +my $beQuiet; # Should not display anything on STDOUT? +my $document = 0; # Will hold the resulting 'idlDocument' +my $parentsOnly = 0; # If 1, parse only enough to populate parents list + +# Default Constructor +sub new +{ + my $object = shift; + my $reference = { }; + + $document = 0; + $beQuiet = shift; + + bless($reference, $object); + return $reference; +} + +# Returns the parsed 'idlDocument' +sub Parse +{ + my $object = shift; + my $fileName = shift; + my $defines = shift; + my $preprocessor = shift; + $parentsOnly = shift; + + if (!$preprocessor) { + require Config; + my $gccLocation = ""; + if ($ENV{CC}) { + $gccLocation = $ENV{CC}; + } elsif (($Config::Config{'osname'}) =~ /solaris/i) { + $gccLocation = "/usr/sfw/bin/gcc"; + } else { + $gccLocation = "/usr/bin/gcc"; + } + $preprocessor = $gccLocation . " -E -P -x c++"; + } + + if (!$defines) { + $defines = ""; + } + + print " | *** Starting to parse $fileName...\n |\n" unless $beQuiet; + + my $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName); + close PP_IN; + my @documentContent = <PP_OUT>; + close PP_OUT; + waitpid($pid, 0); + + my $dataAvailable = 0; + + # Simple IDL Parser (tm) + foreach (@documentContent) { + my $newParseMode = $object->DetermineParseMode($_); + + if ($newParseMode ne MODE_UNDEF) { + if ($dataAvailable eq 0) { + $dataAvailable = 1; # Start node building... + } else { + $object->ProcessSection(); + } + } + + # Update detected data stream mode... + if ($newParseMode ne MODE_UNDEF) { + $parseMode = $newParseMode; + } + + push(@temporaryContent, $_); + } + + # Check if there is anything remaining to parse... + if (($parseMode ne MODE_UNDEF) and ($#temporaryContent > 0)) { + $object->ProcessSection(); + } + + print " | *** Finished parsing!\n" unless $beQuiet; + + $document->fileName($fileName); + + return $document; +} + +sub ParseModule +{ + my $object = shift; + my $dataNode = shift; + + print " |- Trying to parse module...\n" unless $beQuiet; + + my $data = join("", @temporaryContent); + $data =~ /$IDLStructure::moduleSelector/; + + my $moduleName = (defined($1) ? $1 : die("Parsing error!\nSource:\n$data\n)")); + $dataNode->module($moduleName); + + print " |----> Module; NAME \"$moduleName\"\n |-\n |\n" unless $beQuiet; +} + +sub dumpExtendedAttributes +{ + my $padStr = shift; + my $attrs = shift; + + if (!%{$attrs}) { + return ""; + } + + my @temp; + while ((my $name, my $value) = each(%{$attrs})) { + push(@temp, "$name=$value"); + } + + return $padStr . "[" . join(", ", @temp) . "]"; +} + +sub parseExtendedAttributes +{ + my $str = shift; + $str =~ s/\[\s*(.*?)\s*\]/$1/g; + + my %attrs = (); + + foreach my $value (split(/\s*,\s*/, $str)) { + (my $name, my $val) = split(/\s*=\s*/, $value, 2); + + # Attributes with no value are set to be true + $val = 1 unless defined $val; + $attrs{$name} = $val; + die("Invalid extended attribute name: '$name'\n") if $name =~ /\s/; + } + + return \%attrs; +} + +sub ParseInterface +{ + my $object = shift; + my $dataNode = shift; + my $sectionName = shift; + + my $data = join("", @temporaryContent); + + # Look for end-of-interface mark + $data =~ /};/g; + $data = substr($data, index($data, $sectionName), pos($data) - length($data)); + + $data =~ s/[\n\r]/ /g; + + # Beginning of the regexp parsing magic + if ($sectionName eq "exception") { + print " |- Trying to parse exception...\n" unless $beQuiet; + + my $exceptionName = ""; + my $exceptionData = ""; + my $exceptionDataName = ""; + my $exceptionDataType = ""; + + # Match identifier of the exception, and enclosed data... + $data =~ /$IDLStructure::exceptionSelector/; + $exceptionName = (defined($1) ? $1 : die("Parsing error!\nSource:\n$data\n)")); + $exceptionData = (defined($2) ? $2 : die("Parsing error!\nSource:\n$data\n)")); + + ('' =~ /^/); # Reset variables needed for regexp matching + + # ... parse enclosed data (get. name & type) + $exceptionData =~ /$IDLStructure::exceptionSubSelector/; + $exceptionDataType = (defined($1) ? $1 : die("Parsing error!\nSource:\n$data\n)")); + $exceptionDataName = (defined($2) ? $2 : die("Parsing error!\nSource:\n$data\n)")); + + # Fill in domClass datastructure + $dataNode->name($exceptionName); + + my $newDataNode = new domAttribute(); + $newDataNode->type("readonly attribute"); + $newDataNode->signature(new domSignature()); + + $newDataNode->signature->name($exceptionDataName); + $newDataNode->signature->type($exceptionDataType); + + my $arrayRef = $dataNode->attributes; + push(@$arrayRef, $newDataNode); + + print " |----> Exception; NAME \"$exceptionName\" DATA TYPE \"$exceptionDataType\" DATA NAME \"$exceptionDataName\"\n |-\n |\n" unless $beQuiet; + } elsif ($sectionName eq "interface") { + print " |- Trying to parse interface...\n" unless $beQuiet; + + my $interfaceName = ""; + my $interfaceData = ""; + + # Match identifier of the interface, and enclosed data... + $data =~ /$IDLStructure::interfaceSelector/; + + my $interfaceExtendedAttributes = (defined($1) ? $1 : " "); chop($interfaceExtendedAttributes); + $interfaceName = (defined($2) ? $2 : die("Parsing error!\nSource:\n$data\n)")); + my $interfaceBase = (defined($3) ? $3 : ""); + $interfaceData = (defined($4) ? $4 : die("Parsing error!\nSource:\n$data\n)")); + + # Fill in known parts of the domClass datastructure now... + $dataNode->name($interfaceName); + $dataNode->extendedAttributes(parseExtendedAttributes($interfaceExtendedAttributes)); + + # Inheritance detection + my @interfaceParents = split(/,/, $interfaceBase); + foreach(@interfaceParents) { + my $line = $_; + $line =~ s/\s*//g; + + my $arrayRef = $dataNode->parents; + push(@$arrayRef, $line); + } + + return if $parentsOnly; + + $interfaceData =~ s/[\n\r]/ /g; + my @interfaceMethods = split(/;/, $interfaceData); + + foreach my $line (@interfaceMethods) { + if ($line =~ /\Wattribute\W/) { + $line =~ /$IDLStructure::interfaceAttributeSelector/; + + my $attributeType = (defined($1) ? $1 : die("Parsing error!\nSource:\n$line\n)")); + my $attributeExtendedAttributes = (defined($2) ? $2 : " "); chop($attributeExtendedAttributes); + + my $attributeDataType = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)")); + my $attributeDataName = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)")); + + ('' =~ /^/); # Reset variables needed for regexp matching + + $line =~ /$IDLStructure::getterRaisesSelector/; + my $getterException = (defined($1) ? $1 : ""); + + $line =~ /$IDLStructure::setterRaisesSelector/; + my $setterException = (defined($1) ? $1 : ""); + + my $newDataNode = new domAttribute(); + $newDataNode->type($attributeType); + $newDataNode->signature(new domSignature()); + + $newDataNode->signature->name($attributeDataName); + $newDataNode->signature->type($attributeDataType); + $newDataNode->signature->extendedAttributes(parseExtendedAttributes($attributeExtendedAttributes)); + + my $arrayRef = $dataNode->attributes; + push(@$arrayRef, $newDataNode); + + print " | |> Attribute; TYPE \"$attributeType\" DATA NAME \"$attributeDataName\" DATA TYPE \"$attributeDataType\" GET EXCEPTION? \"$getterException\" SET EXCEPTION? \"$setterException\"" . + dumpExtendedAttributes("\n | ", $newDataNode->signature->extendedAttributes) . "\n" unless $beQuiet; + + $getterException =~ s/\s+//g; + $setterException =~ s/\s+//g; + @{$newDataNode->getterExceptions} = split(/,/, $getterException); + @{$newDataNode->setterExceptions} = split(/,/, $setterException); + } elsif (($line !~ s/^\s*$//g) and ($line !~ /^\s*const/)) { + $line =~ /$IDLStructure::interfaceMethodSelector/ or die "Parsing error!\nSource:\n$line\n)"; + + my $methodExtendedAttributes = (defined($1) ? $1 : " "); chop($methodExtendedAttributes); + my $methodType = (defined($2) ? $2 : die("Parsing error!\nSource:\n$line\n)")); + my $methodName = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)")); + my $methodSignature = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)")); + + ('' =~ /^/); # Reset variables needed for regexp matching + + $line =~ /$IDLStructure::raisesSelector/; + my $methodException = (defined($1) ? $1 : ""); + + my $newDataNode = new domFunction(); + + $newDataNode->signature(new domSignature()); + $newDataNode->signature->name($methodName); + $newDataNode->signature->type($methodType); + $newDataNode->signature->extendedAttributes(parseExtendedAttributes($methodExtendedAttributes)); + + print " | |- Method; TYPE \"$methodType\" NAME \"$methodName\" EXCEPTION? \"$methodException\"" . + dumpExtendedAttributes("\n | ", $newDataNode->signature->extendedAttributes) . "\n" unless $beQuiet; + + $methodException =~ s/\s+//g; + @{$newDataNode->raisesExceptions} = split(/,/, $methodException); + + # Split arguments at commas but only if the comma + # is not within attribute brackets, expressed here + # as being followed by a ']' without a preceding '['. + # Note that this assumes that attributes don't nest. + my @params = split(/,(?![^[]*\])/, $methodSignature); + foreach(@params) { + my $line = $_; + + $line =~ /$IDLStructure::interfaceParameterSelector/; + my $paramDirection = $1; + my $paramExtendedAttributes = (defined($2) ? $2 : " "); chop($paramExtendedAttributes); + my $paramType = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)")); + my $paramName = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)")); + + my $paramDataNode = new domSignature(); + $paramDataNode->direction($paramDirection); + $paramDataNode->name($paramName); + $paramDataNode->type($paramType); + $paramDataNode->extendedAttributes(parseExtendedAttributes($paramExtendedAttributes)); + + my $arrayRef = $newDataNode->parameters; + push(@$arrayRef, $paramDataNode); + + print " | |> Param; TYPE \"$paramType\" NAME \"$paramName\"" . + dumpExtendedAttributes("\n | ", $paramDataNode->extendedAttributes) . "\n" unless $beQuiet; + } + + my $arrayRef = $dataNode->functions; + push(@$arrayRef, $newDataNode); + } elsif ($line =~ /^\s*const/) { + $line =~ /$IDLStructure::constantSelector/; + my $constType = (defined($1) ? $1 : die("Parsing error!\nSource:\n$line\n)")); + my $constName = (defined($2) ? $2 : die("Parsing error!\nSource:\n$line\n)")); + my $constValue = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)")); + + my $newDataNode = new domConstant(); + $newDataNode->name($constName); + $newDataNode->type($constType); + $newDataNode->value($constValue); + + my $arrayRef = $dataNode->constants; + push(@$arrayRef, $newDataNode); + + print " | |> Constant; TYPE \"$constType\" NAME \"$constName\" VALUE \"$constValue\"\n" unless $beQuiet; + } + } + + print " |----> Interface; NAME \"$interfaceName\"" . + dumpExtendedAttributes("\n | ", $dataNode->extendedAttributes) . "\n |-\n |\n" unless $beQuiet; + } +} + +# Internal helper +sub DetermineParseMode +{ + my $object = shift; + my $line = shift; + + my $mode = MODE_UNDEF; + if ($_ =~ /module/) { + $mode = MODE_MODULE; + } elsif ($_ =~ /interface/) { + $mode = MODE_INTERFACE; + } elsif ($_ =~ /exception/) { + $mode = MODE_EXCEPTION; + } elsif ($_ =~ /(\A|\b)alias/) { + # The (\A|\b) above is needed so we don't match attributes + # whose names contain the substring "alias". + $mode = MODE_ALIAS; + } + + return $mode; +} + +# Internal helper +sub ProcessSection +{ + my $object = shift; + + if ($parseMode eq MODE_MODULE) { + die ("Two modules in one file! Fatal error!\n") if ($document ne 0); + $document = new idlDocument(); + $object->ParseModule($document); + } elsif ($parseMode eq MODE_INTERFACE) { + my $node = new domClass(); + $object->ParseInterface($node, "interface"); + + die ("No module specified! Fatal Error!\n") if ($document eq 0); + my $arrayRef = $document->classes; + push(@$arrayRef, $node); + } elsif($parseMode eq MODE_EXCEPTION) { + my $node = new domClass(); + $object->ParseInterface($node, "exception"); + + die ("No module specified! Fatal Error!\n") if ($document eq 0); + my $arrayRef = $document->classes; + push(@$arrayRef, $node); + } elsif($parseMode eq MODE_ALIAS) { + print " |- Trying to parse alias...\n" unless $beQuiet; + + my $line = join("", @temporaryContent); + $line =~ /$IDLStructure::aliasSelector/; + + my $interfaceName = (defined($1) ? $1 : die("Parsing error!\nSource:\n$line\n)")); + my $wrapperName = (defined($2) ? $2 : die("Parsing error!\nSource:\n$line\n)")); + + print " |----> Alias; INTERFACE \"$interfaceName\" WRAPPER \"$wrapperName\"\n |-\n |\n" unless $beQuiet; + + # FIXME: Check if alias is already in aliases + my $aliases = $document->aliases; + $aliases->{$interfaceName} = $wrapperName; + } + + @temporaryContent = ""; +} + +1; diff --git a/Source/WebCore/bindings/scripts/IDLStructure.pm b/Source/WebCore/bindings/scripts/IDLStructure.pm new file mode 100644 index 0000000..f9dd4ab --- /dev/null +++ b/Source/WebCore/bindings/scripts/IDLStructure.pm @@ -0,0 +1,112 @@ +# +# KDOM IDL parser +# +# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.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. +# + +package IDLStructure; + +use strict; + +use Class::Struct; + +# Used to represent a parsed IDL document +struct( idlDocument => { + module => '$', # Module identifier + classes => '@', # All parsed interfaces + fileName => '$' # file name +}); + +# Used to represent 'interface' / 'exception' blocks +struct( domClass => { + name => '$', # Class identifier (without module) + parents => '@', # List of strings + constants => '@', # List of 'domConstant' + functions => '@', # List of 'domFunction' + attributes => '@', # List of 'domAttribute' + extendedAttributes => '$', # Extended attributes +}); + +# Used to represent domClass contents (name of method, signature) +struct( domFunction => { + signature => '$', # Return type/Object name/extended attributes + parameters => '@', # List of 'domSignature' + raisesExceptions => '@', # Possibly raised exceptions. +}); + +# Used to represent domClass contents (name of attribute, signature) +struct( domAttribute => { + type => '$', # Attribute type (including namespace) + signature => '$', # Attribute signature + getterExceptions => '@', # Possibly raised exceptions. + setterExceptions => '@', # Possibly raised exceptions. +}); + +# Used to represent a map of 'variable name' <-> 'variable type' +struct( domSignature => { + direction => '$', # Variable direction (in or out) + name => '$', # Variable name + type => '$', # Variable type + extendedAttributes => '$' # Extended attributes +}); + +# Used to represent string constants +struct( domConstant => { + name => '$', # DOM Constant identifier + type => '$', # Type of data + value => '$', # Constant value +}); + +# Helpers +our $idlId = '[a-zA-Z0-9]'; # Generic identifier +our $idlIdNs = '[a-zA-Z0-9:]'; # Generic identifier including namespace +our $idlIdNsList = '[a-zA-Z0-9:,\ ]'; # List of Generic identifiers including namespace + +our $idlType = '[a-zA-Z0-9_]'; # Generic type/"value string" identifier +# Match a string value, a hexadecimal number, or an integral number. +# Note: some of the characters that are allowed in the string value may not be allowed by +# interfaceSelector. +our $constValue = '("[^"\r\n]*")|(0[xX][a-fA-F0-9]+)|(-?[0-9]*)'; +our $idlDataType = '[a-zA-Z0-9\ ]'; # Generic data type identifier + +# Magic IDL parsing regular expressions +my $supportedTypes = "((?:unsigned )?(?:int|short|(?:long )?long)|(?:$idlIdNs*))"; + +# Special IDL notations +our $extendedAttributeSyntax = '\[[^]]*\]'; # Used for extended attributes + +# Regular expression based IDL 'syntactical tokenizer' used in the IDLParser +our $moduleSelector = 'module\s*(' . $idlId . '*)\s*{'; +our $moduleNSSelector = 'module\s*(' . $idlId . '*)\s*\[ns\s*(' . $idlIdNs . '*)\s*(' . $idlIdNs . '*)\]\s*;'; +our $constantSelector = 'const\s*' . $supportedTypes . '\s*(' . $idlType . '*)\s*=\s*(' . $constValue . ')'; +our $raisesSelector = 'raises\s*\((' . $idlIdNsList . '*)\s*\)'; +our $getterRaisesSelector = '\bgetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)'; +our $setterRaisesSelector = '\bsetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)'; + +our $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)'; + +our $exceptionSelector = 'exception\s*(' . $idlIdNs . '*)\s*([a-zA-Z\s{;]*};)'; +our $exceptionSubSelector = '{\s*' . $supportedTypes . '\s*(' . $idlType . '*)\s*;\s*}'; + +our $interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([-a-zA-Z0-9_"=\s(),;:\[\]&\|]*)'; +our $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)'; +our $interfaceParameterSelector = '(in|out)\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)'; + +our $interfaceAttributeSelector = '\s*(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)'; + +1; diff --git a/Source/WebCore/bindings/scripts/InFilesParser.pm b/Source/WebCore/bindings/scripts/InFilesParser.pm new file mode 100644 index 0000000..6539380 --- /dev/null +++ b/Source/WebCore/bindings/scripts/InFilesParser.pm @@ -0,0 +1,154 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2008 Julien Chaffraix <jchaffraix@webkit.org> +# +# 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. +# + +use strict; + +package InFilesParser; + +my $isParsingCommonParameters; +my $hasStartedParsing; + +# Helper functions + +sub trimComment +{ + my $string = shift; + $string =~ s/#.+$//; + chomp($string); + return $string; +} + +sub trimWS +{ + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + chomp($string); + return $string; +} + +sub trimQuoteAndWS +{ + my $string = shift; + $string =~ s/\"([^\"]+)\"/$1/; + return trimWS($string); +} + +# Default constructor + +sub new +{ + my $object = shift; + my $reference = { }; + + # Initialize the parser. + $isParsingCommonParameters = 1; + $hasStartedParsing = 0; + + bless($reference, $object); + return $reference; +} + +# parse take 3 attributes: +# - the filestream to read from (the caller has to open / close it). +# - the commonParameterHandler called when parsing the first part of the file with the parameter and the value. +# - the perTagHandler called for each optional parameter with the element name, the parameter and its value. +# If no parameter were provided, it is called once with an empty parameter and value. +sub parse($) +{ + my $object = shift; + my $fileStream = shift; # IO::File only + my $commonParameterHandler = shift; + my $perTagHandler = shift; + + foreach (<$fileStream>) { + # Ignore whitespace, in case the .in files have the wrong EOL + # markers and those are getting treated as whitespace. + $_ = trimWS($_); + + # Empty line, change from common parameter part + # to per tag part if we have started parsing. + if (/^$/) { + if ($hasStartedParsing) { + $isParsingCommonParameters = 0; + } + next; + } + + # There may be a few empty lines at the beginning of the file + # so detect the first non empty line which starts the common + # parameters part. + $hasStartedParsing = 1; + + if (/^#/) { + next; + } + + $_ = trimComment($_); + + if ($isParsingCommonParameters) { + my ($name, $value) = split '=', $_; + + $name = trimWS($name); + if (defined($value)) { + $value = trimQuoteAndWS($value); + } else { + # We default to 1 as it eases the syntax. + $value = "1"; + } + + &$commonParameterHandler($name, $value); + } else { + # Parsing per-tag parameters. + + # Split the tag name ($1) from the optionnal parameter(s) ($2) + /^(\S+)\s*(.*)$/; + my $elementName = $1; + + if ($2) { + my @options = split "," , $2; + my ($option, $value); + for (my $i = 0; $i < @options; ++$i) { + ($option, $value) = split "=", $options[$i]; + $option = trimWS($option); + if (defined($value)) { + $value = trimQuoteAndWS($value); + } else { + # We default to 1 as it eases the syntax. + $value = "1"; + } + + &$perTagHandler($elementName, $option, $value); + } + } else { + # No parameter was given so call it with empty strings. + &$perTagHandler($elementName, "", ""); + } + } + } +} + +1; diff --git a/Source/WebCore/bindings/scripts/generate-bindings.pl b/Source/WebCore/bindings/scripts/generate-bindings.pl new file mode 100755 index 0000000..57a3928 --- /dev/null +++ b/Source/WebCore/bindings/scripts/generate-bindings.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl -w +# +# Copyright (C) 2005 Apple Computer, Inc. +# Copyright (C) 2006 Anders Carlsson <andersca@mac.com> +# +# 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 +# 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. +# + +# This script is a temporary hack. +# Files are generated in the source directory, when they really should go +# to the DerivedSources directory. +# This should also eventually be a build rule driven off of .idl files +# however a build rule only solution is blocked by several radars: +# <rdar://problems/4251781&4251785> + +use strict; + +use File::Path; +use Getopt::Long; +use Cwd; + +use IDLParser; +use CodeGenerator; + +my @idlDirectories; +my $outputDirectory; +my $outputHeadersDirectory; +my $generator; +my $defines; +my $filename; +my $prefix; +my $preprocessor; +my $writeDependencies; +my $verbose; + +GetOptions('include=s@' => \@idlDirectories, + 'outputDir=s' => \$outputDirectory, + 'outputHeadersDir=s' => \$outputHeadersDirectory, + 'generator=s' => \$generator, + 'defines=s' => \$defines, + 'filename=s' => \$filename, + 'prefix=s' => \$prefix, + 'preprocessor=s' => \$preprocessor, + 'verbose' => \$verbose, + 'write-dependencies' => \$writeDependencies); + +my $idlFile = $ARGV[0]; + +die('Must specify input file.') unless defined($idlFile); +die('Must specify generator') unless defined($generator); +die('Must specify output directory.') unless defined($outputDirectory); +die('Must specify defines') unless defined($defines); + +if (!$outputHeadersDirectory) { + $outputHeadersDirectory = $outputDirectory; +} +if ($verbose) { + print "$generator: $idlFile\n"; +} +$defines =~ s/^\s+|\s+$//g; # trim whitespace + +# Parse the given IDL file. +my $parser = IDLParser->new(!$verbose); +my $document = $parser->Parse($idlFile, $defines, $preprocessor); + +# Generate desired output for given IDL file. +my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose); +$codeGen->ProcessDocument($document, $defines); diff --git a/Source/WebCore/bindings/scripts/gobject-generate-headers.pl b/Source/WebCore/bindings/scripts/gobject-generate-headers.pl new file mode 100644 index 0000000..1017406 --- /dev/null +++ b/Source/WebCore/bindings/scripts/gobject-generate-headers.pl @@ -0,0 +1,77 @@ +#!/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") { + 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 <webkit/WebKitDOM${class}.h>\n"; + } +} + +print "\n"; +print "#endif\n"; diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp new file mode 100644 index 0000000..a58da40 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp @@ -0,0 +1,120 @@ +/* + * 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. + */ + +#include "config.h" + +#if ENABLE(DATABASE) + +#include "WebDOMTestCallback.h" + +#include "Class1.h" +#include "Class2.h" +#include "Class3.h" +#include "KURL.h" +#include "TestCallback.h" +#include "WebDOMClass1.h" +#include "WebDOMClass2.h" +#include "WebDOMClass3.h" +#include "WebDOMString.h" +#include "WebExceptionHandler.h" +#include "wtf/text/AtomicString.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +struct WebDOMTestCallback::WebDOMTestCallbackPrivate { + WebDOMTestCallbackPrivate(WebCore::TestCallback* object = 0) + : impl(object) + { + } + + RefPtr<WebCore::TestCallback> impl; +}; + +WebDOMTestCallback::WebDOMTestCallback() + : WebDOMObject() + , m_impl(0) +{ +} + +WebDOMTestCallback::WebDOMTestCallback(WebCore::TestCallback* impl) + : WebDOMObject() + , m_impl(new WebDOMTestCallbackPrivate(impl)) +{ +} + +WebDOMTestCallback::WebDOMTestCallback(const WebDOMTestCallback& copy) + : WebDOMObject() +{ + m_impl = copy.impl() ? new WebDOMTestCallbackPrivate(copy.impl()) : 0; +} + +WebDOMTestCallback& WebDOMTestCallback::operator=(const WebDOMTestCallback& copy) +{ + delete m_impl; + m_impl = copy.impl() ? new WebDOMTestCallbackPrivate(copy.impl()) : 0; + return *this; +} + +WebCore::TestCallback* WebDOMTestCallback::impl() const +{ + return m_impl ? m_impl->impl.get() : 0; +} + +WebDOMTestCallback::~WebDOMTestCallback() +{ + delete m_impl; + m_impl = 0; +} + +bool WebDOMTestCallback::callbackWithClass1Param(const WebDOMClass1& class1Param) +{ + if (!impl()) + return false; + + return impl()->callbackWithClass1Param(toWebCore(class1Param)); +} + +bool WebDOMTestCallback::callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg) +{ + if (!impl()) + return false; + + return impl()->callbackWithClass2Param(toWebCore(class2Param), strArg); +} + +int WebDOMTestCallback::callbackWithNonBoolReturnType(const WebDOMClass3& class3Param) +{ + if (!impl()) + return 0; + + return impl()->callbackWithNonBoolReturnType(toWebCore(class3Param)); +} + +WebCore::TestCallback* toWebCore(const WebDOMTestCallback& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestCallback toWebKit(WebCore::TestCallback* value) +{ + return WebDOMTestCallback(value); +} + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h new file mode 100644 index 0000000..91ff787 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h @@ -0,0 +1,66 @@ +/* + * 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. + */ + +#ifndef WebDOMTestCallback_h +#define WebDOMTestCallback_h + +#if ENABLE(DATABASE) + +#include <WebDOMObject.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestCallback; +}; + +class WebDOMClass1; +class WebDOMClass2; +class WebDOMClass3; +class WebDOMClass5; +class WebDOMClass6; + +class WebDOMTestCallback : public WebDOMObject { +public: + WebDOMTestCallback(); + explicit WebDOMTestCallback(WebCore::TestCallback*); + WebDOMTestCallback(const WebDOMTestCallback&); + WebDOMTestCallback& operator=(const WebDOMTestCallback&); + virtual ~WebDOMTestCallback(); + + bool callbackWithClass1Param(const WebDOMClass1& class1Param); + bool callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg); + int callbackWithNonBoolReturnType(const WebDOMClass3& class3Param); + int customCallback(const WebDOMClass5& class5Param, const WebDOMClass6& class6Param); + + WebCore::TestCallback* impl() const; + +protected: + struct WebDOMTestCallbackPrivate; + WebDOMTestCallbackPrivate* m_impl; +}; + +WebCore::TestCallback* toWebCore(const WebDOMTestCallback&); +WebDOMTestCallback toWebKit(WebCore::TestCallback*); + +#endif +#endif // ENABLE(DATABASE) + diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp new file mode 100644 index 0000000..7fa4af3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp @@ -0,0 +1,87 @@ +/* + * 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. + */ + +#include "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "WebDOMTestInterface.h" + +#include "TestInterface.h" +#include "WebExceptionHandler.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +struct WebDOMTestInterface::WebDOMTestInterfacePrivate { + WebDOMTestInterfacePrivate(WebCore::TestInterface* object = 0) + : impl(object) + { + } + + RefPtr<WebCore::TestInterface> impl; +}; + +WebDOMTestInterface::WebDOMTestInterface() + : WebDOMObject() + , m_impl(0) +{ +} + +WebDOMTestInterface::WebDOMTestInterface(WebCore::TestInterface* impl) + : WebDOMObject() + , m_impl(new WebDOMTestInterfacePrivate(impl)) +{ +} + +WebDOMTestInterface::WebDOMTestInterface(const WebDOMTestInterface& copy) + : WebDOMObject() +{ + m_impl = copy.impl() ? new WebDOMTestInterfacePrivate(copy.impl()) : 0; +} + +WebDOMTestInterface& WebDOMTestInterface::operator=(const WebDOMTestInterface& copy) +{ + delete m_impl; + m_impl = copy.impl() ? new WebDOMTestInterfacePrivate(copy.impl()) : 0; + return *this; +} + +WebCore::TestInterface* WebDOMTestInterface::impl() const +{ + return m_impl ? m_impl->impl.get() : 0; +} + +WebDOMTestInterface::~WebDOMTestInterface() +{ + delete m_impl; + m_impl = 0; +} + +WebCore::TestInterface* toWebCore(const WebDOMTestInterface& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestInterface toWebKit(WebCore::TestInterface* value) +{ + return WebDOMTestInterface(value); +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h new file mode 100644 index 0000000..5db5db8 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h @@ -0,0 +1,57 @@ +/* + * 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. + */ + +#ifndef WebDOMTestInterface_h +#define WebDOMTestInterface_h + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include <WebDOMObject.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestInterface; +}; + + +class WebDOMTestInterface : public WebDOMObject { +public: + WebDOMTestInterface(); + explicit WebDOMTestInterface(WebCore::TestInterface*); + WebDOMTestInterface(const WebDOMTestInterface&); + WebDOMTestInterface& operator=(const WebDOMTestInterface&); + virtual ~WebDOMTestInterface(); + + + WebCore::TestInterface* impl() const; + +protected: + struct WebDOMTestInterfacePrivate; + WebDOMTestInterfacePrivate* m_impl; +}; + +WebCore::TestInterface* toWebCore(const WebDOMTestInterface&); +WebDOMTestInterface toWebKit(WebCore::TestInterface*); + +#endif +#endif // ENABLE(Condition1) || ENABLE(Condition2) + diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestMediaQueryListListener.cpp new file mode 100644 index 0000000..7543fc4 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestMediaQueryListListener.cpp @@ -0,0 +1,92 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebDOMTestMediaQueryListListener.h" + +#include "MediaQueryListListener.h" +#include "TestMediaQueryListListener.h" +#include "WebDOMMediaQueryListListener.h" +#include "WebExceptionHandler.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +struct WebDOMTestMediaQueryListListener::WebDOMTestMediaQueryListListenerPrivate { + WebDOMTestMediaQueryListListenerPrivate(WebCore::TestMediaQueryListListener* object = 0) + : impl(object) + { + } + + RefPtr<WebCore::TestMediaQueryListListener> impl; +}; + +WebDOMTestMediaQueryListListener::WebDOMTestMediaQueryListListener() + : WebDOMObject() + , m_impl(0) +{ +} + +WebDOMTestMediaQueryListListener::WebDOMTestMediaQueryListListener(WebCore::TestMediaQueryListListener* impl) + : WebDOMObject() + , m_impl(new WebDOMTestMediaQueryListListenerPrivate(impl)) +{ +} + +WebDOMTestMediaQueryListListener::WebDOMTestMediaQueryListListener(const WebDOMTestMediaQueryListListener& copy) + : WebDOMObject() +{ + m_impl = copy.impl() ? new WebDOMTestMediaQueryListListenerPrivate(copy.impl()) : 0; +} + +WebDOMTestMediaQueryListListener& WebDOMTestMediaQueryListListener::operator=(const WebDOMTestMediaQueryListListener& copy) +{ + delete m_impl; + m_impl = copy.impl() ? new WebDOMTestMediaQueryListListenerPrivate(copy.impl()) : 0; + return *this; +} + +WebCore::TestMediaQueryListListener* WebDOMTestMediaQueryListListener::impl() const +{ + return m_impl ? m_impl->impl.get() : 0; +} + +WebDOMTestMediaQueryListListener::~WebDOMTestMediaQueryListListener() +{ + delete m_impl; + m_impl = 0; +} + +void WebDOMTestMediaQueryListListener::method(const WebDOMMediaQueryListListener& listener) +{ + if (!impl()) + return; + + impl()->method(toWebCore(listener)); +} + +WebCore::TestMediaQueryListListener* toWebCore(const WebDOMTestMediaQueryListListener& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestMediaQueryListListener toWebKit(WebCore::TestMediaQueryListListener* value) +{ + return WebDOMTestMediaQueryListListener(value); +} diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestMediaQueryListListener.h new file mode 100644 index 0000000..8f89836 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestMediaQueryListListener.h @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#ifndef WebDOMTestMediaQueryListListener_h +#define WebDOMTestMediaQueryListListener_h + +#include <WebDOMObject.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestMediaQueryListListener; +}; + +class WebDOMMediaQueryListListener; + +class WebDOMTestMediaQueryListListener : public WebDOMObject { +public: + WebDOMTestMediaQueryListListener(); + explicit WebDOMTestMediaQueryListListener(WebCore::TestMediaQueryListListener*); + WebDOMTestMediaQueryListListener(const WebDOMTestMediaQueryListListener&); + WebDOMTestMediaQueryListListener& operator=(const WebDOMTestMediaQueryListListener&); + virtual ~WebDOMTestMediaQueryListListener(); + + void method(const WebDOMMediaQueryListListener& listener); + + WebCore::TestMediaQueryListListener* impl() const; + +protected: + struct WebDOMTestMediaQueryListListenerPrivate; + WebDOMTestMediaQueryListListenerPrivate* m_impl; +}; + +WebCore::TestMediaQueryListListener* toWebCore(const WebDOMTestMediaQueryListListener&); +WebDOMTestMediaQueryListListener toWebKit(WebCore::TestMediaQueryListListener*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp new file mode 100644 index 0000000..65e5bf3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp @@ -0,0 +1,834 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebDOMTestObj.h" + +#include "HTMLNames.h" +#include "IDBKey.h" +#include "KURL.h" +#include "OptionsObject.h" +#include "SerializedScriptValue.h" +#include "TestObj.h" +#include "WebDOMIDBKey.h" +#include "WebDOMOptionsObject.h" +#include "WebDOMString.h" +#include "WebExceptionHandler.h" +#include "WebNativeEventListener.h" +#include "wtf/text/AtomicString.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +struct WebDOMTestObj::WebDOMTestObjPrivate { + WebDOMTestObjPrivate(WebCore::TestObj* object = 0) + : impl(object) + { + } + + RefPtr<WebCore::TestObj> impl; +}; + +WebDOMTestObj::WebDOMTestObj() + : WebDOMObject() + , m_impl(0) +{ +} + +WebDOMTestObj::WebDOMTestObj(WebCore::TestObj* impl) + : WebDOMObject() + , m_impl(new WebDOMTestObjPrivate(impl)) +{ +} + +WebDOMTestObj::WebDOMTestObj(const WebDOMTestObj& copy) + : WebDOMObject() +{ + m_impl = copy.impl() ? new WebDOMTestObjPrivate(copy.impl()) : 0; +} + +WebDOMTestObj& WebDOMTestObj::operator=(const WebDOMTestObj& copy) +{ + delete m_impl; + m_impl = copy.impl() ? new WebDOMTestObjPrivate(copy.impl()) : 0; + return *this; +} + +WebCore::TestObj* WebDOMTestObj::impl() const +{ + return m_impl ? m_impl->impl.get() : 0; +} + +WebDOMTestObj::~WebDOMTestObj() +{ + delete m_impl; + m_impl = 0; +} + +int WebDOMTestObj::readOnlyIntAttr() const +{ + if (!impl()) + return 0; + + return impl()->readOnlyIntAttr(); +} + +WebDOMString WebDOMTestObj::readOnlyStringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->readOnlyStringAttr()); +} + +WebDOMTestObj WebDOMTestObj::readOnlyTestObjAttr() const +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->readOnlyTestObjAttr())); +} + +short WebDOMTestObj::shortAttr() const +{ + if (!impl()) + return 0; + + return impl()->shortAttr(); +} + +void WebDOMTestObj::setShortAttr(short newShortAttr) +{ + if (!impl()) + return; + + impl()->setShortAttr(newShortAttr); +} + +unsigned short WebDOMTestObj::unsignedShortAttr() const +{ + if (!impl()) + return 0; + + return impl()->unsignedShortAttr(); +} + +void WebDOMTestObj::setUnsignedShortAttr(unsigned short newUnsignedShortAttr) +{ + if (!impl()) + return; + + impl()->setUnsignedShortAttr(newUnsignedShortAttr); +} + +int WebDOMTestObj::intAttr() const +{ + if (!impl()) + return 0; + + return impl()->intAttr(); +} + +void WebDOMTestObj::setIntAttr(int newIntAttr) +{ + if (!impl()) + return; + + impl()->setIntAttr(newIntAttr); +} + +long long WebDOMTestObj::longLongAttr() const +{ + if (!impl()) + return 0; + + return impl()->longLongAttr(); +} + +void WebDOMTestObj::setLongLongAttr(long long newLongLongAttr) +{ + if (!impl()) + return; + + impl()->setLongLongAttr(newLongLongAttr); +} + +unsigned long long WebDOMTestObj::unsignedLongLongAttr() const +{ + if (!impl()) + return 0; + + return impl()->unsignedLongLongAttr(); +} + +void WebDOMTestObj::setUnsignedLongLongAttr(unsigned long long newUnsignedLongLongAttr) +{ + if (!impl()) + return; + + impl()->setUnsignedLongLongAttr(newUnsignedLongLongAttr); +} + +WebDOMString WebDOMTestObj::stringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->stringAttr()); +} + +void WebDOMTestObj::setStringAttr(const WebDOMString& newStringAttr) +{ + if (!impl()) + return; + + impl()->setStringAttr(newStringAttr); +} + +WebDOMTestObj WebDOMTestObj::testObjAttr() const +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->testObjAttr())); +} + +void WebDOMTestObj::setTestObjAttr(const WebDOMTestObj& newTestObjAttr) +{ + if (!impl()) + return; + + impl()->setTestObjAttr(toWebCore(newTestObjAttr)); +} + +WebDOMTestObj WebDOMTestObj::XMLObjAttr() const +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->xmlObjAttr())); +} + +void WebDOMTestObj::setXMLObjAttr(const WebDOMTestObj& newXMLObjAttr) +{ + if (!impl()) + return; + + impl()->setXMLObjAttr(toWebCore(newXMLObjAttr)); +} + +bool WebDOMTestObj::create() const +{ + if (!impl()) + return false; + + return impl()->isCreate(); +} + +void WebDOMTestObj::setCreate(bool newCreate) +{ + if (!impl()) + return; + + impl()->setCreate(newCreate); +} + +WebDOMString WebDOMTestObj::reflectedStringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); +} + +void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, newReflectedStringAttr); +} + +int WebDOMTestObj::reflectedIntegralAttr() const +{ + if (!impl()) + return 0; + + return impl()->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); +} + +void WebDOMTestObj::setReflectedIntegralAttr(int newReflectedIntegralAttr) +{ + if (!impl()) + return; + + impl()->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, newReflectedIntegralAttr); +} + +unsigned WebDOMTestObj::reflectedUnsignedIntegralAttr() const +{ + if (!impl()) + return unsigned(); + + return impl()->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr); +} + +void WebDOMTestObj::setReflectedUnsignedIntegralAttr(unsigned newReflectedUnsignedIntegralAttr) +{ + if (!impl()) + return; + + impl()->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, newReflectedUnsignedIntegralAttr); +} + +bool WebDOMTestObj::reflectedBooleanAttr() const +{ + if (!impl()) + return false; + + return impl()->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); +} + +void WebDOMTestObj::setReflectedBooleanAttr(bool newReflectedBooleanAttr) +{ + if (!impl()) + return; + + impl()->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, newReflectedBooleanAttr); +} + +WebDOMString WebDOMTestObj::reflectedURLAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); +} + +void WebDOMTestObj::setReflectedURLAttr(const WebDOMString& newReflectedURLAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, newReflectedURLAttr); +} + +WebDOMString WebDOMTestObj::reflectedNonEmptyURLAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); +} + +void WebDOMTestObj::setReflectedNonEmptyURLAttr(const WebDOMString& newReflectedNonEmptyURLAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, newReflectedNonEmptyURLAttr); +} + +WebDOMString WebDOMTestObj::reflectedStringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); +} + +void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, newReflectedStringAttr); +} + +int WebDOMTestObj::reflectedCustomIntegralAttr() const +{ + if (!impl()) + return 0; + + return impl()->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); +} + +void WebDOMTestObj::setReflectedCustomIntegralAttr(int newReflectedCustomIntegralAttr) +{ + if (!impl()) + return; + + impl()->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, newReflectedCustomIntegralAttr); +} + +bool WebDOMTestObj::reflectedCustomBooleanAttr() const +{ + if (!impl()) + return false; + + return impl()->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); +} + +void WebDOMTestObj::setReflectedCustomBooleanAttr(bool newReflectedCustomBooleanAttr) +{ + if (!impl()) + return; + + impl()->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, newReflectedCustomBooleanAttr); +} + +WebDOMString WebDOMTestObj::reflectedCustomURLAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); +} + +void WebDOMTestObj::setReflectedCustomURLAttr(const WebDOMString& newReflectedCustomURLAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, newReflectedCustomURLAttr); +} + +WebDOMString WebDOMTestObj::reflectedCustomNonEmptyURLAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); +} + +void WebDOMTestObj::setReflectedCustomNonEmptyURLAttr(const WebDOMString& newReflectedCustomNonEmptyURLAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, newReflectedCustomNonEmptyURLAttr); +} + +int WebDOMTestObj::attrWithGetterException() const +{ + if (!impl()) + return 0; + + WebCore::ExceptionCode ec = 0; + int result = impl()->attrWithGetterException(ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); + return result; +} + +void WebDOMTestObj::setAttrWithGetterException(int newAttrWithGetterException) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setAttrWithGetterException(newAttrWithGetterException, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +int WebDOMTestObj::attrWithSetterException() const +{ + if (!impl()) + return 0; + + return impl()->attrWithSetterException(); +} + +void WebDOMTestObj::setAttrWithSetterException(int newAttrWithSetterException) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setAttrWithSetterException(newAttrWithSetterException, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +WebDOMString WebDOMTestObj::stringAttrWithGetterException() const +{ + if (!impl()) + return WebDOMString(); + + WebCore::ExceptionCode ec = 0; + WebDOMString result = impl()->stringAttrWithGetterException(ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); + return static_cast<const WTF::String&>(result); +} + +void WebDOMTestObj::setStringAttrWithGetterException(const WebDOMString& newStringAttrWithGetterException) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setStringAttrWithGetterException(newStringAttrWithGetterException, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +WebDOMString WebDOMTestObj::stringAttrWithSetterException() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->stringAttrWithSetterException()); +} + +void WebDOMTestObj::setStringAttrWithSetterException(const WebDOMString& newStringAttrWithSetterException) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setStringAttrWithSetterException(newStringAttrWithSetterException, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +WebDOMString WebDOMTestObj::scriptStringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->scriptStringAttr()); +} + +#if ENABLE(Condition1) +int WebDOMTestObj::conditionalAttr1() const +{ + if (!impl()) + return 0; + + return impl()->conditionalAttr1(); +} + +void WebDOMTestObj::setConditionalAttr1(int newConditionalAttr1) +{ + if (!impl()) + return; + + impl()->setConditionalAttr1(newConditionalAttr1); +} + +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) +int WebDOMTestObj::conditionalAttr2() const +{ + if (!impl()) + return 0; + + return impl()->conditionalAttr2(); +} + +void WebDOMTestObj::setConditionalAttr2(int newConditionalAttr2) +{ + if (!impl()) + return; + + impl()->setConditionalAttr2(newConditionalAttr2); +} + +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) +int WebDOMTestObj::conditionalAttr3() const +{ + if (!impl()) + return 0; + + return impl()->conditionalAttr3(); +} + +void WebDOMTestObj::setConditionalAttr3(int newConditionalAttr3) +{ + if (!impl()) + return; + + impl()->setConditionalAttr3(newConditionalAttr3); +} + +#endif +int WebDOMTestObj::description() const +{ + if (!impl()) + return 0; + + return impl()->description(); +} + +int WebDOMTestObj::id() const +{ + if (!impl()) + return 0; + + return impl()->id(); +} + +void WebDOMTestObj::setId(int newId) +{ + if (!impl()) + return; + + impl()->setId(newId); +} + +WebDOMString WebDOMTestObj::hash() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->hash()); +} + +void WebDOMTestObj::voidMethod() +{ + if (!impl()) + return; + + impl()->voidMethod(); +} + +void WebDOMTestObj::voidMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg) +{ + if (!impl()) + return; + + impl()->voidMethodWithArgs(intArg, strArg, toWebCore(objArg)); +} + +int WebDOMTestObj::intMethod() +{ + if (!impl()) + return 0; + + return impl()->intMethod(); +} + +int WebDOMTestObj::intMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg) +{ + if (!impl()) + return 0; + + return impl()->intMethodWithArgs(intArg, strArg, toWebCore(objArg)); +} + +WebDOMTestObj WebDOMTestObj::objMethod() +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->objMethod())); +} + +WebDOMTestObj WebDOMTestObj::objMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg) +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->objMethodWithArgs(intArg, strArg, toWebCore(objArg)))); +} + +WebDOMTestObj WebDOMTestObj::methodThatRequiresAllArgs(const WebDOMString& strArg, const WebDOMTestObj& objArg) +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->methodThatRequiresAllArgs(strArg, toWebCore(objArg)))); +} + +WebDOMTestObj WebDOMTestObj::methodThatRequiresAllArgsAndThrows(const WebDOMString& strArg, const WebDOMTestObj& objArg) +{ + if (!impl()) + return WebDOMTestObj(); + + WebCore::ExceptionCode ec = 0; + WebDOMTestObj result = toWebKit(WTF::getPtr(impl()->methodThatRequiresAllArgsAndThrows(strArg, toWebCore(objArg), ec))); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); + return result; +} + +void WebDOMTestObj::serializedValue(const WebDOMString& serializedArg) +{ + if (!impl()) + return; + + impl()->serializedValue(WebCore::SerializedScriptValue::create(WTF::String(serializedArg))); +} + +void WebDOMTestObj::idbKey(const WebDOMIDBKey& key) +{ + if (!impl()) + return; + + impl()->idbKey(toWebCore(key)); +} + +void WebDOMTestObj::optionsObject(const WebDOMOptionsObject& oo, const WebDOMOptionsObject& ooo) +{ + if (!impl()) + return; + + impl()->optionsObject(toWebCore(oo), toWebCore(ooo)); +} + +void WebDOMTestObj::methodWithException() +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->methodWithException(ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +void WebDOMTestObj::addEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture) +{ + if (!impl()) + return; + + impl()->addEventListener(type, toWebCore(listener), useCapture); +} + +void WebDOMTestObj::removeEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture) +{ + if (!impl()) + return; + + impl()->removeEventListener(type, toWebCore(listener), useCapture); +} + +void WebDOMTestObj::withDynamicFrame() +{ + if (!impl()) + return; + + impl()->withDynamicFrame(); +} + +void WebDOMTestObj::withDynamicFrameAndArg(int intArg) +{ + if (!impl()) + return; + + impl()->withDynamicFrameAndArg(intArg); +} + +void WebDOMTestObj::withDynamicFrameAndOptionalArg(int intArg, int optionalArg) +{ + if (!impl()) + return; + + impl()->withDynamicFrameAndOptionalArg(intArg, optionalArg); +} + +void WebDOMTestObj::withScriptStateVoid() +{ + if (!impl()) + return; + + impl()->withScriptStateVoid(); +} + +WebDOMTestObj WebDOMTestObj::withScriptStateObj() +{ + if (!impl()) + return WebDOMTestObj(); + + return toWebKit(WTF::getPtr(impl()->withScriptStateObj())); +} + +void WebDOMTestObj::withScriptStateVoidException() +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->withScriptStateVoidException(ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +WebDOMTestObj WebDOMTestObj::withScriptStateObjException() +{ + if (!impl()) + return WebDOMTestObj(); + + WebCore::ExceptionCode ec = 0; + WebDOMTestObj result = toWebKit(WTF::getPtr(impl()->withScriptStateObjException(ec))); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); + return result; +} + +void WebDOMTestObj::withScriptExecutionContext() +{ + if (!impl()) + return; + + impl()->withScriptExecutionContext(); +} + +void WebDOMTestObj::methodWithOptionalArg(int opt) +{ + if (!impl()) + return; + + impl()->methodWithOptionalArg(opt); +} + +void WebDOMTestObj::methodWithNonOptionalArgAndOptionalArg(int nonOpt, int opt) +{ + if (!impl()) + return; + + impl()->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); +} + +void WebDOMTestObj::methodWithNonOptionalArgAndTwoOptionalArgs(int nonOpt, int opt1, int opt2) +{ + if (!impl()) + return; + + impl()->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); +} + +void WebDOMTestObj::classMethod() +{ + if (!impl()) + return; + + impl()->classMethod(); +} + +int WebDOMTestObj::classMethodWithOptional(int arg) +{ + if (!impl()) + return 0; + + return impl()->classMethodWithOptional(arg); +} + +WebCore::TestObj* toWebCore(const WebDOMTestObj& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestObj toWebKit(WebCore::TestObj* value) +{ + return WebDOMTestObj(value); +} diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h new file mode 100644 index 0000000..abbbf2f --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h @@ -0,0 +1,174 @@ +/* + * 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. + */ + +#ifndef WebDOMTestObj_h +#define WebDOMTestObj_h + +#include <WebDOMObject.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestObj; +}; + +class WebDOMEventListener; +class WebDOMIDBKey; +class WebDOMOptionsObject; +class WebDOMString; +class WebDOMTestObj; + +class WebDOMTestObj : public WebDOMObject { +public: + WebDOMTestObj(); + explicit WebDOMTestObj(WebCore::TestObj*); + WebDOMTestObj(const WebDOMTestObj&); + WebDOMTestObj& operator=(const WebDOMTestObj&); + virtual ~WebDOMTestObj(); + + enum { + WEBDOM_CONST_VALUE_0 = 0, + WEBDOM_CONST_VALUE_1 = 1, + WEBDOM_CONST_VALUE_2 = 2, + WEBDOM_CONST_VALUE_4 = 4, + WEBDOM_CONST_VALUE_8 = 8, + WEBDOM_CONST_VALUE_9 = -1, + WEBDOM_CONST_VALUE_10 = "my constant string", + WEBDOM_CONST_VALUE_11 = 0xffffffff, + WEBDOM_CONST_VALUE_12 = 0x01, + WEBDOM_CONST_VALUE_13 = 0X20, + WEBDOM_CONST_VALUE_14 = 0x1abc + }; + + int readOnlyIntAttr() const; + WebDOMString readOnlyStringAttr() const; + WebDOMTestObj readOnlyTestObjAttr() const; + short shortAttr() const; + void setShortAttr(short); + unsigned short unsignedShortAttr() const; + void setUnsignedShortAttr(unsigned short); + int intAttr() const; + void setIntAttr(int); + long long longLongAttr() const; + void setLongLongAttr(long long); + unsigned long long unsignedLongLongAttr() const; + void setUnsignedLongLongAttr(unsigned long long); + WebDOMString stringAttr() const; + void setStringAttr(const WebDOMString&); + WebDOMTestObj testObjAttr() const; + void setTestObjAttr(const WebDOMTestObj&); + WebDOMTestObj XMLObjAttr() const; + void setXMLObjAttr(const WebDOMTestObj&); + bool create() const; + void setCreate(bool); + WebDOMString reflectedStringAttr() const; + void setReflectedStringAttr(const WebDOMString&); + int reflectedIntegralAttr() const; + void setReflectedIntegralAttr(int); + unsigned reflectedUnsignedIntegralAttr() const; + void setReflectedUnsignedIntegralAttr(unsigned); + bool reflectedBooleanAttr() const; + void setReflectedBooleanAttr(bool); + WebDOMString reflectedURLAttr() const; + void setReflectedURLAttr(const WebDOMString&); + WebDOMString reflectedNonEmptyURLAttr() const; + void setReflectedNonEmptyURLAttr(const WebDOMString&); + WebDOMString reflectedStringAttr() const; + void setReflectedStringAttr(const WebDOMString&); + int reflectedCustomIntegralAttr() const; + void setReflectedCustomIntegralAttr(int); + bool reflectedCustomBooleanAttr() const; + void setReflectedCustomBooleanAttr(bool); + WebDOMString reflectedCustomURLAttr() const; + void setReflectedCustomURLAttr(const WebDOMString&); + WebDOMString reflectedCustomNonEmptyURLAttr() const; + void setReflectedCustomNonEmptyURLAttr(const WebDOMString&); + int attrWithGetterException() const; + void setAttrWithGetterException(int); + int attrWithSetterException() const; + void setAttrWithSetterException(int); + WebDOMString stringAttrWithGetterException() const; + void setStringAttrWithGetterException(const WebDOMString&); + WebDOMString stringAttrWithSetterException() const; + void setStringAttrWithSetterException(const WebDOMString&); + int customAttr() const; + void setCustomAttr(int); + WebDOMString scriptStringAttr() const; +#if ENABLE(Condition1) + int conditionalAttr1() const; + void setConditionalAttr1(int); +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) + int conditionalAttr2() const; + void setConditionalAttr2(int); +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) + int conditionalAttr3() const; + void setConditionalAttr3(int); +#endif + int description() const; + int id() const; + void setId(int); + WebDOMString hash() const; + + void voidMethod(); + void voidMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg); + int intMethod(); + int intMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg); + WebDOMTestObj objMethod(); + WebDOMTestObj objMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg); + WebDOMTestObj methodThatRequiresAllArgs(const WebDOMString& strArg, const WebDOMTestObj& objArg); + WebDOMTestObj methodThatRequiresAllArgsAndThrows(const WebDOMString& strArg, const WebDOMTestObj& objArg); + void serializedValue(const WebDOMString& serializedArg); + void idbKey(const WebDOMIDBKey& key); + void optionsObject(const WebDOMOptionsObject& oo, const WebDOMOptionsObject& ooo); + void methodWithException(); + void customMethod(); + void customMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg); + void addEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture); + void removeEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture); + void withDynamicFrame(); + void withDynamicFrameAndArg(int intArg); + void withDynamicFrameAndOptionalArg(int intArg, int optionalArg); + void withDynamicFrameAndUserGesture(int intArg); + void withDynamicFrameAndUserGestureASAD(int intArg, int optionalArg); + void withScriptStateVoid(); + WebDOMTestObj withScriptStateObj(); + void withScriptStateVoidException(); + WebDOMTestObj withScriptStateObjException(); + void withScriptExecutionContext(); + void methodWithOptionalArg(int opt); + void methodWithNonOptionalArgAndOptionalArg(int nonOpt, int opt); + void methodWithNonOptionalArgAndTwoOptionalArgs(int nonOpt, int opt1, int opt2); + void classMethod(); + int classMethodWithOptional(int arg); + + WebCore::TestObj* impl() const; + +protected: + struct WebDOMTestObjPrivate; + WebDOMTestObjPrivate* m_impl; +}; + +WebCore::TestObj* toWebCore(const WebDOMTestObj&); +WebDOMTestObj toWebKit(WebCore::TestObj*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp new file mode 100644 index 0000000..9c8fa59 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -0,0 +1,206 @@ +/* + 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. +*/ + +#include <glib-object.h> +#include "config.h" + +#if ENABLE(DATABASE) + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "JSMainThreadExecState.h" +#include "TestCallback.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMClass1.h" +#include "webkit/WebKitDOMClass1Private.h" +#include "webkit/WebKitDOMClass2.h" +#include "webkit/WebKitDOMClass2Private.h" +#include "webkit/WebKitDOMClass3.h" +#include "webkit/WebKitDOMClass3Private.h" +#include "webkit/WebKitDOMTestCallback.h" +#include "webkit/WebKitDOMTestCallbackPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +WebKitDOMTestCallback* kit(WebCore::TestCallback* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestCallback*>(ret); + + return static_cast<WebKitDOMTestCallback*>(DOMObjectCache::put(obj, WebKit::wrapTestCallback(obj))); +} + +} // namespace WebKit // + +gboolean +webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail(class1param, 0); + WebCore::Class1 * converted_class1param = NULL; + if (class1param != NULL) { + converted_class1param = WebKit::core(class1param); + g_return_val_if_fail(converted_class1param, 0); + } + gboolean res = item->callbackWithClass1Param(converted_class1param); + return res; +} + +gboolean +webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2param, const gchar* str_arg) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail(class2param, 0); + g_return_val_if_fail(str_arg, 0); + WebCore::Class2 * converted_class2param = NULL; + if (class2param != NULL) { + converted_class2param = WebKit::core(class2param); + g_return_val_if_fail(converted_class2param, 0); + } + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); + gboolean res = item->callbackWithClass2Param(converted_class2param, converted_str_arg); + return res; +} + +glong +webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3param) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail(class3param, 0); + WebCore::Class3 * converted_class3param = NULL; + if (class3param != NULL) { + converted_class3param = WebKit::core(class3param); + g_return_val_if_fail(converted_class3param, 0); + } + glong res = item->callbackWithNonBoolReturnType(converted_class3param); + return res; +} + + +G_DEFINE_TYPE(WebKitDOMTestCallback, webkit_dom_test_callback, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebCore::TestCallback* core(WebKitDOMTestCallback* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_callback_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject) { + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->finalize(object); +} + +static void webkit_dom_test_callback_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_callback_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_callback_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->constructed(object); +} + +static void webkit_dom_test_callback_class_init(WebKitDOMTestCallbackClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_callback_finalize; + gobjectClass->set_property = webkit_dom_test_callback_set_property; + gobjectClass->get_property = webkit_dom_test_callback_get_property; + gobjectClass->constructed = webkit_dom_test_callback_constructed; + + + +} + +static void webkit_dom_test_callback_init(WebKitDOMTestCallback* request) +{ +} + +namespace WebKit { +WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + coreObject->ref(); + + return WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, + "core-object", coreObject, NULL)); +} +} // namespace WebKit +#endif /* ENABLE(DATABASE) */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h new file mode 100644 index 0000000..4f0ac91 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h @@ -0,0 +1,60 @@ +/* + 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. +*/ + +#ifndef WebKitDOMTestCallback_h +#define WebKitDOMTestCallback_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_CALLBACK (webkit_dom_test_callback_get_type()) +#define WEBKIT_DOM_TEST_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallback)) +#define WEBKIT_DOM_TEST_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallbackClass) +#define WEBKIT_DOM_IS_TEST_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK)) +#define WEBKIT_DOM_IS_TEST_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_CALLBACK)) +#define WEBKIT_DOM_TEST_CALLBACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallbackClass)) + +struct _WebKitDOMTestCallback { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestCallbackClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_callback_get_type (void); + +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param); + +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2param, const gchar* str_arg); + +WEBKIT_API glong +webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3param); + +G_END_DECLS + +#endif /* WebKitDOMTestCallback_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h new file mode 100644 index 0000000..3ad6ff4 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h @@ -0,0 +1,39 @@ +/* + 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. +*/ + +#ifndef WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H +#define WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestCallback.h" +namespace WebKit { + WebKitDOMTestCallback * + wrapTestCallback(WebCore::TestCallback *coreObject); + + WebCore::TestCallback * + core(WebKitDOMTestCallback *request); + + WebKitDOMTestCallback* + kit(WebCore::TestCallback* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp new file mode 100644 index 0000000..b68340b --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -0,0 +1,150 @@ +/* + 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. +*/ + +#include <glib-object.h> +#include "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "JSMainThreadExecState.h" +#include "TestInterface.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMTestInterface.h" +#include "webkit/WebKitDOMTestInterfacePrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +WebKitDOMTestInterface* kit(WebCore::TestInterface* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestInterface*>(ret); + + return static_cast<WebKitDOMTestInterface*>(DOMObjectCache::put(obj, WebKit::wrapTestInterface(obj))); +} + +} // namespace WebKit // + + +G_DEFINE_TYPE(WebKitDOMTestInterface, webkit_dom_test_interface, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebCore::TestInterface* core(WebKitDOMTestInterface* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_interface_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject) { + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->finalize(object); +} + +static void webkit_dom_test_interface_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_interface_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_interface_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->constructed(object); +} + +static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_interface_finalize; + gobjectClass->set_property = webkit_dom_test_interface_set_property; + gobjectClass->get_property = webkit_dom_test_interface_get_property; + gobjectClass->constructed = webkit_dom_test_interface_constructed; + + + +} + +static void webkit_dom_test_interface_init(WebKitDOMTestInterface* request) +{ +} + +namespace WebKit { +WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + coreObject->ref(); + + return WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, + "core-object", coreObject, NULL)); +} +} // namespace WebKit +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h new file mode 100644 index 0000000..f9af866 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h @@ -0,0 +1,51 @@ +/* + 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. +*/ + +#ifndef WebKitDOMTestInterface_h +#define WebKitDOMTestInterface_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_INTERFACE (webkit_dom_test_interface_get_type()) +#define WEBKIT_DOM_TEST_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterface)) +#define WEBKIT_DOM_TEST_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterfaceClass) +#define WEBKIT_DOM_IS_TEST_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE)) +#define WEBKIT_DOM_IS_TEST_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_INTERFACE)) +#define WEBKIT_DOM_TEST_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterfaceClass)) + +struct _WebKitDOMTestInterface { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestInterfaceClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_interface_get_type (void); + +G_END_DECLS + +#endif /* WebKitDOMTestInterface_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h new file mode 100644 index 0000000..0a4e3a2 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h @@ -0,0 +1,39 @@ +/* + 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. +*/ + +#ifndef WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H +#define WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestInterface.h" +namespace WebKit { + WebKitDOMTestInterface * + wrapTestInterface(WebCore::TestInterface *coreObject); + + WebCore::TestInterface * + core(WebKitDOMTestInterface *request); + + WebKitDOMTestInterface* + kit(WebCore::TestInterface* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp new file mode 100644 index 0000000..93d0bde --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp @@ -0,0 +1,147 @@ +/* + 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. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "JSMainThreadExecState.h" +#include "TestMediaQueryListListener.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMTestMediaQueryListListener.h" +#include "webkit/WebKitDOMTestMediaQueryListListenerPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +WebKitDOMTestMediaQueryListListener* kit(WebCore::TestMediaQueryListListener* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestMediaQueryListListener*>(ret); + + return static_cast<WebKitDOMTestMediaQueryListListener*>(DOMObjectCache::put(obj, WebKit::wrapTestMediaQueryListListener(obj))); +} + +} // namespace WebKit // + + +G_DEFINE_TYPE(WebKitDOMTestMediaQueryListListener, webkit_dom_test_media_query_list_listener, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebCore::TestMediaQueryListListener* core(WebKitDOMTestMediaQueryListListener* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestMediaQueryListListener* coreObject = static_cast<WebCore::TestMediaQueryListListener*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_media_query_list_listener_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject) { + WebCore::TestMediaQueryListListener* coreObject = static_cast<WebCore::TestMediaQueryListListener *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_media_query_list_listener_parent_class)->finalize(object); +} + +static void webkit_dom_test_media_query_list_listener_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_media_query_list_listener_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_media_query_list_listener_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_media_query_list_listener_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_media_query_list_listener_parent_class)->constructed(object); +} + +static void webkit_dom_test_media_query_list_listener_class_init(WebKitDOMTestMediaQueryListListenerClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_media_query_list_listener_finalize; + gobjectClass->set_property = webkit_dom_test_media_query_list_listener_set_property; + gobjectClass->get_property = webkit_dom_test_media_query_list_listener_get_property; + gobjectClass->constructed = webkit_dom_test_media_query_list_listener_constructed; + + + +} + +static void webkit_dom_test_media_query_list_listener_init(WebKitDOMTestMediaQueryListListener* request) +{ +} + +namespace WebKit { +WebKitDOMTestMediaQueryListListener* wrapTestMediaQueryListListener(WebCore::TestMediaQueryListListener* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + coreObject->ref(); + + return WEBKIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER(g_object_new(WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER, + "core-object", coreObject, NULL)); +} +} // namespace WebKit diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h new file mode 100644 index 0000000..612439b --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h @@ -0,0 +1,51 @@ +/* + 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. +*/ + +#ifndef WebKitDOMTestMediaQueryListListener_h +#define WebKitDOMTestMediaQueryListListener_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER (webkit_dom_test_media_query_list_listener_get_type()) +#define WEBKIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER, WebKitDOMTestMediaQueryListListener)) +#define WEBKIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER, WebKitDOMTestMediaQueryListListenerClass) +#define WEBKIT_DOM_IS_TEST_MEDIA_QUERY_LIST_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER)) +#define WEBKIT_DOM_IS_TEST_MEDIA_QUERY_LIST_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER)) +#define WEBKIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER, WebKitDOMTestMediaQueryListListenerClass)) + +struct _WebKitDOMTestMediaQueryListListener { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestMediaQueryListListenerClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_media_query_list_listener_get_type (void); + +G_END_DECLS + +#endif /* WebKitDOMTestMediaQueryListListener_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h new file mode 100644 index 0000000..5fc652f --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h @@ -0,0 +1,39 @@ +/* + 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. +*/ + +#ifndef WEB_KIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_PRIVATE_H +#define WEB_KIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestMediaQueryListListener.h" +namespace WebKit { + WebKitDOMTestMediaQueryListListener * + wrapTestMediaQueryListListener(WebCore::TestMediaQueryListListener *coreObject); + + WebCore::TestMediaQueryListListener * + core(WebKitDOMTestMediaQueryListListener *request); + + WebKitDOMTestMediaQueryListListener* + kit(WebCore::TestMediaQueryListListener* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_PRIVATE_H */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp new file mode 100644 index 0000000..6c94d94 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -0,0 +1,1812 @@ +/* + 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. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "HTMLNames.h" +#include "JSMainThreadExecState.h" +#include "TestObj.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMIDBKey.h" +#include "webkit/WebKitDOMIDBKeyPrivate.h" +#include "webkit/WebKitDOMOptionsObject.h" +#include "webkit/WebKitDOMOptionsObjectPrivate.h" +#include "webkit/WebKitDOMSerializedScriptValue.h" +#include "webkit/WebKitDOMSerializedScriptValuePrivate.h" +#include "webkit/WebKitDOMTestObj.h" +#include "webkit/WebKitDOMTestObjPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +WebKitDOMTestObj* kit(WebCore::TestObj* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestObj*>(ret); + + return static_cast<WebKitDOMTestObj*>(DOMObjectCache::put(obj, WebKit::wrapTestObj(obj))); +} + +} // namespace WebKit // + +void +webkit_dom_test_obj_void_method(WebKitDOMTestObj* self) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->voidMethod(); +} + +void +webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(str_arg); + g_return_if_fail(obj_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = NULL; + if (obj_arg != NULL) { + converted_obj_arg = WebKit::core(obj_arg); + g_return_if_fail(converted_obj_arg); + } + item->voidMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); +} + +glong +webkit_dom_test_obj_int_method(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->intMethod(); + return res; +} + +glong +webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = NULL; + if (obj_arg != NULL) { + converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + } + glong res = item->intMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); + return res; +} + +WebKitDOMTestObj* +webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethod()); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +WebKitDOMTestObj* +webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = NULL; + if (obj_arg != NULL) { + converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + } + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg)); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args(WebKitDOMTestObj* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = NULL; + if (obj_arg != NULL) { + converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + } + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgs(converted_str_arg, converted_obj_arg)); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = NULL; + if (obj_arg != NULL) { + converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + } + WebCore::ExceptionCode ec = 0; + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgsAndThrows(converted_str_arg, converted_obj_arg, ec)); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +void +webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serialized_arg) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(serialized_arg); + WebCore::SerializedScriptValue * converted_serialized_arg = NULL; + if (serialized_arg != NULL) { + converted_serialized_arg = WebKit::core(serialized_arg); + g_return_if_fail(converted_serialized_arg); + } + item->serializedValue(converted_serialized_arg); +} + +void +webkit_dom_test_obj_idb_key(WebKitDOMTestObj* self, WebKitDOMIDBKey* key) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(key); + WebCore::IDBKey * converted_key = NULL; + if (key != NULL) { + converted_key = WebKit::core(key); + g_return_if_fail(converted_key); + } + item->idbKey(converted_key); +} + +void +webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMOptionsObject* oo, WebKitDOMOptionsObject* ooo) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(oo); + g_return_if_fail(ooo); + WebCore::OptionsObject * converted_oo = NULL; + if (oo != NULL) { + converted_oo = WebKit::core(oo); + g_return_if_fail(converted_oo); + } + WebCore::OptionsObject * converted_ooo = NULL; + if (ooo != NULL) { + converted_ooo = WebKit::core(ooo); + g_return_if_fail(converted_ooo); + } + item->optionsObject(converted_oo, converted_ooo); +} + +void +webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->methodWithException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + + +/* TODO: event function webkit_dom_test_obj_add_event_listener */ + + +/* TODO: event function webkit_dom_test_obj_remove_event_listener */ + +void +webkit_dom_test_obj_with_dynamic_frame(WebKitDOMTestObj* self) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrame(); +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_arg(WebKitDOMTestObj* self, glong int_arg) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndArg(int_arg); +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_optional_arg(WebKitDOMTestObj* self, glong int_arg, glong optional_arg) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndOptionalArg(int_arg, optional_arg); +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture(WebKitDOMTestObj* self, glong int_arg, gboolean isUserGesture) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndUserGesture(int_arg, false); +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad(WebKitDOMTestObj* self, glong int_arg, glong optional_arg, gboolean isUserGesture) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndUserGestureASAD(int_arg, optional_arg, false); +} + +void +webkit_dom_test_obj_with_script_state_void(WebKitDOMTestObj* self) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withScriptStateVoid(); +} + +WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj()); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +void +webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError **error) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->withScriptStateVoidException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GError **error) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec)); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +void +webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->withScriptExecutionContext(); +} + +void +webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->methodWithOptionalArg(opt); +} + +void +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong non_opt, glong opt) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt); +} + +void +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong non_opt, glong opt1, glong opt2) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2); +} + +void +webkit_dom_test_obj_class_method(WebKitDOMTestObj* self) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->classMethod(); +} + +glong +webkit_dom_test_obj_class_method_with_optional(WebKitDOMTestObj* self, glong arg) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->classMethodWithOptional(arg); + return res; +} + +glong +webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->readOnlyIntAttr(); + return res; +} + +gchar* +webkit_dom_test_obj_get_read_only_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->readOnlyStringAttr()); + return res; +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_read_only_test_obj_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->readOnlyTestObjAttr()); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +gshort +webkit_dom_test_obj_get_short_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gshort res = item->shortAttr(); + return res; +} + +void +webkit_dom_test_obj_set_short_attr(WebKitDOMTestObj* self, gshort value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setShortAttr(value); +} + +gushort +webkit_dom_test_obj_get_unsigned_short_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gushort res = item->unsignedShortAttr(); + return res; +} + +void +webkit_dom_test_obj_set_unsigned_short_attr(WebKitDOMTestObj* self, gushort value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setUnsignedShortAttr(value); +} + +glong +webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->intAttr(); + return res; +} + +void +webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setIntAttr(value); +} + +gint64 +webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gint64 res = item->longLongAttr(); + return res; +} + +void +webkit_dom_test_obj_set_long_long_attr(WebKitDOMTestObj* self, gint64 value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setLongLongAttr(value); +} + +guint64 +webkit_dom_test_obj_get_unsigned_long_long_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + guint64 res = item->unsignedLongLongAttr(); + return res; +} + +void +webkit_dom_test_obj_set_unsigned_long_long_attr(WebKitDOMTestObj* self, guint64 value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setUnsignedLongLongAttr(value); +} + +gchar* +webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->stringAttr()); + return res; +} + +void +webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setStringAttr(converted_value); +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr()); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +void +webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::TestObj * converted_value = NULL; + if (value != NULL) { + converted_value = WebKit::core(value); + g_return_if_fail(converted_value); + } + item->setTestObjAttr(converted_value); +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_xml_obj_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->xmlObjAttr()); + WebKitDOMTestObj* res = WebKit::kit(g_res.get()); + return res; +} + +void +webkit_dom_test_obj_set_xml_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::TestObj * converted_value = NULL; + if (value != NULL) { + converted_value = WebKit::core(value); + g_return_if_fail(converted_value); + } + item->setXMLObjAttr(converted_value); +} + +gboolean +webkit_dom_test_obj_get_create(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gboolean res = item->isCreate(); + return res; +} + +void +webkit_dom_test_obj_set_create(WebKitDOMTestObj* self, gboolean value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setCreate(value); +} + +gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, converted_value); +} + +glong +webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value); +} + +gulong +webkit_dom_test_obj_get_reflected_unsigned_integral_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gulong res = item->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_unsigned_integral_attr(WebKitDOMTestObj* self, gulong value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, value); +} + +gboolean +webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gboolean res = item->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value); +} + +gchar* +webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, converted_value); +} + +gchar* +webkit_dom_test_obj_get_reflected_non_empty_url_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_non_empty_url_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, converted_value); +} + +gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, converted_value); +} + +glong +webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value); +} + +gboolean +webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gboolean res = item->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gboolean value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value); +} + +gchar* +webkit_dom_test_obj_get_reflected_custom_url_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_custom_url_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, converted_value); +} + +gchar* +webkit_dom_test_obj_get_reflected_custom_non_empty_url_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_custom_non_empty_url_attr(WebKitDOMTestObj* self, const gchar* value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, converted_value); +} + +glong +webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + glong res = item->attrWithGetterException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + return res; +} + +void +webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->setAttrWithGetterException(value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +glong +webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithSetterException(); + return res; +} + +void +webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->setAttrWithSetterException(value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +gchar* +webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + gchar* res = convertToUTF8String(item->stringAttrWithGetterException(ec)); + return res; +} + +void +webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + WebCore::ExceptionCode ec = 0; + item->setStringAttrWithGetterException(converted_value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +gchar* +webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->stringAttrWithSetterException()); + return res; +} + +void +webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WTF::String converted_value = WTF::String::fromUTF8(value); + WebCore::ExceptionCode ec = 0; + item->setStringAttrWithSetterException(converted_value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +gchar* +webkit_dom_test_obj_get_script_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->scriptStringAttr()); + return res; +} + +glong +webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self) +{ +#if ENABLE(Condition1) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->conditionalAttr1(); + return res; +#else + return static_cast<glong>(0); +#endif /* ENABLE(Condition1) */ +} + +void +webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value) +{ +#if ENABLE(Condition1) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setConditionalAttr1(value); +#endif /* ENABLE(Condition1) */ +} + +glong +webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self) +{ +#if ENABLE(Condition1) && ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->conditionalAttr2(); + return res; +#else + return static_cast<glong>(0); +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +} + +void +webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value) +{ +#if ENABLE(Condition1) && ENABLE(Condition2) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setConditionalAttr2(value); +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +} + +glong +webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->conditionalAttr3(); + return res; +#else + return static_cast<glong>(0); +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +void +webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setConditionalAttr3(value); +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +glong +webkit_dom_test_obj_get_description(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->description(); + return res; +} + +glong +webkit_dom_test_obj_get_id(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + glong res = item->id(); + return res; +} + +void +webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + item->setId(value); +} + +gchar* +webkit_dom_test_obj_get_hash(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->hash()); + return res; +} + + +G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebCore::TestObj* core(WebKitDOMTestObj* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, + PROP_READ_ONLY_INT_ATTR, + PROP_READ_ONLY_STRING_ATTR, + PROP_READ_ONLY_TEST_OBJ_ATTR, + PROP_SHORT_ATTR, + PROP_UNSIGNED_SHORT_ATTR, + PROP_INT_ATTR, + PROP_LONG_LONG_ATTR, + PROP_UNSIGNED_LONG_LONG_ATTR, + PROP_STRING_ATTR, + PROP_TEST_OBJ_ATTR, + PROP_XML_OBJ_ATTR, + PROP_CREATE, + PROP_REFLECTED_STRING_ATTR, + PROP_REFLECTED_INTEGRAL_ATTR, + PROP_REFLECTED_UNSIGNED_INTEGRAL_ATTR, + PROP_REFLECTED_BOOLEAN_ATTR, + PROP_REFLECTED_URL_ATTR, + PROP_REFLECTED_NON_EMPTY_URL_ATTR, + PROP_REFLECTED_STRING_ATTR, + PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR, + PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR, + PROP_REFLECTED_CUSTOM_URL_ATTR, + PROP_REFLECTED_CUSTOM_NON_EMPTY_URL_ATTR, + PROP_ATTR_WITH_GETTER_EXCEPTION, + PROP_ATTR_WITH_SETTER_EXCEPTION, + PROP_STRING_ATTR_WITH_GETTER_EXCEPTION, + PROP_STRING_ATTR_WITH_SETTER_EXCEPTION, + PROP_CUSTOM_ATTR, + PROP_SCRIPT_STRING_ATTR, +#if ENABLE(Condition1) + PROP_CONDITIONAL_ATTR1, +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + PROP_CONDITIONAL_ATTR2, +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + PROP_CONDITIONAL_ATTR3, +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + PROP_DESCRIPTION, + PROP_ID, + PROP_HASH, +}; + + +static void webkit_dom_test_obj_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject) { + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->finalize(object); +} + +static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (prop_id) { + case PROP_UNSIGNED_SHORT_ATTR: + { + coreSelf->setUnsignedShortAttr((g_value_get_ushort(value))); + break; + } + case PROP_INT_ATTR: + { + coreSelf->setIntAttr((g_value_get_long(value))); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: + { + coreSelf->setUnsignedLongLongAttr((g_value_get_uint64(value))); + break; + } + case PROP_STRING_ATTR: + { + coreSelf->setStringAttr(WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_CREATE: + { + coreSelf->setCreate((g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_STRING_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_INTEGRAL_ATTR: + { + coreSelf->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, (g_value_get_long(value))); + break; + } + case PROP_REFLECTED_UNSIGNED_INTEGRAL_ATTR: + { + coreSelf->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, (g_value_get_ulong(value))); + break; + } + case PROP_REFLECTED_BOOLEAN_ATTR: + { + coreSelf->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, (g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_URL_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_NON_EMPTY_URL_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_STRING_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: + { + coreSelf->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, (g_value_get_long(value))); + break; + } + case PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR: + { + coreSelf->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, (g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_CUSTOM_URL_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_CUSTOM_NON_EMPTY_URL_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + coreSelf->setAttrWithGetterException((g_value_get_long(value)), ec); + break; + } + case PROP_ATTR_WITH_SETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + coreSelf->setAttrWithSetterException((g_value_get_long(value)), ec); + break; + } + case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + coreSelf->setStringAttrWithGetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); + break; + } + case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + coreSelf->setStringAttrWithSetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); + break; + } +#if ENABLE(Condition1) + case PROP_CONDITIONAL_ATTR1: + { + coreSelf->setConditionalAttr1((g_value_get_long(value))); + break; + } +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR2: + { + coreSelf->setConditionalAttr2((g_value_get_long(value))); + break; + } +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR3: + { + coreSelf->setConditionalAttr3((g_value_get_long(value))); + break; + } +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + case PROP_ID: + { + coreSelf->setId((g_value_get_long(value))); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (prop_id) { + case PROP_READ_ONLY_INT_ATTR: + { + g_value_set_long(value, coreSelf->readOnlyIntAttr()); + break; + } + case PROP_READ_ONLY_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->readOnlyStringAttr())); + break; + } + case PROP_READ_ONLY_TEST_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->readOnlyTestObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_SHORT_ATTR: + { + g_value_set_int(value, coreSelf->shortAttr()); + break; + } + case PROP_UNSIGNED_SHORT_ATTR: + { + g_value_set_uint(value, coreSelf->unsignedShortAttr()); + break; + } + case PROP_INT_ATTR: + { + g_value_set_long(value, coreSelf->intAttr()); + break; + } + case PROP_LONG_LONG_ATTR: + { + g_value_set_int64(value, coreSelf->longLongAttr()); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: + { + g_value_set_uint64(value, coreSelf->unsignedLongLongAttr()); + break; + } + case PROP_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr())); + break; + } + case PROP_TEST_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_XML_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->xmlObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_CREATE: + { + g_value_set_boolean(value, coreSelf->isCreate()); + break; + } + case PROP_REFLECTED_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr))); + break; + } + case PROP_REFLECTED_INTEGRAL_ATTR: + { + g_value_set_long(value, coreSelf->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); + break; + } + case PROP_REFLECTED_UNSIGNED_INTEGRAL_ATTR: + { + g_value_set_ulong(value, coreSelf->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)); + break; + } + case PROP_REFLECTED_BOOLEAN_ATTR: + { + g_value_set_boolean(value, coreSelf->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); + break; + } + case PROP_REFLECTED_URL_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr))); + break; + } + case PROP_REFLECTED_NON_EMPTY_URL_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr))); + break; + } + case PROP_REFLECTED_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr))); + break; + } + case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: + { + g_value_set_long(value, coreSelf->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); + break; + } + case PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR: + { + g_value_set_boolean(value, coreSelf->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); + break; + } + case PROP_REFLECTED_CUSTOM_URL_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr))); + break; + } + case PROP_REFLECTED_CUSTOM_NON_EMPTY_URL_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr))); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + g_value_set_long(value, coreSelf->attrWithGetterException(ec)); + break; + } + case PROP_ATTR_WITH_SETTER_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithSetterException()); + break; + } + case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttrWithGetterException(ec))); + break; + } + case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: + { + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttrWithSetterException())); + break; + } + case PROP_SCRIPT_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->scriptStringAttr())); + break; + } +#if ENABLE(Condition1) + case PROP_CONDITIONAL_ATTR1: + { + g_value_set_long(value, coreSelf->conditionalAttr1()); + break; + } +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR2: + { + g_value_set_long(value, coreSelf->conditionalAttr2()); + break; + } +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR3: + { + g_value_set_long(value, coreSelf->conditionalAttr3()); + break; + } +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + case PROP_DESCRIPTION: + { + g_value_set_long(value, coreSelf->description()); + break; + } + case PROP_ID: + { + g_value_set_long(value, coreSelf->id()); + break; + } + case PROP_HASH: + { + g_value_take_string(value, convertToUTF8String(coreSelf->hash())); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_obj_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed(object); +} + +static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_obj_finalize; + gobjectClass->set_property = webkit_dom_test_obj_set_property; + gobjectClass->get_property = webkit_dom_test_obj_get_property; + gobjectClass->constructed = webkit_dom_test_obj_constructed; + + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_INT_ATTR, + g_param_spec_long("read-only-int-attr", /* name */ + "test_obj_read-only-int-attr", /* short description */ + "read-only glong TestObj.read-only-int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_STRING_ATTR, + g_param_spec_string("read-only-string-attr", /* name */ + "test_obj_read-only-string-attr", /* short description */ + "read-only gchar* TestObj.read-only-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_TEST_OBJ_ATTR, + g_param_spec_object("read-only-test-obj-attr", /* name */ + "test_obj_read-only-test-obj-attr", /* short description */ + "read-only WebKitDOMTestObj* TestObj.read-only-test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_SHORT_ATTR, + g_param_spec_int("short-attr", /* name */ + "test_obj_short-attr", /* short description */ + "read-write gshort TestObj.short-attr", /* longer - could do with some extra doc stuff here */ + G_MININT, /* min */ +G_MAXINT, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_UNSIGNED_SHORT_ATTR, + g_param_spec_uint("unsigned-short-attr", /* name */ + "test_obj_unsigned-short-attr", /* short description */ + "read-write gushort TestObj.unsigned-short-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXUINT16, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_INT_ATTR, + g_param_spec_long("int-attr", /* name */ + "test_obj_int-attr", /* short description */ + "read-write glong TestObj.int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_LONG_LONG_ATTR, + g_param_spec_int64("long-long-attr", /* name */ + "test_obj_long-long-attr", /* short description */ + "read-write gint64 TestObj.long-long-attr", /* longer - could do with some extra doc stuff here */ + G_MININT64, /* min */ +G_MAXINT64, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_UNSIGNED_LONG_LONG_ATTR, + g_param_spec_uint64("unsigned-long-long-attr", /* name */ + "test_obj_unsigned-long-long-attr", /* short description */ + "read-write guint64 TestObj.unsigned-long-long-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXUINT64, /* min */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR, + g_param_spec_string("string-attr", /* name */ + "test_obj_string-attr", /* short description */ + "read-write gchar* TestObj.string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_TEST_OBJ_ATTR, + g_param_spec_object("test-obj-attr", /* name */ + "test_obj_test-obj-attr", /* short description */ + "read-write WebKitDOMTestObj* TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_XML_OBJ_ATTR, + g_param_spec_object("xml-obj-attr", /* name */ + "test_obj_xml-obj-attr", /* short description */ + "read-write WebKitDOMTestObj* TestObj.xml-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_CREATE, + g_param_spec_boolean("create", /* name */ + "test_obj_create", /* short description */ + "read-write gboolean TestObj.create", /* longer - could do with some extra doc stuff here */ + FALSE, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_STRING_ATTR, + g_param_spec_string("reflected-string-attr", /* name */ + "test_obj_reflected-string-attr", /* short description */ + "read-write gchar* TestObj.reflected-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_INTEGRAL_ATTR, + g_param_spec_long("reflected-integral-attr", /* name */ + "test_obj_reflected-integral-attr", /* short description */ + "read-write glong TestObj.reflected-integral-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_UNSIGNED_INTEGRAL_ATTR, + g_param_spec_ulong("reflected-unsigned-integral-attr", /* name */ + "test_obj_reflected-unsigned-integral-attr", /* short description */ + "read-write gulong TestObj.reflected-unsigned-integral-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXULONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_BOOLEAN_ATTR, + g_param_spec_boolean("reflected-boolean-attr", /* name */ + "test_obj_reflected-boolean-attr", /* short description */ + "read-write gboolean TestObj.reflected-boolean-attr", /* longer - could do with some extra doc stuff here */ + FALSE, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_URL_ATTR, + g_param_spec_string("reflected-url-attr", /* name */ + "test_obj_reflected-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-url-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_NON_EMPTY_URL_ATTR, + g_param_spec_string("reflected-non-empty-url-attr", /* name */ + "test_obj_reflected-non-empty-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-non-empty-url-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_STRING_ATTR, + g_param_spec_string("reflected-string-attr", /* name */ + "test_obj_reflected-string-attr", /* short description */ + "read-write gchar* TestObj.reflected-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR, + g_param_spec_long("reflected-custom-integral-attr", /* name */ + "test_obj_reflected-custom-integral-attr", /* short description */ + "read-write glong TestObj.reflected-custom-integral-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR, + g_param_spec_boolean("reflected-custom-boolean-attr", /* name */ + "test_obj_reflected-custom-boolean-attr", /* short description */ + "read-write gboolean TestObj.reflected-custom-boolean-attr", /* longer - could do with some extra doc stuff here */ + FALSE, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_CUSTOM_URL_ATTR, + g_param_spec_string("reflected-custom-url-attr", /* name */ + "test_obj_reflected-custom-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-custom-url-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_CUSTOM_NON_EMPTY_URL_ATTR, + g_param_spec_string("reflected-custom-non-empty-url-attr", /* name */ + "test_obj_reflected-custom-non-empty-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-custom-non-empty-url-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_GETTER_EXCEPTION, + g_param_spec_long("attr-with-getter-exception", /* name */ + "test_obj_attr-with-getter-exception", /* short description */ + "read-write glong TestObj.attr-with-getter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_SETTER_EXCEPTION, + g_param_spec_long("attr-with-setter-exception", /* name */ + "test_obj_attr-with-setter-exception", /* short description */ + "read-write glong TestObj.attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR_WITH_GETTER_EXCEPTION, + g_param_spec_string("string-attr-with-getter-exception", /* name */ + "test_obj_string-attr-with-getter-exception", /* short description */ + "read-write gchar* TestObj.string-attr-with-getter-exception", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR_WITH_SETTER_EXCEPTION, + g_param_spec_string("string-attr-with-setter-exception", /* name */ + "test_obj_string-attr-with-setter-exception", /* short description */ + "read-write gchar* TestObj.string-attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_SCRIPT_STRING_ATTR, + g_param_spec_string("script-string-attr", /* name */ + "test_obj_script-string-attr", /* short description */ + "read-only gchar* TestObj.script-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); +#if ENABLE(Condition1) + g_object_class_install_property(gobjectClass, + PROP_CONDITIONAL_ATTR1, + g_param_spec_long("conditional-attr1", /* name */ + "test_obj_conditional-attr1", /* short description */ + "read-write glong TestObj.conditional-attr1", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + g_object_class_install_property(gobjectClass, + PROP_CONDITIONAL_ATTR2, + g_param_spec_long("conditional-attr2", /* name */ + "test_obj_conditional-attr2", /* short description */ + "read-write glong TestObj.conditional-attr2", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_object_class_install_property(gobjectClass, + PROP_CONDITIONAL_ATTR3, + g_param_spec_long("conditional-attr3", /* name */ + "test_obj_conditional-attr3", /* short description */ + "read-write glong TestObj.conditional-attr3", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + g_object_class_install_property(gobjectClass, + PROP_DESCRIPTION, + g_param_spec_long("description", /* name */ + "test_obj_description", /* short description */ + "read-only glong TestObj.description", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_ID, + g_param_spec_long("id", /* name */ + "test_obj_id", /* short description */ + "read-write glong TestObj.id", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_HASH, + g_param_spec_string("hash", /* name */ + "test_obj_hash", /* short description */ + "read-only gchar* TestObj.hash", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + + +} + +static void webkit_dom_test_obj_init(WebKitDOMTestObj* request) +{ +} + +namespace WebKit { +WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + coreObject->ref(); + + return WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, + "core-object", coreObject, NULL)); +} +} // namespace WebKit diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h new file mode 100644 index 0000000..0416664 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -0,0 +1,324 @@ +/* + 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. +*/ + +#ifndef WebKitDOMTestObj_h +#define WebKitDOMTestObj_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_OBJ (webkit_dom_test_obj_get_type()) +#define WEBKIT_DOM_TEST_OBJ(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObj)) +#define WEBKIT_DOM_TEST_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObjClass) +#define WEBKIT_DOM_IS_TEST_OBJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_OBJ)) +#define WEBKIT_DOM_IS_TEST_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_OBJ)) +#define WEBKIT_DOM_TEST_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObjClass)) + +struct _WebKitDOMTestObj { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestObjClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_obj_get_type (void); + +WEBKIT_API void +webkit_dom_test_obj_void_method(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API glong +webkit_dom_test_obj_int_method(WebKitDOMTestObj* self); + +WEBKIT_API glong +webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args(WebKitDOMTestObj* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serialized_arg); + +WEBKIT_API void +webkit_dom_test_obj_idb_key(WebKitDOMTestObj* self, WebKitDOMIDBKey* key); + +WEBKIT_API void +webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMOptionsObject* oo, WebKitDOMOptionsObject* ooo); + +WEBKIT_API void +webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error); + + +/* TODO: event function webkit_dom_test_obj_add_event_listener */ + + +/* TODO: event function webkit_dom_test_obj_remove_event_listener */ + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_arg(WebKitDOMTestObj* self, glong int_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_optional_arg(WebKitDOMTestObj* self, glong int_arg, glong optional_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture(WebKitDOMTestObj* self, glong int_arg, gboolean isUserGesture); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad(WebKitDOMTestObj* self, glong int_arg, glong optional_arg, gboolean isUserGesture); + +WEBKIT_API void +webkit_dom_test_obj_with_script_state_void(WebKitDOMTestObj* self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError **error); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt); + +WEBKIT_API void +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong non_opt, glong opt); + +WEBKIT_API void +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong non_opt, glong opt1, glong opt2); + +WEBKIT_API void +webkit_dom_test_obj_class_method(WebKitDOMTestObj* self); + +WEBKIT_API glong +webkit_dom_test_obj_class_method_with_optional(WebKitDOMTestObj* self, glong arg); + +WEBKIT_API glong +webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_read_only_string_attr(WebKitDOMTestObj* self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_read_only_test_obj_attr(WebKitDOMTestObj* self); + +WEBKIT_API gshort +webkit_dom_test_obj_get_short_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_short_attr(WebKitDOMTestObj* self, gshort value); + +WEBKIT_API gushort +webkit_dom_test_obj_get_unsigned_short_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_unsigned_short_attr(WebKitDOMTestObj* self, gushort value); + +WEBKIT_API glong +webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value); + +WEBKIT_API gint64 +webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_long_long_attr(WebKitDOMTestObj* self, gint64 value); + +WEBKIT_API guint64 +webkit_dom_test_obj_get_unsigned_long_long_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_unsigned_long_long_attr(WebKitDOMTestObj* self, guint64 value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_xml_obj_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_xml_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value); + +WEBKIT_API gboolean +webkit_dom_test_obj_get_create(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_create(WebKitDOMTestObj* self, gboolean value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API glong +webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong value); + +WEBKIT_API gulong +webkit_dom_test_obj_get_reflected_unsigned_integral_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_unsigned_integral_attr(WebKitDOMTestObj* self, gulong value); + +WEBKIT_API gboolean +webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_non_empty_url_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_non_empty_url_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API glong +webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, glong value); + +WEBKIT_API gboolean +webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gboolean value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_custom_url_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_custom_url_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_custom_non_empty_url_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_custom_non_empty_url_attr(WebKitDOMTestObj* self, const gchar* value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_script_string_attr(WebKitDOMTestObj* self); + +WEBKIT_API glong +webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_description(WebKitDOMTestObj* self); + +WEBKIT_API glong +webkit_dom_test_obj_get_id(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_hash(WebKitDOMTestObj* self); + +G_END_DECLS + +#endif /* WebKitDOMTestObj_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h new file mode 100644 index 0000000..96722f7 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h @@ -0,0 +1,39 @@ +/* + 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. +*/ + +#ifndef WEB_KIT_DOM_TEST_OBJ_PRIVATE_H +#define WEB_KIT_DOM_TEST_OBJ_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestObj.h" +namespace WebKit { + WebKitDOMTestObj * + wrapTestObj(WebCore::TestObj *coreObject); + + WebCore::TestObj * + core(WebKitDOMTestObj *request); + + WebKitDOMTestObj* + kit(WebCore::TestObj* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_OBJ_PRIVATE_H */ diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp new file mode 100644 index 0000000..069b8ae --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -0,0 +1,98 @@ +/* + 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. +*/ + +#include "config.h" + +#if ENABLE(DATABASE) + +#include "JSTestCallback.h" + +#include "JSClass1.h" +#include "JSClass2.h" +#include "ScriptExecutionContext.h" +#include <runtime/JSLock.h> +#include <wtf/MainThread.h> + +using namespace JSC; + +namespace WebCore { + +JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) + : ActiveDOMCallback(globalObject->scriptExecutionContext()) + , m_data(new JSCallbackData(callback, globalObject)) +{ +} + +JSTestCallback::~JSTestCallback() +{ + ScriptExecutionContext* context = scriptExecutionContext(); + // When the context is destroyed, all tasks with a reference to a callback + // should be deleted. So if the context is 0, we are on the context thread. + if (!context || context->isContextThread()) + delete m_data; + else + context->postTask(DeleteCallbackDataTask::create(m_data)); +#ifndef NDEBUG + m_data = 0; +#endif +} + +// Functions + +bool JSTestCallback::callbackWithClass1Param(Class1* class1Param) +{ + if (!canInvokeCallback()) + return true; + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + ExecState* exec = m_data->globalObject()->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, class1Param)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +bool JSTestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) +{ + if (!canInvokeCallback()) + return true; + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + ExecState* exec = m_data->globalObject()->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, class2Param)); + args.append(jsString(exec, strArg)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +} + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h new file mode 100644 index 0000000..ae91a6c --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -0,0 +1,58 @@ +/* + 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. +*/ + +#ifndef JSTestCallback_h +#define JSTestCallback_h + +#if ENABLE(DATABASE) + +#include "ActiveDOMCallback.h" +#include "JSCallbackData.h" +#include "TestCallback.h" +#include <wtf/Forward.h> + +namespace WebCore { + +class JSTestCallback : public TestCallback, public ActiveDOMCallback { +public: + static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) + { + return adoptRef(new JSTestCallback(callback, globalObject)); + } + + virtual ~JSTestCallback(); + + // Functions + virtual bool callbackWithClass1Param(Class1* class1Param); + virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); + virtual int customCallback(Class5* class5Param, Class6* class6Param); + +private: + JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*); + + JSCallbackData* m_data; +}; + +} // namespace WebCore + +#endif // ENABLE(DATABASE) + +#endif diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp new file mode 100644 index 0000000..8e71df1 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -0,0 +1,185 @@ +/* + 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. +*/ + +#include "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "JSTestInterface.h" + +#include "TestInterface.h" +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestInterface); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfaceTableValues[2] = +{ + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfaceTable = { 2, 1, JSTestInterfaceTableValues, 0 }; +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfaceConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfaceConstructorTable = { 1, 0, JSTestInterfaceConstructorTableValues, 0 }; +class JSTestInterfaceConstructor : public DOMConstructorObject { +public: + JSTestInterfaceConstructor(JSC::ExecState*, JSDOMGlobalObject*); + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestInterface(JSC::ExecState*); + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); +}; + +const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", 0, &JSTestInterfaceConstructorTable, 0 }; + +JSTestInterfaceConstructor::JSTestInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + +bool JSTestInterfaceConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, slot); +} + +bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, descriptor); +} + +EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterface(ExecState* exec) +{ + ScriptExecutionContext* context = static_cast<JSTestInterfaceConstructor*>(exec->callee())->scriptExecutionContext(); + if (!context) + return throwVMError(exec, createReferenceError(exec, "Reference error")); + return JSValue::encode(asObject(toJS(exec, static_cast<JSTestInterfaceConstructor*>(exec->callee())->globalObject(), TestInterface::create(context)))); +} + +ConstructType JSTestInterfaceConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructJSTestInterface; + return ConstructTypeHost; +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfacePrototypeTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfacePrototypeTable = { 1, 0, JSTestInterfacePrototypeTableValues, 0 }; +const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", 0, &JSTestInterfacePrototypeTable, 0 }; + +JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestInterface>(exec, globalObject); +} + +const ClassInfo JSTestInterface::s_info = { "TestInterface", 0, &JSTestInterfaceTable, 0 }; + +JSTestInterface::JSTestInterface(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestInterface> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestInterface::~JSTestInterface() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestInterfacePrototype(globalObject, JSTestInterfacePrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestInterface::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestInterface, Base>(exec, &JSTestInterfaceTable, this, propertyName, slot); +} + +bool JSTestInterface::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestInterface, Base>(exec, &JSTestInterfaceTable, this, propertyName, descriptor); +} + +JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); + return JSTestInterface::getConstructor(exec, domObject->globalObject()); +} +JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestInterface* object) +{ + return getDOMObjectWrapper<JSTestInterface>(exec, globalObject, object); +} +TestInterface* toTestInterface(JSC::JSValue value) +{ + return value.inherits(&JSTestInterface::s_info) ? static_cast<JSTestInterface*>(asObject(value))->impl() : 0; +} + +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h new file mode 100644 index 0000000..09d7d7c --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h @@ -0,0 +1,86 @@ +/* + 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. +*/ + +#ifndef JSTestInterface_h +#define JSTestInterface_h + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/JSObjectWithGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestInterface; + +class JSTestInterface : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestInterface(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestInterface>); + virtual ~JSTestInterface(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + TestInterface* impl() const { return m_impl.get(); } + +private: + RefPtr<TestInterface> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestInterface*); +TestInterface* toTestInterface(JSC::JSValue); + +class JSTestInterfacePrototype : public JSC::JSObjectWithGlobalObject { + typedef JSC::JSObjectWithGlobalObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestInterfacePrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } +protected: + static const unsigned StructureFlags = Base::StructureFlags; +}; + +// Attributes + +JSC::JSValue jsTestInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif // ENABLE(Condition1) || ENABLE(Condition2) + +#endif diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp new file mode 100644 index 0000000..e505ed2 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp @@ -0,0 +1,194 @@ +/* + 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. +*/ + +#include "config.h" +#include "JSTestMediaQueryListListener.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "MediaQueryListListener.h" +#include "TestMediaQueryListListener.h" +#include <runtime/Error.h> +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestMediaQueryListListener); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestMediaQueryListListenerTableValues[2] = +{ + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestMediaQueryListListenerConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestMediaQueryListListenerTable = { 2, 1, JSTestMediaQueryListListenerTableValues, 0 }; +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestMediaQueryListListenerConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestMediaQueryListListenerConstructorTable = { 1, 0, JSTestMediaQueryListListenerConstructorTableValues, 0 }; +class JSTestMediaQueryListListenerConstructor : public DOMConstructorObject { +public: + JSTestMediaQueryListListenerConstructor(JSC::ExecState*, JSDOMGlobalObject*); + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSTestMediaQueryListListenerConstructor::s_info = { "TestMediaQueryListListenerConstructor", 0, &JSTestMediaQueryListListenerConstructorTable, 0 }; + +JSTestMediaQueryListListenerConstructor::JSTestMediaQueryListListenerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestMediaQueryListListenerConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSTestMediaQueryListListenerPrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + +bool JSTestMediaQueryListListenerConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestMediaQueryListListenerConstructor, DOMObject>(exec, &JSTestMediaQueryListListenerConstructorTable, this, propertyName, slot); +} + +bool JSTestMediaQueryListListenerConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestMediaQueryListListenerConstructor, DOMObject>(exec, &JSTestMediaQueryListListenerConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestMediaQueryListListenerPrototypeTableValues[2] = +{ + { "method", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestMediaQueryListListenerPrototypeFunctionMethod), (intptr_t)1 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestMediaQueryListListenerPrototypeTable = { 2, 1, JSTestMediaQueryListListenerPrototypeTableValues, 0 }; +const ClassInfo JSTestMediaQueryListListenerPrototype::s_info = { "TestMediaQueryListListenerPrototype", 0, &JSTestMediaQueryListListenerPrototypeTable, 0 }; + +JSObject* JSTestMediaQueryListListenerPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestMediaQueryListListener>(exec, globalObject); +} + +bool JSTestMediaQueryListListenerPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot<JSObject>(exec, &JSTestMediaQueryListListenerPrototypeTable, this, propertyName, slot); +} + +bool JSTestMediaQueryListListenerPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticFunctionDescriptor<JSObject>(exec, &JSTestMediaQueryListListenerPrototypeTable, this, propertyName, descriptor); +} + +const ClassInfo JSTestMediaQueryListListener::s_info = { "TestMediaQueryListListener", 0, &JSTestMediaQueryListListenerTable, 0 }; + +JSTestMediaQueryListListener::JSTestMediaQueryListListener(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestMediaQueryListListener> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestMediaQueryListListener::~JSTestMediaQueryListListener() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestMediaQueryListListener::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestMediaQueryListListenerPrototype(globalObject, JSTestMediaQueryListListenerPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestMediaQueryListListener::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestMediaQueryListListener, Base>(exec, &JSTestMediaQueryListListenerTable, this, propertyName, slot); +} + +bool JSTestMediaQueryListListener::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestMediaQueryListListener, Base>(exec, &JSTestMediaQueryListListenerTable, this, propertyName, descriptor); +} + +JSValue jsTestMediaQueryListListenerConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestMediaQueryListListener* domObject = static_cast<JSTestMediaQueryListListener*>(asObject(slotBase)); + return JSTestMediaQueryListListener::getConstructor(exec, domObject->globalObject()); +} +JSValue JSTestMediaQueryListListener::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestMediaQueryListListenerConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestMediaQueryListListener::s_info)) + return throwVMTypeError(exec); + JSTestMediaQueryListListener* castedThis = static_cast<JSTestMediaQueryListListener*>(asObject(thisValue)); + TestMediaQueryListListener* imp = static_cast<TestMediaQueryListListener*>(castedThis->impl()); + RefPtr<MediaQueryListListener> listener = MediaQueryListListener::create(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->method(listener); + return JSValue::encode(jsUndefined()); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestMediaQueryListListener* object) +{ + return getDOMObjectWrapper<JSTestMediaQueryListListener>(exec, globalObject, object); +} +TestMediaQueryListListener* toTestMediaQueryListListener(JSC::JSValue value) +{ + return value.inherits(&JSTestMediaQueryListListener::s_info) ? static_cast<JSTestMediaQueryListListener*>(asObject(value))->impl() : 0; +} + +} diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h new file mode 100644 index 0000000..1863703 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h @@ -0,0 +1,87 @@ +/* + 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. +*/ + +#ifndef JSTestMediaQueryListListener_h +#define JSTestMediaQueryListListener_h + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/JSObjectWithGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestMediaQueryListListener; + +class JSTestMediaQueryListListener : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestMediaQueryListListener(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestMediaQueryListListener>); + virtual ~JSTestMediaQueryListListener(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + TestMediaQueryListListener* impl() const { return m_impl.get(); } + +private: + RefPtr<TestMediaQueryListListener> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestMediaQueryListListener*); +TestMediaQueryListListener* toTestMediaQueryListListener(JSC::JSValue); + +class JSTestMediaQueryListListenerPrototype : public JSC::JSObjectWithGlobalObject { + typedef JSC::JSObjectWithGlobalObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestMediaQueryListListenerPrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod(JSC::ExecState*); +// Attributes + +JSC::JSValue jsTestMediaQueryListListenerConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp new file mode 100644 index 0000000..c4c77ee --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -0,0 +1,1646 @@ +/* + 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. +*/ + +#include "config.h" +#include "JSTestObj.h" + +#include "ExceptionCode.h" +#include "HTMLNames.h" +#include "IDBBindingUtilities.h" +#include "IDBKey.h" +#include "JSDOMBinding.h" +#include "JSEventListener.h" +#include "JSOptionsObject.h" +#include "JSTestCallback.h" +#include "JSTestObj.h" +#include "JSlog.h" +#include "KURL.h" +#include "ScriptArguments.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" +#include "SerializedScriptValue.h" +#include "TestObj.h" +#include <runtime/Error.h> +#include <runtime/JSNumberCell.h> +#include <runtime/JSString.h> +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestObj); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjTableValues[37] = +{ + { "readOnlyIntAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyStringAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyTestObjAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyTestObjAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "shortAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjShortAttr), (intptr_t)setJSTestObjShortAttr THUNK_GENERATOR(0) }, + { "unsignedShortAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedShortAttr), (intptr_t)setJSTestObjUnsignedShortAttr THUNK_GENERATOR(0) }, + { "intAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjIntAttr), (intptr_t)setJSTestObjIntAttr THUNK_GENERATOR(0) }, + { "longLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongLongAttr), (intptr_t)setJSTestObjLongLongAttr THUNK_GENERATOR(0) }, + { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr THUNK_GENERATOR(0) }, + { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t)setJSTestObjStringAttr THUNK_GENERATOR(0) }, + { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t)setJSTestObjTestObjAttr THUNK_GENERATOR(0) }, + { "XMLObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjXMLObjAttr), (intptr_t)setJSTestObjXMLObjAttr THUNK_GENERATOR(0) }, + { "create", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCreate), (intptr_t)setJSTestObjCreate THUNK_GENERATOR(0) }, + { "reflectedStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedStringAttr), (intptr_t)setJSTestObjReflectedStringAttr THUNK_GENERATOR(0) }, + { "reflectedIntegralAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedIntegralAttr), (intptr_t)setJSTestObjReflectedIntegralAttr THUNK_GENERATOR(0) }, + { "reflectedUnsignedIntegralAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedUnsignedIntegralAttr), (intptr_t)setJSTestObjReflectedUnsignedIntegralAttr THUNK_GENERATOR(0) }, + { "reflectedBooleanAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedBooleanAttr), (intptr_t)setJSTestObjReflectedBooleanAttr THUNK_GENERATOR(0) }, + { "reflectedURLAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedURLAttr), (intptr_t)setJSTestObjReflectedURLAttr THUNK_GENERATOR(0) }, + { "reflectedNonEmptyURLAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedNonEmptyURLAttr), (intptr_t)setJSTestObjReflectedNonEmptyURLAttr THUNK_GENERATOR(0) }, + { "reflectedStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedStringAttr), (intptr_t)setJSTestObjReflectedStringAttr THUNK_GENERATOR(0) }, + { "reflectedCustomIntegralAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedCustomIntegralAttr), (intptr_t)setJSTestObjReflectedCustomIntegralAttr THUNK_GENERATOR(0) }, + { "reflectedCustomBooleanAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedCustomBooleanAttr), (intptr_t)setJSTestObjReflectedCustomBooleanAttr THUNK_GENERATOR(0) }, + { "reflectedCustomURLAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedCustomURLAttr), (intptr_t)setJSTestObjReflectedCustomURLAttr THUNK_GENERATOR(0) }, + { "reflectedCustomNonEmptyURLAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedCustomNonEmptyURLAttr), (intptr_t)setJSTestObjReflectedCustomNonEmptyURLAttr THUNK_GENERATOR(0) }, + { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) }, + { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) }, + { "stringAttrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithGetterException), (intptr_t)setJSTestObjStringAttrWithGetterException THUNK_GENERATOR(0) }, + { "stringAttrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithSetterException), (intptr_t)setJSTestObjStringAttrWithSetterException THUNK_GENERATOR(0) }, + { "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) }, + { "scriptStringAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, +#if ENABLE(Condition1) + { "conditionalAttr1", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConditionalAttr1), (intptr_t)setJSTestObjConditionalAttr1 THUNK_GENERATOR(0) }, +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) + { "conditionalAttr2", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConditionalAttr2), (intptr_t)setJSTestObjConditionalAttr2 THUNK_GENERATOR(0) }, +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) + { "conditionalAttr3", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConditionalAttr3), (intptr_t)setJSTestObjConditionalAttr3 THUNK_GENERATOR(0) }, +#endif + { "description", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjDescription), (intptr_t)0 THUNK_GENERATOR(0) }, + { "id", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjId), (intptr_t)setJSTestObjId THUNK_GENERATOR(0) }, + { "hash", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjHash), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjTable = { 133, 127, JSTestObjTableValues, 0 }; +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjConstructorTableValues[12] = +{ + { "CONST_VALUE_0", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_0), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_1", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_1), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_2", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_2), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_4", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_4), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_8", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_8), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_9", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_9), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_10", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_10), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_11", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_11), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_12", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_12), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_13", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_13), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_14", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_14), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjConstructorTable = { 33, 31, JSTestObjConstructorTableValues, 0 }; + +COMPILE_ASSERT(0 == TestObj::CONST_VALUE_0, TestObjEnumCONST_VALUE_0IsWrongUseDontCheckEnums); +COMPILE_ASSERT(1 == TestObj::CONST_VALUE_1, TestObjEnumCONST_VALUE_1IsWrongUseDontCheckEnums); +COMPILE_ASSERT(2 == TestObj::CONST_VALUE_2, TestObjEnumCONST_VALUE_2IsWrongUseDontCheckEnums); +COMPILE_ASSERT(4 == TestObj::CONST_VALUE_4, TestObjEnumCONST_VALUE_4IsWrongUseDontCheckEnums); +COMPILE_ASSERT(8 == TestObj::CONST_VALUE_8, TestObjEnumCONST_VALUE_8IsWrongUseDontCheckEnums); +COMPILE_ASSERT(-1 == TestObj::CONST_VALUE_9, TestObjEnumCONST_VALUE_9IsWrongUseDontCheckEnums); +COMPILE_ASSERT("my constant string" == TestObj::CONST_VALUE_10, TestObjEnumCONST_VALUE_10IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0xffffffff == TestObj::CONST_VALUE_11, TestObjEnumCONST_VALUE_11IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0x01 == TestObj::CONST_VALUE_12, TestObjEnumCONST_VALUE_12IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0X20 == TestObj::CONST_VALUE_13, TestObjEnumCONST_VALUE_13IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDontCheckEnums); + +class JSTestObjConstructor : public DOMConstructorObject { +public: + JSTestObjConstructor(JSC::ExecState*, JSDOMGlobalObject*); + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", 0, &JSTestObjConstructorTable, 0 }; + +JSTestObjConstructor::JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + +bool JSTestObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, slot); +} + +bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjPrototypeTableValues[48] = +{ + { "CONST_VALUE_0", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_0), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_1", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_1), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_2", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_2), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_4", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_4), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_8", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_8), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_9", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_9), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_10", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_10), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_11", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_11), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_12", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_12), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_13", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_13), (intptr_t)0 THUNK_GENERATOR(0) }, + { "CONST_VALUE_14", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_14), (intptr_t)0 THUNK_GENERATOR(0) }, + { "voidMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "voidMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "intMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "intMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "objMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "objMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "methodThatRequiresAllArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodThatRequiresAllArgs), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodThatRequiresAllArgsAndThrows", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows), (intptr_t)2 THUNK_GENERATOR(0) }, + { "serializedValue", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) }, + { "idbKey", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIdbKey), (intptr_t)1 THUNK_GENERATOR(0) }, + { "optionsObject", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOptionsObject), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodWithException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "customArgsAndException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) }, + { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "withDynamicFrame", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGesture", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGestureASAD", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withScriptStateVoid", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObj", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateVoidException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObjException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptExecutionContext", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptExecutionContext), (intptr_t)0 THUNK_GENERATOR(0) }, + { "methodWithOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "methodWithCallbackArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithNonCallbackArgAndCallbackArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodWithCallbackAndOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "overloadedMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2 THUNK_GENERATOR(0) }, + { "classMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "classMethodWithOptional", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithOptional), (intptr_t)1 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = { 136, 127, JSTestObjPrototypeTableValues, 0 }; +const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 }; + +JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestObj>(exec, globalObject); +} + +bool JSTestObjPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticPropertySlot<JSTestObjPrototype, JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, slot); +} + +bool JSTestObjPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticPropertyDescriptor<JSTestObjPrototype, JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, descriptor); +} + +const ClassInfo JSTestObj::s_info = { "TestObj", 0, &JSTestObjTable, 0 }; + +JSTestObj::JSTestObj(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestObj::~JSTestObj() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestObjPrototype(globalObject, JSTestObjPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestObj::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, slot); +} + +bool JSTestObj::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, descriptor); +} + +JSValue jsTestObjReadOnlyIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->readOnlyIntAttr()); + return result; +} + +JSValue jsTestObjReadOnlyStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->readOnlyStringAttr()); + return result; +} + +JSValue jsTestObjReadOnlyTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->readOnlyTestObjAttr())); + return result; +} + +JSValue jsTestObjShortAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->shortAttr()); + return result; +} + +JSValue jsTestObjUnsignedShortAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->unsignedShortAttr()); + return result; +} + +JSValue jsTestObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->intAttr()); + return result; +} + +JSValue jsTestObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->longLongAttr()); + return result; +} + +JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->unsignedLongLongAttr()); + return result; +} + +JSValue jsTestObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->stringAttr()); + return result; +} + +JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->testObjAttr())); + return result; +} + +JSValue jsTestObjXMLObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->xmlObjAttr())); + return result; +} + +JSValue jsTestObjCreate(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsBoolean(imp->isCreate()); + return result; +} + +JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return result; +} + +JSValue jsTestObjReflectedIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); + return result; +} + +JSValue jsTestObjReflectedUnsignedIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(std::max(0, imp->getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr))); + return result; +} + +JSValue jsTestObjReflectedBooleanAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsBoolean(imp->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); + return result; +} + +JSValue jsTestObjReflectedURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return result; +} + +JSValue jsTestObjReflectedNonEmptyURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); + return result; +} + +JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedCustomIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedCustomBooleanAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsBoolean(imp->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedCustomURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedCustomNonEmptyURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); + return result; +} + +JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + ExceptionCode ec = 0; + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSC::JSValue result = jsNumber(imp->attrWithGetterException(ec)); + setDOMException(exec, ec); + return result; +} + +JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->attrWithSetterException()); + return result; +} + +JSValue jsTestObjStringAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + ExceptionCode ec = 0; + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSC::JSValue result = jsString(exec, imp->stringAttrWithGetterException(ec)); + setDOMException(exec, ec); + return result; +} + +JSValue jsTestObjStringAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->stringAttrWithSetterException()); + return result; +} + +JSValue jsTestObjCustomAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + return castedThis->customAttr(exec); +} + +JSValue jsTestObjScriptStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsOwnedStringOrNull(exec, imp->scriptStringAttr()); + return result; +} + +#if ENABLE(Condition1) +JSValue jsTestObjConditionalAttr1(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->conditionalAttr1()); + return result; +} +#endif + +#if ENABLE(Condition1) && ENABLE(Condition2) +JSValue jsTestObjConditionalAttr2(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->conditionalAttr2()); + return result; +} +#endif + +#if ENABLE(Condition1) || ENABLE(Condition2) +JSValue jsTestObjConditionalAttr3(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->conditionalAttr3()); + return result; +} +#endif + +JSValue jsTestObjDescription(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->description()); + return result; +} + +JSValue jsTestObjId(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(imp->id()); + return result; +} + +JSValue jsTestObjHash(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->hash()); + return result; +} + +JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase)); + return JSTestObj::getConstructor(exec, domObject->globalObject()); +} +void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, this, slot); +} + +void setJSTestObjShortAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setShortAttr(value.toInt32(exec)); +} + +void setJSTestObjUnsignedShortAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setUnsignedShortAttr(value.toUInt32(exec)); +} + +void setJSTestObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntAttr(value.toInt32(exec)); +} + +void setJSTestObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setLongLongAttr(static_cast<long long>(value.toInteger(exec))); +} + +void setJSTestObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec))); +} + +void setJSTestObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setStringAttr(ustringToString(value.toString(exec))); +} + +void setJSTestObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setTestObjAttr(toTestObj(value)); +} + +void setJSTestObjXMLObjAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setXMLObjAttr(toTestObj(value)); +} + +void setJSTestObjCreate(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setCreate(value.toBoolean(exec)); +} + +void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value.toInt32(exec)); +} + +void setJSTestObjReflectedUnsignedIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, value.toUInt32(exec)); +} + +void setJSTestObjReflectedBooleanAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value.toBoolean(exec)); +} + +void setJSTestObjReflectedURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedNonEmptyURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedCustomIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value.toInt32(exec)); +} + +void setJSTestObjReflectedCustomBooleanAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value.toBoolean(exec)); +} + +void setJSTestObjReflectedCustomURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedCustomNonEmptyURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + imp->setAttrWithGetterException(value.toInt32(exec), ec); + setDOMException(exec, ec); +} + +void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + imp->setAttrWithSetterException(value.toInt32(exec), ec); + setDOMException(exec, ec); +} + +void setJSTestObjStringAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + imp->setStringAttrWithGetterException(ustringToString(value.toString(exec)), ec); + setDOMException(exec, ec); +} + +void setJSTestObjStringAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + imp->setStringAttrWithSetterException(ustringToString(value.toString(exec)), ec); + setDOMException(exec, ec); +} + +void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + static_cast<JSTestObj*>(thisObject)->setCustomAttr(exec, value); +} + +#if ENABLE(Condition1) +void setJSTestObjConditionalAttr1(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setConditionalAttr1(value.toInt32(exec)); +} +#endif + +#if ENABLE(Condition1) && ENABLE(Condition2) +void setJSTestObjConditionalAttr2(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setConditionalAttr2(value.toInt32(exec)); +} +#endif + +#if ENABLE(Condition1) || ENABLE(Condition2) +void setJSTestObjConditionalAttr3(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setConditionalAttr3(value.toInt32(exec)); +} +#endif + +void setJSTestObjId(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setId(value.toInt32(exec)); +} + +JSValue JSTestObj::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestObjConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->voidMethod(); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->voidMethodWithArgs(intArg, strArg, objArg); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = jsNumber(imp->intMethod()); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + + JSC::JSValue result = jsNumber(imp->intMethodWithArgs(intArg, strArg, objArg)); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethod())); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + if (exec->argumentCount() < 2) + return JSValue::encode(jsUndefined()); + const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + TestObj* objArg = toTestObj(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgs(strArg, objArg))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + if (exec->argumentCount() < 2) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + ExceptionCode ec = 0; + const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + TestObj* objArg = toTestObj(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec))); + setDOMException(exec, ec); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->serializedValue(serializedArg); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + RefPtr<IDBKey> key = createIDBKeyFromValue(exec, exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->idbKey(key); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + OptionsObject* oo = toOptionsObject(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 1) { + imp->optionsObject(oo); + return JSValue::encode(jsUndefined()); + } + + OptionsObject* ooo = toOptionsObject(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->optionsObject(oo, ooo); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + imp->methodWithException(ec); + setDOMException(exec, ec); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + return JSValue::encode(castedThis->customMethod(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + return JSValue::encode(castedThis->customMethodWithArgs(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1)); + size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; + RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); + log* intArg = tolog(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->customArgsAndException(intArg, scriptArguments, callStack, ec); + setDOMException(exec, ec); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue listener = exec->argument(1); + if (!listener.isObject()) + return JSValue::encode(jsUndefined()); + imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec)); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue listener = exec->argument(1); + if (!listener.isObject()) + return JSValue::encode(jsUndefined()); + imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec)); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return JSValue::encode(jsUndefined()); + + imp->withDynamicFrame(dynamicFrame); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return JSValue::encode(jsUndefined()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->withDynamicFrameAndArg(dynamicFrame, intArg); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return JSValue::encode(jsUndefined()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 1) { + imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg); + return JSValue::encode(jsUndefined()); + } + + int optionalArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return JSValue::encode(jsUndefined()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture()); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return JSValue::encode(jsUndefined()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 1) { + imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg); + return JSValue::encode(jsUndefined()); + } + + int optionalArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture()); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->withScriptStateVoid(exec); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObj(exec))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + imp->withScriptStateVoidException(exec, ec); + setDOMException(exec, ec); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObjException(exec, ec))); + setDOMException(exec, ec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContext(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + if (!scriptContext) + return JSValue::encode(jsUndefined()); + + imp->withScriptExecutionContext(scriptContext); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 0) { + imp->methodWithOptionalArg(); + return JSValue::encode(jsUndefined()); + } + + int opt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->methodWithOptionalArg(opt); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonOpt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 1) { + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); + return JSValue::encode(jsUndefined()); + } + + int opt = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonOpt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 1) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); + return JSValue::encode(jsUndefined()); + } + + int opt1 = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + int opt2 = exec->argument(2).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); + + imp->methodWithCallbackArg(callback); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonCallback = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject()); + + imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + RefPtr<TestCallback> callback; + if (exec->argumentCount() > 0 && !exec->argument(0).isNull() && !exec->argument(0).isUndefined()) { + if (!exec->argument(0).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); + } + + imp->methodWithCallbackAndOptionalArg(callback); + return JSValue::encode(jsUndefined()); +} + +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + TestObj* objArg = toTestObj(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->overloadedMethod(objArg, strArg); + return JSValue::encode(jsUndefined()); +} + +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + TestObj* objArg = toTestObj(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 1) { + imp->overloadedMethod(objArg); + return JSValue::encode(jsUndefined()); + } + + int intArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->overloadedMethod(objArg, intArg); + return JSValue::encode(jsUndefined()); +} + +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->overloadedMethod(strArg); + return JSValue::encode(jsUndefined()); +} + +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + imp->overloadedMethod(intArg); + return JSValue::encode(jsUndefined()); +} + +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod5(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); + + imp->overloadedMethod(callback); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecState* exec) +{ + if ((exec->argumentCount() == 2 && (exec->argument(0).isNull() || (exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info))) && (exec->argument(1).isNull() || exec->argument(1).isUndefined() || exec->argument(1).isString() || exec->argument(1).isObject()))) + return jsTestObjPrototypeFunctionOverloadedMethod1(exec); + if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || (exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info)))) || (exec->argumentCount() == 2 && (exec->argument(0).isNull() || (exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info))))) + return jsTestObjPrototypeFunctionOverloadedMethod2(exec); + if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || exec->argument(0).isUndefined() || exec->argument(0).isString() || exec->argument(0).isObject()))) + return jsTestObjPrototypeFunctionOverloadedMethod3(exec); + if (exec->argumentCount() == 1) + return jsTestObjPrototypeFunctionOverloadedMethod4(exec); + if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || exec->argument(0).isObject()))) + return jsTestObjPrototypeFunctionOverloadedMethod5(exec); + return throwVMTypeError(exec); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethod(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->classMethod(); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithOptional(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + int argsCount = exec->argumentCount(); + if (argsCount <= 0) { + + JSC::JSValue result = jsNumber(imp->classMethodWithOptional()); + return JSValue::encode(result); + } + + int arg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + + JSC::JSValue result = jsNumber(imp->classMethodWithOptional(arg)); + return JSValue::encode(result); +} + +// Constant getters + +JSValue jsTestObjCONST_VALUE_0(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(0)); +} + +JSValue jsTestObjCONST_VALUE_1(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(1)); +} + +JSValue jsTestObjCONST_VALUE_2(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(2)); +} + +JSValue jsTestObjCONST_VALUE_4(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(4)); +} + +JSValue jsTestObjCONST_VALUE_8(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(8)); +} + +JSValue jsTestObjCONST_VALUE_9(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(-1)); +} + +JSValue jsTestObjCONST_VALUE_10(ExecState* exec, JSValue, const Identifier&) +{ + return jsStringOrNull(exec, String("my constant string")); +} + +JSValue jsTestObjCONST_VALUE_11(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(0xffffffff)); +} + +JSValue jsTestObjCONST_VALUE_12(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(0x01)); +} + +JSValue jsTestObjCONST_VALUE_13(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(0X20)); +} + +JSValue jsTestObjCONST_VALUE_14(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast<int>(0x1abc)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object) +{ + return getDOMObjectWrapper<JSTestObj>(exec, globalObject, object); +} +TestObj* toTestObj(JSC::JSValue value) +{ + return value.inherits(&JSTestObj::s_info) ? static_cast<JSTestObj*>(asObject(value))->impl() : 0; +} + +} diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h new file mode 100644 index 0000000..b8713ae --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -0,0 +1,208 @@ +/* + 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. +*/ + +#ifndef JSTestObj_h +#define JSTestObj_h + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/JSObjectWithGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestObj; + +class JSTestObj : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestObj(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestObj>); + virtual ~JSTestObj(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom attributes + JSC::JSValue customAttr(JSC::ExecState*) const; + void setCustomAttr(JSC::ExecState*, JSC::JSValue); + + // Custom functions + JSC::JSValue customMethod(JSC::ExecState*); + JSC::JSValue customMethodWithArgs(JSC::ExecState*); + TestObj* impl() const { return m_impl.get(); } + +private: + RefPtr<TestObj> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestObj*); +TestObj* toTestObj(JSC::JSValue); + +class JSTestObjPrototype : public JSC::JSObjectWithGlobalObject { + typedef JSC::JSObjectWithGlobalObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestObjPrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContext(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethod(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithOptional(JSC::ExecState*); +// Attributes + +JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjReadOnlyStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjReadOnlyTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjShortAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjShortAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedShortAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedShortAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjIntAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjTestObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjXMLObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjXMLObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjCreate(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjCreate(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedIntegralAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedIntegralAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedUnsignedIntegralAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedUnsignedIntegralAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedBooleanAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedBooleanAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedURLAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedURLAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedNonEmptyURLAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedNonEmptyURLAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedCustomIntegralAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedCustomIntegralAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedCustomBooleanAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedCustomBooleanAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedCustomURLAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedCustomURLAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedCustomNonEmptyURLAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedCustomNonEmptyURLAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttrWithGetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjCustomAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjScriptStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjConditionalAttr1(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjConditionalAttr1(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjConditionalAttr2(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjConditionalAttr2(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjConditionalAttr3(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjConditionalAttr3(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjDescription(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjId(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjId(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjHash(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsTestObjCONST_VALUE_0(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_1(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_2(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_4(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_8(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_9(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_10(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_11(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_12(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_13(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjCONST_VALUE_14(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h new file mode 100644 index 0000000..1213c6f --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMClass1; +@class DOMClass2; +@class DOMClass3; +@class DOMClass5; +@class DOMClass6; +@class NSString; + +@interface DOMTestCallback : DOMObject +- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param; +- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg; +- (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param; +- (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param; +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm new file mode 100644 index 0000000..e941eda --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm @@ -0,0 +1,127 @@ +/* + * 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. + */ + +#import "config.h" + +#if ENABLE(DATABASE) + +#import "DOMInternal.h" + +#import "DOMTestCallback.h" + +#import "Class1.h" +#import "Class2.h" +#import "Class3.h" +#import "Class5.h" +#import "Class6.h" +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMClass1Internal.h" +#import "DOMClass2Internal.h" +#import "DOMClass3Internal.h" +#import "DOMClass5Internal.h" +#import "DOMClass6Internal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestCallbackInternal.h" +#import "ExceptionHandlers.h" +#import "JSMainThreadExecState.h" +#import "KURL.h" +#import "TestCallback.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestCallback*>(_internal) + +@implementation DOMTestCallback + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestCallback class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackWithClass1Param(core(class1Param)); +} + +- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackWithClass2Param(core(class2Param), strArg); +} + +- (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackWithNonBoolReturnType(core(class3Param)); +} + +- (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param +{ + WebCore::JSMainThreadNullState state; + return IMPL->customCallback(core(class5Param), core(class6Param)); +} + +@end + +WebCore::TestCallback* core(DOMTestCallback *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestCallback*>(wrapper->_internal) : 0; +} + +DOMTestCallback *kit(WebCore::TestCallback* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestCallback *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestCallback *wrapper = [[DOMTestCallback alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h new file mode 100644 index 0000000..d8ea940 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#import <WebCore/DOMTestCallback.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestCallback; +} + +WebCore::TestCallback* core(DOMTestCallback *); +DOMTestCallback *kit(WebCore::TestCallback*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h new file mode 100644 index 0000000..db7be28 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h @@ -0,0 +1,34 @@ +/* + * 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. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@interface DOMTestInterface : DOMObject +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm new file mode 100644 index 0000000..ab59333 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm @@ -0,0 +1,92 @@ +/* + * 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. + */ + +#import "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#import "DOMInternal.h" + +#import "DOMTestInterface.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestInterfaceInternal.h" +#import "ExceptionHandlers.h" +#import "JSMainThreadExecState.h" +#import "TestInterface.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestInterface*>(_internal) + +@implementation DOMTestInterface + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestInterface class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +@end + +WebCore::TestInterface* core(DOMTestInterface *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestInterface*>(wrapper->_internal) : 0; +} + +DOMTestInterface *kit(WebCore::TestInterface* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestInterface *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestInterface *wrapper = [[DOMTestInterface alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h new file mode 100644 index 0000000..fef60a3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#import <WebCore/DOMTestInterface.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestInterface; +} + +WebCore::TestInterface* core(DOMTestInterface *); +DOMTestInterface *kit(WebCore::TestInterface*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.h new file mode 100644 index 0000000..20be806 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.h @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMMediaQueryListListener; + +@interface DOMTestMediaQueryListListener : DOMObject +- (void)method:(DOMMediaQueryListListener *)listener; +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.mm new file mode 100644 index 0000000..74e3d52 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.mm @@ -0,0 +1,95 @@ +/* + * 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. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestMediaQueryListListener.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMMediaQueryListListenerInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestMediaQueryListListenerInternal.h" +#import "ExceptionHandlers.h" +#import "JSMainThreadExecState.h" +#import "MediaQueryListListener.h" +#import "TestMediaQueryListListener.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestMediaQueryListListener*>(_internal) + +@implementation DOMTestMediaQueryListListener + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestMediaQueryListListener class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (void)method:(DOMMediaQueryListListener *)listener +{ + WebCore::JSMainThreadNullState state; + IMPL->method(core(listener)); +} + +@end + +WebCore::TestMediaQueryListListener* core(DOMTestMediaQueryListListener *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestMediaQueryListListener*>(wrapper->_internal) : 0; +} + +DOMTestMediaQueryListListener *kit(WebCore::TestMediaQueryListListener* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestMediaQueryListListener *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestMediaQueryListListener *wrapper = [[DOMTestMediaQueryListListener alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListenerInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListenerInternal.h new file mode 100644 index 0000000..b1421a3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListenerInternal.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#import <WebCore/DOMTestMediaQueryListListener.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestMediaQueryListListener; +} + +WebCore::TestMediaQueryListListener* core(DOMTestMediaQueryListListener *); +DOMTestMediaQueryListListener *kit(WebCore::TestMediaQueryListListener*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h new file mode 100644 index 0000000..c6ab368 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -0,0 +1,157 @@ +/* + * 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. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMIDBKey; +@class DOMOptionsObject; +@class DOMTestObj; +@class DOMlog; +@class NSString; +@protocol DOMEventListener; + +enum { + DOM_CONST_VALUE_0 = 0, + DOM_CONST_VALUE_1 = 1, + DOM_CONST_VALUE_2 = 2, + DOM_CONST_VALUE_4 = 4, + DOM_CONST_VALUE_8 = 8, + DOM_CONST_VALUE_9 = -1, + DOM_CONST_VALUE_10 = "my constant string", + DOM_CONST_VALUE_11 = 0xffffffff, + DOM_CONST_VALUE_12 = 0x01, + DOM_CONST_VALUE_13 = 0X20, + DOM_CONST_VALUE_14 = 0x1abc +}; + +@interface DOMTestObj : DOMObject +- (int)readOnlyIntAttr; +- (NSString *)readOnlyStringAttr; +- (DOMTestObj *)readOnlyTestObjAttr; +- (short)shortAttr; +- (void)setShortAttr:(short)newShortAttr; +- (unsigned short)unsignedShortAttr; +- (void)setUnsignedShortAttr:(unsigned short)newUnsignedShortAttr; +- (int)intAttr; +- (void)setIntAttr:(int)newIntAttr; +- (long long)longLongAttr; +- (void)setLongLongAttr:(long long)newLongLongAttr; +- (unsigned long long)unsignedLongLongAttr; +- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr; +- (NSString *)stringAttr; +- (void)setStringAttr:(NSString *)newStringAttr; +- (DOMTestObj *)testObjAttr; +- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr; +- (DOMTestObj *)XMLObjAttr; +- (void)setXMLObjAttr:(DOMTestObj *)newXMLObjAttr; +- (BOOL)create; +- (void)setCreate:(BOOL)newCreate; +- (NSString *)reflectedStringAttr; +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr; +- (int)reflectedIntegralAttr; +- (void)setReflectedIntegralAttr:(int)newReflectedIntegralAttr; +- (unsigned)reflectedUnsignedIntegralAttr; +- (void)setReflectedUnsignedIntegralAttr:(unsigned)newReflectedUnsignedIntegralAttr; +- (BOOL)reflectedBooleanAttr; +- (void)setReflectedBooleanAttr:(BOOL)newReflectedBooleanAttr; +- (NSString *)reflectedURLAttr; +- (void)setReflectedURLAttr:(NSString *)newReflectedURLAttr; +- (NSString *)reflectedNonEmptyURLAttr; +- (void)setReflectedNonEmptyURLAttr:(NSString *)newReflectedNonEmptyURLAttr; +- (NSString *)reflectedStringAttr; +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr; +- (int)reflectedCustomIntegralAttr; +- (void)setReflectedCustomIntegralAttr:(int)newReflectedCustomIntegralAttr; +- (BOOL)reflectedCustomBooleanAttr; +- (void)setReflectedCustomBooleanAttr:(BOOL)newReflectedCustomBooleanAttr; +- (NSString *)reflectedCustomURLAttr; +- (void)setReflectedCustomURLAttr:(NSString *)newReflectedCustomURLAttr; +- (NSString *)reflectedCustomNonEmptyURLAttr; +- (void)setReflectedCustomNonEmptyURLAttr:(NSString *)newReflectedCustomNonEmptyURLAttr; +- (int)attrWithGetterException; +- (void)setAttrWithGetterException:(int)newAttrWithGetterException; +- (int)attrWithSetterException; +- (void)setAttrWithSetterException:(int)newAttrWithSetterException; +- (NSString *)stringAttrWithGetterException; +- (void)setStringAttrWithGetterException:(NSString *)newStringAttrWithGetterException; +- (NSString *)stringAttrWithSetterException; +- (void)setStringAttrWithSetterException:(NSString *)newStringAttrWithSetterException; +- (int)customAttr; +- (void)setCustomAttr:(int)newCustomAttr; +- (NSString *)scriptStringAttr; +#if ENABLE(Condition1) +- (int)conditionalAttr1; +- (void)setConditionalAttr1:(int)newConditionalAttr1; +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) +- (int)conditionalAttr2; +- (void)setConditionalAttr2:(int)newConditionalAttr2; +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) +- (int)conditionalAttr3; +- (void)setConditionalAttr3:(int)newConditionalAttr3; +#endif +- (int)descriptionName; +- (int)idName; +- (void)setIdName:(int)newIdName; +- (NSString *)hashName; +- (void)voidMethod; +- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (int)intMethod; +- (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)objMethod; +- (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)methodThatRequiresAllArgs:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)methodThatRequiresAllArgsAndThrows:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (void)serializedValue:(NSString *)serializedArg; +- (void)idbKey:(DOMIDBKey *)key; +- (void)optionsObject:(DOMOptionsObject *)oo ooo:(DOMOptionsObject *)ooo; +- (void)methodWithException; +- (void)customMethod; +- (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (void)customArgsAndException:(DOMlog *)intArg; +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; +- (void)withDynamicFrame; +- (void)withDynamicFrameAndArg:(int)intArg; +- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg; +- (void)withDynamicFrameAndUserGesture:(int)intArg; +- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg; +- (void)withScriptStateVoid; +- (DOMTestObj *)withScriptStateObj; +- (void)withScriptStateVoidException; +- (DOMTestObj *)withScriptStateObjException; +- (void)withScriptExecutionContext; +- (void)methodWithOptionalArg:(int)opt; +- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt; +- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2; +- (void)classMethod; +- (int)classMethodWithOptional:(int)arg; +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm new file mode 100644 index 0000000..f43f58a --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -0,0 +1,712 @@ +/* + * 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. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestObj.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMIDBKeyInternal.h" +#import "DOMNodeInternal.h" +#import "DOMOptionsObjectInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestObjInternal.h" +#import "DOMlogInternal.h" +#import "EventListener.h" +#import "ExceptionHandlers.h" +#import "HTMLNames.h" +#import "IDBKey.h" +#import "JSMainThreadExecState.h" +#import "KURL.h" +#import "ObjCEventListener.h" +#import "OptionsObject.h" +#import "SerializedScriptValue.h" +#import "TestObj.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import "log.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestObj*>(_internal) + +@implementation DOMTestObj + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestObj class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (int)readOnlyIntAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->readOnlyIntAttr(); +} + +- (NSString *)readOnlyStringAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->readOnlyStringAttr(); +} + +- (DOMTestObj *)readOnlyTestObjAttr +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->readOnlyTestObjAttr())); +} + +- (short)shortAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->shortAttr(); +} + +- (void)setShortAttr:(short)newShortAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setShortAttr(newShortAttr); +} + +- (unsigned short)unsignedShortAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->unsignedShortAttr(); +} + +- (void)setUnsignedShortAttr:(unsigned short)newUnsignedShortAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setUnsignedShortAttr(newUnsignedShortAttr); +} + +- (int)intAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->intAttr(); +} + +- (void)setIntAttr:(int)newIntAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setIntAttr(newIntAttr); +} + +- (long long)longLongAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->longLongAttr(); +} + +- (void)setLongLongAttr:(long long)newLongLongAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setLongLongAttr(newLongLongAttr); +} + +- (unsigned long long)unsignedLongLongAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->unsignedLongLongAttr(); +} + +- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setUnsignedLongLongAttr(newUnsignedLongLongAttr); +} + +- (NSString *)stringAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->stringAttr(); +} + +- (void)setStringAttr:(NSString *)newStringAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setStringAttr(newStringAttr); +} + +- (DOMTestObj *)testObjAttr +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->testObjAttr())); +} + +- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr +{ + WebCore::JSMainThreadNullState state; + ASSERT(newTestObjAttr); + + IMPL->setTestObjAttr(core(newTestObjAttr)); +} + +- (DOMTestObj *)XMLObjAttr +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->xmlObjAttr())); +} + +- (void)setXMLObjAttr:(DOMTestObj *)newXMLObjAttr +{ + WebCore::JSMainThreadNullState state; + ASSERT(newXMLObjAttr); + + IMPL->setXMLObjAttr(core(newXMLObjAttr)); +} + +- (BOOL)create +{ + WebCore::JSMainThreadNullState state; + return IMPL->isCreate(); +} + +- (void)setCreate:(BOOL)newCreate +{ + WebCore::JSMainThreadNullState state; + IMPL->setCreate(newCreate); +} + +- (NSString *)reflectedStringAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr); +} + +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, newReflectedStringAttr); +} + +- (int)reflectedIntegralAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); +} + +- (void)setReflectedIntegralAttr:(int)newReflectedIntegralAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, newReflectedIntegralAttr); +} + +- (unsigned)reflectedUnsignedIntegralAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr); +} + +- (void)setReflectedUnsignedIntegralAttr:(unsigned)newReflectedUnsignedIntegralAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, newReflectedUnsignedIntegralAttr); +} + +- (BOOL)reflectedBooleanAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); +} + +- (void)setReflectedBooleanAttr:(BOOL)newReflectedBooleanAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, newReflectedBooleanAttr); +} + +- (NSString *)reflectedURLAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr); +} + +- (void)setReflectedURLAttr:(NSString *)newReflectedURLAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, newReflectedURLAttr); +} + +- (NSString *)reflectedNonEmptyURLAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr); +} + +- (void)setReflectedNonEmptyURLAttr:(NSString *)newReflectedNonEmptyURLAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, newReflectedNonEmptyURLAttr); +} + +- (NSString *)reflectedStringAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr); +} + +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, newReflectedStringAttr); +} + +- (int)reflectedCustomIntegralAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); +} + +- (void)setReflectedCustomIntegralAttr:(int)newReflectedCustomIntegralAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, newReflectedCustomIntegralAttr); +} + +- (BOOL)reflectedCustomBooleanAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); +} + +- (void)setReflectedCustomBooleanAttr:(BOOL)newReflectedCustomBooleanAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, newReflectedCustomBooleanAttr); +} + +- (NSString *)reflectedCustomURLAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr); +} + +- (void)setReflectedCustomURLAttr:(NSString *)newReflectedCustomURLAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, newReflectedCustomURLAttr); +} + +- (NSString *)reflectedCustomNonEmptyURLAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr); +} + +- (void)setReflectedCustomNonEmptyURLAttr:(NSString *)newReflectedCustomNonEmptyURLAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, newReflectedCustomNonEmptyURLAttr); +} + +- (int)attrWithGetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + int result = IMPL->attrWithGetterException(ec); + WebCore::raiseOnDOMError(ec); + return result; +} + +- (void)setAttrWithGetterException:(int)newAttrWithGetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->setAttrWithGetterException(newAttrWithGetterException, ec); + WebCore::raiseOnDOMError(ec); +} + +- (int)attrWithSetterException +{ + WebCore::JSMainThreadNullState state; + return IMPL->attrWithSetterException(); +} + +- (void)setAttrWithSetterException:(int)newAttrWithSetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->setAttrWithSetterException(newAttrWithSetterException, ec); + WebCore::raiseOnDOMError(ec); +} + +- (NSString *)stringAttrWithGetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + NSString *result = IMPL->stringAttrWithGetterException(ec); + WebCore::raiseOnDOMError(ec); + return result; +} + +- (void)setStringAttrWithGetterException:(NSString *)newStringAttrWithGetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->setStringAttrWithGetterException(newStringAttrWithGetterException, ec); + WebCore::raiseOnDOMError(ec); +} + +- (NSString *)stringAttrWithSetterException +{ + WebCore::JSMainThreadNullState state; + return IMPL->stringAttrWithSetterException(); +} + +- (void)setStringAttrWithSetterException:(NSString *)newStringAttrWithSetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->setStringAttrWithSetterException(newStringAttrWithSetterException, ec); + WebCore::raiseOnDOMError(ec); +} + +- (int)customAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->customAttr(); +} + +- (void)setCustomAttr:(int)newCustomAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setCustomAttr(newCustomAttr); +} + +- (NSString *)scriptStringAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->scriptStringAttr(); +} + +#if ENABLE(Condition1) +- (int)conditionalAttr1 +{ + WebCore::JSMainThreadNullState state; + return IMPL->conditionalAttr1(); +} + +- (void)setConditionalAttr1:(int)newConditionalAttr1 +{ + WebCore::JSMainThreadNullState state; + IMPL->setConditionalAttr1(newConditionalAttr1); +} +#endif + +#if ENABLE(Condition1) && ENABLE(Condition2) +- (int)conditionalAttr2 +{ + WebCore::JSMainThreadNullState state; + return IMPL->conditionalAttr2(); +} + +- (void)setConditionalAttr2:(int)newConditionalAttr2 +{ + WebCore::JSMainThreadNullState state; + IMPL->setConditionalAttr2(newConditionalAttr2); +} +#endif + +#if ENABLE(Condition1) || ENABLE(Condition2) +- (int)conditionalAttr3 +{ + WebCore::JSMainThreadNullState state; + return IMPL->conditionalAttr3(); +} + +- (void)setConditionalAttr3:(int)newConditionalAttr3 +{ + WebCore::JSMainThreadNullState state; + IMPL->setConditionalAttr3(newConditionalAttr3); +} +#endif + +- (int)descriptionName +{ + WebCore::JSMainThreadNullState state; + return IMPL->description(); +} + +- (int)idName +{ + WebCore::JSMainThreadNullState state; + return IMPL->id(); +} + +- (void)setIdName:(int)newIdName +{ + WebCore::JSMainThreadNullState state; + IMPL->setId(newIdName); +} + +- (NSString *)hashName +{ + WebCore::JSMainThreadNullState state; + return IMPL->hash(); +} + +- (void)voidMethod +{ + WebCore::JSMainThreadNullState state; + IMPL->voidMethod(); +} + +- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::JSMainThreadNullState state; + IMPL->voidMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (int)intMethod +{ + WebCore::JSMainThreadNullState state; + return IMPL->intMethod(); +} + +- (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::JSMainThreadNullState state; + return IMPL->intMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (DOMTestObj *)objMethod +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->objMethod())); +} + +- (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->objMethodWithArgs(intArg, strArg, core(objArg)))); +} + +- (DOMTestObj *)methodThatRequiresAllArgs:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->methodThatRequiresAllArgs(strArg, core(objArg)))); +} + +- (DOMTestObj *)methodThatRequiresAllArgsAndThrows:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + DOMTestObj *result = kit(WTF::getPtr(IMPL->methodThatRequiresAllArgsAndThrows(strArg, core(objArg), ec))); + WebCore::raiseOnDOMError(ec); + return result; +} + +- (void)serializedValue:(NSString *)serializedArg +{ + WebCore::JSMainThreadNullState state; + IMPL->serializedValue(WebCore::SerializedScriptValue::create(WTF::String(serializedArg))); +} + +- (void)idbKey:(DOMIDBKey *)key +{ + WebCore::JSMainThreadNullState state; + IMPL->idbKey(core(key)); +} + +- (void)optionsObject:(DOMOptionsObject *)oo ooo:(DOMOptionsObject *)ooo +{ + WebCore::JSMainThreadNullState state; + IMPL->optionsObject(core(oo), core(ooo)); +} + +- (void)methodWithException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->methodWithException(ec); + WebCore::raiseOnDOMError(ec); +} + +- (void)customMethod +{ + WebCore::JSMainThreadNullState state; + IMPL->customMethod(); +} + +- (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::JSMainThreadNullState state; + IMPL->customMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (void)customArgsAndException:(DOMlog *)intArg +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->customArgsAndException(core(intArg), ec); + WebCore::raiseOnDOMError(ec); +} + +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture +{ + WebCore::JSMainThreadNullState state; + RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); + IMPL->addEventListener(type, WTF::getPtr(nativeEventListener), useCapture); +} + +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture +{ + WebCore::JSMainThreadNullState state; + RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); + IMPL->removeEventListener(type, WTF::getPtr(nativeEventListener), useCapture); +} + +- (void)withDynamicFrame +{ + WebCore::JSMainThreadNullState state; + IMPL->withDynamicFrame(); +} + +- (void)withDynamicFrameAndArg:(int)intArg +{ + WebCore::JSMainThreadNullState state; + IMPL->withDynamicFrameAndArg(intArg); +} + +- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg +{ + WebCore::JSMainThreadNullState state; + IMPL->withDynamicFrameAndOptionalArg(intArg, optionalArg); +} + +- (void)withDynamicFrameAndUserGesture:(int)intArg +{ + WebCore::JSMainThreadNullState state; + IMPL->withDynamicFrameAndUserGesture(intArg); +} + +- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg +{ + WebCore::JSMainThreadNullState state; + IMPL->withDynamicFrameAndUserGestureASAD(intArg, optionalArg); +} + +- (void)withScriptStateVoid +{ + WebCore::JSMainThreadNullState state; + IMPL->withScriptStateVoid(); +} + +- (DOMTestObj *)withScriptStateObj +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->withScriptStateObj())); +} + +- (void)withScriptStateVoidException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->withScriptStateVoidException(ec); + WebCore::raiseOnDOMError(ec); +} + +- (DOMTestObj *)withScriptStateObjException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + DOMTestObj *result = kit(WTF::getPtr(IMPL->withScriptStateObjException(ec))); + WebCore::raiseOnDOMError(ec); + return result; +} + +- (void)withScriptExecutionContext +{ + WebCore::JSMainThreadNullState state; + IMPL->withScriptExecutionContext(); +} + +- (void)methodWithOptionalArg:(int)opt +{ + WebCore::JSMainThreadNullState state; + IMPL->methodWithOptionalArg(opt); +} + +- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt +{ + WebCore::JSMainThreadNullState state; + IMPL->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); +} + +- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2 +{ + WebCore::JSMainThreadNullState state; + IMPL->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); +} + +- (void)classMethod +{ + WebCore::JSMainThreadNullState state; + IMPL->classMethod(); +} + +- (int)classMethodWithOptional:(int)arg +{ + WebCore::JSMainThreadNullState state; + return IMPL->classMethodWithOptional(arg); +} + +@end + +WebCore::TestObj* core(DOMTestObj *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestObj*>(wrapper->_internal) : 0; +} + +DOMTestObj *kit(WebCore::TestObj* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestObj *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestObj *wrapper = [[DOMTestObj alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h new file mode 100644 index 0000000..c24ea84 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#import <WebCore/DOMTestObj.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestObj; +} + +WebCore::TestObj* core(DOMTestObj *); +DOMTestObj *kit(WebCore::TestObj*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/TestCallback.idl b/Source/WebCore/bindings/scripts/test/TestCallback.idl new file mode 100644 index 0000000..25db4c6 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/TestCallback.idl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, 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 WARRANTIEstrArg, 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. + */ + +// This IDL file is for testing the bindings code generator with an interface +// that has the "Callback" attribute and for tracking changes in its ouput. +module test { + interface [ + Conditional=DATABASE, + Callback + ] TestCallback { + boolean callbackWithClass1Param(in Class1 class1Param); + boolean callbackWithClass2Param(in Class2 class2Param, in DOMString strArg); + long callbackWithNonBoolReturnType(in Class3 class3Param); + [Custom] long customCallback(in Class5 class5Param, in Class6 class6Param); + }; +} diff --git a/Source/WebCore/bindings/scripts/test/TestInterface.idl b/Source/WebCore/bindings/scripts/test/TestInterface.idl new file mode 100644 index 0000000..1f0aa18 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/TestInterface.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, 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 WARRANTIEstrArg, 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. + */ + +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. +module test { + interface [ + Conditional=Condition1|Condition2, + CanBeConstructed, + CallWith=ScriptExecutionContext + ] TestInterface { + }; +} diff --git a/Source/WebCore/bindings/scripts/test/TestMediaQueryListListener.idl b/Source/WebCore/bindings/scripts/test/TestMediaQueryListListener.idl new file mode 100644 index 0000000..536393b --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/TestMediaQueryListListener.idl @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// This IDL file is for testing the bindings code generator with an interface +// that has methods receiving a parameter of the type MediaQueryListListener. +module test { + interface TestMediaQueryListListener { + void method(in MediaQueryListListener listener); + }; +} diff --git a/Source/WebCore/bindings/scripts/test/TestObj.idl b/Source/WebCore/bindings/scripts/test/TestObj.idl new file mode 100644 index 0000000..a4eff26 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/TestObj.idl @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, 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 WARRANTIEstrArg, 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. + */ + +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. +module test { + interface TestObj { + // Attributes + readonly attribute long readOnlyIntAttr; + readonly attribute DOMString readOnlyStringAttr; + readonly attribute TestObj readOnlyTestObjAttr; + attribute short shortAttr; + attribute unsigned short unsignedShortAttr; + attribute long intAttr; + attribute long long longLongAttr; + attribute unsigned long long unsignedLongLongAttr; + attribute DOMString stringAttr; + attribute TestObj testObjAttr; + + JS, V8 + // WK_ucfirst, WK_lcfirst exceptional cases. + attribute TestObj XMLObjAttr; + attribute boolean create; + + // Reflected DOM attributes + attribute [Reflect] DOMString reflectedStringAttr; + attribute [Reflect] long reflectedIntegralAttr; + attribute [Reflect] unsigned long reflectedUnsignedIntegralAttr; + attribute [Reflect] boolean reflectedBooleanAttr; + attribute [Reflect, URL] DOMString reflectedURLAttr; + attribute [Reflect, NonEmpty, URL] DOMString reflectedNonEmptyURLAttr; + attribute [Reflect=customContentStringAttr] DOMString reflectedStringAttr; + attribute [Reflect=customContentIntegralAttr] long reflectedCustomIntegralAttr; + attribute [Reflect=customContentBooleanAttr] boolean reflectedCustomBooleanAttr; + attribute [Reflect=customContentURLAttr, URL] DOMString reflectedCustomURLAttr; + attribute [Reflect=customContentNonEmptyURLAttr, NonEmpty, URL] DOMString reflectedCustomNonEmptyURLAttr; + + // Methods + void voidMethod(); + void voidMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + long intMethod(); + long intMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + TestObj objMethod(); + TestObj objMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + + [RequiresAllArguments] TestObj methodThatRequiresAllArgs(in DOMString strArg, in TestObj objArg); + [RequiresAllArguments=Raise] TestObj methodThatRequiresAllArgsAndThrows(in DOMString strArg, in TestObj objArg) + raises(DOMException); + + void serializedValue(in SerializedScriptValue serializedArg); + void idbKey(in IDBKey key); + void optionsObject(in OptionsObject oo, in [Optional] OptionsObject ooo); + + // Exceptions + void methodWithException() raises(DOMException); + attribute long attrWithGetterException getter raises(DOMException); + attribute long attrWithSetterException setter raises(DOMException); + attribute DOMString stringAttrWithGetterException getter raises(DOMException); + attribute DOMString stringAttrWithSetterException setter raises(DOMException); + + // 'Custom' extended attribute + attribute [Custom] long customAttr; + [Custom] void customMethod(); + [Custom] void customMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + + [CustomArgumentHandling] void customArgsAndException(in log intArg) + raises(DOMException); + + void addEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); + void removeEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); + + // 'CallWith' extended attribute + [CallWith=DynamicFrame] void withDynamicFrame(); + [CallWith=DynamicFrame] void withDynamicFrameAndArg(in long intArg); + [CallWith=DynamicFrame] void withDynamicFrameAndOptionalArg(in long intArg, in [Optional] long optionalArg); + [NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGesture(in long intArg); + [NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGestureASAD(in long intArg, in [Optional] long optionalArg); + [CallWith=ScriptState] void withScriptStateVoid(); + [CallWith=ScriptState] TestObj withScriptStateObj(); + [CallWith=ScriptState] void withScriptStateVoidException() + raises(DOMException); + [CallWith=ScriptState] TestObj withScriptStateObjException() + raises(DOMException); + [CallWith=ScriptExecutionContext] void withScriptExecutionContext(); + + // 'Optional' extended attribute + void methodWithOptionalArg(in [Optional] long opt); + void methodWithNonOptionalArgAndOptionalArg(in long nonOpt, in [Optional] long opt); + void methodWithNonOptionalArgAndTwoOptionalArgs(in long nonOpt, in [Optional] long opt1, in long opt2); + +#if defined(TESTING_V8) || defined(TESTING_JS) + // 'Callback' extended attribute + void methodWithCallbackArg(in [Callback] TestCallback callback); + void methodWithNonCallbackArgAndCallbackArg(in long nonCallback, in [Callback] TestCallback callback); + void methodWithCallbackAndOptionalArg(in [Callback, Optional] TestCallback callback); +#endif + + // 'ConvertScriptString' extended attribute + readonly attribute [ConvertScriptString] DOMString scriptStringAttr; + + // 'Conditional' extended attribute + attribute [Conditional=Condition1] long conditionalAttr1; + attribute [Conditional=Condition1&Condition2] long conditionalAttr2; + attribute [Conditional=Condition1|Condition2] long conditionalAttr3; + +#if defined(TESTING_V8) || defined(TESTING_JS) + // Overloads + void overloadedMethod(in TestObj objArg, in DOMString strArg); + void overloadedMethod(in TestObj objArg, in [Optional] long intArg); + void overloadedMethod(in DOMString strArg); + void overloadedMethod(in long intArg); + void overloadedMethod(in [Callback] TestCallback callback); +#endif + + // Class methods within JavaScript (like what's used for IDBKeyRange). + [ClassMethod] void classMethod(); + [ClassMethod] long classMethodWithOptional(in [Optional] long arg); + +#if defined(TESTING_V8) + // 'EnabledAtRuntime' methods and attributes. + [EnabledAtRuntime] void enabledAtRuntimeMethod1(in int intArg); + [EnabledAtRuntime=FeatureName] void enabledAtRuntimeMethod2(in int intArg); + attribute [EnabledAtRuntime] long enabledAtRuntimeAttr1; + attribute [EnabledAtRuntime=FeatureName] long enabledAtRuntimeAttr2; +#endif + + // ObjectiveC reserved words. + readonly attribute long description; + attribute long id; + readonly attribute DOMString hash; + + // Check constants and enums. + const unsigned short CONST_VALUE_0 = 0; + const unsigned short CONST_VALUE_1 = 1; + const unsigned short CONST_VALUE_2 = 2; + const unsigned short CONST_VALUE_4 = 4; + const unsigned short CONST_VALUE_8 = 8; + const short CONST_VALUE_9 = -1; + const DOMString CONST_VALUE_10 = "my constant string"; + const unsigned short CONST_VALUE_11 = 0xffffffff; + const unsigned short CONST_VALUE_12 = 0x01; + const unsigned short CONST_VALUE_13 = 0X20; + const unsigned short CONST_VALUE_14 = 0x1abc; + }; +} diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp new file mode 100644 index 0000000..c286c24 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -0,0 +1,113 @@ +/* + 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. +*/ + +#include "config.h" +#include "V8TestCallback.h" + +#if ENABLE(DATABASE) + +#include "ScriptExecutionContext.h" +#include "V8Class1.h" +#include "V8Class2.h" +#include "V8CustomVoidCallback.h" +#include "V8DOMString.h" +#include "V8Proxy.h" + +#include <wtf/Assertions.h> + +namespace WebCore { + +V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : ActiveDOMCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) + , m_worldContext(UseCurrentWorld) +{ +} + +V8TestCallback::~V8TestCallback() +{ + m_callback.Dispose(); +} + +// Functions + +bool V8TestCallback::callbackWithClass1Param(Class1* class1Param) +{ + if (!canInvokeCallback()) + return true; + + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param); + if (class1ParamHandle.IsEmpty()) { + CRASH(); + return true; + } + + v8::Handle<v8::Value> argv[] = { + class1ParamHandle + }; + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext()); +} + +bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) +{ + if (!canInvokeCallback()) + return true; + + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param); + if (class2ParamHandle.IsEmpty()) { + CRASH(); + return true; + } + v8::Handle<v8::Value> strArgHandle = toV8(strArg); + if (strArgHandle.IsEmpty()) { + CRASH(); + return true; + } + + v8::Handle<v8::Value> argv[] = { + class2ParamHandle, + strArgHandle + }; + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()); +} + +} // namespace WebCore + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h new file mode 100644 index 0000000..a105d75 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -0,0 +1,64 @@ +/* + 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. +*/ + +#if ENABLE(DATABASE) + +#ifndef V8TestCallback_h +#define V8TestCallback_h + +#include "ActiveDOMCallback.h" +#include "TestCallback.h" +#include "WorldContextHandle.h" +#include <v8.h> +#include <wtf/Forward.h> + +namespace WebCore { + +class ScriptExecutionContext; + +class V8TestCallback : public TestCallback, public ActiveDOMCallback { +public: + static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) + { + ASSERT(value->IsObject()); + ASSERT(context); + return adoptRef(new V8TestCallback(value->ToObject(), context)); + } + + virtual ~V8TestCallback(); + + // Functions + virtual bool callbackWithClass1Param(Class1* class1Param); + virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); + virtual int customCallback(Class5* class5Param, Class6* class6Param); + +private: + V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*); + + v8::Persistent<v8::Object> m_callback; + WorldContextHandle m_worldContext; +}; + +} + +#endif // V8TestCallback_h + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp new file mode 100644 index 0000000..267f1f0 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp @@ -0,0 +1,99 @@ +/* + 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. +*/ + +#include "config.h" +#include "V8TestInterface.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" + +namespace WebCore { + +WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, 0 }; + +namespace TestInterfaceInternal { + +template <typename T> void V8_USE(T) { } + +} // namespace TestInterfaceInternal + +v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestInterface.Contructor"); + return V8Proxy::constructDOMObjectWithScriptExecutionContext<TestInterface>(args, &info); +} +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, + 0, 0, + 0, 0); + desc->SetCallHandler(V8TestInterface::constructorCallback); + + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestInterface::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestInterfaceRawCache = createRawTemplate(); + return V8TestInterfaceRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestInterface::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestInterfaceCache = ConfigureV8TestInterfaceTemplate(GetRawTemplate()); + return V8TestInterfaceCache; +} + +bool V8TestInterface::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestInterface::wrapSlow(TestInterface* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +void V8TestInterface::derefObject(void* object) +{ + static_cast<TestInterface*>(object)->deref(); +} + +} // namespace WebCore + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h new file mode 100644 index 0000000..c1e319b --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h @@ -0,0 +1,77 @@ +/* + 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. +*/ + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#ifndef V8TestInterface_h +#define V8TestInterface_h + +#include "TestInterface.h" +#include "V8DOMWrapper.h" +#include "WrapperTypeInfo.h" +#include "wtf/text/StringHash.h" +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestInterface { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestInterface* toNative(v8::Handle<v8::Object> object) + { + return reinterpret_cast<TestInterface*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(TestInterface*); + static void derefObject(void*); + static WrapperTypeInfo info; + static v8::Handle<v8::Value> constructorCallback(const v8::Arguments& args); + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +private: + static v8::Handle<v8::Object> wrapSlow(TestInterface*); +}; + + +v8::Handle<v8::Object> V8TestInterface::wrap(TestInterface* impl) +{ + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return V8TestInterface::wrapSlow(impl); +} + +inline v8::Handle<v8::Value> toV8(TestInterface* impl) +{ + if (!impl) + return v8::Null(); + return V8TestInterface::wrap(impl); +} +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestInterface > impl) +{ + return toV8(impl.get()); +} +} + +#endif // V8TestInterface_h +#endif // ENABLE(Condition1) || ENABLE(Condition2) + diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp new file mode 100644 index 0000000..ab9e6db --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp @@ -0,0 +1,106 @@ +/* + 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. +*/ + +#include "config.h" +#include "V8TestMediaQueryListListener.h" + +#include "ExceptionCode.h" +#include "MediaQueryListListener.h" +#include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8BindingMacros.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" + +namespace WebCore { + +WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0 }; + +namespace TestMediaQueryListListenerInternal { + +template <typename T> void V8_USE(T) { } + +static v8::Handle<v8::Value> methodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestMediaQueryListListener.method"); + TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder()); + EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(args[0])); + imp->method(listener); + return v8::Handle<v8::Value>(); +} + +} // namespace TestMediaQueryListListenerInternal + +static const BatchedCallback TestMediaQueryListListenerCallbacks[] = { + {"method", TestMediaQueryListListenerInternal::methodCallback}, +}; +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestMediaQueryListListenerTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestMediaQueryListListener", v8::Persistent<v8::FunctionTemplate>(), V8TestMediaQueryListListener::internalFieldCount, + 0, 0, + TestMediaQueryListListenerCallbacks, WTF_ARRAY_LENGTH(TestMediaQueryListListenerCallbacks)); + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); + + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestMediaQueryListListener::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestMediaQueryListListenerRawCache = createRawTemplate(); + return V8TestMediaQueryListListenerRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestMediaQueryListListener::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestMediaQueryListListenerCache = ConfigureV8TestMediaQueryListListenerTemplate(GetRawTemplate()); + return V8TestMediaQueryListListenerCache; +} + +bool V8TestMediaQueryListListener::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestMediaQueryListListener::wrapSlow(TestMediaQueryListListener* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +void V8TestMediaQueryListListener::derefObject(void* object) +{ + static_cast<TestMediaQueryListListener*>(object)->deref(); +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h new file mode 100644 index 0000000..908d9cd --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h @@ -0,0 +1,72 @@ +/* + 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. +*/ + +#ifndef V8TestMediaQueryListListener_h +#define V8TestMediaQueryListListener_h + +#include "TestMediaQueryListListener.h" +#include "V8DOMWrapper.h" +#include "WrapperTypeInfo.h" +#include "wtf/text/StringHash.h" +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestMediaQueryListListener { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestMediaQueryListListener* toNative(v8::Handle<v8::Object> object) + { + return reinterpret_cast<TestMediaQueryListListener*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(TestMediaQueryListListener*); + static void derefObject(void*); + static WrapperTypeInfo info; + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +private: + static v8::Handle<v8::Object> wrapSlow(TestMediaQueryListListener*); +}; + + +v8::Handle<v8::Object> V8TestMediaQueryListListener::wrap(TestMediaQueryListListener* impl) +{ + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return V8TestMediaQueryListListener::wrapSlow(impl); +} + +inline v8::Handle<v8::Value> toV8(TestMediaQueryListListener* impl) +{ + if (!impl) + return v8::Null(); + return V8TestMediaQueryListListener::wrap(impl); +} +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestMediaQueryListListener > impl) +{ + return toV8(impl.get()); +} +} + +#endif // V8TestMediaQueryListListener_h diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp new file mode 100644 index 0000000..7a759a3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -0,0 +1,1392 @@ +/* + 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. +*/ + +#include "config.h" +#include "V8TestObj.h" + +#include "ExceptionCode.h" +#include "HTMLNames.h" +#include "IDBBindingUtilities.h" +#include "IDBKey.h" +#include "OptionsObject.h" +#include "RuntimeEnabledFeatures.h" +#include "ScriptArguments.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" +#include "SerializedScriptValue.h" +#include "V8Binding.h" +#include "V8BindingMacros.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" +#include "V8TestCallback.h" +#include "V8int.h" +#include "V8log.h" +#include <wtf/GetPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0 }; + +namespace TestObjInternal { + +template <typename T> void V8_USE(T) { } + +static v8::Handle<v8::Value> readOnlyIntAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.readOnlyIntAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->readOnlyIntAttr()); +} + +static v8::Handle<v8::Value> readOnlyStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.readOnlyStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->readOnlyStringAttr()); +} + +static v8::Handle<v8::Value> readOnlyTestObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.readOnlyTestObjAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + RefPtr<TestObj> result = imp->readOnlyTestObjAttr(); + v8::Handle<v8::Value> wrapper = result.get() ? getDOMObjectMap().get(result.get()) : v8::Handle<v8::Value>(); + if (wrapper.IsEmpty()) { + wrapper = toV8(result.get()); + if (!wrapper.IsEmpty()) + V8DOMWrapper::setHiddenReference(info.Holder(), wrapper); + } + return wrapper; +} + +static v8::Handle<v8::Value> shortAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.shortAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->shortAttr()); +} + +static void shortAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.shortAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setShortAttr(v); + return; +} + +static v8::Handle<v8::Value> unsignedShortAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedShortAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->unsignedShortAttr()); +} + +static void unsignedShortAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedShortAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toUInt32(value); + imp->setUnsignedShortAttr(v); + return; +} + +static v8::Handle<v8::Value> intAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.intAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->intAttr()); +} + +static void intAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.intAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setIntAttr(v); + return; +} + +static v8::Handle<v8::Value> longLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Number::New(static_cast<double>(imp->longLongAttr())); +} + +static void longLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + long long v = toInt64(value); + imp->setLongLongAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> unsignedLongLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Number::New(static_cast<double>(imp->unsignedLongLongAttr())); +} + +static void unsignedLongLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + unsigned long long v = toInt64(value); + imp->setUnsignedLongLongAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> stringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->stringAttr()); +} + +static void stringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<>, v, value); + imp->setStringAttr(v); + return; +} + +static v8::Handle<v8::Value> testObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.testObjAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return toV8(imp->testObjAttr()); +} + +static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.testObjAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0; + imp->setTestObjAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> XMLObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.XMLObjAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return toV8(imp->xmlObjAttr()); +} + +static void XMLObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.XMLObjAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0; + imp->setXMLObjAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> createAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.create._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Boolean(imp->isCreate()); +} + +static void createAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.create._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + bool v = value->BooleanValue(); + imp->setCreate(v); + return; +} + +static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); +} + +static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedStringAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value); + imp->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedIntegralAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); +} + +static void reflectedIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedIntegralAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedUnsignedIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedUnsignedIntegralAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::NewFromUnsigned(imp->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)); +} + +static void reflectedUnsignedIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedUnsignedIntegralAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + unsigned v = toUInt32(value); + imp->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedBooleanAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedBooleanAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); +} + +static void reflectedBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedBooleanAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + bool v = value->BooleanValue(); + imp->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedURLAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); +} + +static void reflectedURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedURLAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value); + imp->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedNonEmptyURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedNonEmptyURLAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); +} + +static void reflectedNonEmptyURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedNonEmptyURLAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value); + imp->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); +} + +static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedStringAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value); + imp->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedCustomIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomIntegralAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); +} + +static void reflectedCustomIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomIntegralAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedCustomBooleanAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); +} + +static void reflectedCustomBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + bool v = value->BooleanValue(); + imp->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedCustomURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomURLAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); +} + +static void reflectedCustomURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomURLAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value); + imp->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedCustomNonEmptyURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomNonEmptyURLAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); +} + +static void reflectedCustomNonEmptyURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomNonEmptyURLAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value); + imp->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> attrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithGetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + ExceptionCode ec = 0; + int v = imp->attrWithGetterException(ec); + if (UNLIKELY(ec)) { + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); + } + return v8::Integer::New(v); +} + +static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithGetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + ExceptionCode ec = 0; + imp->setAttrWithGetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); + return; +} + +static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithSetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->attrWithSetterException()); +} + +static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithSetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + ExceptionCode ec = 0; + imp->setAttrWithSetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); + return; +} + +static v8::Handle<v8::Value> stringAttrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttrWithGetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + ExceptionCode ec = 0; + String v = imp->stringAttrWithGetterException(ec); + if (UNLIKELY(ec)) { + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); + } + return v8String(v); +} + +static void stringAttrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttrWithGetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<>, v, value); + ExceptionCode ec = 0; + imp->setStringAttrWithGetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); + return; +} + +static v8::Handle<v8::Value> stringAttrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttrWithSetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->stringAttrWithSetterException()); +} + +static void stringAttrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttrWithSetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<>, v, value); + ExceptionCode ec = 0; + imp->setStringAttrWithSetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); + return; +} + +static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.scriptStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8StringOrNull(imp->scriptStringAttr()); +} + +#if ENABLE(Condition1) + +static v8::Handle<v8::Value> conditionalAttr1AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr1._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->conditionalAttr1()); +} + +#endif // ENABLE(Condition1) + +#if ENABLE(Condition1) + +static void conditionalAttr1AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr1._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setConditionalAttr1(v); + return; +} + +#endif // ENABLE(Condition1) + +#if ENABLE(Condition1) && ENABLE(Condition2) + +static v8::Handle<v8::Value> conditionalAttr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr2._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->conditionalAttr2()); +} + +#endif // ENABLE(Condition1) && ENABLE(Condition2) + +#if ENABLE(Condition1) && ENABLE(Condition2) + +static void conditionalAttr2AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr2._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setConditionalAttr2(v); + return; +} + +#endif // ENABLE(Condition1) && ENABLE(Condition2) + +#if ENABLE(Condition1) || ENABLE(Condition2) + +static v8::Handle<v8::Value> conditionalAttr3AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr3._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->conditionalAttr3()); +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) + +#if ENABLE(Condition1) || ENABLE(Condition2) + +static void conditionalAttr3AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr3._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setConditionalAttr3(v); + return; +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) + +static v8::Handle<v8::Value> enabledAtRuntimeAttr1AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.enabledAtRuntimeAttr1._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->enabledAtRuntimeAttr1()); +} + +static void enabledAtRuntimeAttr1AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.enabledAtRuntimeAttr1._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setEnabledAtRuntimeAttr1(v); + return; +} + +static v8::Handle<v8::Value> enabledAtRuntimeAttr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.enabledAtRuntimeAttr2._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->enabledAtRuntimeAttr2()); +} + +static void enabledAtRuntimeAttr2AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.enabledAtRuntimeAttr2._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setEnabledAtRuntimeAttr2(v); + return; +} + +static v8::Handle<v8::Value> descriptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.description._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->description()); +} + +static v8::Handle<v8::Value> idAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.id._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->id()); +} + +static void idAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.id._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setId(v); + return; +} + +static v8::Handle<v8::Value> hashAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.hash._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->hash()); +} + +static v8::Handle<v8::Value> voidMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.voidMethod"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + imp->voidMethod(); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.voidMethodWithArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); + imp->voidMethodWithArgs(intArg, strArg, objArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> intMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.intMethod"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + return v8::Integer::New(imp->intMethod()); +} + +static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.intMethodWithArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); + return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg)); +} + +static v8::Handle<v8::Value> objMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.objMethod"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + return toV8(imp->objMethod()); +} + +static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.objMethodWithArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); + return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); +} + +static v8::Handle<v8::Value> methodThatRequiresAllArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodThatRequiresAllArgs"); + if (args.Length() < 2) + return v8::Handle<v8::Value>(); + TestObj* imp = V8TestObj::toNative(args.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); + return toV8(imp->methodThatRequiresAllArgs(strArg, objArg)); +} + +static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodThatRequiresAllArgsAndThrows"); + if (args.Length() < 2) + return throwError("Not enough arguments", V8Proxy::SyntaxError); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); + RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec); + if (UNLIKELY(ec)) + goto fail; + return toV8(result.release()); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.serializedValue"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + bool serializedArgDidThrow = false; + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], serializedArgDidThrow); + if (serializedArgDidThrow) + return v8::Undefined(); + imp->serializedValue(serializedArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> idbKeyCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.idbKey"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + RefPtr<IDBKey> key = createIDBKeyFromValue(args[0]); + if (UNLIKELY(!key)) { + ec = TYPE_MISMATCH_ERR; + goto fail; + } + imp->idbKey(key); + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> optionsObjectCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.optionsObject"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(OptionsObject, oo, args[0]); + if (args.Length() <= 1) { + imp->optionsObject(oo); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(OptionsObject, ooo, args[1]); + imp->optionsObject(oo, ooo); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + imp->methodWithException(ec); + if (UNLIKELY(ec)) + goto fail; + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.customArgsAndException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + RefPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1)); + size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; + RefPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); + if (!callStack) + return v8::Undefined(); + EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + imp->customArgsAndException(intArg, scriptArguments, callStack, ec); + if (UNLIKELY(ec)) + goto fail; + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.addEventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOrCreate); + if (listener) { + V8TestObj::toNative(args.Holder())->addEventListener(v8ValueToAtomicWebCoreString(args[0]), listener, args[2]->BooleanValue()); + createHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.removeEventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly); + if (listener) { + V8TestObj::toNative(args.Holder())->removeEventListener(v8ValueToAtomicWebCoreString(args[0]), listener.get(), args[2]->BooleanValue()); + removeHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +static v8::Handle<v8::Value> withDynamicFrameCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrame"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrame(enteredFrame); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndArg(enteredFrame, intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + if (args.Length() <= 1) { + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1])); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg, optionalArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGesture(enteredFrame, intArg, processingUserGesture()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + if (args.Length() <= 1) { + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, processingUserGesture()); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1])); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, optionalArg, processingUserGesture()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateVoidCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateVoid"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EmptyScriptState state; + imp->withScriptStateVoid(&state); + if (state.hadException()) + return throwError(state.exception()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateObjCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateObj"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EmptyScriptState state; + RefPtr<TestObj> result = imp->withScriptStateObj(&state); + if (state.hadException()) + return throwError(state.exception()); + return toV8(result.release()); +} + +static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateVoidException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + EmptyScriptState state; + imp->withScriptStateVoidException(&state, ec); + if (UNLIKELY(ec)) + goto fail; + if (state.hadException()) + return throwError(state.exception()); + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateObjException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + EmptyScriptState state; + RefPtr<TestObj> result = imp->withScriptStateObjException(&state, ec); + if (UNLIKELY(ec)) + goto fail; + if (state.hadException()) + return throwError(state.exception()); + return toV8(result.release()); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptExecutionContextCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptExecutionContext"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ScriptExecutionContext* scriptContext = getScriptExecutionContext(); + if (!scriptContext) + return v8::Undefined(); + imp->withScriptExecutionContext(scriptContext); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + if (args.Length() <= 0) { + imp->methodWithOptionalArg(); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(int, opt, toInt32(args[0])); + imp->methodWithOptionalArg(opt); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0])); + if (args.Length() <= 1) { + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(int, opt, toInt32(args[1])); + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0])); + if (args.Length() <= 1) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(int, opt1, toInt32(args[1])); + EXCEPTION_BLOCK(int, opt2, toInt32(args[2])); + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithCallbackArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithCallbackArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + if (args.Length() <= 0 || !args[0]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); + imp->methodWithCallbackArg(callback); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithNonCallbackArgAndCallbackArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, nonCallback, toInt32(args[0])); + if (args.Length() <= 1 || !args[1]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext()); + imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithCallbackAndOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithCallbackAndOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + RefPtr<TestCallback> callback; + if (args.Length() > 0 && !args[0]->IsNull() && !args[0]->IsUndefined()) { + if (!args[0]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + callback = V8TestCallback::create(args[0], getScriptExecutionContext()); + } + imp->methodWithCallbackAndOptionalArg(callback); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod1"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + imp->overloadedMethod(objArg, strArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod2"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + if (args.Length() <= 1) { + imp->overloadedMethod(objArg); + return v8::Handle<v8::Value>(); + } + EXCEPTION_BLOCK(int, intArg, toInt32(args[1])); + imp->overloadedMethod(objArg, intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod3"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + imp->overloadedMethod(strArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod4"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + imp->overloadedMethod(intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod5Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod5"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + if (args.Length() <= 0 || !args[0]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); + imp->overloadedMethod(callback); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod"); + if ((args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject()))) + return overloadedMethod1Callback(args); + if ((args.Length() == 1 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0]))) || (args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])))) + return overloadedMethod2Callback(args); + if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject()))) + return overloadedMethod3Callback(args); + if (args.Length() == 1) + return overloadedMethod4Callback(args); + if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsObject()))) + return overloadedMethod5Callback(args); + V8Proxy::throwTypeError(); + return notHandledByInterceptor(); +} + +static v8::Handle<v8::Value> classMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.classMethod"); + TestObj::classMethod(); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> classMethodWithOptionalCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.classMethodWithOptional"); + if (args.Length() <= 0) { + return v8::Integer::New(TestObj::classMethodWithOptional()); + } + EXCEPTION_BLOCK(int, arg, toInt32(args[0])); + return v8::Integer::New(TestObj::classMethodWithOptional(arg)); +} + +static v8::Handle<v8::Value> enabledAtRuntimeMethod1Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.enabledAtRuntimeMethod1"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(args[0]) ? V8int::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + imp->enabledAtRuntimeMethod1(intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> enabledAtRuntimeMethod2Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.enabledAtRuntimeMethod2"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(args[0]) ? V8int::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + imp->enabledAtRuntimeMethod2(intArg); + return v8::Handle<v8::Value>(); +} + +} // namespace TestObjInternal + +static const BatchedAttribute TestObjAttrs[] = { + // Attribute 'readOnlyIntAttr' (Type: 'readonly attribute' ExtAttr: '') + {"readOnlyIntAttr", TestObjInternal::readOnlyIntAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'readOnlyStringAttr' (Type: 'readonly attribute' ExtAttr: '') + {"readOnlyStringAttr", TestObjInternal::readOnlyStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'readOnlyTestObjAttr' (Type: 'readonly attribute' ExtAttr: '') + {"readOnlyTestObjAttr", TestObjInternal::readOnlyTestObjAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'shortAttr' (Type: 'attribute' ExtAttr: '') + {"shortAttr", TestObjInternal::shortAttrAttrGetter, TestObjInternal::shortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedShortAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedShortAttr", TestObjInternal::unsignedShortAttrAttrGetter, TestObjInternal::unsignedShortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'intAttr' (Type: 'attribute' ExtAttr: '') + {"intAttr", TestObjInternal::intAttrAttrGetter, TestObjInternal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'longLongAttr' (Type: 'attribute' ExtAttr: '') + {"longLongAttr", TestObjInternal::longLongAttrAttrGetter, TestObjInternal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedLongLongAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedLongLongAttr", TestObjInternal::unsignedLongLongAttrAttrGetter, TestObjInternal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '') + {"stringAttr", TestObjInternal::stringAttrAttrGetter, TestObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '') + {"testObjAttr", TestObjInternal::testObjAttrAttrGetter, TestObjInternal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'XMLObjAttr' (Type: 'attribute' ExtAttr: '') + {"XMLObjAttr", TestObjInternal::XMLObjAttrAttrGetter, TestObjInternal::XMLObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'create' (Type: 'attribute' ExtAttr: '') + {"create", TestObjInternal::createAttrGetter, TestObjInternal::createAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedStringAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedStringAttr", TestObjInternal::reflectedStringAttrAttrGetter, TestObjInternal::reflectedStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedIntegralAttr", TestObjInternal::reflectedIntegralAttrAttrGetter, TestObjInternal::reflectedIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedUnsignedIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedUnsignedIntegralAttr", TestObjInternal::reflectedUnsignedIntegralAttrAttrGetter, TestObjInternal::reflectedUnsignedIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedBooleanAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedBooleanAttr", TestObjInternal::reflectedBooleanAttrAttrGetter, TestObjInternal::reflectedBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedURLAttr' (Type: 'attribute' ExtAttr: 'URL Reflect') + {"reflectedURLAttr", TestObjInternal::reflectedURLAttrAttrGetter, TestObjInternal::reflectedURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedNonEmptyURLAttr' (Type: 'attribute' ExtAttr: 'URL NonEmpty Reflect') + {"reflectedNonEmptyURLAttr", TestObjInternal::reflectedNonEmptyURLAttrAttrGetter, TestObjInternal::reflectedNonEmptyURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedStringAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedStringAttr", TestObjInternal::reflectedStringAttrAttrGetter, TestObjInternal::reflectedStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedCustomIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedCustomIntegralAttr", TestObjInternal::reflectedCustomIntegralAttrAttrGetter, TestObjInternal::reflectedCustomIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedCustomBooleanAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedCustomBooleanAttr", TestObjInternal::reflectedCustomBooleanAttrAttrGetter, TestObjInternal::reflectedCustomBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedCustomURLAttr' (Type: 'attribute' ExtAttr: 'URL Reflect') + {"reflectedCustomURLAttr", TestObjInternal::reflectedCustomURLAttrAttrGetter, TestObjInternal::reflectedCustomURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedCustomNonEmptyURLAttr' (Type: 'attribute' ExtAttr: 'URL NonEmpty Reflect') + {"reflectedCustomNonEmptyURLAttr", TestObjInternal::reflectedCustomNonEmptyURLAttrAttrGetter, TestObjInternal::reflectedCustomNonEmptyURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'attrWithGetterException' (Type: 'attribute' ExtAttr: '') + {"attrWithGetterException", TestObjInternal::attrWithGetterExceptionAttrGetter, TestObjInternal::attrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'attrWithSetterException' (Type: 'attribute' ExtAttr: '') + {"attrWithSetterException", TestObjInternal::attrWithSetterExceptionAttrGetter, TestObjInternal::attrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'stringAttrWithGetterException' (Type: 'attribute' ExtAttr: '') + {"stringAttrWithGetterException", TestObjInternal::stringAttrWithGetterExceptionAttrGetter, TestObjInternal::stringAttrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'stringAttrWithSetterException' (Type: 'attribute' ExtAttr: '') + {"stringAttrWithSetterException", TestObjInternal::stringAttrWithSetterExceptionAttrGetter, TestObjInternal::stringAttrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'customAttr' (Type: 'attribute' ExtAttr: 'Custom') + {"customAttr", V8TestObj::customAttrAccessorGetter, V8TestObj::customAttrAccessorSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'scriptStringAttr' (Type: 'readonly attribute' ExtAttr: 'ConvertScriptString') + {"scriptStringAttr", TestObjInternal::scriptStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#if ENABLE(Condition1) + // Attribute 'conditionalAttr1' (Type: 'attribute' ExtAttr: 'Conditional') + {"conditionalAttr1", TestObjInternal::conditionalAttr1AttrGetter, TestObjInternal::conditionalAttr1AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#endif // ENABLE(Condition1) +#if ENABLE(Condition1) && ENABLE(Condition2) + // Attribute 'conditionalAttr2' (Type: 'attribute' ExtAttr: 'Conditional') + {"conditionalAttr2", TestObjInternal::conditionalAttr2AttrGetter, TestObjInternal::conditionalAttr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#endif // ENABLE(Condition1) && ENABLE(Condition2) +#if ENABLE(Condition1) || ENABLE(Condition2) + // Attribute 'conditionalAttr3' (Type: 'attribute' ExtAttr: 'Conditional') + {"conditionalAttr3", TestObjInternal::conditionalAttr3AttrGetter, TestObjInternal::conditionalAttr3AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#endif // ENABLE(Condition1) || ENABLE(Condition2) + // Attribute 'description' (Type: 'readonly attribute' ExtAttr: '') + {"description", TestObjInternal::descriptionAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'id' (Type: 'attribute' ExtAttr: '') + {"id", TestObjInternal::idAttrGetter, TestObjInternal::idAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'hash' (Type: 'readonly attribute' ExtAttr: '') + {"hash", TestObjInternal::hashAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +}; +static const BatchedCallback TestObjCallbacks[] = { + {"voidMethod", TestObjInternal::voidMethodCallback}, + {"intMethod", TestObjInternal::intMethodCallback}, + {"objMethod", TestObjInternal::objMethodCallback}, + {"serializedValue", TestObjInternal::serializedValueCallback}, + {"idbKey", TestObjInternal::idbKeyCallback}, + {"optionsObject", TestObjInternal::optionsObjectCallback}, + {"methodWithException", TestObjInternal::methodWithExceptionCallback}, + {"customMethod", V8TestObj::customMethodCallback}, + {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback}, + {"addEventListener", TestObjInternal::addEventListenerCallback}, + {"removeEventListener", TestObjInternal::removeEventListenerCallback}, + {"withDynamicFrame", TestObjInternal::withDynamicFrameCallback}, + {"withDynamicFrameAndArg", TestObjInternal::withDynamicFrameAndArgCallback}, + {"withDynamicFrameAndOptionalArg", TestObjInternal::withDynamicFrameAndOptionalArgCallback}, + {"withDynamicFrameAndUserGesture", TestObjInternal::withDynamicFrameAndUserGestureCallback}, + {"withDynamicFrameAndUserGestureASAD", TestObjInternal::withDynamicFrameAndUserGestureASADCallback}, + {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback}, + {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback}, + {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback}, + {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback}, + {"withScriptExecutionContext", TestObjInternal::withScriptExecutionContextCallback}, + {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, + {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, + {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, + {"methodWithCallbackArg", TestObjInternal::methodWithCallbackArgCallback}, + {"methodWithNonCallbackArgAndCallbackArg", TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback}, + {"methodWithCallbackAndOptionalArg", TestObjInternal::methodWithCallbackAndOptionalArgCallback}, + {"overloadedMethod", TestObjInternal::overloadedMethodCallback}, +}; +static const BatchedConstant TestObjConsts[] = { + {"CONST_VALUE_0", static_cast<signed int>(0)}, + {"CONST_VALUE_1", static_cast<signed int>(1)}, + {"CONST_VALUE_2", static_cast<signed int>(2)}, + {"CONST_VALUE_4", static_cast<signed int>(4)}, + {"CONST_VALUE_8", static_cast<signed int>(8)}, + {"CONST_VALUE_9", static_cast<signed int>(-1)}, + {"CONST_VALUE_10", static_cast<signed int>("my constant string")}, + {"CONST_VALUE_11", static_cast<signed int>(0xffffffff)}, + {"CONST_VALUE_12", static_cast<signed int>(0x01)}, + {"CONST_VALUE_13", static_cast<signed int>(0X20)}, + {"CONST_VALUE_14", static_cast<signed int>(0x1abc)}, +}; + +COMPILE_ASSERT(0 == TestObj::CONST_VALUE_0, TestObjEnumCONST_VALUE_0IsWrongUseDontCheckEnums); +COMPILE_ASSERT(1 == TestObj::CONST_VALUE_1, TestObjEnumCONST_VALUE_1IsWrongUseDontCheckEnums); +COMPILE_ASSERT(2 == TestObj::CONST_VALUE_2, TestObjEnumCONST_VALUE_2IsWrongUseDontCheckEnums); +COMPILE_ASSERT(4 == TestObj::CONST_VALUE_4, TestObjEnumCONST_VALUE_4IsWrongUseDontCheckEnums); +COMPILE_ASSERT(8 == TestObj::CONST_VALUE_8, TestObjEnumCONST_VALUE_8IsWrongUseDontCheckEnums); +COMPILE_ASSERT(-1 == TestObj::CONST_VALUE_9, TestObjEnumCONST_VALUE_9IsWrongUseDontCheckEnums); +COMPILE_ASSERT("my constant string" == TestObj::CONST_VALUE_10, TestObjEnumCONST_VALUE_10IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0xffffffff == TestObj::CONST_VALUE_11, TestObjEnumCONST_VALUE_11IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0x01 == TestObj::CONST_VALUE_12, TestObjEnumCONST_VALUE_12IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0X20 == TestObj::CONST_VALUE_13, TestObjEnumCONST_VALUE_13IsWrongUseDontCheckEnums); +COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDontCheckEnums); + +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestObj", v8::Persistent<v8::FunctionTemplate>(), V8TestObj::internalFieldCount, + TestObjAttrs, WTF_ARRAY_LENGTH(TestObjAttrs), + TestObjCallbacks, WTF_ARRAY_LENGTH(TestObjCallbacks)); + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); + + if (RuntimeEnabledFeatures::enabledAtRuntimeAttr1Enabled()) { + static const BatchedAttribute attrData =\ + // Attribute 'enabledAtRuntimeAttr1' (Type: 'attribute' ExtAttr: 'EnabledAtRuntime') + {"enabledAtRuntimeAttr1", TestObjInternal::enabledAtRuntimeAttr1AttrGetter, TestObjInternal::enabledAtRuntimeAttr1AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; + configureAttribute(instance, proto, attrData); + } + if (RuntimeEnabledFeatures::featureNameEnabled()) { + static const BatchedAttribute attrData =\ + // Attribute 'enabledAtRuntimeAttr2' (Type: 'attribute' ExtAttr: 'EnabledAtRuntime') + {"enabledAtRuntimeAttr2", TestObjInternal::enabledAtRuntimeAttr2AttrGetter, TestObjInternal::enabledAtRuntimeAttr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; + configureAttribute(instance, proto, attrData); + } + + // Custom Signature 'voidMethodWithArgs' + const int voidMethodWithArgsArgc = 3; + v8::Handle<v8::FunctionTemplate> voidMethodWithArgsArgv[voidMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> voidMethodWithArgsSignature = v8::Signature::New(desc, voidMethodWithArgsArgc, voidMethodWithArgsArgv); + proto->Set(v8::String::New("voidMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::voidMethodWithArgsCallback, v8::Handle<v8::Value>(), voidMethodWithArgsSignature)); + + // Custom Signature 'intMethodWithArgs' + const int intMethodWithArgsArgc = 3; + v8::Handle<v8::FunctionTemplate> intMethodWithArgsArgv[intMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> intMethodWithArgsSignature = v8::Signature::New(desc, intMethodWithArgsArgc, intMethodWithArgsArgv); + proto->Set(v8::String::New("intMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::intMethodWithArgsCallback, v8::Handle<v8::Value>(), intMethodWithArgsSignature)); + + // Custom Signature 'objMethodWithArgs' + const int objMethodWithArgsArgc = 3; + v8::Handle<v8::FunctionTemplate> objMethodWithArgsArgv[objMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> objMethodWithArgsSignature = v8::Signature::New(desc, objMethodWithArgsArgc, objMethodWithArgsArgv); + proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature)); + + // Custom Signature 'methodThatRequiresAllArgs' + const int methodThatRequiresAllArgsArgc = 2; + v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsArgv[methodThatRequiresAllArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> methodThatRequiresAllArgsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsArgc, methodThatRequiresAllArgsArgv); + proto->Set(v8::String::New("methodThatRequiresAllArgs"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsSignature)); + + // Custom Signature 'methodThatRequiresAllArgsAndThrows' + const int methodThatRequiresAllArgsAndThrowsArgc = 2; + v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsAndThrowsArgv[methodThatRequiresAllArgsAndThrowsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> methodThatRequiresAllArgsAndThrowsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsAndThrowsArgc, methodThatRequiresAllArgsAndThrowsArgv); + proto->Set(v8::String::New("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsAndThrowsSignature)); + + // Custom Signature 'customArgsAndException' + const int customArgsAndExceptionArgc = 1; + v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() }; + v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv); + proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature)); + desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); + desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); + if (RuntimeEnabledFeatures::enabledAtRuntimeMethod1Enabled()) + proto->Set(v8::String::New("enabledAtRuntimeMethod1"), v8::FunctionTemplate::New(TestObjInternal::enabledAtRuntimeMethod1Callback, v8::Handle<v8::Value>(), defaultSignature)); + if (RuntimeEnabledFeatures::featureNameEnabled()) + proto->Set(v8::String::New("enabledAtRuntimeMethod2"), v8::FunctionTemplate::New(TestObjInternal::enabledAtRuntimeMethod2Callback, v8::Handle<v8::Value>(), defaultSignature)); + batchConfigureConstants(desc, proto, TestObjConsts, WTF_ARRAY_LENGTH(TestObjConsts)); + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestObj::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestObjRawCache = createRawTemplate(); + return V8TestObjRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestObj::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestObjCache = ConfigureV8TestObjTemplate(GetRawTemplate()); + return V8TestObjCache; +} + +bool V8TestObj::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestObj::wrapSlow(TestObj* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +void V8TestObj::derefObject(void* object) +{ + static_cast<TestObj*>(object)->deref(); +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h new file mode 100644 index 0000000..1e60488 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h @@ -0,0 +1,76 @@ +/* + 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. +*/ + +#ifndef V8TestObj_h +#define V8TestObj_h + +#include "TestObj.h" +#include "V8DOMWrapper.h" +#include "WrapperTypeInfo.h" +#include "wtf/text/StringHash.h" +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestObj { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestObj* toNative(v8::Handle<v8::Object> object) + { + return reinterpret_cast<TestObj*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(TestObj*); + static void derefObject(void*); + static WrapperTypeInfo info; + static v8::Handle<v8::Value> customMethodCallback(const v8::Arguments&); + static v8::Handle<v8::Value> customMethodWithArgsCallback(const v8::Arguments&); + static v8::Handle<v8::Value> customAttrAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info); + static void customAttrAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +private: + static v8::Handle<v8::Object> wrapSlow(TestObj*); +}; + + +v8::Handle<v8::Object> V8TestObj::wrap(TestObj* impl) +{ + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return V8TestObj::wrapSlow(impl); +} + +inline v8::Handle<v8::Value> toV8(TestObj* impl) +{ + if (!impl) + return v8::Null(); + return V8TestObj::wrap(impl); +} +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestObj > impl) +{ + return toV8(impl.get()); +} +} + +#endif // V8TestObj_h |