Fold hb-language.[ch] into hb-common.[ch]
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 11 Apr 2011 21:55:58 +0000 (17:55 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 11 Apr 2011 21:55:58 +0000 (17:55 -0400)
src/Makefile.am
src/hb-buffer.h
src/hb-common.c
src/hb-common.h
src/hb-language.c [deleted file]
src/hb-language.h [deleted file]
src/hb-ot-tag.h
src/hb.h

index 88aadf5..2fbf278 100644 (file)
@@ -21,7 +21,6 @@ HBSOURCES =  \
        hb-object-private.h \
        hb-open-file-private.hh \
        hb-open-type-private.hh \
-       hb-language.c \
        hb-ot-head-private.hh \
        hb-private.h \
        hb-shape.cc \
@@ -34,7 +33,6 @@ HBHEADERS = \
        hb-buffer.h \
        hb-common.h \
        hb-font.h \
-       hb-language.h \
        hb-shape.h \
        hb-unicode.h \
        $(NULL)
index 0185415..652f80b 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "hb-common.h"
 #include "hb-unicode.h"
-#include "hb-language.h"
 
 HB_BEGIN_DECLS
 
index 90cba4e..c57ba0b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010  Red Hat, Inc.
+ * Copyright (C) 2009,2010  Red Hat, Inc.
  *
  *  This is part of HarfBuzz, a text shaping library.
  *
@@ -29,6 +29,8 @@
 HB_BEGIN_DECLS
 
 
+/* hb_tag_t */
+
 hb_tag_t
 hb_tag_from_string (const char *s)
 {
@@ -47,4 +49,92 @@ hb_tag_from_string (const char *s)
 }
 
 
+/* hb_language_t */
+
+static const char canon_map[256] = {
+   0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,
+   0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,
+   0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,  '-',  0,   0,
+  '0', '1', '2', '3', '4', '5', '6', '7',  '8', '9',  0,   0,   0,   0,   0,   0,
+  '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g',  'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+  'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z',  0,   0,   0,   0,  '-',
+   0,  'a', 'b', 'c', 'd', 'e', 'f', 'g',  'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+  'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z',  0,   0,   0,   0,   0
+};
+
+static hb_bool_t
+lang_equal (const void *v1,
+           const void *v2)
+{
+  const unsigned char *p1 = v1;
+  const unsigned char *p2 = v2;
+
+  while (canon_map[*p1] && canon_map[*p1] == canon_map[*p2])
+    {
+      p1++, p2++;
+    }
+
+  return (canon_map[*p1] == canon_map[*p2]);
+}
+
+#if 0
+static unsigned int
+lang_hash (const void *key)
+{
+  const unsigned char *p = key;
+  unsigned int h = 0;
+  while (canon_map[*p])
+    {
+      h = (h << 5) - h + canon_map[*p];
+      p++;
+    }
+
+  return h;
+}
+#endif
+
+
+hb_language_t
+hb_language_from_string (const char *str)
+{
+  static unsigned int num_langs;
+  static unsigned int num_alloced;
+  static const char **langs;
+  unsigned int i;
+  unsigned char *p;
+
+  /* TODO Use a hash table or something */
+
+  if (!str || !*str)
+    return NULL;
+
+  for (i = 0; i < num_langs; i++)
+    if (lang_equal (str, langs[i]))
+      return langs[i];
+
+  if (unlikely (num_langs == num_alloced)) {
+    unsigned int new_alloced = 2 * (8 + num_alloced);
+    const char **new_langs = realloc (langs, new_alloced * sizeof (langs[0]));
+    if (!new_langs)
+      return NULL;
+    num_alloced = new_alloced;
+    langs = new_langs;
+  }
+
+  langs[i] = strdup (str);
+  for (p = (unsigned char *) langs[i]; *p; p++)
+    *p = canon_map[*p];
+
+  num_langs++;
+
+  return (hb_language_t) langs[i];
+}
+
+const char *
+hb_language_to_string (hb_language_t language)
+{
+  return (const char *) language;
+}
+
+
 HB_END_DECLS
index a5ebc29..606e117 100644 (file)
@@ -53,7 +53,26 @@ typedef unsigned long long uint64_t;
 
 typedef int hb_bool_t;
 
+typedef uint32_t hb_codepoint_t;
+typedef int32_t hb_position_t;
+typedef uint32_t hb_mask_t;
+
+typedef union _hb_var_int_t {
+  uint32_t u32;
+  int32_t i32;
+  uint16_t u16[2];
+  int16_t i16[2];
+  uint8_t u8[4];
+  int8_t i8[4];
+} hb_var_int_t;
+
+typedef void (*hb_destroy_func_t) (void *user_data);
+
+
+/* hb_tag_t */
+
 typedef uint32_t hb_tag_t;
+
 #define HB_TAG(a,b,c,d) ((hb_tag_t)((((uint8_t)(a))<<24)|(((uint8_t)(b))<<16)|(((uint8_t)(c))<<8)|((uint8_t)(d))))
 
 #define HB_TAG_NONE HB_TAG(0,0,0,0)
@@ -61,11 +80,7 @@ typedef uint32_t hb_tag_t;
 hb_tag_t hb_tag_from_string (const char *s);
 
 
-typedef uint32_t hb_codepoint_t;
-typedef int32_t hb_position_t;
-typedef uint32_t hb_mask_t;
-
-typedef void (*hb_destroy_func_t) (void *user_data);
+/* hb_direction_t */
 
 typedef enum _hb_direction_t {
   HB_DIRECTION_INVALID = -1,
@@ -82,14 +97,15 @@ typedef enum _hb_direction_t {
 #define HB_DIRECTION_REVERSE(dir)      ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
 
 
-typedef union _hb_var_int_t {
-  uint32_t u32;
-  int32_t i32;
-  uint16_t u16[2];
-  int16_t i16[2];
-  uint8_t u8[4];
-  int8_t i8[4];
-} hb_var_int_t;
+/* hb_language_t */
+
+typedef const void *hb_language_t;
+
+hb_language_t
+hb_language_from_string (const char *str);
+
+const char *
+hb_language_to_string (hb_language_t language);
 
 
 HB_END_DECLS
diff --git a/src/hb-language.c b/src/hb-language.c
deleted file mode 100644 (file)
index 7c2295a..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2009  Red Hat, Inc.
- *
- *  This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#include "hb-private.h"
-
-#include "hb-language.h"
-
-HB_BEGIN_DECLS
-
-
-static const char canon_map[256] = {
-   0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,  '-',  0,   0,
-  '0', '1', '2', '3', '4', '5', '6', '7',  '8', '9',  0,   0,   0,   0,   0,   0,
-  '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g',  'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
-  'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z',  0,   0,   0,   0,  '-',
-   0,  'a', 'b', 'c', 'd', 'e', 'f', 'g',  'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
-  'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z',  0,   0,   0,   0,   0
-};
-
-static hb_bool_t
-lang_equal (const void *v1,
-           const void *v2)
-{
-  const unsigned char *p1 = v1;
-  const unsigned char *p2 = v2;
-
-  while (canon_map[*p1] && canon_map[*p1] == canon_map[*p2])
-    {
-      p1++, p2++;
-    }
-
-  return (canon_map[*p1] == canon_map[*p2]);
-}
-
-#if 0
-static unsigned int
-lang_hash (const void *key)
-{
-  const unsigned char *p = key;
-  unsigned int h = 0;
-  while (canon_map[*p])
-    {
-      h = (h << 5) - h + canon_map[*p];
-      p++;
-    }
-
-  return h;
-}
-#endif
-
-
-hb_language_t
-hb_language_from_string (const char *str)
-{
-  static unsigned int num_langs;
-  static unsigned int num_alloced;
-  static const char **langs;
-  unsigned int i;
-  unsigned char *p;
-
-  /* TODO Use a hash table or something */
-
-  if (!str || !*str)
-    return NULL;
-
-  for (i = 0; i < num_langs; i++)
-    if (lang_equal (str, langs[i]))
-      return langs[i];
-
-  if (unlikely (num_langs == num_alloced)) {
-    unsigned int new_alloced = 2 * (8 + num_alloced);
-    const char **new_langs = realloc (langs, new_alloced * sizeof (langs[0]));
-    if (!new_langs)
-      return NULL;
-    num_alloced = new_alloced;
-    langs = new_langs;
-  }
-
-  langs[i] = strdup (str);
-  for (p = (unsigned char *) langs[i]; *p; p++)
-    *p = canon_map[*p];
-
-  num_langs++;
-
-  return (hb_language_t) langs[i];
-}
-
-const char *
-hb_language_to_string (hb_language_t language)
-{
-  return (const char *) language;
-}
-
-
-HB_END_DECLS
diff --git a/src/hb-language.h b/src/hb-language.h
deleted file mode 100644 (file)
index d3c91fb..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2009  Red Hat, Inc.
- *
- *  This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_LANGUAGE_H
-#define HB_LANGUAGE_H
-
-#include "hb-common.h"
-
-HB_BEGIN_DECLS
-
-
-typedef const void *hb_language_t;
-
-hb_language_t
-hb_language_from_string (const char *str);
-
-const char *
-hb_language_to_string (hb_language_t language);
-
-
-HB_END_DECLS
-
-#endif /* HB_LANGUAGE_H */
index 1eec69f..4a5e26d 100644 (file)
@@ -28,7 +28,6 @@
 #define HB_OT_TAG_H
 
 #include "hb-common.h"
-#include "hb-language.h"
 
 HB_BEGIN_DECLS
 
index 691adee..e705d65 100644 (file)
--- a/src/hb.h
+++ b/src/hb.h
@@ -31,7 +31,6 @@
 #include "hb-buffer.h"
 #include "hb-common.h"
 #include "hb-font.h"
-#include "hb-language.h"
 #include "hb-shape.h"
 #include "hb-unicode.h"