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

Side by Side Diff: Source/bindings/scripts/v8_types.py

Issue 1159403005: bindings: Use IDL dictionary to implement FontFaceSetLoadEventInit (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/tests/idls/core/TestDictionary.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 elif idl_literal.idl_type in ('integer', 'float'): 915 elif idl_literal.idl_type in ('integer', 'float'):
916 member_type = idl_type.numeric_member_type 916 member_type = idl_type.numeric_member_type
917 elif idl_literal.idl_type == 'boolean': 917 elif idl_literal.idl_type == 'boolean':
918 member_type = idl_type.boolean_member_type 918 member_type = idl_type.boolean_member_type
919 else: 919 else:
920 raise ValueError('Unsupported literal type: ' + idl_literal.idl_type) 920 raise ValueError('Unsupported literal type: ' + idl_literal.idl_type)
921 921
922 return '%s::from%s(%s)' % (idl_type.name, member_type.name, 922 return '%s::from%s(%s)' % (idl_type.name, member_type.name,
923 member_type.literal_cpp_value(idl_literal)) 923 member_type.literal_cpp_value(idl_literal))
924 924
925
926 def array_or_sequence_literal_cpp_value(idl_type, idl_literal):
927 # Only support empty arrays.
928 if idl_literal.value == '[]':
929 element_type = idl_type.element_type
930 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', element_type.gc_type)
931 inner_type = cpp_template_type(ref_ptr_type, element_type.name)
932 vector_type = cpp_ptr_type('Vector', 'HeapVector',
933 element_type.gc_type)
934 return cpp_template_type(vector_type, inner_type) + '()'
935 raise ValueError('Unsupported literal type: ' + idl_literal.idl_type)
936
937
925 IdlType.literal_cpp_value = literal_cpp_value 938 IdlType.literal_cpp_value = literal_cpp_value
926 IdlUnionType.literal_cpp_value = union_literal_cpp_value 939 IdlUnionType.literal_cpp_value = union_literal_cpp_value
940 IdlArrayOrSequenceType.literal_cpp_value = array_or_sequence_literal_cpp_value
927 941
928 942
929 ################################################################################ 943 ################################################################################
930 # Utility properties for nullable types 944 # Utility properties for nullable types
931 ################################################################################ 945 ################################################################################
932 946
933 947
934 def cpp_type_has_null_value(idl_type): 948 def cpp_type_has_null_value(idl_type):
935 # - String types (String/AtomicString) represent null as a null string, 949 # - String types (String/AtomicString) represent null as a null string,
936 # i.e. one for which String::isNull() returns true. 950 # i.e. one for which String::isNull() returns true.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 number_of_nullable_member_types_union) 991 number_of_nullable_member_types_union)
978 992
979 993
980 def includes_nullable_type_union(idl_type): 994 def includes_nullable_type_union(idl_type):
981 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type 995 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type
982 return idl_type.number_of_nullable_member_types == 1 996 return idl_type.number_of_nullable_member_types == 1
983 997
984 IdlTypeBase.includes_nullable_type = False 998 IdlTypeBase.includes_nullable_type = False
985 IdlNullableType.includes_nullable_type = True 999 IdlNullableType.includes_nullable_type = True
986 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) 1000 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/idls/core/TestDictionary.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698