From b5fbc3b8f560235d014c62e49220574ffcf89349 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 11 Aug 2014 18:40:01 -0400 Subject: [PATCH] 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. --- src/hb-buffer-private.hh | 4 +--- src/hb-buffer.cc | 4 ++-- test/api/test-buffer.c | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index 68e6fc6b7..069f92558 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -48,15 +48,13 @@ struct hb_buffer_t { 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 2377ba40d..74ae273ee 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -178,6 +178,7 @@ hb_buffer_t::reset (void) 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_buffer_t::clear (void) 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_buffer_get_empty (void) HB_OBJECT_HEADER_STATIC, const_cast (&_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 af73c3f18..17607f1ed 100644 --- a/test/api/test-buffer.c +++ b/test/api/test-buffer.c @@ -110,7 +110,6 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) 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 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) 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 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) 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 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) 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 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) 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