Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: third_party/WebKit/Source/bindings/scripts/idl_definitions.py

Issue 2719913002: bindings: Add idl_types.IdlRecordType. (Closed)
Patch Set: Add some tests to idl_types_test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/idl_types.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/scripts/idl_definitions.py
diff --git a/third_party/WebKit/Source/bindings/scripts/idl_definitions.py b/third_party/WebKit/Source/bindings/scripts/idl_definitions.py
index 52937edac87fb2d5e9aac1532163f7c411428e55..4b00b56fb466e2f272dd79bb8905f85b74abcbfd 100644
--- a/third_party/WebKit/Source/bindings/scripts/idl_definitions.py
+++ b/third_party/WebKit/Source/bindings/scripts/idl_definitions.py
@@ -26,6 +26,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# pylint: disable=relative-import
+
"""Blink IDL Intermediate Representation (IR) classes.
Classes are primarily constructors, which build an IdlDefinitions object
@@ -64,7 +66,13 @@ Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
import abc
-from idl_types import IdlType, IdlUnionType, IdlArrayType, IdlSequenceType, IdlFrozenArrayType, IdlNullableType
+from idl_types import IdlArrayType
+from idl_types import IdlFrozenArrayType
+from idl_types import IdlNullableType
+from idl_types import IdlRecordType
+from idl_types import IdlSequenceType
+from idl_types import IdlType
+from idl_types import IdlUnionType
SPECIAL_KEYWORD_LIST = ['LEGACYCALLER', 'GETTER', 'SETTER', 'DELETER']
@@ -1027,9 +1035,24 @@ def type_node_inner_to_type(node):
return union_type_node_to_idl_union_type(node)
elif node_class == 'Promise':
return IdlType('Promise')
+ elif node_class == 'Record':
+ return record_node_to_type(node)
raise ValueError('Unrecognized node class: %s' % node_class)
+def record_node_to_type(node):
+ children = node.GetChildren()
+ if len(children) != 2:
+ raise ValueError('record<K,V> node expects exactly 2 children, got %d' % (len(children)))
+ key_child = children[0]
+ value_child = children[1]
+ if key_child.GetClass() != 'StringType':
+ raise ValueError('Keys in record<K,V> nodes must be string types.')
+ if value_child.GetClass() != 'Type':
+ raise ValueError('Unrecognized node class for record<K,V> value: %s' % value_child.GetClass())
+ return IdlRecordType(IdlType(key_child.GetName()), type_node_to_type(value_child))
+
+
def sequence_node_to_type(node):
children = node.GetChildren()
class_name = node.GetClass()
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/idl_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698