[config] Don't compile buffer serialize API if HB_NO_BUFFER_SERIALIZE
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 18 Jun 2019 20:26:03 +0000 (13:26 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 18 Jun 2019 20:26:03 +0000 (13:26 -0700)
Part of https://github.com/harfbuzz/harfbuzz/issues/1652

src/hb-buffer-serialize.cc
src/test-buffer-serialize.cc

index d3732fd..77d997c 100644 (file)
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_BUFFER_SERIALIZE
+
 #include "hb-buffer.hh"
 
 
 static const char *serialize_formats[] = {
-#ifndef HB_NO_BUFFER_SERIALIZE
   "text",
   "json",
-#endif
   nullptr
 };
 
@@ -89,10 +91,8 @@ hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format)
 {
   switch ((unsigned) format)
   {
-#ifndef HB_NO_BUFFER_SERIALIZE
     case HB_BUFFER_SERIALIZE_FORMAT_TEXT:      return serialize_formats[0];
     case HB_BUFFER_SERIALIZE_FORMAT_JSON:      return serialize_formats[1];
-#endif
     default:
     case HB_BUFFER_SERIALIZE_FORMAT_INVALID:   return nullptr;
   }
@@ -348,10 +348,6 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
   if (buf_size)
     *buf = '\0';
 
-#ifdef HB_NO_BUFFER_SERIALIZE
-  return 0;
-#endif
-
   assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) ||
          buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS);
 
@@ -457,10 +453,6 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
     end_ptr = &end;
   *end_ptr = buf;
 
-#ifdef HB_NO_BUFFER_SERIALIZE
-  return false;
-#endif
-
   assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) ||
          buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS);
 
@@ -496,3 +488,6 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
 
   }
 }
+
+
+#endif
index a91f4f7..28826be 100644 (file)
 int
 main (int argc, char **argv)
 {
+  bool ret = true;
+
+#ifndef HB_NO_BUFFER_SERIALIZE
+
   if (argc != 2) {
     fprintf (stderr, "usage: %s font-file\n", argv[0]);
     exit (1);
@@ -59,7 +63,6 @@ main (int argc, char **argv)
   hb_buffer_t *buf;
   buf = hb_buffer_create ();
 
-  bool ret = true;
   char line[BUFSIZ], out[BUFSIZ];
   while (fgets (line, sizeof(line), stdin) != nullptr)
   {
@@ -85,5 +88,7 @@ main (int argc, char **argv)
 
   hb_font_destroy (font);
 
+#endif
+
   return !ret;
 }