summaryrefslogtreecommitdiff
path: root/pango2/emoji_presentation_scanner.c
blob: 69c2ae9f533309c837053a644b6942a169c2f5cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#line 1 "pango2/emoji_presentation_scanner.rl"
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.


#line 6 "pango2/emoji_presentation_scanner.c"
static const signed char _emoji_presentation_actions[] = {
	0, 1, 0, 1, 1, 1, 7, 1,
	8, 1, 9, 1, 10, 1, 11, 1,
	12, 1, 13, 1, 14, 2, 2, 3,
	2, 2, 4, 2, 2, 5, 2, 2,
	6, 0
};

static const signed char _emoji_presentation_key_offsets[] = {
	0, 5, 7, 14, 18, 20, 21, 24,
	29, 30, 34, 36, 0
};

static const unsigned char _emoji_presentation_trans_keys[] = {
	3u, 7u, 13u, 0u, 2u, 14u, 15u, 0u,
	1u, 2u, 3u, 6u, 7u, 13u, 9u, 10u,
	11u, 12u, 10u, 12u, 10u, 4u, 10u, 12u,
	4u, 9u, 10u, 11u, 12u, 6u, 9u, 10u,
	11u, 12u, 8u, 10u, 9u, 10u, 11u, 12u,
	14u, 0u
};

static const signed char _emoji_presentation_single_lengths[] = {
	3, 2, 7, 4, 2, 1, 3, 5,
	1, 4, 2, 5, 0
};

static const signed char _emoji_presentation_range_lengths[] = {
	1, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0
};

static const signed char _emoji_presentation_index_offsets[] = {
	0, 5, 8, 16, 21, 24, 26, 30,
	36, 38, 43, 46, 0
};

static const signed char _emoji_presentation_cond_targs[] = {
	6, 4, 4, 4, 2, 1, 2, 2,
	3, 3, 3, 7, 8, 9, 11, 2,
	2, 0, 2, 5, 2, 0, 5, 2,
	0, 2, 5, 0, 5, 2, 5, 2,
	0, 2, 5, 2, 2, 2, 2, 0,
	2, 10, 2, 2, 0, 2, 2, 0,
	2, 5, 1, 2, 2, 2, 2, 2,
	2, 2, 2, 2, 2, 2, 2, 2,
	0
};

static const signed char _emoji_presentation_cond_actions[] = {
	27, 27, 27, 27, 19, 0, 7, 17,
	30, 21, 27, 27, 0, 30, 27, 9,
	7, 0, 5, 24, 19, 0, 27, 13,
	0, 19, 27, 0, 27, 13, 27, 7,
	0, 5, 24, 13, 7, 15, 7, 0,
	5, 24, 15, 7, 0, 11, 7, 0,
	5, 24, 0, 13, 19, 17, 0, 19,
	13, 19, 13, 13, 15, 15, 11, 13,
	0
};

static const signed char _emoji_presentation_to_state_actions[] = {
	0, 0, 1, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0
};

static const signed char _emoji_presentation_from_state_actions[] = {
	0, 0, 3, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0
};

static const signed char _emoji_presentation_eof_trans[] = {
	53, 54, 55, 56, 57, 58, 59, 60,
	61, 62, 63, 64, 0
};

static const int emoji_presentation_start = 2;

static const int emoji_presentation_en_text_and_emoji_run = 2;


#line 9 "pango2/emoji_presentation_scanner.rl"



#line 81 "pango2/emoji_presentation_scanner.rl"


