Commit 0819d21a authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Support stringifier of IDL interface

Bug: 839389
Change-Id: I382b2f7eef3897248263a7c7dda8849f58ca1536
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035630Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738436}
parent be9cafe1
...@@ -57,6 +57,9 @@ class CodeGenContext(object): ...@@ -57,6 +57,9 @@ class CodeGenContext(object):
"operation": None, "operation": None,
"operation_group": None, "operation_group": None,
# Special member-ish definition
"stringifier": None,
# The names of the class being generated and its base class. # The names of the class being generated and its base class.
"base_class_name": None, "base_class_name": None,
"class_name": None, "class_name": None,
...@@ -226,6 +229,9 @@ class CodeGenContext(object): ...@@ -226,6 +229,9 @@ class CodeGenContext(object):
@property @property
def property_(self): def property_(self):
if self.stringifier:
return _StringifierProperty(self.stringifier)
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.exposed_construct or self.dict_member or self.exposed_construct
or self.operation_group) or self.operation_group)
...@@ -244,3 +250,47 @@ class CodeGenContext(object): ...@@ -244,3 +250,47 @@ class CodeGenContext(object):
CodeGenContext.init() CodeGenContext.init()
class _PropertyBase(object):
def __init__(self, identifier, extended_attributes, owner, debug_info):
assert isinstance(identifier, web_idl.Identifier)
assert identifier
assert isinstance(extended_attributes, web_idl.ExtendedAttributes)
assert isinstance(debug_info, web_idl.DebugInfo)
self._identifier = identifier
self._extended_attributes = extended_attributes
self._owner = owner
self._debug_info = debug_info
@property
def identifier(self):
return self._identifier
@property
def extended_attributes(self):
return self._extended_attributes
@property
def owner(self):
return self._owner
@property
def debug_info(self):
return self._debug_info
class _StringifierProperty(_PropertyBase):
def __init__(self, stringifier):
if stringifier.attribute:
extended_attributes = stringifier.attribute.extended_attributes
else:
extended_attributes = stringifier.operation.extended_attributes
_PropertyBase.__init__(
self,
identifier=web_idl.Identifier("toString"),
extended_attributes=extended_attributes,
owner=stringifier.owner,
debug_info=stringifier.debug_info)
...@@ -35,6 +35,8 @@ from .attribute import Attribute ...@@ -35,6 +35,8 @@ from .attribute import Attribute
from .callback_function import CallbackFunction from .callback_function import CallbackFunction
from .callback_interface import CallbackInterface from .callback_interface import CallbackInterface
from .composition_parts import Component from .composition_parts import Component
from .composition_parts import DebugInfo
from .composition_parts import Identifier
from .constant import Constant from .constant import Constant
from .constructor import Constructor from .constructor import Constructor
from .constructor import ConstructorGroup from .constructor import ConstructorGroup
...@@ -44,10 +46,17 @@ from .dictionary import Dictionary ...@@ -44,10 +46,17 @@ from .dictionary import Dictionary
from .dictionary import DictionaryMember from .dictionary import DictionaryMember
from .enumeration import Enumeration from .enumeration import Enumeration
from .exposure import Exposure from .exposure import Exposure
from .extended_attribute import ExtendedAttribute
from .extended_attribute import ExtendedAttributes
from .function_like import FunctionLike from .function_like import FunctionLike
from .function_like import OverloadGroup from .function_like import OverloadGroup
from .idl_type import IdlType from .idl_type import IdlType
from .interface import Interface from .interface import Interface
from .interface import Iterable
from .interface import Maplike
from .interface import PropertyAccessors
from .interface import Setlike
from .interface import Stringifier
from .literal_constant import LiteralConstant from .literal_constant import LiteralConstant
from .namespace import Namespace from .namespace import Namespace
from .operation import Operation from .operation import Operation
......
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