From 59721c2f372918555f3d238b449a61907d1fc94c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 29 Jan 2021 11:34:59 -0700 Subject: [PATCH] [use] Move data table into same compilation unit --- src/Makefile.sources | 2 +- src/gen-use-table.py | 11 ++-- src/harfbuzz.cc | 1 - src/hb-ot-shape-complex-use-machine.hh | 55 +++++++++---------- src/hb-ot-shape-complex-use-machine.rl | 5 -- ...le.cc => hb-ot-shape-complex-use-table.hh} | 11 ++-- src/hb-ot-shape-complex-use.cc | 1 + src/meson.build | 2 +- src/update-unicode-tables.make | 4 +- 9 files changed, 42 insertions(+), 50 deletions(-) rename src/{hb-ot-shape-complex-use-table.cc => hb-ot-shape-complex-use-table.hh} (99%) diff --git a/src/Makefile.sources b/src/Makefile.sources index 65a7e3b77..2e38d7317 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -123,7 +123,7 @@ HB_BASE_sources = \ hb-ot-shape-complex-syllabic.cc \ hb-ot-shape-complex-syllabic.hh \ hb-ot-shape-complex-thai.cc \ - hb-ot-shape-complex-use-table.cc \ + hb-ot-shape-complex-use-table.hh \ hb-ot-shape-complex-use.cc \ hb-ot-shape-complex-vowel-constraints.cc \ hb-ot-shape-complex-vowel-constraints.hh \ diff --git a/src/gen-use-table.py b/src/gen-use-table.py index d8efba184..35d9abf1e 100755 --- a/src/gen-use-table.py +++ b/src/gen-use-table.py @@ -457,9 +457,10 @@ for h in headers: print (" * %s" % (l.strip())) print (" */") print () -print ('#include "hb.hh"') +print ("#ifndef HB_OT_SHAPE_COMPLEX_USE_TABLE_HH") +print ("#define HB_OT_SHAPE_COMPLEX_USE_TABLE_HH") print () -print ('#ifndef HB_NO_OT_SHAPE') +print ('#include "hb.hh"') print () print ('#include "hb-ot-shape-complex-use-machine.hh"') print () @@ -511,7 +512,7 @@ for k,v in sorted(use_positions.items()): print ("#define %s USE(%s)" % (tag, tag)) print ('#pragma GCC diagnostic pop') print ("") -print ("static const USE_TABLE_ELEMENT_TYPE use_table[] = {") +print ("static const uint8_t use_table[] = {") for u in uu: if u <= last: continue @@ -547,7 +548,7 @@ occupancy = used * 100. / total page_bits = 12 print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)) print () -print ("USE_TABLE_ELEMENT_TYPE") +print ("static inline uint8_t") print ("hb_use_get_category (hb_codepoint_t u)") print ("{") print (" switch (u >> %d)" % page_bits) @@ -577,7 +578,7 @@ for k,v in sorted(use_positions.items()): print ("#undef %s" % tag) print () print () -print ('#endif') +print ("#endif /* HB_OT_SHAPE_COMPLEX_USE_TABLE_HH */") print ("/* == End of generated table == */") # Maintain at least 50% occupancy in the table */ diff --git a/src/harfbuzz.cc b/src/harfbuzz.cc index cc0dcb937..fe0010097 100644 --- a/src/harfbuzz.cc +++ b/src/harfbuzz.cc @@ -31,7 +31,6 @@ #include "hb-ot-shape-complex-myanmar.cc" #include "hb-ot-shape-complex-syllabic.cc" #include "hb-ot-shape-complex-thai.cc" -#include "hb-ot-shape-complex-use-table.cc" #include "hb-ot-shape-complex-use.cc" #include "hb-ot-shape-complex-vowel-constraints.cc" #include "hb-ot-shape-fallback.cc" diff --git a/src/hb-ot-shape-complex-use-machine.hh b/src/hb-ot-shape-complex-use-machine.hh index c08f22420..a5ee7156a 100644 --- a/src/hb-ot-shape-complex-use-machine.hh +++ b/src/hb-ot-shape-complex-use-machine.hh @@ -40,11 +40,6 @@ #define USE(Cat) use_syllable_machine_ex_##Cat -#define USE_TABLE_ELEMENT_TYPE uint8_t - -HB_INTERNAL USE_TABLE_ELEMENT_TYPE -hb_use_get_category (hb_codepoint_t u); - enum use_syllable_type_t { use_independent_cluster, use_virama_terminated_cluster, @@ -59,7 +54,7 @@ enum use_syllable_type_t { }; -#line 63 "hb-ot-shape-complex-use-machine.hh" +#line 58 "hb-ot-shape-complex-use-machine.hh" #define use_syllable_machine_ex_B 1u #define use_syllable_machine_ex_CMAbv 31u #define use_syllable_machine_ex_CMBlw 32u @@ -101,7 +96,7 @@ enum use_syllable_type_t { #define use_syllable_machine_ex_ZWNJ 14u -#line 105 "hb-ot-shape-complex-use-machine.hh" +#line 100 "hb-ot-shape-complex-use-machine.hh" static const unsigned char _use_syllable_machine_trans_keys[] = { 1u, 1u, 1u, 1u, 0u, 51u, 11u, 48u, 11u, 48u, 1u, 1u, 22u, 48u, 23u, 48u, 24u, 47u, 25u, 47u, 26u, 47u, 45u, 46u, 46u, 46u, 24u, 48u, 24u, 48u, 24u, 48u, @@ -370,11 +365,11 @@ static const int use_syllable_machine_error = -1; static const int use_syllable_machine_en_main = 2; -#line 64 "hb-ot-shape-complex-use-machine.rl" +#line 59 "hb-ot-shape-complex-use-machine.rl" -#line 181 "hb-ot-shape-complex-use-machine.rl" +#line 176 "hb-ot-shape-complex-use-machine.rl" #define found_syllable(syllable_type) \ @@ -457,7 +452,7 @@ find_syllables_use (hb_buffer_t *buffer) unsigned int act HB_UNUSED; int cs; -#line 461 "hb-ot-shape-complex-use-machine.hh" +#line 456 "hb-ot-shape-complex-use-machine.hh" { cs = use_syllable_machine_start; ts = 0; @@ -465,12 +460,12 @@ find_syllables_use (hb_buffer_t *buffer) act = 0; } -#line 265 "hb-ot-shape-complex-use-machine.rl" +#line 260 "hb-ot-shape-complex-use-machine.rl" unsigned int syllable_serial = 1; -#line 474 "hb-ot-shape-complex-use-machine.hh" +#line 469 "hb-ot-shape-complex-use-machine.hh" { int _slen; int _trans; @@ -484,7 +479,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 488 "hb-ot-shape-complex-use-machine.hh" +#line 483 "hb-ot-shape-complex-use-machine.hh" } _keys = _use_syllable_machine_trans_keys + (cs<<1); @@ -507,62 +502,62 @@ _eof_trans: {te = p+1;} break; case 5: -#line 168 "hb-ot-shape-complex-use-machine.rl" +#line 163 "hb-ot-shape-complex-use-machine.rl" {te = p+1;{ found_syllable (independent_cluster); }} break; case 9: -#line 171 "hb-ot-shape-complex-use-machine.rl" +#line 166 "hb-ot-shape-complex-use-machine.rl" {te = p+1;{ found_syllable (standard_cluster); }} break; case 7: -#line 176 "hb-ot-shape-complex-use-machine.rl" +#line 171 "hb-ot-shape-complex-use-machine.rl" {te = p+1;{ found_syllable (broken_cluster); }} break; case 6: -#line 177 "hb-ot-shape-complex-use-machine.rl" +#line 172 "hb-ot-shape-complex-use-machine.rl" {te = p+1;{ found_syllable (non_cluster); }} break; case 10: -#line 169 "hb-ot-shape-complex-use-machine.rl" +#line 164 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (virama_terminated_cluster); }} break; case 11: -#line 170 "hb-ot-shape-complex-use-machine.rl" +#line 165 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (sakot_terminated_cluster); }} break; case 8: -#line 171 "hb-ot-shape-complex-use-machine.rl" +#line 166 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (standard_cluster); }} break; case 13: -#line 172 "hb-ot-shape-complex-use-machine.rl" +#line 167 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (number_joiner_terminated_cluster); }} break; case 12: -#line 173 "hb-ot-shape-complex-use-machine.rl" +#line 168 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (numeral_cluster); }} break; case 14: -#line 174 "hb-ot-shape-complex-use-machine.rl" +#line 169 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (symbol_cluster); }} break; case 17: -#line 175 "hb-ot-shape-complex-use-machine.rl" +#line 170 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (hieroglyph_cluster); }} break; case 15: -#line 176 "hb-ot-shape-complex-use-machine.rl" +#line 171 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (broken_cluster); }} break; case 16: -#line 177 "hb-ot-shape-complex-use-machine.rl" +#line 172 "hb-ot-shape-complex-use-machine.rl" {te = p;p--;{ found_syllable (non_cluster); }} break; case 1: -#line 176 "hb-ot-shape-complex-use-machine.rl" +#line 171 "hb-ot-shape-complex-use-machine.rl" {{p = ((te))-1;}{ found_syllable (broken_cluster); }} break; -#line 566 "hb-ot-shape-complex-use-machine.hh" +#line 561 "hb-ot-shape-complex-use-machine.hh" } _again: @@ -571,7 +566,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 575 "hb-ot-shape-complex-use-machine.hh" +#line 570 "hb-ot-shape-complex-use-machine.hh" } if ( ++p != pe ) @@ -587,7 +582,7 @@ _again: } -#line 270 "hb-ot-shape-complex-use-machine.rl" +#line 265 "hb-ot-shape-complex-use-machine.rl" } diff --git a/src/hb-ot-shape-complex-use-machine.rl b/src/hb-ot-shape-complex-use-machine.rl index 8dec98d73..1880c06f5 100644 --- a/src/hb-ot-shape-complex-use-machine.rl +++ b/src/hb-ot-shape-complex-use-machine.rl @@ -38,11 +38,6 @@ #define USE(Cat) use_syllable_machine_ex_##Cat -#define USE_TABLE_ELEMENT_TYPE uint8_t - -HB_INTERNAL USE_TABLE_ELEMENT_TYPE -hb_use_get_category (hb_codepoint_t u); - enum use_syllable_type_t { use_independent_cluster, use_virama_terminated_cluster, diff --git a/src/hb-ot-shape-complex-use-table.cc b/src/hb-ot-shape-complex-use-table.hh similarity index 99% rename from src/hb-ot-shape-complex-use-table.cc rename to src/hb-ot-shape-complex-use-table.hh index 23de8a12e..a35894ce8 100644 --- a/src/hb-ot-shape-complex-use-table.cc +++ b/src/hb-ot-shape-complex-use-table.hh @@ -31,9 +31,10 @@ * UnicodeData.txt does not have a header. */ -#include "hb.hh" +#ifndef HB_OT_SHAPE_COMPLEX_USE_TABLE_HH +#define HB_OT_SHAPE_COMPLEX_USE_TABLE_HH -#ifndef HB_NO_OT_SHAPE +#include "hb.hh" #include "hb-ot-shape-complex-use-machine.hh" @@ -80,7 +81,7 @@ #define VMPre USE(VMPre) #pragma GCC diagnostic pop -static const USE_TABLE_ELEMENT_TYPE use_table[] = { +static const uint8_t use_table[] = { #define use_offset_0x0028u 0 @@ -1066,7 +1067,7 @@ static const USE_TABLE_ELEMENT_TYPE use_table[] = { }; /* Table items: 8824; occupancy: 79% */ -USE_TABLE_ELEMENT_TYPE +static inline uint8_t hb_use_get_category (hb_codepoint_t u) { switch (u >> 12) @@ -1198,5 +1199,5 @@ hb_use_get_category (hb_codepoint_t u) #undef VMPre -#endif +#endif /* HB_OT_SHAPE_COMPLEX_USE_TABLE_HH */ /* == End of generated table == */ diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 214c6de4c..0d0b7e771 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -31,6 +31,7 @@ #ifndef HB_NO_OT_SHAPE #include "hb-ot-shape-complex-use-machine.hh" +#include "hb-ot-shape-complex-use-table.hh" #include "hb-ot-shape-complex-arabic.hh" #include "hb-ot-shape-complex-arabic-joining-list.hh" #include "hb-ot-shape-complex-vowel-constraints.hh" diff --git a/src/meson.build b/src/meson.build index 33366e897..a6c0590bc 100644 --- a/src/meson.build +++ b/src/meson.build @@ -129,7 +129,7 @@ hb_base_sources = files( 'hb-ot-shape-complex-syllabic.cc', 'hb-ot-shape-complex-syllabic.hh', 'hb-ot-shape-complex-thai.cc', - 'hb-ot-shape-complex-use-table.cc', + 'hb-ot-shape-complex-use-table.hh', 'hb-ot-shape-complex-use.cc', 'hb-ot-shape-complex-vowel-constraints.cc', 'hb-ot-shape-complex-vowel-constraints.hh', diff --git a/src/update-unicode-tables.make b/src/update-unicode-tables.make index 3053ac0a4..95edb9a75 100755 --- a/src/update-unicode-tables.make +++ b/src/update-unicode-tables.make @@ -4,7 +4,7 @@ all: packtab \ hb-ot-shape-complex-arabic-joining-list.hh \ hb-ot-shape-complex-arabic-table.hh hb-unicode-emoji-table.hh \ hb-ot-shape-complex-indic-table.cc hb-ot-tag-table.hh \ - hb-ucd-table.hh hb-ot-shape-complex-use-table.cc \ + hb-ucd-table.hh hb-ot-shape-complex-use-table.hh \ hb-ot-shape-complex-vowel-constraints.cc .PHONY: all clean packtab @@ -21,7 +21,7 @@ hb-ot-tag-table.hh: gen-tag-table.py languagetags language-subtag-registry ./$^ > $@ || ($(RM) $@; false) hb-ucd-table.hh: gen-ucd-table.py ucd.nounihan.grouped.zip hb-common.h ./$^ > $@ || ($(RM) $@; false) -hb-ot-shape-complex-use-table.cc: gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt ArabicShaping.txt Blocks.txt ms-use/IndicSyllabicCategory-Additional.txt ms-use/IndicPositionalCategory-Additional.txt +hb-ot-shape-complex-use-table.hh: gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt ArabicShaping.txt Blocks.txt ms-use/IndicSyllabicCategory-Additional.txt ms-use/IndicPositionalCategory-Additional.txt ./$^ > $@ || ($(RM) $@; false) hb-ot-shape-complex-vowel-constraints.cc: gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt ./$^ > $@ || ($(RM) $@; false)