[use] Move data table into same compilation unit

This commit is contained in:
Behdad Esfahbod 2021-01-29 11:34:59 -07:00
parent d9b167da3d
commit 59721c2f37
9 changed files with 42 additions and 50 deletions

View File

@ -123,7 +123,7 @@ HB_BASE_sources = \
hb-ot-shape-complex-syllabic.cc \ hb-ot-shape-complex-syllabic.cc \
hb-ot-shape-complex-syllabic.hh \ hb-ot-shape-complex-syllabic.hh \
hb-ot-shape-complex-thai.cc \ 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-use.cc \
hb-ot-shape-complex-vowel-constraints.cc \ hb-ot-shape-complex-vowel-constraints.cc \
hb-ot-shape-complex-vowel-constraints.hh \ hb-ot-shape-complex-vowel-constraints.hh \

View File

@ -457,9 +457,10 @@ for h in headers:
print (" * %s" % (l.strip())) print (" * %s" % (l.strip()))
print (" */") print (" */")
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 ()
print ('#ifndef HB_NO_OT_SHAPE') print ('#include "hb.hh"')
print () print ()
print ('#include "hb-ot-shape-complex-use-machine.hh"') print ('#include "hb-ot-shape-complex-use-machine.hh"')
print () print ()
@ -511,7 +512,7 @@ for k,v in sorted(use_positions.items()):
print ("#define %s USE(%s)" % (tag, tag)) print ("#define %s USE(%s)" % (tag, tag))
print ('#pragma GCC diagnostic pop') print ('#pragma GCC diagnostic pop')
print ("") print ("")
print ("static const USE_TABLE_ELEMENT_TYPE use_table[] = {") print ("static const uint8_t use_table[] = {")
for u in uu: for u in uu:
if u <= last: if u <= last:
continue continue
@ -547,7 +548,7 @@ occupancy = used * 100. / total
page_bits = 12 page_bits = 12
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)) print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
print () print ()
print ("USE_TABLE_ELEMENT_TYPE") print ("static inline uint8_t")
print ("hb_use_get_category (hb_codepoint_t u)") print ("hb_use_get_category (hb_codepoint_t u)")
print ("{") print ("{")
print (" switch (u >> %d)" % page_bits) print (" switch (u >> %d)" % page_bits)
@ -577,7 +578,7 @@ for k,v in sorted(use_positions.items()):
print ("#undef %s" % tag) print ("#undef %s" % tag)
print () print ()
print () print ()
print ('#endif') print ("#endif /* HB_OT_SHAPE_COMPLEX_USE_TABLE_HH */")
print ("/* == End of generated table == */") print ("/* == End of generated table == */")
# Maintain at least 50% occupancy in the table */ # Maintain at least 50% occupancy in the table */

View File

@ -31,7 +31,6 @@
#include "hb-ot-shape-complex-myanmar.cc" #include "hb-ot-shape-complex-myanmar.cc"
#include "hb-ot-shape-complex-syllabic.cc" #include "hb-ot-shape-complex-syllabic.cc"
#include "hb-ot-shape-complex-thai.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-use.cc"
#include "hb-ot-shape-complex-vowel-constraints.cc" #include "hb-ot-shape-complex-vowel-constraints.cc"
#include "hb-ot-shape-fallback.cc" #include "hb-ot-shape-fallback.cc"

View File

@ -40,11 +40,6 @@
#define USE(Cat) use_syllable_machine_ex_##Cat #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 { enum use_syllable_type_t {
use_independent_cluster, use_independent_cluster,
use_virama_terminated_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_B 1u
#define use_syllable_machine_ex_CMAbv 31u #define use_syllable_machine_ex_CMAbv 31u
#define use_syllable_machine_ex_CMBlw 32u #define use_syllable_machine_ex_CMBlw 32u
@ -101,7 +96,7 @@ enum use_syllable_type_t {
#define use_syllable_machine_ex_ZWNJ 14u #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[] = { 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, 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, 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; 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) \ #define found_syllable(syllable_type) \
@ -457,7 +452,7 @@ find_syllables_use (hb_buffer_t *buffer)
unsigned int act HB_UNUSED; unsigned int act HB_UNUSED;
int cs; 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; cs = use_syllable_machine_start;
ts = 0; ts = 0;
@ -465,12 +460,12 @@ find_syllables_use (hb_buffer_t *buffer)
act = 0; 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; 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 _slen;
int _trans; int _trans;
@ -484,7 +479,7 @@ _resume:
#line 1 "NONE" #line 1 "NONE"
{ts = p;} {ts = p;}
break; 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); _keys = _use_syllable_machine_trans_keys + (cs<<1);
@ -507,62 +502,62 @@ _eof_trans:
{te = p+1;} {te = p+1;}
break; break;
case 5: 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); }} {te = p+1;{ found_syllable (independent_cluster); }}
break; break;
case 9: 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); }} {te = p+1;{ found_syllable (standard_cluster); }}
break; break;
case 7: 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); }} {te = p+1;{ found_syllable (broken_cluster); }}
break; break;
case 6: 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); }} {te = p+1;{ found_syllable (non_cluster); }}
break; break;
case 10: 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); }} {te = p;p--;{ found_syllable (virama_terminated_cluster); }}
break; break;
case 11: 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); }} {te = p;p--;{ found_syllable (sakot_terminated_cluster); }}
break; break;
case 8: 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); }} {te = p;p--;{ found_syllable (standard_cluster); }}
break; break;
case 13: 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); }} {te = p;p--;{ found_syllable (number_joiner_terminated_cluster); }}
break; break;
case 12: 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); }} {te = p;p--;{ found_syllable (numeral_cluster); }}
break; break;
case 14: 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); }} {te = p;p--;{ found_syllable (symbol_cluster); }}
break; break;
case 17: 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); }} {te = p;p--;{ found_syllable (hieroglyph_cluster); }}
break; break;
case 15: 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); }} {te = p;p--;{ found_syllable (broken_cluster); }}
break; break;
case 16: 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); }} {te = p;p--;{ found_syllable (non_cluster); }}
break; break;
case 1: 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); }} {{p = ((te))-1;}{ found_syllable (broken_cluster); }}
break; break;
#line 566 "hb-ot-shape-complex-use-machine.hh" #line 561 "hb-ot-shape-complex-use-machine.hh"
} }
_again: _again:
@ -571,7 +566,7 @@ _again:
#line 1 "NONE" #line 1 "NONE"
{ts = 0;} {ts = 0;}
break; break;
#line 575 "hb-ot-shape-complex-use-machine.hh" #line 570 "hb-ot-shape-complex-use-machine.hh"
} }
if ( ++p != pe ) 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"
} }

View File

@ -38,11 +38,6 @@
#define USE(Cat) use_syllable_machine_ex_##Cat #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 { enum use_syllable_type_t {
use_independent_cluster, use_independent_cluster,
use_virama_terminated_cluster, use_virama_terminated_cluster,

View File

@ -31,9 +31,10 @@
* UnicodeData.txt does not have a header. * 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" #include "hb-ot-shape-complex-use-machine.hh"
@ -80,7 +81,7 @@
#define VMPre USE(VMPre) #define VMPre USE(VMPre)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
static const USE_TABLE_ELEMENT_TYPE use_table[] = { static const uint8_t use_table[] = {
#define use_offset_0x0028u 0 #define use_offset_0x0028u 0
@ -1066,7 +1067,7 @@ static const USE_TABLE_ELEMENT_TYPE use_table[] = {
}; /* Table items: 8824; occupancy: 79% */ }; /* Table items: 8824; occupancy: 79% */
USE_TABLE_ELEMENT_TYPE static inline uint8_t
hb_use_get_category (hb_codepoint_t u) hb_use_get_category (hb_codepoint_t u)
{ {
switch (u >> 12) switch (u >> 12)
@ -1198,5 +1199,5 @@ hb_use_get_category (hb_codepoint_t u)
#undef VMPre #undef VMPre
#endif #endif /* HB_OT_SHAPE_COMPLEX_USE_TABLE_HH */
/* == End of generated table == */ /* == End of generated table == */

View File

@ -31,6 +31,7 @@
#ifndef HB_NO_OT_SHAPE #ifndef HB_NO_OT_SHAPE
#include "hb-ot-shape-complex-use-machine.hh" #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.hh"
#include "hb-ot-shape-complex-arabic-joining-list.hh" #include "hb-ot-shape-complex-arabic-joining-list.hh"
#include "hb-ot-shape-complex-vowel-constraints.hh" #include "hb-ot-shape-complex-vowel-constraints.hh"

View File

@ -129,7 +129,7 @@ hb_base_sources = files(
'hb-ot-shape-complex-syllabic.cc', 'hb-ot-shape-complex-syllabic.cc',
'hb-ot-shape-complex-syllabic.hh', 'hb-ot-shape-complex-syllabic.hh',
'hb-ot-shape-complex-thai.cc', '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-use.cc',
'hb-ot-shape-complex-vowel-constraints.cc', 'hb-ot-shape-complex-vowel-constraints.cc',
'hb-ot-shape-complex-vowel-constraints.hh', 'hb-ot-shape-complex-vowel-constraints.hh',

View File

@ -4,7 +4,7 @@ all: packtab \
hb-ot-shape-complex-arabic-joining-list.hh \ hb-ot-shape-complex-arabic-joining-list.hh \
hb-ot-shape-complex-arabic-table.hh hb-unicode-emoji-table.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-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 hb-ot-shape-complex-vowel-constraints.cc
.PHONY: all clean packtab .PHONY: all clean packtab
@ -21,7 +21,7 @@ hb-ot-tag-table.hh: gen-tag-table.py languagetags language-subtag-registry
./$^ > $@ || ($(RM) $@; false) ./$^ > $@ || ($(RM) $@; false)
hb-ucd-table.hh: gen-ucd-table.py ucd.nounihan.grouped.zip hb-common.h hb-ucd-table.hh: gen-ucd-table.py ucd.nounihan.grouped.zip hb-common.h
./$^ > $@ || ($(RM) $@; false) ./$^ > $@ || ($(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) ./$^ > $@ || ($(RM) $@; false)
hb-ot-shape-complex-vowel-constraints.cc: gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt hb-ot-shape-complex-vowel-constraints.cc: gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt
./$^ > $@ || ($(RM) $@; false) ./$^ > $@ || ($(RM) $@; false)