@@ -191,11 +191,12 @@ def emit_enums(f, script_list, extension_list, longforms):
191
191
use core::convert::TryFrom;
192
192
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
193
193
#[non_exhaustive]
194
+ #[allow(non_camel_case_types)]
194
195
/// A value of the Script property
195
196
pub enum Script {
196
197
""" )
197
198
for script in script_list :
198
- f .write (" /// %s\n %s,\n " % (longforms [ script ], script ))
199
+ f .write (" /// %s\n %s,\n " % (script , longforms [ script ] ))
199
200
f .write ("""}
200
201
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
201
202
#[non_exhaustive]
@@ -234,7 +235,15 @@ def emit_enums(f, script_list, extension_list, longforms):
234
235
match self {
235
236
""" )
236
237
for script in script_list :
237
- f .write (" Script::%s => \" %s\" ,\n " % (script , longforms [script ]))
238
+ f .write (" Script::%s => \" %s\" ,\n " % (longforms [script ], longforms [script ]))
239
+ f .write (""" }
240
+ }
241
+
242
+ pub(crate) fn inner_short_name(self) -> &'static str {
243
+ match self {
244
+ """ )
245
+ for script in script_list :
246
+ f .write (" Script::%s => \" %s\" ,\n " % (longforms [script ], script ))
238
247
f .write (""" }
239
248
}
240
249
}
@@ -247,7 +256,7 @@ def emit_enums(f, script_list, extension_list, longforms):
247
256
ScriptExtension::Single(s) => vec![s],
248
257
""" )
249
258
for ext in extension_list :
250
- scripts = ", " .join (["Script::%s" % s for s in ext ])
259
+ scripts = ", " .join (["Script::%s" % longforms [ s ] for s in ext ])
251
260
f .write (" %s => vec![%s],\n " % (extension_name (ext ), scripts ))
252
261
f .write (""" _ => unreachable!()
253
262
}
@@ -259,7 +268,7 @@ def emit_enums(f, script_list, extension_list, longforms):
259
268
ScriptExtension::Single(s) => s == other,
260
269
""" )
261
270
for ext in extension_list :
262
- scripts = " || " .join (["other == Script::%s" % s for s in ext ])
271
+ scripts = " || " .join (["other == Script::%s" % longforms [ s ] for s in ext ])
263
272
f .write (" %s => %s,\n " % (extension_name (ext ), scripts ))
264
273
f .write (""" }
265
274
}
@@ -268,10 +277,10 @@ def emit_enums(f, script_list, extension_list, longforms):
268
277
pub(crate) fn inner_intersects(self, other: Self) -> bool {
269
278
match (self, other) {
270
279
(a, b) if a == b => true,
271
- (ScriptExtension::Single(Script::Zyyy ), _) |
272
- (ScriptExtension::Single(Script::Zinh ), _) |
273
- (_, ScriptExtension::Single(Script::Zyyy )) |
274
- (_, ScriptExtension::Single(Script::Zinh )) => true,
280
+ (ScriptExtension::Single(Script::Common ), _) |
281
+ (ScriptExtension::Single(Script::Inherited ), _) |
282
+ (_, ScriptExtension::Single(Script::Common )) |
283
+ (_, ScriptExtension::Single(Script::Inherited )) => true,
275
284
(ScriptExtension::Single(s), o) | (o, ScriptExtension::Single(s)) => o.inner_contains_script(s),
276
285
""" )
277
286
intersections = compute_intersections (extension_list )
@@ -307,10 +316,10 @@ def compute_intersections(extension_list):
307
316
intersections .append ((e1 , e2 ))
308
317
return intersections
309
318
310
- def extension_name (ext ):
319
+ def extension_name (ext , longforms = [] ):
311
320
"""Get the rust source for a given ScriptExtension"""
312
321
if len (ext ) == 1 :
313
- return "ScriptExtension::Single(Script::%s)" % ext [0 ]
322
+ return "ScriptExtension::Single(Script::%s)" % longforms [ ext [0 ] ]
314
323
else :
315
324
return "ScriptExtension::%s" % "" .join (ext )
316
325
@@ -362,8 +371,8 @@ def extension_name(ext):
362
371
emit_search (rf )
363
372
364
373
emit_table (rf , "SCRIPTS" , script_table , t_type = "&'static [(char, char, Script)]" ,
365
- is_pub = False , pfun = lambda x : "(%s,%s, Script::%s)" % (escape_char (x [0 ]), escape_char (x [1 ]), x [2 ]))
374
+ is_pub = False , pfun = lambda x : "(%s,%s, Script::%s)" % (escape_char (x [0 ]), escape_char (x [1 ]), longforms [ x [2 ] ]))
366
375
emit_table (rf , "SCRIPT_EXTENSIONS" , extension_table , t_type = "&'static [(char, char, ScriptExtension)]" ,
367
- is_pub = False , pfun = lambda x : "(%s,%s,%s)" % (escape_char (x [0 ]), escape_char (x [1 ]), extension_name (x [2 ])))
376
+ is_pub = False , pfun = lambda x : "(%s,%s,%s)" % (escape_char (x [0 ]), escape_char (x [1 ]), extension_name (x [2 ], longforms )))
368
377
369
378
# emit_table(rf, "FOObar", properties)
0 commit comments