Reviewed by Maciej. Landed by rwlbuis.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Aug 2006 18:53:25 +0000 (18:53 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Aug 2006 18:53:25 +0000 (18:53 +0000)
        Fixes: http://bugzilla.opendarwin.org/show_bug.cgi?id=10463
        WTF Changes needed for Qt platform code.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15937 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/wtf/Platform.h
JavaScriptCore/wtf/unicode/UnicodeDecomposition.h [new file with mode: 0644]
JavaScriptCore/wtf/unicode/UnicodeDirection.h [new file with mode: 0644]
JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.cpp [new file with mode: 0644]
JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h

index 8f08024..277ff1d 100644 (file)
@@ -1,5 +1,31 @@
 2006-08-17  Nikolas Zimmermann  <zimmermann@kde.org>
 
+        Reviewed by Maciej. Landed by rwlbuis.
+
+        Fixes: http://bugzilla.opendarwin.org/show_bug.cgi?id=10463
+        WTF Changes needed for Qt platform code.
+
+        * wtf/Platform.h:
+        * wtf/unicode/UnicodeDecomposition.h: Added.
+        (WTF::Unicode::):
+        * wtf/unicode/UnicodeDirection.h: Added.
+        (WTF::Unicode::):
+        * wtf/unicode/qt4/UnicodeQt4.cpp: Added.
+        (WTF::Unicode::direction):
+        (WTF::Unicode::category):
+        (WTF::Unicode::decomposition):
+        * wtf/unicode/qt4/UnicodeQt4.h:
+        (WTF::Unicode::toLower):
+        (WTF::Unicode::toUpper):
+        (WTF::Unicode::isPrintableChar):
+        (WTF::Unicode::isSpace):
+        (WTF::Unicode::isPunct):
+        (WTF::Unicode::isDigit):
+        (WTF::Unicode::mirroredChar):
+        (WTF::Unicode::compare):
+
+2006-08-17  Nikolas Zimmermann  <zimmermann@kde.org>
+
         Reviewed by Eric. Landed by rwlbuis.
 
         Fixes: http://bugzilla.opendarwin.org/show_bug.cgi?id=10464
index 6b975dc..4db3c22 100644 (file)
 
 /* Operating environments */
 
-/* I made the BUILDING_KDE__ macro up for the KDE build system to define */
-
-/* PLATFORM(KDE) */
+/* PLATFORM(QT) */
 /* PLATFORM(MAC) */
 /* PLATFORM(WIN) */
-#if defined(BUILDING_KDE__)
-#define KXMLCORE_PLATFORM_KDE 1
+#if defined(BUILDING_QT__)
+#define KXMLCORE_PLATFORM_QT 1
 #elif PLATFORM(DARWIN)
 #define KXMLCORE_PLATFORM_MAC 1
 #elif PLATFORM(WIN_OS)
@@ -80,7 +78,6 @@
 #define KXMLCORE_PLATFORM_GDK 1
 #endif
 
-
 /* CPU */
 
 /* PLATFORM(PPC) */
diff --git a/JavaScriptCore/wtf/unicode/UnicodeDecomposition.h b/JavaScriptCore/wtf/unicode/UnicodeDecomposition.h
new file mode 100644 (file)
index 0000000..15041e5
--- /dev/null
@@ -0,0 +1,104 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_UNICODE_DECOMPOSITION_H
+#define KJS_UNICODE_DECOMPOSITION_H
+
+namespace WTF {
+  namespace Unicode {
+    enum Decomposition {
+      None = 0,
+      Canonical = 0x00000001,
+      Font = 0x00000002,
+      NoBreak = 0x00000004,
+      Initial = 0x00000008,
+      Medial = 0x00000010,
+      Final = 0x00000020,
+      Isolated = 0x00000040,
+      Circle = 0x00000080,
+      Super = 0x00000100,
+      Sub = 0x00000200,
+      Vertical = 0x00000400,
+      Wide = 0x00000800,
+      Narrow = 0x00001000,
+      Small = 0x00002000,
+      Square = 0x00004000,
+      Compat = 0x00008000,
+      Fraction = 0x00010000
+    };
+  }
+}
+
+#endif
+// vim: ts=2 sw=2 et
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_UNICODE_DECOMPOSITION_H
+#define KJS_UNICODE_DECOMPOSITION_H
+
+namespace WTF {
+  namespace Unicode {
+    enum Decomposition {
+      None = 0,
+      Canonical = 0x00000001,
+      Font = 0x00000002,
+      NoBreak = 0x00000004,
+      Initial = 0x00000008,
+      Medial = 0x00000010,
+      Final = 0x00000020,
+      Isolated = 0x00000040,
+      Circle = 0x00000080,
+      Super = 0x00000100,
+      Sub = 0x00000200,
+      Vertical = 0x00000400,
+      Wide = 0x00000800,
+      Narrow = 0x00001000,
+      Small = 0x00002000,
+      Square = 0x00004000,
+      Compat = 0x00008000,
+      Fraction = 0x00010000
+    };
+  }
+}
+
+#endif
+// vim: ts=2 sw=2 et
diff --git a/JavaScriptCore/wtf/unicode/UnicodeDirection.h b/JavaScriptCore/wtf/unicode/UnicodeDirection.h
new file mode 100644 (file)
index 0000000..68efb7e
--- /dev/null
@@ -0,0 +1,106 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_UNICODE_DIRECTION_H
+#define KJS_UNICODE_DIRECTION_H
+
+namespace WTF {
+  namespace Unicode {
+    enum Direction {
+      LeftToRight = 0,
+      RightToLeft = 0x00000001,
+      EuropeanNumber = 0x00000002,
+      EuropeanNumberSeparator = 0x00000004,
+      EuropeanNumberTerminator = 0x00000008,
+      ArabicNumber = 0x00000010,
+      CommonNumberSeparator = 0x00000020,
+      BlockSeparator = 0x00000040,
+      SegmentSeparator = 0x00000080,
+      WhiteSpaceNeutral = 0x00000100,
+      OtherNeutral = 0x00000200,
+      LeftToRightEmbedding = 0x00000400,
+      LeftToRightOverride = 0x00000800,
+      RightToLeftArabic = 0x00001000,
+      RightToLeftEmbedding = 0x00002000,
+      RightToLeftOverride = 0x00004000,
+      PopDirectionalFormat = 0x00008000,
+      NonSpacingMark = 0x00010000,
+      BoundaryNeutral = 0x00020000
+    };
+  }
+}
+
+#endif
+// vim: ts=2 sw=2 et
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_UNICODE_DIRECTION_H
+#define KJS_UNICODE_DIRECTION_H
+
+namespace WTF {
+  namespace Unicode {
+    enum Direction {
+      LeftToRight = 0,
+      RightToLeft = 0x00000001,
+      EuropeanNumber = 0x00000002,
+      EuropeanNumberSeparator = 0x00000004,
+      EuropeanNumberTerminator = 0x00000008,
+      ArabicNumber = 0x00000010,
+      CommonNumberSeparator = 0x00000020,
+      BlockSeparator = 0x00000040,
+      SegmentSeparator = 0x00000080,
+      WhiteSpaceNeutral = 0x00000100,
+      OtherNeutral = 0x00000200,
+      LeftToRightEmbedding = 0x00000400,
+      LeftToRightOverride = 0x00000800,
+      RightToLeftArabic = 0x00001000,
+      RightToLeftEmbedding = 0x00002000,
+      RightToLeftOverride = 0x00004000,
+      PopDirectionalFormat = 0x00008000,
+      NonSpacingMark = 0x00010000,
+      BoundaryNeutral = 0x00020000
+    };
+  }
+}
+
+#endif
+// vim: ts=2 sw=2 et
diff --git a/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.cpp b/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.cpp
new file mode 100644 (file)
index 0000000..694bda9
--- /dev/null
@@ -0,0 +1,394 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "UnicodeQt4.h"
+
+using namespace WTF::Unicode;
+
+Direction WTF::Unicode::direction(int c)
+{
+  // FIXME: implement support for non-BMP code points
+  if ((c & 0xffff0000) != 0)
+    return LeftToRight;
+
+  switch (QChar((unsigned short)c).direction()) {
+    case QChar::DirL:
+      return LeftToRight;
+    case QChar::DirR:
+      return RightToLeft;
+    case QChar::DirNSM:
+      return NonSpacingMark;
+    case QChar::DirBN:
+      return BoundaryNeutral;
+    case QChar::DirEN:
+      return EuropeanNumber;
+    case QChar::DirES:
+      return EuropeanNumberSeparator;
+    case QChar::DirET:
+      return EuropeanNumberTerminator;
+    case QChar::DirAN:
+      return ArabicNumber;
+    case QChar::DirCS:
+      return CommonNumberSeparator;
+    case QChar::DirB:
+      return BlockSeparator;
+    case QChar::DirS:
+      return SegmentSeparator;
+    case QChar::DirWS:
+      return WhiteSpaceNeutral;
+    case QChar::DirON:
+      return OtherNeutral;
+    case QChar::DirLRE:
+      return LeftToRightEmbedding;
+    case QChar::DirLRO:
+      return LeftToRightOverride;
+    case QChar::DirAL:
+      return RightToLeftArabic;
+    case QChar::DirRLE:
+      return RightToLeftEmbedding;
+    case QChar::DirRLO:
+      return RightToLeftOverride;
+    case QChar::DirPDF:
+      return PopDirectionalFormat;
+    default:
+      return LeftToRight;
+  }
+}
+
+CharCategory WTF::Unicode::category(int c)
+{
+  // FIXME: implement support for non-BMP code points
+  if ((c & 0xffff0000) != 0)
+    return NoCategory;
+
+  switch (QChar((unsigned short)c).category()) {
+    case QChar::Mark_NonSpacing:
+      return Mark_NonSpacing;
+    case QChar::Mark_SpacingCombining:
+      return Mark_SpacingCombining;
+    case QChar::Mark_Enclosing:
+      return Mark_Enclosing;
+    case QChar::Number_DecimalDigit:
+      return Number_DecimalDigit;
+    case QChar::Number_Letter:
+      return Number_Letter;
+    case QChar::Number_Other:
+      return Number_Other;
+    case QChar::Separator_Space:
+      return Separator_Space;
+    case QChar::Separator_Line:
+      return Separator_Line;
+    case QChar::Separator_Paragraph:
+      return Separator_Paragraph;
+    case QChar::Other_Control:
+      return Other_Control;
+    case QChar::Other_Format:
+      return Other_Format;
+    case QChar::Other_Surrogate:
+      return Other_Surrogate;
+    case QChar::Other_PrivateUse:
+      return Other_PrivateUse;
+    case QChar::Other_NotAssigned:
+      return Other_NotAssigned;
+    case QChar::Letter_Uppercase:
+      return Letter_Uppercase;
+    case QChar::Letter_Lowercase:
+      return Letter_Lowercase;
+    case QChar::Letter_Titlecase:
+      return Letter_Titlecase;
+    case QChar::Letter_Modifier:
+      return Letter_Modifier;
+    case QChar::Letter_Other:
+      return Letter_Other;
+    case QChar::Punctuation_Connector:
+      return Punctuation_Connector;
+    case QChar::Punctuation_Dash:
+      return Punctuation_Dash;
+    case QChar::Punctuation_Open:
+      return Punctuation_Open;
+    case QChar::Punctuation_Close:
+      return Punctuation_Close;
+    case QChar::Punctuation_InitialQuote:
+      return Punctuation_InitialQuote;
+    case QChar::Punctuation_FinalQuote:
+      return Punctuation_FinalQuote;
+    case QChar::Punctuation_Other:
+      return Punctuation_Other;
+    case QChar::Symbol_Math:
+      return Symbol_Math;
+    case QChar::Symbol_Currency:
+      return Symbol_Currency;
+    case QChar::Symbol_Modifier:
+      return Symbol_Modifier;
+    case QChar::Symbol_Other:
+      return Symbol_Other;
+    default:
+      return NoCategory;
+  }
+}
+
+
+Decomposition WTF::Unicode::decomposition(int c)
+{
+  // FIXME: implement support for non-BMP code points
+  if ((c & 0xffff0000) != 0)
+    return None;
+
+  switch (QChar((unsigned short)c).decompositionTag()) {
+    default:
+    case QChar::NoDecomposition:
+      return None;
+    case QChar::Canonical:
+      return Canonical;
+    case QChar::Font:
+      return Font;
+    case QChar::NoBreak:
+      return NoBreak;
+    case QChar::Initial:
+      return Initial;
+    case QChar::Medial:
+      return Medial;
+    case QChar::Final:
+      return Final;
+    case QChar::Isolated:
+      return Isolated;
+    case QChar::Circle:
+      return Circle;
+    case QChar::Super:
+      return Super;
+    case QChar::Sub:
+      return Sub;
+    case QChar::Vertical:
+      return Vertical;
+    case QChar::Wide:
+      return Wide;
+    case QChar::Narrow:
+      return Narrow;
+    case QChar::Small:
+      return Small;
+    case QChar::Square:
+      return Square;
+    case QChar::Compat:
+      return Compat;
+    case QChar::Fraction:
+      return Fraction;
+  }
+}
+
+// vim: ts=2 sw=2 et
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2006 George Staikos <staikos@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "UnicodeQt4.h"
+
+using namespace WTF::Unicode;
+
+Direction WTF::Unicode::direction(int c)
+{
+  // FIXME: implement support for non-BMP code points
+  if ((c & 0xffff0000) != 0)
+    return LeftToRight;
+
+  switch (QChar((unsigned short)c).direction()) {
+    case QChar::DirL:
+      return LeftToRight;
+    case QChar::DirR:
+      return RightToLeft;
+    case QChar::DirNSM:
+      return NonSpacingMark;
+    case QChar::DirBN:
+      return BoundaryNeutral;
+    case QChar::DirEN:
+      return EuropeanNumber;
+    case QChar::DirES:
+      return EuropeanNumberSeparator;
+    case QChar::DirET:
+      return EuropeanNumberTerminator;
+    case QChar::DirAN:
+      return ArabicNumber;
+    case QChar::DirCS:
+      return CommonNumberSeparator;
+    case QChar::DirB:
+      return BlockSeparator;
+    case QChar::DirS:
+      return SegmentSeparator;
+    case QChar::DirWS:
+      return WhiteSpaceNeutral;
+    case QChar::DirON:
+      return OtherNeutral;
+    case QChar::DirLRE:
+      return LeftToRightEmbedding;
+    case QChar::DirLRO:
+      return LeftToRightOverride;
+    case QChar::DirAL:
+      return RightToLeftArabic;
+    case QChar::DirRLE:
+      return RightToLeftEmbedding;
+    case QChar::DirRLO:
+      return RightToLeftOverride;
+    case QChar::DirPDF:
+      return PopDirectionalFormat;
+    default:
+      return LeftToRight;
+  }
+}
+
+CharCategory WTF::Unicode::category(int c)
+{
+  // FIXME: implement support for non-BMP code points
+  if ((c & 0xffff0000) != 0)
+    return NoCategory;
+
+  switch (QChar((unsigned short)c).category()) {
+    case QChar::Mark_NonSpacing:
+      return Mark_NonSpacing;
+    case QChar::Mark_SpacingCombining:
+      return Mark_SpacingCombining;
+    case QChar::Mark_Enclosing:
+      return Mark_Enclosing;
+    case QChar::Number_DecimalDigit:
+      return Number_DecimalDigit;
+    case QChar::Number_Letter:
+      return Number_Letter;
+    case QChar::Number_Other:
+      return Number_Other;
+    case QChar::Separator_Space:
+      return Separator_Space;
+    case QChar::Separator_Line:
+      return Separator_Line;
+    case QChar::Separator_Paragraph:
+      return Separator_Paragraph;
+    case QChar::Other_Control:
+      return Other_Control;
+    case QChar::Other_Format:
+      return Other_Format;
+    case QChar::Other_Surrogate:
+      return Other_Surrogate;
+    case QChar::Other_PrivateUse:
+      return Other_PrivateUse;
+    case QChar::Other_NotAssigned:
+      return Other_NotAssigned;
+    case QChar::Letter_Uppercase:
+      return Letter_Uppercase;
+    case QChar::Letter_Lowercase:
+      return Letter_Lowercase;
+    case QChar::Letter_Titlecase:
+      return Letter_Titlecase;
+    case QChar::Letter_Modifier:
+      return Letter_Modifier;
+    case QChar::Letter_Other:
+      return Letter_Other;
+    case QChar::Punctuation_Connector:
+      return Punctuation_Connector;
+    case QChar::Punctuation_Dash:
+      return Punctuation_Dash;
+    case QChar::Punctuation_Open:
+      return Punctuation_Open;
+    case QChar::Punctuation_Close:
+      return Punctuation_Close;
+    case QChar::Punctuation_InitialQuote:
+      return Punctuation_InitialQuote;
+    case QChar::Punctuation_FinalQuote:
+      return Punctuation_FinalQuote;
+    case QChar::Punctuation_Other:
+      return Punctuation_Other;
+    case QChar::Symbol_Math:
+      return Symbol_Math;
+    case QChar::Symbol_Currency:
+      return Symbol_Currency;
+    case QChar::Symbol_Modifier:
+      return Symbol_Modifier;
+    case QChar::Symbol_Other:
+      return Symbol_Other;
+    default:
+      return NoCategory;
+  }
+}
+
+
+Decomposition WTF::Unicode::decomposition(int c)
+{
+  // FIXME: implement support for non-BMP code points
+  if ((c & 0xffff0000) != 0)
+    return None;
+
+  switch (QChar((unsigned short)c).decompositionTag()) {
+    default:
+    case QChar::NoDecomposition:
+      return None;
+    case QChar::Canonical:
+      return Canonical;
+    case QChar::Font:
+      return Font;
+    case QChar::NoBreak:
+      return NoBreak;
+    case QChar::Initial:
+      return Initial;
+    case QChar::Medial:
+      return Medial;
+    case QChar::Final:
+      return Final;
+    case QChar::Isolated:
+      return Isolated;
+    case QChar::Circle:
+      return Circle;
+    case QChar::Super:
+      return Super;
+    case QChar::Sub:
+      return Sub;
+    case QChar::Vertical:
+      return Vertical;
+    case QChar::Wide:
+      return Wide;
+    case QChar::Narrow:
+      return Narrow;
+    case QChar::Small:
+      return Small;
+    case QChar::Square:
+      return Square;
+    case QChar::Compat:
+      return Compat;
+    case QChar::Fraction:
+      return Fraction;
+  }
+}
+
+// vim: ts=2 sw=2 et
index c51f662..28ff8d9 100644 (file)
 #define KJS_UNICODE_QT4_H
 
 #include <QChar>
+#include <QString>
+
+#include <config.h>
+#include <kjs/ustring.h>
 
 #include "../UnicodeCategory.h"
+#include "../UnicodeDecomposition.h"
+#include "../UnicodeDirection.h"
+
+#include <stdint.h>
 
 namespace WTF {
   namespace Unicode {
@@ -40,6 +48,11 @@ namespace WTF {
       return strLength;
     }
 
+    inline uint16_t toLower(uint16_t ch)
+    {
+      return QChar(ch).toLower().unicode();
+    }
+
     inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
     {
       destIfNeeded = 0;
@@ -50,87 +63,58 @@ namespace WTF {
       return strLength;
     }
 
+    inline uint16_t toUpper(uint16_t ch)
+    {
+      return QChar(ch).toUpper().unicode();
+    }
+
     inline bool isFormatChar(int32_t c)
     {
       return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format;
     }
 
+    inline bool isPrintableChar(int32_t c)
+    {
+      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPrint(); 
+    }
+
     inline bool isSeparatorSpace(int32_t c)
     {
       return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space;
     }
 
-    inline CharCategory category(int32_t c)
+    inline bool isSpace(int32_t c)
+    {
+      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isSpace();
+    }
+
+    inline bool isPunct(int32_t c)
+    {
+      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPunct();
+    }
+
+    inline bool isDigit(int32_t c)
+    {
+      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isDigit();
+    }
+
+    inline uint16_t mirroredChar(uint16_t c)
     {
-      // FIXME: implement support for non-BMP code points
-      if ((c & 0xffff0000) != 0)
-        return NoCategory;
-
-      switch (QChar((unsigned short)c).category()) {
-        case QChar::Mark_NonSpacing:
-          return Mark_NonSpacing;
-        case QChar::Mark_SpacingCombining:
-          return Mark_SpacingCombining;
-        case QChar::Mark_Enclosing:
-          return Mark_Enclosing;
-        case QChar::Number_DecimalDigit:
-          return Number_DecimalDigit;
-        case QChar::Number_Letter:
-          return Number_Letter;
-        case QChar::Number_Other:
-          return Number_Other;
-        case QChar::Separator_Space:
-          return Separator_Space;
-        case QChar::Separator_Line:
-          return Separator_Line;
-        case QChar::Separator_Paragraph:
-          return Separator_Paragraph;
-        case QChar::Other_Control:
-          return Other_Control;
-        case QChar::Other_Format:
-          return Other_Format;
-        case QChar::Other_Surrogate:
-          return Other_Surrogate;
-        case QChar::Other_PrivateUse:
-          return Other_PrivateUse;
-        case QChar::Other_NotAssigned:
-          return Other_NotAssigned;
-        case QChar::Letter_Uppercase:
-          return Letter_Uppercase;
-        case QChar::Letter_Lowercase:
-          return Letter_Lowercase;
-        case QChar::Letter_Titlecase:
-          return Letter_Titlecase;
-        case QChar::Letter_Modifier:
-          return Letter_Modifier;
-        case QChar::Letter_Other:
-          return Letter_Other;
-        case QChar::Punctuation_Connector:
-          return Punctuation_Connector;
-        case QChar::Punctuation_Dash:
-          return Punctuation_Dash;
-        case QChar::Punctuation_Open:
-          return Punctuation_Open;
-        case QChar::Punctuation_Close:
-          return Punctuation_Close;
-        case QChar::Punctuation_InitialQuote:
-          return Punctuation_InitialQuote;
-        case QChar::Punctuation_FinalQuote:
-          return Punctuation_FinalQuote;
-        case QChar::Punctuation_Other:
-          return Punctuation_Other;
-        case QChar::Symbol_Math:
-          return Symbol_Math;
-        case QChar::Symbol_Currency:
-          return Symbol_Currency;
-        case QChar::Symbol_Modifier:
-          return Symbol_Modifier;
-        case QChar::Symbol_Other:
-          return Symbol_Other;
-        default:
-          return NoCategory;
-      }
+      return QChar(c).mirroredChar().unicode();
     }
+
+    inline int compare(const KJS::UChar *a, const KJS::UChar *b, int len, bool caseSensitive = true)
+    {
+      const QString left(reinterpret_cast<const QChar *>(a), len);
+      const QString right(reinterpret_cast<const QChar *>(b), len);
+      return left.compare(right, caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
+    }
+
+    Direction direction(int c);
+
+    CharCategory category(int c);
+
+    Decomposition decomposition(int c);
   }
 }