Commit 44668ef6 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Add a check of IDL partial definitions

Checks consistency between non-partial and partial definitions.

Bug: 839389
Change-Id: Id5643b3f7eb93227d8f8b1c182da9d52e781fffd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446311
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813666}
parent 4a577773
......@@ -286,7 +286,27 @@ class IdlCompiler(object):
posixpath.extsep.join([filename, 'h']))
new_ir.code_generator_info.set_blink_headers([header])
def _check_existence_of_non_partials(self, non_partial_kind, partial_kind):
non_partials = self._ir_map.find_by_kind(non_partial_kind)
partials = self._ir_map.find_by_kind(partial_kind)
for identifier, partial_irs in partials.items():
if not non_partials.get(identifier):
locations = ''.join(
map(lambda ir: ' {}\n'.format(ir.debug_info.location),
partial_irs))
raise ValueError(
'{} {} is defined without a non-partial definition.\n'
'{}'.format(partial_irs[0].kind, identifier, locations))
def _merge_partial_interface_likes(self):
self._check_existence_of_non_partials(IRMap.IR.Kind.INTERFACE,
IRMap.IR.Kind.PARTIAL_INTERFACE)
self._check_existence_of_non_partials(
IRMap.IR.Kind.INTERFACE_MIXIN,
IRMap.IR.Kind.PARTIAL_INTERFACE_MIXIN)
self._check_existence_of_non_partials(IRMap.IR.Kind.NAMESPACE,
IRMap.IR.Kind.PARTIAL_NAMESPACE)
irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.INTERFACE,
IRMap.IR.Kind.INTERFACE_MIXIN,
IRMap.IR.Kind.NAMESPACE)
......@@ -304,6 +324,9 @@ class IdlCompiler(object):
self._merge_interface_like_irs(ir_sets_to_merge)
def _merge_partial_dictionaries(self):
self._check_existence_of_non_partials(IRMap.IR.Kind.DICTIONARY,
IRMap.IR.Kind.PARTIAL_DICTIONARY)
old_dictionaries = self._ir_map.find_by_kind(IRMap.IR.Kind.DICTIONARY)
old_partial_dictionaries = self._ir_map.find_by_kind(
IRMap.IR.Kind.PARTIAL_DICTIONARY)
......
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