bug 795025 part 0 - update the genUnicodePropertyData tool for rearranged harfbuzz headers. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Tue, 09 Oct 2012 10:24:33 +0100
changeset 118378 3fb90364f6d5c8cf1c826125c78056dfe4d42356
parent 118377 55585f89f069054b65fc464d8ba144cdb45459d3
child 118379 2c7c166cc00291ae55cdb6e6f82353b94e709f27
push id273
push userlsblakk@mozilla.com
push dateThu, 14 Feb 2013 23:19:38 +0000
treeherdermozilla-release@c5e807a3f8b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs795025
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 795025 part 0 - update the genUnicodePropertyData tool for rearranged harfbuzz headers. r=smontagu
intl/unicharutil/tools/genUnicodePropertyData.pl
--- a/intl/unicharutil/tools/genUnicodePropertyData.pl
+++ b/intl/unicharutil/tools/genUnicodePropertyData.pl
@@ -49,20 +49,20 @@
 use strict;
 use List::Util qw(first);
 
 if ($#ARGV != 1) {
     print <<__EOT;
 # Run this tool using a command line of the form
 #
 #     perl genUnicodePropertyData.pl \
-#             /path/to/hb-common.h   \
+#             /path/to/harfbuzz/src  \
 #             /path/to/UCD-directory
 #
-# where hb-common.h is currently found in the gfx/harfbuzz/src directory,
+# where harfbuzz/src is the directory containing harfbuzz .cc and .hh files,
 # and UCD-directory is a directory containing the current Unicode Character
 # Database files (UnicodeData.txt, etc), available from
 # http://www.unicode.org/Public/UNIDATA/
 #
 # This will generate (or overwrite!) the files
 #
 #     nsUnicodePropertyData.cpp
 #     nsUnicodeScriptCodes.h
@@ -202,33 +202,43 @@ my %scriptCode = (
 );
 
 my $sc = -1;
 my $cc = -1;
 my %catCode;
 my @scriptCodeToTag;
 my @scriptCodeToName;
 
-open FH, "< $ARGV[0]" or die "can't open $ARGV[0] (should be header file hb-common.h)\n";
-while (<FH>) {
-    if (m/HB_SCRIPT_([A-Z_]+)\s*=\s*HB_TAG\s*\(('.','.','.','.')\)\s*,/) {
-        unless (exists $scriptCode{$1}) {
-            warn "unknown script name $1 found in hb-common.h\n";
-            next;
+sub readHarfBuzzHeader
+{
+    my $file = shift;
+    open FH, "< $ARGV[0]/$file" or die "can't open harfbuzz header $ARGV[0]/$file\n";
+    while (<FH>) {
+        if (m/HB_SCRIPT_([A-Z_]+)\s*=\s*HB_TAG\s*\(('.','.','.','.')\)\s*,/) {
+            unless (exists $scriptCode{$1}) {
+                warn "unknown script name $1 found in $file\n";
+                next;
+            }
+            $sc = $scriptCode{$1};
+            $scriptCodeToTag[$sc] = $2;
+            $scriptCodeToName[$sc] = $1;
         }
-        $sc = $scriptCode{$1};
-        $scriptCodeToTag[$sc] = $2;
-        $scriptCodeToName[$sc] = $1;
+        if (m/HB_UNICODE_GENERAL_CATEGORY_([A-Z_]+)/) {
+            $cc++;
+            $catCode{$1} = $cc;
+        }
     }
-    if (m/HB_UNICODE_GENERAL_CATEGORY_([A-Z_]+)/) {
-        $cc++;
-        $catCode{$1} = $cc;
-    }
+    close FH;
 }
-close FH;
+
+&readHarfBuzzHeader("hb-common.h");
+&readHarfBuzzHeader("hb-unicode.h");
+
+die "didn't find HarfBuzz script codes\n" if $sc == -1;
+die "didn't find HarfBuzz category codes\n" if $cc == -1;
 
 my %xidmodCode = (
 'inclusion'         => 0,
 'recommended'       => 1,
 'default-ignorable' => 2,
 'historic'          => 3,
 'limited-use'       => 4,
 'not-NFKC'          => 5,
@@ -776,17 +786,18 @@ print DATA_TABLES <<__END;
 __END
 
 close DATA_TABLES;
 
 print HEADER "enum {\n";
 for (my $i = 0; $i < scalar @scriptCodeToName; ++$i) {
   print HEADER "  MOZ_SCRIPT_", $scriptCodeToName[$i], " = ", $i, ",\n";
 }
-print HEADER "  MOZ_SCRIPT_INVALID = -1\n";
+print HEADER "\n  MOZ_NUM_SCRIPT_CODES = ", scalar @scriptCodeToName, ",\n";
+print HEADER "\n  MOZ_SCRIPT_INVALID = -1\n";
 print HEADER "};\n\n";
 
 print HEADER <<__END;
 #endif
 /*
  * * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * *
  */
 __END