9 our @ISA = qw(Exporter);
11 # Items to export into callers namespace by default. Note: do not export
12 # names by default without a very good reason. Use EXPORT_OK instead.
13 # Do not simply export all your public functions/methods/constants.
15 # This allows declaration use mkcommon ':all';
16 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
18 our %EXPORT_TAGS = ( 'all' => [ qw(
22 our @EXPORT_OK = ( @
{ $EXPORT_TAGS{'all'} } );
28 our $VERSION = '0.01';
32 # Preloaded methods go here.
38 my $class = ref($this) || $this;
42 $$self{'char_array'}=[];
43 $$self{'char_class'}=[];
44 $$self{'char_start'}=[0];
46 $$self{'last_block'}=-1;
60 push @
{$$this{'char_array'}}, [$f, $l];
61 push @
{$$this{'char_class'}}, $$this{'last'};
64 sub _doemit_endblock
{
68 push @
{$$this{'char_start'}}, $#{$$this{'char_array'}}+1;
71 # _doemit invokes _doemit_block() for each unicode char range with a given
72 # linebreaking class. However, once a unicode char range starts in a different
73 # $BLOCK_SIZE character class, call _doemit_endblock() before calling _doemit_block().
75 # If a single unicode char range crosses a $BLOCK_SIZE character class boundary,
76 # split it at the boundary; call _doemit_endblock() to finish the current $BLOCK_SIZE
77 # char boundary, call _doemit_endblock(), then call _doemit_block() for the
78 # rest of the char range.
85 $this->_doemit_endblock()
86 if int($$this{'last_f'} / $BLOCK_SIZE)
87 != $$this{'last_block'} && $$this{'last_block'} != -1;
89 if (int($$this{'last_f'} / $BLOCK_SIZE) != int($$this{'last_l'} / $BLOCK_SIZE))
91 while (int($$this{'last_f'} / $BLOCK_SIZE) != int($$this{'last_l'} / $BLOCK_SIZE))
93 my $n=int($$this{'last_f'} / $BLOCK_SIZE) * $BLOCK_SIZE + ($BLOCK_SIZE-1);
95 $this->_doemit_block($$this{'last_f'}, $n);
96 $this->_doemit_endblock();
97 $$this{'last_f'}=$n+1;
100 $this->_doemit_block($$this{'last_f'}, $$this{'last_l'});
102 $$this{'last_block'}=int($$this{'last_l'} / $BLOCK_SIZE);
106 # Coalesce adjacent unicode char blocks that have the same linebreaking
107 # property. Invoke _doemit() for the accumulate unicode char range once
108 # a range with a different linebreaking class is seen.
118 if ($$this{'last_l'} + 1 == $f && $$this{'last'} eq $t)
124 $this->_doemit() if $$this{'last'}; # New linebreaking class
134 $this->_doemit(); # Emit last linebreaking unicode char range class
136 $this->_doemit_endblock(); # End of the most recent $BLOCK_SIZE char range class
138 print "static const uint8_t unicode_rangetab[][2]={\n";
142 my $modulo=sprintf("0x%X", $BLOCK_SIZE-1);
144 foreach ( @
{$$this{'char_array'}} )
146 print "${comma}{0x" . sprintf("%04x", $$_[0]) . " & $modulo, 0x"
147 . sprintf("%04x", $$_[1]) . " & $modulo}";
153 print "static const uint8_t unicode_classtab[]={\n";
156 foreach ( @
{$$this{'char_class'}} )
164 print "static const size_t unicode_indextab[]={\n";
169 foreach (@
{$$this{'char_start'}})
174 if ($sp <= $#{$$this{'char_array'}})
176 my $block=int($$this{'char_array'}->[$sp]->[0] / $BLOCK_SIZE);
178 $cnt = $block - $prev_block;