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 6fd2403fb5eea5482cfdeadcc9893321bbd560fc..af13a84fe70c38c9417748d4b278c856fd7335cf 100644 |
--- a/Source/bindings/scripts/code_generator_v8.py |
+++ b/Source/bindings/scripts/code_generator_v8.py |
@@ -36,6 +36,7 @@ import os |
import posixpath |
import re |
import sys |
+import idl_definitions |
# jinja2 is in chromium's third_party directory. |
module_path, module_name = os.path.split(__file__) |
@@ -60,6 +61,7 @@ CALLBACK_INTERFACE_H_INCLUDES = set([ |
CPP_TYPE_SPECIAL_CONVERSION_RULES = { |
+ 'any': 'ScriptValue', |
'float': 'float', |
'double': 'double', |
'long long': 'long long', |
@@ -117,6 +119,8 @@ def cpp_type(data_type, pointer_type): |
def cpp_value_to_js_value(data_type, cpp_value, isolate, creation_context=''): |
"""Returns a expression that represent JS value corresponding to a C++ value.""" |
+ if data_type == 'any': |
+ return '%s.v8Value()' % cpp_value |
if data_type == 'boolean': |
return 'v8Boolean(%s, %s)' % (cpp_value, isolate) |
if data_type in ['long long', 'unsigned long long', 'DOMTimeStamp']: |
@@ -148,6 +152,8 @@ def generate_conditional_string(interface_or_attribute_or_operation): |
def includes_for_type(data_type): |
if primitive_type(data_type) or data_type == 'DOMString': |
return set() |
+ if data_type == 'any': |
+ return set(['bindings/v8/ScriptValue.h']) |
if sequence_type(data_type): |
return includes_for_type(sequence_type(data_type)) |
return set(['V8%s.h' % data_type]) |
@@ -230,8 +236,8 @@ class CodeGeneratorV8: |
} |
if self.interface.is_callback: |
template_contents.update(self.generate_callback_interface()) |
- header_file_text = apply_template('templates/callback.h', template_contents) |
- cpp_file_text = apply_template('templates/callback.cpp', template_contents) |
+ header_file_text = apply_template('templates/callback.h.tmpl', template_contents) |
+ cpp_file_text = apply_template('templates/callback.cpp.tmpl', template_contents) |
else: |
# FIXME: Implement. |
header_file_text = '' |
@@ -266,6 +272,13 @@ class CodeGeneratorV8: |
def argument_declaration(argument): |
return '%s %s' % (cpp_type(argument.data_type, 'raw'), argument.name) |
+ # FIXME: The CallWith extended attribute should be parsed into a list of values |
+ call_with_this_value = 'ThisValue' in operation.extended_attributes.get('CallWith', '').split('|') |
haraken
2013/08/05 10:52:41
Could you implement a helper method so that we can
alancutter (OOO until 2018)
2013/08/06 04:47:13
Done.
|
+ this_value_argument = generate_argument(idl_definitions.IdlArgument('thisValue', 'any')) |
+ declaration_arguments = operation.arguments |
+ if call_with_this_value: |
+ declaration_arguments = [idl_definitions.IdlArgument('thisValue', 'any')] + declaration_arguments |
haraken
2013/08/05 10:52:41
Can't you write this as follows?
operation.argu
|
+ |
arguments = [] |
custom = 'Custom' in operation.extended_attributes |
if not custom: |
@@ -274,10 +287,12 @@ class CodeGeneratorV8: |
raise Exception("We don't yet support callbacks that return non-boolean values.") |
arguments = [generate_argument(argument) for argument in operation.arguments] |
method = { |
+ 'call_with_this_value': call_with_this_value, |
+ 'this_value_argument': this_value_argument, |
'return_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': ', '.join([argument_declaration(argument) for argument in declaration_arguments]), |
'handles': ', '.join(['%sHandle' % argument.name for argument in operation.arguments]), |
'custom': custom, |
} |