summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm')
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm74
1 files changed, 62 insertions, 12 deletions
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
index d46d88a72..91248c550 100644
--- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
+++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
@@ -4,6 +4,7 @@
# 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>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -28,6 +29,7 @@ use File::stat;
# Global Variables
my $module = "";
my $outputDir = "";
+my $writeDependencies = 0;
my %publicInterfaces = ();
my $newPublicClass = 0;
my $interfaceAvailabilityVersion = "";
@@ -49,6 +51,7 @@ my @internalHeaderContent = ();
my @implContentHeader = ();
my @implContent = ();
my %implIncludes = ();
+my @depsContent = ();
# Hashes
my %protocolTypeHash = ("XPathNSResolver" => 1, "EventListener" => 1, "EventTarget" => 1, "NodeFilter" => 1,
@@ -194,6 +197,9 @@ sub new
$codeGenerator = shift;
$outputDir = shift;
+ shift; # $useLayerOnTop
+ shift; # $preprocessor
+ $writeDependencies = shift;
bless($reference, $object);
return $reference;
@@ -305,7 +311,7 @@ sub GetClassName
my $name = $codeGenerator->StripModule(shift);
# special cases
- return "NSString" if $codeGenerator->IsStringType($name);
+ 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";
@@ -486,6 +492,11 @@ sub GetObjCTypeGetter
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(WebCore::String($argName))";
+ }
return "core($argName)";
}
@@ -601,6 +612,11 @@ sub AddIncludesForType
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";
@@ -709,6 +725,8 @@ sub GenerateHeader
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 . ";";
@@ -976,8 +994,10 @@ sub GenerateImplementation
my $object = shift;
my $dataNode = shift;
+ my @ancestorInterfaceNames = ();
+
if (@{$dataNode->parents} > 1) {
- $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode);
+ $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@ancestorInterfaceNames);
}
my $interfaceName = $dataNode->name;
@@ -1059,9 +1079,12 @@ sub GenerateImplementation
# 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, " $assertMainThread\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");
@@ -1128,15 +1151,21 @@ sub GenerateImplementation
# - GETTER
my $getterSig = "- ($attributeType)$attributeInterfaceName\n";
+
+ # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++
+ $attributeName =~ s/operatorAnimated/_operatorAnimated/ if ($attributeName =~ /operatorAnimated/);
+ $getterSig =~ s/operator/_operator/ if ($getterSig =~ /operator/);
+
my $hasGetterException = @{$attribute->getterExceptions};
my $getterContentHead;
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL);
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
- $getterContentHead = "IMPL->${getAttributeFunctionName}(WebCore::HTMLNames::${contentAttributeName}Attr";
+ $getterContentHead = "IMPL->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr";
} else {
$getterContentHead = "IMPL->" . $codeGenerator->WK_lcfirst($attributeName) . "(";
}
@@ -1201,6 +1230,9 @@ sub GenerateImplementation
} elsif ($idlType eq "Color") {
$getterContentHead = "WebCore::nsColor($getterContentHead";
$getterContentTail .= ")";
+ } elsif ($attribute->signature->type eq "SerializedScriptValue") {
+ $getterContentHead = "$getterContentHead";
+ $getterContentTail .= "->toString()";
} elsif (ConversionNeeded($attribute->signature->type)) {
$getterContentHead = "kit(WTF::getPtr($getterContentHead";
$getterContentTail .= "))";
@@ -1267,20 +1299,20 @@ sub GenerateImplementation
} else {
push(@implContent, " IMPL->$coreSetterName($arg);\n");
}
- } elsif ($hasSetterException) {
- push(@implContent, " $exceptionInit\n");
- push(@implContent, " IMPL->$coreSetterName($arg, ec);\n");
- push(@implContent, " $exceptionRaiseOnError\n");
} else {
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
+ push(@implContent, " $exceptionInit\n") if $hasSetterException;
+ my $ec = $hasSetterException ? ", ec" : "";
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL);
- push(@implContent, " IMPL->setAttribute(WebCore::HTMLNames::${contentAttributeName}Attr, $arg);\n");
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
+ push(@implContent, " IMPL->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, $arg$ec);\n");
} else {
- push(@implContent, " IMPL->$coreSetterName($arg);\n");
+ push(@implContent, " IMPL->$coreSetterName($arg$ec);\n");
}
+ push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException;
}
push(@implContent, "}\n\n");
@@ -1435,6 +1467,8 @@ sub GenerateImplementation
push(@functionContent, " return $toReturn;\n");
push(@functionContent, " return nil;\n");
}
+ } elsif ($returnType eq "SerializedScriptValue") {
+ $content = "foo";
} else {
if (ConversionNeeded($function->signature->type)) {
if ($codeGenerator->IsPodType($function->signature->type)) {
@@ -1540,6 +1574,12 @@ sub GenerateImplementation
# - End the ifdef conditional if necessary
push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional;
+
+ # - Generate dependencies.
+ if ($writeDependencies && @ancestorInterfaceNames) {
+ push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestorInterfaceNames), "\n");
+ push(@depsContent, map { "$_.idl :\n" } @ancestorInterfaceNames);
+ }
}
# Internal helper
@@ -1553,12 +1593,14 @@ sub WriteData
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";
@@ -1621,6 +1663,14 @@ sub WriteData
@internalHeaderContent = ();
}
+
+ # Write dependency file.
+ if (@depsContent) {
+ open(DEPS, ">$depsFileName") or die "Couldn't open file $depsFileName";
+ print DEPS @depsContent;
+ close(DEPS);
+ @depsContent = ();
+ }
}
1;