summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/create-html-entity-table
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/Scripts/create-html-entity-table')
-rwxr-xr-xWebKitTools/Scripts/create-html-entity-table183
1 files changed, 0 insertions, 183 deletions
diff --git a/WebKitTools/Scripts/create-html-entity-table b/WebKitTools/Scripts/create-html-entity-table
deleted file mode 100755
index c408207..0000000
--- a/WebKitTools/Scripts/create-html-entity-table
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * 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.
-# * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "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 THE COPYRIGHT
-# OWNER 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 os.path
-import string
-import sys
-
-# Hack sys.path to avoid executing webkitpy __init__.py code which may
-# use Python 2.5 features. This code needs to run on Python 2.3 in order
-# to support Mac OS X Tiger.
-scripts_directory = sys.path[0]
-sys.path.append("%s/webkitpy/thirdparty" % scripts_directory)
-
-import simplejson
-
-
-def convert_entity_to_cpp_name(entity):
- postfix = "EntityName"
- if entity[-1] == ";":
- return "%sSemicolon%s" % (entity[:-1], postfix)
- return "%s%s" % (entity, postfix)
-
-
-def convert_entity_to_uchar_array(entity):
- return "{'%s'}" % "', '".join(entity)
-
-
-def convert_value_to_int(value):
- assert(value[0] == "U")
- assert(value[1] == "+")
- return "0x" + value[2:]
-
-
-def offset_table_entry(offset):
- return " &staticEntityTable[%s]," % offset
-
-
-program_name = os.path.basename(__file__)
-if len(sys.argv) < 4 or sys.argv[1] != "-o":
- print >> sys.stderr, "Usage: %s -o OUTPUT_FILE INPUT_FILE" % program_name
- exit(1)
-
-output_path = sys.argv[2]
-input_path = sys.argv[3]
-
-html_entity_names_file = open(input_path)
-entries = simplejson.load(html_entity_names_file)
-html_entity_names_file.close()
-
-entries.sort(lambda a, b: cmp(a['entity'], b['entity']))
-entity_count = len(entries)
-
-output_file = open(output_path, "w")
-
-print >> output_file, """/*
- * Copyright (C) 2010 Google, Inc. All Rights Reserved.
- *
- * 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 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 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 FILE IS GENERATED BY WebKitTools/Scripts/create-html-entity-table
-// DO NOT EDIT (unless you are a ninja)!
-
-#include "config.h"
-#include "HTMLEntityTable.h"
-
-namespace WebCore {
-
-namespace {
-"""
-
-for entry in entries:
- print >> output_file, "const UChar %sEntityName[] = %s;" % (
- convert_entity_to_cpp_name(entry["entity"]),
- convert_entity_to_uchar_array(entry["entity"]))
-
-print >> output_file, """
-HTMLEntityTableEntry staticEntityTable[%s] = {""" % entity_count
-
-index = {}
-offset = 0
-for entry in entries:
- letter = entry["entity"][0]
- if not index.get(letter):
- index[letter] = offset
- print >> output_file, ' { %sEntityName, %s, %s },' % (
- convert_entity_to_cpp_name(entry["entity"]),
- len(entry["entity"]),
- convert_value_to_int(entry["value"]))
- offset += 1
-
-print >> output_file, """};
-"""
-
-print >> output_file, "const HTMLEntityTableEntry* uppercaseOffset[] = {"
-for letter in string.uppercase:
- print >> output_file, offset_table_entry(index[letter])
-print >> output_file, offset_table_entry(index['a'])
-print >> output_file, """};
-
-const HTMLEntityTableEntry* lowercaseOffset[] = {"""
-for letter in string.lowercase:
- print >> output_file, offset_table_entry(index[letter])
-print >> output_file, offset_table_entry(entity_count)
-print >> output_file, """};
-
-}
-
-const HTMLEntityTableEntry* HTMLEntityTable::firstEntryStartingWith(UChar c)
-{
- if (c >= 'A' && c <= 'Z')
- return uppercaseOffset[c - 'A'];
- if (c >= 'a' && c <= 'z')
- return lowercaseOffset[c - 'a'];
- return 0;
-}
-
-const HTMLEntityTableEntry* HTMLEntityTable::lastEntryStartingWith(UChar c)
-{
- if (c >= 'A' && c <= 'Z')
- return uppercaseOffset[c - 'A' + 1] - 1;
- if (c >= 'a' && c <= 'z')
- return lowercaseOffset[c - 'a' + 1] - 1;
- return 0;
-}
-
-const HTMLEntityTableEntry* HTMLEntityTable::firstEntry()
-{
- return &staticEntityTable[0];
-}
-
-const HTMLEntityTableEntry* HTMLEntityTable::lastEntry()
-{
- return &staticEntityTable[%s - 1];
-}
-
-}
-""" % entity_count