Commit 54e555e4 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Implement public representation of Typedef

Bug: 839389
Change-Id: I04ec1ffa64070b9a76fa5c9d9dc82a59ab4cf014
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1714810Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680333}
parent eec5897a
......@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from .typedef import Typedef
from .user_defined_type import UserDefinedType
......@@ -52,7 +53,7 @@ class DatabaseBody(object):
self._defs[kind] = {}
def register(self, kind, user_defined_type):
assert isinstance(user_defined_type, UserDefinedType)
assert isinstance(user_defined_type, (UserDefinedType, Typedef))
assert kind in DatabaseBody.Kind.itervalues()
try:
self.find_by_identifier(user_defined_type.identifier)
......
......@@ -8,6 +8,7 @@ from .dictionary import Dictionary
from .identifier_ir_map import IdentifierIRMap
from .idl_type import IdlTypeFactory
from .reference import RefByIdFactory
from .typedef import Typedef
class IdlCompiler(object):
......@@ -103,6 +104,11 @@ class IdlCompiler(object):
for ir in dictionary_irs.itervalues():
self._db.register(DatabaseBody.Kind.DICTIONARY, Dictionary(ir))
typedef_irs = self._ir_map.find_by_kind(
IdentifierIRMap.IR.Kind.TYPEDEF)
for ir in typedef_irs.itervalues():
self._db.register(DatabaseBody.Kind.TYPEDEF, Typedef(ir))
def _resolve_references_to_idl_type(self):
def resolve(ref):
# Resolve to stubs for the time being.
......
......@@ -12,6 +12,7 @@ from .common import WithExtendedAttributes
from .common import WithIdentifier
from .reference import Proxy
from .reference import RefById
from .typedef import Typedef
from .user_defined_type import UserDefinedType
# The implementation class hierarchy of IdlType
......@@ -562,6 +563,7 @@ class TypedefType(IdlType, WithIdentifier):
code_generator_info=None,
debug_info=None,
pass_key=None):
assert isinstance(typedef, Typedef)
IdlType.__init__(
self,
code_generator_info=code_generator_info,
......
......@@ -31,10 +31,18 @@ class Typedef(WithIdentifier, WithCodeGeneratorInfo, WithComponent,
self.idl_type = idl_type
def __init__(self, ir):
assert isinstance(ir, Typedef.IR)
WithIdentifier.__init__(self, ir.identifier)
WithCodeGeneratorInfo.__init__(self,
ir.code_generator_info.make_copy())
WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info.make_copy())
self._idl_type = ir.idl_type
@property
def idl_type(self):
"""
Returns the type to have an alias.
@return IdlType
"""
assert False, 'Not implemented yet'
"""Returns the typedef'ed type."""
return self._idl_type
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