Commit 339c7f0b authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Minor updates on CodeGenerationContext

Renames CodeGenerationContext.property to |property_| in order
to avoid conflict with the built-in property function.

Also adds more utility properties.

Bug: 839389
Change-Id: I166374af1d3dc451b1e783d873f61f5b6aa48c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1882188Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709858}
parent 1db0fd35
...@@ -53,7 +53,7 @@ class CodeGenerationContext(object): ...@@ -53,7 +53,7 @@ class CodeGenerationContext(object):
cls._computational_attrs = ( cls._computational_attrs = (
"class_like", "class_like",
"member_like", "member_like",
"property", "property_",
) )
# Define public readonly properties of this class. # Define public readonly properties of this class.
...@@ -123,7 +123,7 @@ class CodeGenerationContext(object): ...@@ -123,7 +123,7 @@ class CodeGenerationContext(object):
for attr in self._computational_attrs: for attr in self._computational_attrs:
value = getattr(self, attr) value = getattr(self, attr)
if value is not None: if value is not None:
bindings[attr] = value bindings[attr.strip("_")] = value
return bindings return bindings
...@@ -132,15 +132,41 @@ class CodeGenerationContext(object): ...@@ -132,15 +132,41 @@ class CodeGenerationContext(object):
return (self.callback_interface or self.dictionary or self.interface return (self.callback_interface or self.dictionary or self.interface
or self.namespace) or self.namespace)
@property
def is_return_by_argument(self):
if self.return_type is None:
return None
return_type = self.return_type.unwrap()
return return_type.is_dictionary or return_type.is_union
@property
def may_throw_exception(self):
if not self.member_like:
return None
ext_attr = self.member_like.extended_attributes.get("RaisesException")
if not ext_attr:
return False
return (not ext_attr.values
or (self.attribute_get and "Getter" in ext_attr.values)
or (self.attribute_set and "Setter" in ext_attr.values))
@property @property
def member_like(self): def member_like(self):
return (self.attribute or self.constant or self.constructor return (self.attribute or self.constant or self.constructor
or self.dict_member or self.operation) or self.dict_member or self.operation)
@property @property
def property(self): def property_(self):
return (self.attribute or self.constant or self.constructor_group return (self.attribute or self.constant or self.constructor_group
or self.dict_member or self.operation_group) or self.dict_member or self.operation_group)
@property
def return_type(self):
if self.attribute_get:
return self.attribute.idl_type
if self.operation:
return self.operation.return_type
return None
CodeGenerationContext.init() CodeGenerationContext.init()
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