@@ -191,11 +191,12 @@ def emit_enums(f, script_list, extension_list, longforms):
191191use core::convert::TryFrom;
192192#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
193193#[non_exhaustive]
194+ #[allow(non_camel_case_types)]
194195/// A value of the Script property
195196pub enum Script {
196197""" )
197198 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 ] ))
199200 f .write ("""}
200201#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
201202#[non_exhaustive]
@@ -234,7 +235,15 @@ def emit_enums(f, script_list, extension_list, longforms):
234235 match self {
235236""" )
236237 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 ))
238247 f .write (""" }
239248 }
240249}
@@ -247,7 +256,7 @@ def emit_enums(f, script_list, extension_list, longforms):
247256 ScriptExtension::Single(s) => vec![s],
248257""" )
249258 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 ])
251260 f .write (" %s => vec![%s],\n " % (extension_name (ext ), scripts ))
252261 f .write (""" _ => unreachable!()
253262 }
@@ -259,7 +268,7 @@ def emit_enums(f, script_list, extension_list, longforms):
259268 ScriptExtension::Single(s) => s == other,
260269""" )
261270 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 ])
263272 f .write (" %s => %s,\n " % (extension_name (ext ), scripts ))
264273 f .write (""" }
265274 }
@@ -268,10 +277,10 @@ def emit_enums(f, script_list, extension_list, longforms):
268277 pub(crate) fn inner_intersects(self, other: Self) -> bool {
269278 match (self, other) {
270279 (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,
275284 (ScriptExtension::Single(s), o) | (o, ScriptExtension::Single(s)) => o.inner_contains_script(s),
276285""" )
277286 intersections = compute_intersections (extension_list )
@@ -307,10 +316,10 @@ def compute_intersections(extension_list):
307316 intersections .append ((e1 , e2 ))
308317 return intersections
309318
310- def extension_name (ext ):
319+ def extension_name (ext , longforms = [] ):
311320 """Get the rust source for a given ScriptExtension"""
312321 if len (ext ) == 1 :
313- return "ScriptExtension::Single(Script::%s)" % ext [0 ]
322+ return "ScriptExtension::Single(Script::%s)" % longforms [ ext [0 ] ]
314323 else :
315324 return "ScriptExtension::%s" % "" .join (ext )
316325
@@ -362,8 +371,8 @@ def extension_name(ext):
362371 emit_search (rf )
363372
364373 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 ] ]))
366375 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 )))
368377
369378 # emit_table(rf, "FOObar", properties)
0 commit comments