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

IDL compiler: Collect Blink header names

Collects Blink headers based of filepaths of interface and partial
interface.  Interface mixins do not have Blink headers.

Bug: 839389
Change-Id: I88d12ea57e0dbef6475a19ad382694cd4b7efd44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983697Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728821}
parent 0b218df9
......@@ -7,6 +7,7 @@
_CODE_GENERATOR_INFO_ATTRIBUTES = (
'defined_in_mixin',
'defined_in_partial',
'blink_headers',
'property_implemented_as',
'receiver_implemented_as',
)
......
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import posixpath
from .code_generator_info import CodeGeneratorInfo
from .code_generator_info import CodeGeneratorInfoMutable
from .exposure import Exposure
......@@ -138,10 +140,20 @@ class WithComponent(object):
class Location(object):
_blink_path_prefix = posixpath.sep + posixpath.join(
'third_party', 'blink', 'renderer', '')
def __init__(self, filepath=None, line_number=None, position=None):
assert filepath is None or isinstance(filepath, str)
assert line_number is None or isinstance(line_number, int)
assert position is None or isinstance(position, int)
# idl_parser produces paths based on the working directory, which may
# not be the project root directory, e.g. "../../third_party/blink/...".
# Canonicalize the paths heuristically.
index = filepath.find(self._blink_path_prefix)
if index >= 0:
filepath = filepath[index + 1:]
self._filepath = filepath
self._line_number = line_number
self._position = position # Position number in a file
......
......@@ -4,6 +4,7 @@
import functools
import itertools
import posixpath
from .callback_function import CallbackFunction
from .callback_interface import CallbackInterface
......@@ -80,6 +81,7 @@ class IdlCompiler(object):
# Merge partial definitions.
self._record_defined_in_partial_and_mixin()
self._propagate_extattrs_per_idl_fragment()
self._determine_blink_headers()
self._merge_partial_interface_likes()
self._merge_partial_dictionaries()
# Merge mixins.
......@@ -211,6 +213,21 @@ class IdlCompiler(object):
map(process_interface_like, old_irs)
def _determine_blink_headers(self):
irs = self._ir_map.irs_of_kinds(
IRMap.IR.Kind.INTERFACE, IRMap.IR.Kind.NAMESPACE,
IRMap.IR.Kind.PARTIAL_INTERFACE, IRMap.IR.Kind.PARTIAL_NAMESPACE)
self._ir_map.move_to_new_phase()
for old_ir in irs:
new_ir = make_copy(old_ir)
self._ir_map.add(new_ir)
basepath, _ = posixpath.splitext(
new_ir.debug_info.location.filepath)
header = posixpath.extsep.join([basepath, "h"])
new_ir.code_generator_info.set_blink_headers([header])
def _merge_partial_interface_likes(self):
irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.INTERFACE,
IRMap.IR.Kind.INTERFACE_MIXIN,
......@@ -286,6 +303,13 @@ class IdlCompiler(object):
new_ir.constants.extend(to_be_merged.constants)
new_ir.operations.extend(to_be_merged.operations)
new_ir_headers = new_ir.code_generator_info.blink_headers
to_be_merged_headers = (
to_be_merged.code_generator_info.blink_headers)
if (new_ir_headers is not None
and to_be_merged_headers is not None):
new_ir_headers.extend(to_be_merged_headers)
def _process_interface_inheritances(self):
def is_own_member(member):
return 'Unforgeable' in member.extended_attributes
......
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