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

Unified Diff: Source/bindings/scripts/code_generator_v8.py

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More generator changes Created 7 years, 4 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
Index: Source/bindings/scripts/code_generator_v8.py
diff --git a/Source/bindings/scripts/code_generator_v8.py b/Source/bindings/scripts/code_generator_v8.py
index 41e81fdaae08a507ec9365f5c4e5ecb204048477..ecce6ef48c97fb1cf918082237023962479b8dda 100644
--- a/Source/bindings/scripts/code_generator_v8.py
+++ b/Source/bindings/scripts/code_generator_v8.py
@@ -209,6 +209,19 @@ def v8_class_name(interface):
return v8_type(interface.name)
+def has_extended_attribute_value(extended_attributes, key, value):
+ return key in extended_attributes and value in extended_attribute_values(extended_attributes, key)
+
+
+def extended_attribute_values(extended_attributes, key):
haraken 2013/08/07 00:55:54 Nit: Do you need this helper? You might be able to
alancutter (OOO until 2018) 2013/08/07 01:12:48 I think the motivation for making it a separate fu
Nils Barth (inactive) 2013/08/07 01:50:34 For reference, I suggested these functions; as Ala
+ if key not in extended_attributes:
+ return None
+ values_string = extended_attributes[key]
+ if not values_string:
+ return []
+ return re.split('[|&]', values_string)
+
+
class CodeGeneratorV8:
def __init__(self, definitions, interface_name, output_directory, relative_dir_posix, idl_directories, verbose=False):
self.idl_definitions = definitions
@@ -254,12 +267,12 @@ class CodeGeneratorV8:
header_basename = v8_class_name(self.interface) + '.h'
cpp_basename = v8_class_name(self.interface) + '.cpp'
if self.interface.is_callback:
- header_template = 'templates/callback_interface.h'
- cpp_template = 'templates/callback_interface.cpp'
+ header_template = 'templates/callback_interface.h.tmpl'
+ cpp_template = 'templates/callback_interface.cpp.tmpl'
template_contents = self.generate_callback_interface()
else:
- header_template = 'templates/interface.h'
- cpp_template = 'templates/interface.cpp'
+ header_template = 'templates/interface.h.tmpl'
+ cpp_template = 'templates/interface.cpp.tmpl'
template_contents = self.generate_interface()
template_contents['conditional_string'] = generate_conditional_string(self.interface)
header_file_text = apply_template(header_template, template_contents)
@@ -323,6 +336,7 @@ class CodeGeneratorV8:
def argument_declaration(argument):
return '%s %s' % (cpp_type(argument.data_type, 'raw'), argument.name)
+ call_with_this_handle = has_extended_attribute_value(operation.extended_attributes, 'CallWith', 'ThisValue')
arguments = []
custom = 'Custom' in operation.extended_attributes
if not custom:
@@ -330,11 +344,15 @@ class CodeGeneratorV8:
if operation.data_type != 'boolean':
raise Exception("We don't yet support callbacks that return non-boolean values.")
arguments = [generate_argument(argument) for argument in operation.arguments]
+ argument_declaration = ', '.join([argument_declaration(argument) for argument in operation.arguments])
+ if call_with_this_handle:
+ argument_declaration = 'ScriptValue thisValue, ' + argument_declaration
method = {
+ 'call_with_this_handle': call_with_this_handle,
'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'),
'name': operation.name,
'arguments': arguments,
- 'argument_declaration': ', '.join([argument_declaration(argument) for argument in operation.arguments]),
+ 'argument_declaration': argument_declaration,
'handles': ', '.join(['%sHandle' % argument.name for argument in operation.arguments]),
'custom': custom,
}

Powered by Google App Engine
This is Rietveld 408576698