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

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',
88 'PromiseResolver': 'ScriptPromiseResolver',
87 } 89 }
88 CPP_UNSIGNED_TYPES = set([ 90 CPP_UNSIGNED_TYPES = set([
89 'octet', 91 'octet',
90 'unsigned int', 92 'unsigned int',
91 'unsigned long', 93 'unsigned long',
92 'unsigned short', 94 'unsigned short',
93 ]) 95 ])
94 PRIMITIVE_TYPES = set([ 96 PRIMITIVE_TYPES = set([
95 'boolean', 97 'boolean',
96 'void', 98 'void',
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 for acronym in ACRONYMS: 206 for acronym in ACRONYMS:
205 if name.startswith(acronym): 207 if name.startswith(acronym):
206 name.replace(acronym, acronym.lower()) 208 name.replace(acronym, acronym.lower())
207 return name 209 return name
208 return name[0].lower() + name[1:] 210 return name[0].lower() + name[1:]
209 211
210 212
211 def includes_for_type(data_type): 213 def includes_for_type(data_type):
212 if primitive_type(data_type) or data_type == 'DOMString': 214 if primitive_type(data_type) or data_type == 'DOMString':
213 return set() 215 return set()
216 if data_type == 'Promise':
217 return set(['ScriptPromise.h'])
218 if data_type == 'PromiseResolver':
219 return set(['ScriptPromiseResolver.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