Commit 1c654ac6 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Implement IDL constants

Bug: 839389
Change-Id: Ibb8351683cb95481e5e4d293dca499479f7beaaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1980656
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727150}
parent 6ee86f36
...@@ -132,19 +132,29 @@ def namespace_f(format_string, *args, **kwargs): ...@@ -132,19 +132,29 @@ def namespace_f(format_string, *args, **kwargs):
def _concat(style_func, args): def _concat(style_func, args):
assert callable(style_func) assert callable(style_func)
return style_func(" ".join(map(str, args))) return style_func(" ".join(map(_tokenize, args)))
def _format(style_func, format_string, *args, **kwargs): def _format(style_func, format_string, *args, **kwargs):
assert callable(style_func) assert callable(style_func)
assert isinstance(format_string, str) assert isinstance(format_string, str)
args = map(style_func, map(str, args)) args = map(style_func, map(_tokenize, args))
for key, value in kwargs.iteritems(): for key, value in kwargs.iteritems():
kwargs[key] = style_func(str(value)) kwargs[key] = style_func(_tokenize(value))
return format_string.format(*args, **kwargs) return format_string.format(*args, **kwargs)
def _tokenize(s):
s = str(s)
if "_" in s and s.isupper():
# NameStyleConverter doesn't treat "ABC_DEF" as two tokens of "abc" and
# "def" while treating "abc_def" as "abc" and "def". Help
# NameStyleConverter by lowering the string.
return s.lower()
return s
class raw(object): class raw(object):
""" """
Namespace to provide (unrecommended) raw controls on case conversions. Namespace to provide (unrecommended) raw controls on case conversions.
......
...@@ -66,6 +66,14 @@ class Constant(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo, ...@@ -66,6 +66,14 @@ class Constant(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo,
"""Returns the type""" """Returns the type"""
return self._idl_type return self._idl_type
@property
def is_static(self):
return True
@property
def is_readonly(self):
return True
@property @property
def value(self): def value(self):
"""Returns the value.""" """Returns the value."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment