API: Do not clear buffer-flags in hb_buffer_clear_contents()
After 763e5466c0a03a7c27020e1e2598e488612529a7, one doesn't
need to set flags for different pieces of text. The flags now
are something the client sets up once, depending on how it
actually uses the buffer. As such, don't clear it in
clear_contents().
Tests updated.
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 68e6fc6..069f925 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -48,15 +48,13 @@
ASSERT_POD ();
/* Information about how the text in the buffer should be treated */
-
hb_unicode_funcs_t *unicode; /* Unicode functions */
- hb_segment_properties_t props; /* Script, language, direction */
hb_buffer_flags_t flags; /* BOT / EOT / etc. */
hb_codepoint_t replacement; /* U+FFFD or something else. */
/* Buffer contents */
-
hb_buffer_content_type_t content_type;
+ hb_segment_properties_t props; /* Script, language, direction */
bool in_error; /* Allocation failed */
bool have_output; /* Whether we have an output buffer going on */
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 2377ba4..74ae273 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -178,6 +178,7 @@
hb_unicode_funcs_destroy (unicode);
unicode = hb_unicode_funcs_get_default ();
+ flags = HB_BUFFER_FLAG_DEFAULT;
replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT;
clear ();
@@ -191,7 +192,6 @@
hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT;
props = default_props;
- flags = HB_BUFFER_FLAG_DEFAULT;
content_type = HB_BUFFER_CONTENT_TYPE_INVALID;
in_error = false;
@@ -702,11 +702,11 @@
HB_OBJECT_HEADER_STATIC,
const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil),
- HB_SEGMENT_PROPERTIES_DEFAULT,
HB_BUFFER_FLAG_DEFAULT,
HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT,
HB_BUFFER_CONTENT_TYPE_INVALID,
+ HB_SEGMENT_PROPERTIES_DEFAULT,
true, /* in_error */
true, /* have_output */
true /* have_positions */
diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c
index af73c3f..17607f1 100644
--- a/test/api/test-buffer.c
+++ b/test/api/test-buffer.c
@@ -110,7 +110,6 @@
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
- g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_DEFAULT);
/* test property changes are retained */
@@ -131,9 +130,11 @@
hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT);
g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT);
+ hb_buffer_set_replacement_codepoint (b, (unsigned int) -1);
+ g_assert (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1);
- /* test clear clears all properties but unicode_funcs */
+ /* test clear_contents clears all these properties: */
hb_buffer_clear_contents (b);
@@ -141,7 +142,11 @@
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
- g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
+
+ /* but not these: */
+
+ g_assert (hb_buffer_get_flags (b) != HB_BUFFER_FLAGS_DEFAULT);
+ g_assert (hb_buffer_get_replacement_codepoint (b) != HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
/* test reset clears all properties */
@@ -158,6 +163,9 @@
hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT);
g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT);
+ hb_buffer_set_replacement_codepoint (b, (unsigned int) -1);
+ g_assert (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1);
+
hb_buffer_reset (b);
g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
@@ -165,6 +173,7 @@
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
+ g_assert (hb_buffer_get_replacement_codepoint (b) == HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
}
static void