summaryrefslogtreecommitdiff
path: root/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-20 14:01:09 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-20 14:01:09 +0200
commit6dbcd09121fe266c7704a524b5cbd7f2754659c0 (patch)
tree5ae0d16cec0cc61f576d51c57b3a4613c7e91e22 /Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
parent6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (diff)
downloadqtwebkit-6dbcd09121fe266c7704a524b5cbd7f2754659c0.tar.gz
Imported WebKit commit 080af0beaa6f0ba8ff8f44cb8bd8b5dcf75ac0af (http://svn.webkit.org/repository/webkit/trunk@129119)
New snapshot with prospective build fix for incorrect QtWebKit master module header file creation
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm')
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm51
1 files changed, 44 insertions, 7 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
index 40d92ead7..f2da64036 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
@@ -1,4 +1,5 @@
# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2012 Samsung Electronics
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -29,11 +30,12 @@ package CodeGeneratorTestRunner;
sub new
{
- my ($class, $codeGenerator, $outputDir) = @_;
+ my ($class, $codeGenerator, $outputDir, $outputHeaderDir, $layerOnTop, $preprocessor, $writeDependencies, $verbose, $idlFilePath) = @_;
my $reference = {
codeGenerator => $codeGenerator,
outputDir => $outputDir,
+ idlFilePath => $idlFilePath,
};
bless($reference, $class);
@@ -72,12 +74,37 @@ sub _classRefGetter
return $$self{codeGenerator}->WK_lcfirst(_implementationClassName($idlType)) . "Class";
}
-sub _fileHeaderString
+sub _parseLicenseBlock
{
- my ($filename) = @_;
+ my ($fileHandle) = @_;
+
+ my ($copyright, $readCount, $buffer, $currentCharacter, $previousCharacter);
+ my $startSentinel = "/*";
+ my $lengthOfStartSentinel = length($startSentinel);
+ $readCount = read($fileHandle, $buffer, $lengthOfStartSentinel);
+ return "" if ($readCount < $lengthOfStartSentinel || $buffer ne $startSentinel);
+ $copyright = $buffer;
+
+ while ($readCount = read($fileHandle, $currentCharacter, 1)) {
+ $copyright .= $currentCharacter;
+ return $copyright if $currentCharacter eq "/" && $previousCharacter eq "*";
+ $previousCharacter = $currentCharacter;
+ }
+
+ return "";
+}
+
+sub _parseLicenseBlockFromFile
+{
+ my ($path) = @_;
+ open my $fileHandle, "<", $path or die "Failed to open $path for reading: $!";
+ my $licenseBlock = _parseLicenseBlock($fileHandle);
+ close($fileHandle);
+ return $licenseBlock;
+}
- # FIXME: We should pull header out of the IDL file to get the copyright
- # year(s) right.
+sub _defaultLicenseBlock
+{
return <<EOF;
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
@@ -106,6 +133,16 @@ sub _fileHeaderString
EOF
}
+sub _licenseBlock
+{
+ my ($self) = @_;
+ return $self->{licenseBlock} if $self->{licenseBlock};
+
+ my $licenseBlock = _parseLicenseBlockFromFile($self->{idlFilePath}) || _defaultLicenseBlock();
+ $self->{licenseBlock} = $licenseBlock;
+ return $licenseBlock;
+}
+
sub _generateHeaderFile
{
my ($self, $interface) = @_;
@@ -117,7 +154,7 @@ sub _generateHeaderFile
my $implementationClassName = _implementationClassName($idlType);
my $filename = $className . ".h";
- push(@contents, _fileHeaderString($filename));
+ push(@contents, $self->_licenseBlock());
my $parentClassName = _parentClassName($interface);
@@ -184,7 +221,7 @@ sub _generateImplementationFile
my $implementationClassName = _implementationClassName($idlType);
my $filename = $className . ".cpp";
- push(@contentsPrefix, _fileHeaderString($filename));
+ push(@contentsPrefix, $self->_licenseBlock());
my $classRefGetter = $self->_classRefGetter($idlType);
my $parentClassName = _parentClassName($interface);