OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [libjava/] [scripts/] [MakeCharTables.java] - Diff between revs 762 and 783

Only display areas with differences | Details | Blame | View Log

Rev 762 Rev 783
/* MakeCharTables.java - converts gnu.java.lang.CharData into
/* MakeCharTables.java - converts gnu.java.lang.CharData into
                         include/java-chartables.h
                         include/java-chartables.h
   Copyright (C) 2002 Free Software Foundation, Inc.
   Copyright (C) 2002 Free Software Foundation, Inc.
 
 
This file is part of GNU Classpath.
This file is part of GNU Classpath.
 
 
GNU Classpath is free software; you can redistribute it and/or modify
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
the Free Software Foundation; either version 2, or (at your option)
any later version.
any later version.
 
 
GNU Classpath is distributed in the hope that it will be useful, but
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
02110-1301 USA.
 
 
Linking this library statically or dynamically with other modules is
Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
conditions of the GNU General Public License cover the whole
combination.
combination.
 
 
As a special exception, the copyright holders of this library give you
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */
exception statement from your version. */
 
 
import gnu.java.lang.CharData;
import gnu.java.lang.CharData;
 
 
public class MakeCharTables implements CharData
public class MakeCharTables implements CharData
{
{
  public static void main(String[] args)
  public static void main(String[] args)
  {
  {
    System.out.println("/* java-chartables.h -- Character tables for java.lang.Character -*- c++ -*-\n"
    System.out.println("/* java-chartables.h -- Character tables for java.lang.Character -*- c++ -*-\n"
                       + "   Copyright (C) 2002 Free Software Foundation, Inc.\n"
                       + "   Copyright (C) 2002 Free Software Foundation, Inc.\n"
                       + "   *** This file is generated by scripts/MakeCharTables.java ***\n"
                       + "   *** This file is generated by scripts/MakeCharTables.java ***\n"
                       + "\n"
                       + "\n"
                       + "This file is part of GNU Classpath.\n"
                       + "This file is part of GNU Classpath.\n"
                       + "\n"
                       + "\n"
                       + "GNU Classpath is free software; you can redistribute it and/or modify\n"
                       + "GNU Classpath is free software; you can redistribute it and/or modify\n"
                       + "it under the terms of the GNU General Public License as published by\n"
                       + "it under the terms of the GNU General Public License as published by\n"
                       + "the Free Software Foundation; either version 2, or (at your option)\n"
                       + "the Free Software Foundation; either version 2, or (at your option)\n"
                       + "any later version.\n"
                       + "any later version.\n"
                       + "\n"
                       + "\n"
                       + "GNU Classpath is distributed in the hope that it will be useful, but\n"
                       + "GNU Classpath is distributed in the hope that it will be useful, but\n"
                       + "WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                       + "WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                       + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
                       + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
                       + "General Public License for more details.\n"
                       + "General Public License for more details.\n"
                       + "\n"
                       + "\n"
                       + "You should have received a copy of the GNU General Public License\n"
                       + "You should have received a copy of the GNU General Public License\n"
                       + "along with GNU Classpath; see the file COPYING.  If not, write to the\n"
                       + "along with GNU Classpath; see the file COPYING.  If not, write to the\n"
                       + "Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
                       + "Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
                       + "02110-1301 USA.\n"
                       + "02110-1301 USA.\n"
                       + "\n"
                       + "\n"
                       + "Linking this library statically or dynamically with other modules is\n"
                       + "Linking this library statically or dynamically with other modules is\n"
                       + "making a combined work based on this library.  Thus, the terms and\n"
                       + "making a combined work based on this library.  Thus, the terms and\n"
                       + "conditions of the GNU General Public License cover the whole\n"
                       + "conditions of the GNU General Public License cover the whole\n"
                       + "combination.\n"
                       + "combination.\n"
                       + "\n"
                       + "\n"
                       + "As a special exception, the copyright holders of this library give you\n"
                       + "As a special exception, the copyright holders of this library give you\n"
                       + "permission to link this library with independent modules to produce an\n"
                       + "permission to link this library with independent modules to produce an\n"
                       + "executable, regardless of the license terms of these independent\n"
                       + "executable, regardless of the license terms of these independent\n"
                       + "modules, and to copy and distribute the resulting executable under\n"
                       + "modules, and to copy and distribute the resulting executable under\n"
                       + "terms of your choice, provided that you also meet, for each linked\n"
                       + "terms of your choice, provided that you also meet, for each linked\n"
                       + "independent module, the terms and conditions of the license of that\n"
                       + "independent module, the terms and conditions of the license of that\n"
                       + "module.  An independent module is a module which is not derived from\n"
                       + "module.  An independent module is a module which is not derived from\n"
                       + "or based on this library.  If you modify this library, you may extend\n"
                       + "or based on this library.  If you modify this library, you may extend\n"
                       + "this exception to your version of the library, but you are not\n"
                       + "this exception to your version of the library, but you are not\n"
                       + "obligated to do so.  If you do not wish to do so, delete this\n"
                       + "obligated to do so.  If you do not wish to do so, delete this\n"
                       + "exception statement from your version. */\n"
                       + "exception statement from your version. */\n"
                       + "\n"
                       + "\n"
                       + "#ifndef __JAVA_CHARTABLES_H__\n"
                       + "#ifndef __JAVA_CHARTABLES_H__\n"
                       + "#define __JAVA_CHARTABLES_H__\n"
                       + "#define __JAVA_CHARTABLES_H__\n"
                       + "\n"
                       + "\n"
                       + "// These tables are automatically generated by scripts/MakeCharTables.java.\n"
                       + "// These tables are automatically generated by scripts/MakeCharTables.java.\n"
                       + "// This is in turn parsing gnu.java.lang.CharData, which is generated by\n"
                       + "// This is in turn parsing gnu.java.lang.CharData, which is generated by\n"
                       + "// scripts/unicode-muncher.pl.  The Unicode data comes from\n"
                       + "// scripts/unicode-muncher.pl.  The Unicode data comes from\n"
                       + "// www.unicode.org; this header is based on\n"
                       + "// www.unicode.org; this header is based on\n"
                       + "// " + SOURCE + ". JDK 1.4 uses Unicode version 3.0.0.\n"
                       + "// " + SOURCE + ". JDK 1.4 uses Unicode version 3.0.0.\n"
                       + "// DO NOT EDIT the tables.  Instead, fix the upstream scripts and run\n"
                       + "// DO NOT EDIT the tables.  Instead, fix the upstream scripts and run\n"
                       + "// them again.\n"
                       + "// them again.\n"
                       + "\n"
                       + "\n"
                       + "// The data is stored in C style arrays of the appropriate CNI types, to\n"
                       + "// The data is stored in C style arrays of the appropriate CNI types, to\n"
                       + "// guarantee that the data is constant and non-relocatable.  The field\n"
                       + "// guarantee that the data is constant and non-relocatable.  The field\n"
                       + "// <code>blocks</code> stores the offset of a block of 2<supSHIFT</sup>\n"
                       + "// <code>blocks</code> stores the offset of a block of 2<supSHIFT</sup>\n"
                       + "// characters within <code>data</code>. The data field, in turn, stores\n"
                       + "// characters within <code>data</code>. The data field, in turn, stores\n"
                       + "// information about each character in the low order bits, and an offset\n"
                       + "// information about each character in the low order bits, and an offset\n"
                       + "// into the attribute tables <code>upper</code>, <code>lower</code>,\n"
                       + "// into the attribute tables <code>upper</code>, <code>lower</code>,\n"
                       + "// <code>numValue</code>, and <code>direction</code>.  Notice that the\n"
                       + "// <code>numValue</code>, and <code>direction</code>.  Notice that the\n"
                       + "// attribute tables are much smaller than 0xffff entries; as many characters\n"
                       + "// attribute tables are much smaller than 0xffff entries; as many characters\n"
                       + "// in Unicode share common attributes.  Finally, there is a listing for\n"
                       + "// in Unicode share common attributes.  Finally, there is a listing for\n"
                       + "// <code>title</code> exceptions (most characters just have the same title\n"
                       + "// <code>title</code> exceptions (most characters just have the same title\n"
                       + "// case as upper case).\n"
                       + "// case as upper case).\n"
                       + "\n"
                       + "\n"
                       + "// This file should only be included by natCharacter.cc\n"
                       + "// This file should only be included by natCharacter.cc\n"
                       + "\n"
                       + "\n"
                       + "/**\n"
                       + "/**\n"
                       + " * The character shift amount to look up the block offset. In other words,\n"
                       + " * The character shift amount to look up the block offset. In other words,\n"
                       + " * <code>(char) (blocks[ch >> SHIFT] + ch)</code> is the index where\n"
                       + " * <code>(char) (blocks[ch >> SHIFT] + ch)</code> is the index where\n"
                       + " * <code>ch</code> is described in <code>data</code>.\n"
                       + " * <code>ch</code> is described in <code>data</code>.\n"
                       + " */\n"
                       + " */\n"
                       + "#define SHIFT " + SHIFT);
                       + "#define SHIFT " + SHIFT);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * The mapping of character blocks to their location in <code>data</code>.\n"
                  + " * The mapping of character blocks to their location in <code>data</code>.\n"
                  + " * Each entry has been adjusted so that a modulo 16 sum with the desired\n"
                  + " * Each entry has been adjusted so that a modulo 16 sum with the desired\n"
                  + " * character gives the actual index into <code>data</code>.\n"
                  + " * character gives the actual index into <code>data</code>.\n"
                  + " */",
                  + " */",
                  char.class, "blocks", BLOCKS);
                  char.class, "blocks", BLOCKS);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * Information about each character.  The low order 5 bits form the\n"
                  + " * Information about each character.  The low order 5 bits form the\n"
                  + " * character type, the next bit is a flag for non-breaking spaces, and the\n"
                  + " * character type, the next bit is a flag for non-breaking spaces, and the\n"
                  + " * next bit is a flag for mirrored directionality.  The high order 9 bits\n"
                  + " * next bit is a flag for mirrored directionality.  The high order 9 bits\n"
                  + " * form the offset into the attribute tables.  Note that this limits the\n"
                  + " * form the offset into the attribute tables.  Note that this limits the\n"
                  + " * number of unique character attributes to 512, which is not a problem\n"
                  + " * number of unique character attributes to 512, which is not a problem\n"
                  + " * as of Unicode version 3.2.0, but may soon become one.\n"
                  + " * as of Unicode version 3.2.0, but may soon become one.\n"
                  + " */",
                  + " */",
                  char.class, "data", DATA);
                  char.class, "data", DATA);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * This is the attribute table for computing the numeric value of a\n"
                  + " * This is the attribute table for computing the numeric value of a\n"
                  + " * character.  The value is -1 if Unicode does not define a value, -2\n"
                  + " * character.  The value is -1 if Unicode does not define a value, -2\n"
                  + " * if the value is not a positive integer, otherwise it is the value.\n"
                  + " * if the value is not a positive integer, otherwise it is the value.\n"
                  + " */",
                  + " */",
                  short.class, "numValue", NUM_VALUE);
                  short.class, "numValue", NUM_VALUE);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * This is the attribute table for computing the uppercase representation\n"
                  + " * This is the attribute table for computing the uppercase representation\n"
                  + " * of a character.  The value is the difference between the character and\n"
                  + " * of a character.  The value is the difference between the character and\n"
                  + " * its uppercase version.\n"
                  + " * its uppercase version.\n"
                  + " */",
                  + " */",
                  short.class, "upper", UPPER);
                  short.class, "upper", UPPER);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * This is the attribute table for computing the lowercase representation\n"
                  + " * This is the attribute table for computing the lowercase representation\n"
                  + " * of a character.  The value is the difference between the character and\n"
                  + " * of a character.  The value is the difference between the character and\n"
                  + " * its lowercase version.\n"
                  + " * its lowercase version.\n"
                  + " */",
                  + " */",
                  short.class, "lower", LOWER);
                  short.class, "lower", LOWER);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * This is the attribute table for computing the directionality class\n"
                  + " * This is the attribute table for computing the directionality class\n"
                  + " * of a character.  At present, the value is in the range 0 - 18 if the\n"
                  + " * of a character.  At present, the value is in the range 0 - 18 if the\n"
                  + " * character has a direction, otherwise it is -1.\n"
                  + " * character has a direction, otherwise it is -1.\n"
                  + " */",
                  + " */",
                  byte.class, "direction", DIRECTION);
                  byte.class, "direction", DIRECTION);
 
 
    convertString("/**\n"
    convertString("/**\n"
                  + " * This is the listing of titlecase special cases (all other character\n"
                  + " * This is the listing of titlecase special cases (all other character\n"
                  + " * can use <code>upper</code> to determine their titlecase).  The listing\n"
                  + " * can use <code>upper</code> to determine their titlecase).  The listing\n"
                  + " * is a sequence of character pairs; converting the first character of the\n"
                  + " * is a sequence of character pairs; converting the first character of the\n"
                  + " * pair to titlecase produces the second character.\n"
                  + " * pair to titlecase produces the second character.\n"
                  + " */",
                  + " */",
                  char.class, "title", TITLE);
                  char.class, "title", TITLE);
 
 
    System.out.println();
    System.out.println();
    System.out.println("#endif /* __JAVA_CHARTABLES_H__ */");
    System.out.println("#endif /* __JAVA_CHARTABLES_H__ */");
  }
  }
 
 
  private static void convertString(String header, Class type,
  private static void convertString(String header, Class type,
                                    String name, String field)
                                    String name, String field)
  {
  {
    System.out.println();
    System.out.println();
    System.out.println(header);
    System.out.println(header);
    System.out.println("static const j" + type.getName() + " " + name
    System.out.println("static const j" + type.getName() + " " + name
                       + "[] = {");
                       + "[] = {");
    char[] data = field.toCharArray();
    char[] data = field.toCharArray();
    int wrap;
    int wrap;
    if (type == char.class)
    if (type == char.class)
      wrap = 10;
      wrap = 10;
    else if (type == byte.class)
    else if (type == byte.class)
      wrap = 21;
      wrap = 21;
    else if (type == short.class)
    else if (type == short.class)
      wrap = 13;
      wrap = 13;
    else
    else
      throw new Error("Unexpeced type");
      throw new Error("Unexpeced type");
    for (int i = 0; i < data.length; i += wrap)
    for (int i = 0; i < data.length; i += wrap)
      {
      {
        System.out.print("   ");
        System.out.print("   ");
        for (int j = 0; j < wrap; j++)
        for (int j = 0; j < wrap; j++)
          {
          {
            if (i + j >= data.length)
            if (i + j >= data.length)
              break;
              break;
            System.out.print(" ");
            System.out.print(" ");
            if (type == char.class)
            if (type == char.class)
              System.out.print((int) data[i + j]);
              System.out.print((int) data[i + j]);
            else if (type == byte.class)
            else if (type == byte.class)
              System.out.print((byte) data[i + j]);
              System.out.print((byte) data[i + j]);
            else if (type == short.class)
            else if (type == short.class)
              System.out.print((short) data[i + j]);
              System.out.print((short) data[i + j]);
            System.out.print(",");
            System.out.print(",");
          }
          }
        System.out.println();
        System.out.println();
      }
      }
    System.out.println("  };\n"
    System.out.println("  };\n"
                       + "/** Length of " + name + ". */\n"
                       + "/** Length of " + name + ". */\n"
                       + "static const int " + name + "_length = "
                       + "static const int " + name + "_length = "
                       + data.length + ";");
                       + data.length + ";");
  }
  }
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.