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

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

Issue 23479016: Introduce Promise mapping to the IDL generator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 CPP_TYPE_SPECIAL_CONVERSION_RULES = { 77 CPP_TYPE_SPECIAL_CONVERSION_RULES = {
78 'float': 'float', 78 'float': 'float',
79 'double': 'double', 79 'double': 'double',
80 'long long': 'long long', 80 'long long': 'long long',
81 'unsigned long long': 'unsigned long long', 81 'unsigned long long': 'unsigned long long',
82 'long': 'int', 82 'long': 'int',
83 'short': 'int', 83 'short': 'int',
84 'byte': 'int', 84 'byte': 'int',
85 'boolean': 'bool', 85 'boolean': 'bool',
86 'DOMString': 'const String&', 86 'DOMString': 'const String&',
87 'Promise': 'ScriptPromise',
87 } 88 }
88 CPP_UNSIGNED_TYPES = set([ 89 CPP_UNSIGNED_TYPES = set([
89 'octet', 90 'octet',
90 'unsigned int', 91 'unsigned int',
91 'unsigned long', 92 'unsigned long',
92 'unsigned short', 93 'unsigned short',
93 ]) 94 ])
95 # Promise is not yet in the Web IDL spec but is going to be speced
96 # as primitive types in the future.
94 PRIMITIVE_TYPES = set([ 97 PRIMITIVE_TYPES = set([
95 'boolean', 98 'boolean',
96 'void', 99 'void',
97 'Date', 100 'Date',
101 'Promise',
98 'byte', 102 'byte',
99 'octet', 103 'octet',
100 'short', 104 'short',
101 'long', 105 'long',
102 'long long', 106 'long long',
103 'unsigned short', 107 'unsigned short',
104 'unsigned long', 108 'unsigned long',
105 'unsigned long long', 109 'unsigned long long',
106 'float', 110 'float',
107 'double', 111 'double',
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 for acronym in ACRONYMS: 208 for acronym in ACRONYMS:
205 if name.startswith(acronym): 209 if name.startswith(acronym):
206 name.replace(acronym, acronym.lower()) 210 name.replace(acronym, acronym.lower())
207 return name 211 return name
208 return name[0].lower() + name[1:] 212 return name[0].lower() + name[1:]
209 213
210 214
211 def includes_for_type(data_type): 215 def includes_for_type(data_type):
212 if primitive_type(data_type) or data_type == 'DOMString': 216 if primitive_type(data_type) or data_type == 'DOMString':
213 return set() 217 return set()
218 if data_type == 'Promise':
219 return set(['ScriptPromise.h'])
214 if array_or_sequence_type(data_type): 220 if array_or_sequence_type(data_type):
215 return includes_for_type(array_or_sequence_type(data_type)) 221 return includes_for_type(array_or_sequence_type(data_type))
216 return set(['V8%s.h' % data_type]) 222 return set(['V8%s.h' % data_type])
217 223
218 224
219 def includes_for_cpp_class(class_name, relative_dir_posix): 225 def includes_for_cpp_class(class_name, relative_dir_posix):
220 return set([posixpath.join(relative_dir_posix, class_name + '.h')]) 226 return set([posixpath.join(relative_dir_posix, class_name + '.h')])
221 227
222 228
223 def includes_for_operation(operation): 229 def includes_for_operation(operation):
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 441
436 methods = [generate_method(operation) for operation in self.interface.op erations] 442 methods = [generate_method(operation) for operation in self.interface.op erations]
437 template_contents = { 443 template_contents = {
438 'cpp_class_name': self.interface.name, 444 'cpp_class_name': self.interface.name,
439 'v8_class_name': v8_class_name(self.interface), 445 'v8_class_name': v8_class_name(self.interface),
440 'cpp_includes': sorted(list(self.cpp_includes)), 446 'cpp_includes': sorted(list(self.cpp_includes)),
441 'header_includes': sorted(list(self.header_includes)), 447 'header_includes': sorted(list(self.header_includes)),
442 'methods': methods, 448 'methods': methods,
443 } 449 }
444 return template_contents 450 return template_contents
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698