From cb3b714db098466d34735c23c79c8d8f34b2e233 Mon Sep 17 00:00:00 2001 From: bashi Date: Tue, 31 Mar 2015 23:56:18 -0700 Subject: [PATCH] IDL: Support 'required' in dictionary Per spec[1], a dictionary member can be specified as 'required'. If it is specified, node.GetProperty('REQUIRED') returns true. [1] http://heycam.github.io/webidl/#required-dictionary-member BUG=472220 Review URL: https://codereview.chromium.org/1046383002 Cr-Commit-Position: refs/heads/master@{#323195} --- tools/idl_parser/idl_parser.py | 11 ++++++++--- tools/idl_parser/test_parser/dictionary_web.idl | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py index 27b19142908e..f8e509f7602f 100755 --- a/tools/idl_parser/idl_parser.py +++ b/tools/idl_parser/idl_parser.py @@ -309,10 +309,15 @@ class IDLParser(object): # [13] def p_DictionaryMember(self, p): - """DictionaryMember : Type identifier Default ';'""" - p[0] = self.BuildNamed('Key', p, 2, ListFromConcat(p[1], p[3])) + """DictionaryMember : Required Type identifier Default ';'""" + p[0] = self.BuildNamed('Key', p, 3, ListFromConcat(p[1], p[2], p[4])) - # [14] NOT IMPLEMENTED (Required) + # [14] + def p_Required(self, p): + """Required : REQUIRED + |""" + if len(p) > 1: + p[0] = self.BuildTrue('REQUIRED') # [15] def p_PartialDictionary(self, p): diff --git a/tools/idl_parser/test_parser/dictionary_web.idl b/tools/idl_parser/test_parser/dictionary_web.idl index ba5b1644cc68..507b28834936 100644 --- a/tools/idl_parser/test_parser/dictionary_web.idl +++ b/tools/idl_parser/test_parser/dictionary_web.idl @@ -69,6 +69,15 @@ dictionary MyDictBig { long unsetLong; }; +/* TREE + *Dictionary(MyDictRequired) + * Key(setLong) + * Type() + * PrimitiveType(long) + */ +dictionary MyDictRequired { + required long setLong; +}; /* ERROR Unexpected "{" after keyword "dictionary". */ dictionary { -- 2.11.4.GIT