static emoji_text_iter_t
scan_emoji_presentation (emoji_text_iter_t p,
const emoji_text_iter_t pe,
EmojiPresentation *state,
gboolean *explicit)
{
	emoji_text_iter_t ts, te;
	const emoji_text_iter_t eof = pe;
	
	unsigned act;
	int cs;
	

#line 104 "pango2/emoji_presentation_scanner.c"
	{
		cs = (int)emoji_presentation_start;
		ts = 0;
		te = 0;
		act = 0;
	}

#line 110 "pango2/emoji_presentation_scanner.c"
	{
		int _klen;
		unsigned int _trans = 0;
		const unsigned char * _keys;
		const signed char * _acts;
		unsigned int _nacts;
		_resume: {}
		if ( p == pe && p != eof )
			goto _out;
		_acts = ( _emoji_presentation_actions + (_emoji_presentation_from_state_actions[cs]));
		_nacts = (unsigned int)(*( _acts));
		_acts += 1;
		while ( _nacts > 0 ) {
			switch ( (*( _acts)) ) {
				case 1:  {
						{
#line 1 "NONE"
						{ts = p;}}
					
#line 129 "pango2/emoji_presentation_scanner.c"

					break; 
				}
			}
			_nacts -= 1;
			_acts += 1;
		}
		
		if ( p == eof ) {
			if ( _emoji_presentation_eof_trans[cs] > 0 ) {
				_trans = (unsigned int)_emoji_presentation_eof_trans[cs] - 1;
			}
		}
		else {
			_keys = ( _emoji_presentation_trans_keys + (_emoji_presentation_key_offsets[cs]));
			_trans = (unsigned int)_emoji_presentation_index_offsets[cs];
			
			_klen = (int)_emoji_presentation_single_lengths[cs];
			if ( _klen > 0 ) {
				const unsigned char *_lower = _keys;
				const unsigned char *_upper = _keys + _klen - 1;
				const unsigned char *_mid;
				while ( 1 ) {
					if ( _upper < _lower ) {
						_keys += _klen;
						_trans += (unsigned int)_klen;
						break;
					}
					
					_mid = _lower + ((_upper-_lower) >> 1);
					if ( ( (*( p))) < (*( _mid)) )
						_upper = _mid - 1;
					else if ( ( (*( p))) > (*( _mid)) )
						_lower = _mid + 1;
					else {
						_trans += (unsigned int)(_mid - _keys);
						goto _match;
					}
				}
			}
			
			_klen = (int)_emoji_presentation_range_lengths[cs];
			if ( _klen > 0 ) {
				const unsigned char *_lower = _keys;
				const unsigned char *_upper = _keys + (_klen<<1) - 2;
				const unsigned char *_mid;
				while ( 1 ) {
					if ( _upper < _lower ) {
						_trans += (unsigned int)_klen;
						break;
					}
					
					_mid = _lower + (((_upper-_lower) >> 1) & ~1);
					if ( ( (*( p))) < (*( _mid)) )
						_upper = _mid - 2;
					else if ( ( (*( p))) > (*( _mid + 1)) )
						_lower = _mid + 2;
					else {
						_trans += (unsigned int)((_mid - _keys)>>1);
						break;
					}
				}
			}
			
			_match: {}
		}
		cs = (int)_emoji_presentation_cond_targs[_trans];
		
		if ( _emoji_presentation_cond_actions[_trans] != 0 ) {
			
			_acts = ( _emoji_presentation_actions + (_emoji_presentation_cond_actions[_trans]));
			_nacts = (unsigned int)(*( _acts));
			_acts += 1;
			while ( _nacts > 0 ) {
				switch ( (*( _acts)) )
				{
					case 2:  {
							{
#line 1 "NONE"
							{te = p+1;}}
						
#line 210 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 3:  {
							{
#line 75 "pango2/emoji_presentation_scanner.rl"
							{act = 2;}}
						
#line 218 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 4:  {
							{
#line 76 "pango2/emoji_presentation_scanner.rl"
							{act = 3;}}
						
#line 226 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 5:  {
							{
#line 77 "pango2/emoji_presentation_scanner.rl"
							{act = 4;}}
						
#line 234 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 6:  {
							{
#line 78 "pango2/emoji_presentation_scanner.rl"
							{act = 5;}}
						
#line 242 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 7:  {
							{
#line 74 "pango2/emoji_presentation_scanner.rl"
							{te = p+1;{
#line 74 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_TEXT; *explicit = TRUE; return te; }
							}}
						
#line 253 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 8:  {
							{
#line 77 "pango2/emoji_presentation_scanner.rl"
							{te = p+1;{
#line 77 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_EMOJI; *explicit = FALSE; return te; }
							}}
						
#line 264 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 9:  {
							{
#line 78 "pango2/emoji_presentation_scanner.rl"
							{te = p+1;{
#line 78 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_NONE; *explicit = TRUE; return te; }
							}}
						
#line 275 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 10:  {
							{
#line 76 "pango2/emoji_presentation_scanner.rl"
							{te = p;p = p - 1;{
#line 76 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_EMOJI; *explicit = TRUE; return te; }
							}}
						
#line 286 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 11:  {
							{
#line 77 "pango2/emoji_presentation_scanner.rl"
							{te = p;p = p - 1;{
#line 77 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_EMOJI; *explicit = FALSE; return te; }
							}}
						
#line 297 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 12:  {
							{
#line 78 "pango2/emoji_presentation_scanner.rl"
							{te = p;p = p - 1;{
#line 78 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_NONE; *explicit = TRUE; return te; }
							}}
						
#line 308 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 13:  {
							{
#line 77 "pango2/emoji_presentation_scanner.rl"
							{p = ((te))-1;
								{
#line 77 "pango2/emoji_presentation_scanner.rl"
									*state = EMOJI_PRESENTATION_EMOJI; *explicit = FALSE; return te; }
							}}
						
#line 320 "pango2/emoji_presentation_scanner.c"

						break; 
					}
					case 14:  {
							{
#line 1 "NONE"
							{switch( act ) {
									case 2:  {
										p = ((te))-1;
										{
#line 75 "pango2/emoji_presentation_scanner.rl"
											*state = EMOJI_PRESENTATION_TEXT; *explicit = FALSE; return te; }
										break; 
									}
									case 3:  {
										p = ((te))-1;
										{
#line 76 "pango2/emoji_presentation_scanner.rl"
											*state = EMOJI_PRESENTATION_EMOJI; *explicit = TRUE; return te; }
										break; 
									}
									case 4:  {
										p = ((te))-1;
										{
#line 77 "pango2/emoji_presentation_scanner.rl"
											*state = EMOJI_PRESENTATION_EMOJI; *explicit = FALSE; return te; }
										break; 
									}
									case 5:  {
										p = ((te))-1;
										{
#line 78 "pango2/emoji_presentation_scanner.rl"
											*state = EMOJI_PRESENTATION_NONE; *explicit = TRUE; return te; }
										break; 
									}
								}}
						}
						
#line 358 "pango2/emoji_presentation_scanner.c"

						break; 
					}
				}
				_nacts -= 1;
				_acts += 1;
			}
			
		}
		
		if ( p == eof ) {
			if ( cs >= 2 )
				goto _out;
		}
		else {
			_acts = ( _emoji_presentation_actions + (_emoji_presentation_to_state_actions[cs]));
			_nacts = (unsigned int)(*( _acts));
			_acts += 1;
			while ( _nacts > 0 ) {
				switch ( (*( _acts)) ) {
					case 0:  {
							{
#line 1 "NONE"
							{ts = 0;}}
						
#line 383 "pango2/emoji_presentation_scanner.c"

						break; 
					}
				}
				_nacts -= 1;
				_acts += 1;
			}
			
			p += 1;
			goto _resume;
		}
		_out: {}
	}
	
#line 98 "pango2/emoji_presentation_scanner.rl"

	
	/* Should not be reached. */
	*state = EMOJI_PRESENTATION_NONE;
	*explicit = FALSE;
	return pe;
}