Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: mojo/public/tools/bindings/pylib/mojom/generate/data.py

Issue 474063002: Mojo: add support for {double,float}.{INFINITY,NEGATIVE_INFINITY,NAN} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another windows fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/pylib/mojom/generate/data.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/data.py b/mojo/public/tools/bindings/pylib/mojom/generate/data.py
index d8891921a136782641d1de90379146e93558b816..98be283b0ae41d3b3fe9dfd9a06d567014c1cde1 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/data.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/data.py
@@ -42,6 +42,17 @@ def istr(index, string):
rv.__index__ = index
return rv
+builtin_values = frozenset([
+ "double.INFINITY",
+ "double.NEGATIVE_INFINITY",
+ "double.NAN",
+ "float.INFINITY",
+ "float.NEGATIVE_INFINITY",
+ "float.NAN"])
+
+def IsBuiltinValue(value):
+ return value in builtin_values
+
def LookupKind(kinds, spec, scope):
"""Tries to find which Kind a spec refers to, given the scope in which its
referenced. Starts checking from the narrowest scope to most general. For
@@ -85,11 +96,15 @@ def LookupValue(values, name, scope, kind):
return values.get(name)
def FixupExpression(module, value, scope, kind):
- """Translates an IDENTIFIER into a structured Value object."""
+ """Translates an IDENTIFIER into a built-in value or structured NamedValue
+ object."""
if isinstance(value, tuple) and value[0] == 'IDENTIFIER':
+ # Allow user defined values to shadow builtins.
result = LookupValue(module.values, value[1], scope, kind)
if result:
return result
+ if IsBuiltinValue(value[1]):
+ return mojom.BuiltinValue(value[1])
return value
def KindToData(kind):
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_js_generator.py ('k') | mojo/public/tools/bindings/pylib/mojom/generate/module.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698