mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 816487 - Allow all ASCII characters for WebIDL enum. r=bz
This commit is contained in:
parent
4c665dc868
commit
d427634999
@ -4452,15 +4452,19 @@ def getEnumValueName(value):
|
||||
# characters in them. Deal with the former by returning "_empty",
|
||||
# deal with possible name collisions from that by throwing if the
|
||||
# enum value is actually "_empty", and throw on any value
|
||||
# containing chars other than [a-z] or '-' for now. Replace '-' with '_'.
|
||||
value = value.replace('-', '_')
|
||||
# containing non-ASCII chars for now. Replace all chars other than
|
||||
# [0-9A-Za-z_] with '_'.
|
||||
if re.match("[^\x20-\x7E]", value):
|
||||
raise SyntaxError('Enum value "' + value + '" contains non-ASCII characters')
|
||||
if re.match("^[0-9]", value):
|
||||
raise SyntaxError('Enum value "' + value + '" starts with a digit')
|
||||
value = re.sub(r'[^0-9A-Za-z_]', '_', value)
|
||||
if re.match("^_[A-Z]|__", value):
|
||||
raise SyntaxError('Enum value "' + value + '" is reserved by the C++ spec')
|
||||
if value == "_empty":
|
||||
raise SyntaxError('"_empty" is not an IDL enum value we support yet')
|
||||
if value == "":
|
||||
return "_empty"
|
||||
if not re.match("^[a-z_]+$", value):
|
||||
raise SyntaxError('Enum value "' + value + '" contains characters '
|
||||
'outside [a-z_]')
|
||||
return MakeNativeName(value)
|
||||
|
||||
class CGEnum(CGThing):
|
||||
|
Loading…
Reference in New Issue
Block a user