Index: Source/core/scripts/StaticString.pm |
diff --git a/Source/core/scripts/StaticString.pm b/Source/core/scripts/StaticString.pm |
index 61968fb40617e4bc87959e75730cd23d9fde8a08..894c2418665fa2f1ba305abf6e9c43937f1bcfd8 100644 |
--- a/Source/core/scripts/StaticString.pm |
+++ b/Source/core/scripts/StaticString.pm |
@@ -26,7 +26,7 @@ package StaticString; |
use strict; |
use Hasher; |
-sub GenerateStrings($) |
+sub GenerateStringDecls($) |
{ |
my $stringsRef = shift; |
my %strings = %$stringsRef; |
@@ -36,50 +36,36 @@ sub GenerateStrings($) |
push(@result, "\n"); |
while ( my ($name, $value) = each %strings ) { |
- push(@result, "static const LChar ${name}String8[] = \"${value}\";\n"); |
- } |
- |
- push(@result, "\n"); |
- |
- while ( my ($name, $value) = each %strings ) { |
my $length = length($value); |
- my $hash = Hasher::GenerateHashValue($value); |
push(@result, <<END); |
-static StringImpl::StaticASCIILiteral ${name}Data = { |
- ${name}String8, |
- StringImpl::StaticASCIILiteral::s_initialRefCount, |
- $length, |
- StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift) |
+static struct { |
+ const char header[sizeof(StringImpl)]; |
+ const char data[$length + 1]; |
+} ${name}Data = { |
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
+ "${value}", |
}; |
END |
} |
- push(@result, "\n"); |
- |
- while ( my ($name, $value) = each %strings ) { |
- push(@result, "static StringImpl* ${name}Impl = reinterpret_cast<StringImpl*>(&${name}Data);\n"); |
- } |
- |
- push(@result, "\n"); |
- |
return join "", @result; |
} |
-sub GenerateStringAsserts($) |
+sub GenerateStringImpls($) |
{ |
my $stringsRef = shift; |
my %strings = %$stringsRef; |
my @result = (); |
- push(@result, "#ifndef NDEBUG\n"); |
+ push(@result, "\n"); |
while ( my ($name, $value) = each %strings ) { |
- push(@result, " ${name}Impl->assertHashIsCorrect();\n"); |
+ my $length = length($value); |
+ my $hash = Hasher::GenerateHashValue($value); |
+ push(@result, " StringImpl* ${name}Impl = new ((void*)&${name}Data.header) StringImpl($length, $hash, StringImpl::StaticString);\n"); |
} |
- push(@result, "#endif // NDEBUG\n"); |
- |
push(@result, "\n"); |
return join "", @result; |