| Index: headless/lib/browser/client_api_generator.py
|
| diff --git a/headless/lib/browser/client_api_generator.py b/headless/lib/browser/client_api_generator.py
|
| index 40f1206d17b206eb0adf31233bd0ced994c0b3b8..e5276c4091904403fb12d9c49e65178a5293b481 100644
|
| --- a/headless/lib/browser/client_api_generator.py
|
| +++ b/headless/lib/browser/client_api_generator.py
|
| @@ -59,9 +59,17 @@ def CamelCaseToHackerStyle(name):
|
| return name.lower()
|
|
|
|
|
| -def MangleEnum(value):
|
| - # Rename NULL enumeration values to avoid a clash with the actual NULL.
|
| - return 'NONE' if value == 'NULL' else value
|
| +def SanitizeLiteral(literal):
|
| + return {
|
| + # Rename null enumeration values to avoid a clash with the NULL macro.
|
| + 'null': 'none',
|
| + # Rename mathematical constants to avoid colliding with C macros.
|
| + 'Infinity': 'InfinityValue',
|
| + '-Infinity': 'NegativeInfinityValue',
|
| + 'NaN': 'NaNValue',
|
| + # Turn negative zero into a safe identifier.
|
| + '-0': 'NegativeZeroValue',
|
| + }.get(literal, literal)
|
|
|
|
|
| def InitializeJinjaEnv(cache_dir):
|
| @@ -77,7 +85,7 @@ def InitializeJinjaEnv(cache_dir):
|
| 'to_title_case': ToTitleCase,
|
| 'dash_to_camelcase': DashToCamelCase,
|
| 'camelcase_to_hacker_style': CamelCaseToHackerStyle,
|
| - 'mangle_enum': MangleEnum,
|
| + 'sanitize_literal': SanitizeLiteral,
|
| })
|
| jinja_env.add_extension('jinja2.ext.loopcontrols')
|
| return jinja_env
|
|
|