Chromium Code Reviews| 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..c8d5ebc8212250a5096b94040494bb731c240d4c 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): |
| + 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 |
| @@ -320,9 +333,10 @@ class CodeGeneratorV8: |
| } |
| def generate_method(operation): |
| - def argument_declaration(argument): |
| + def generate_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([generate_argument_declaration(argument) for argument in operation.arguments]) |
|
arv (Not doing code reviews)
2013/08/08 14:24:51
I was referring to the []. join takes an iterable
alancutter (OOO until 2018)
2013/08/09 05:33:26
I see now, that is better.
Done.
|
| + 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, |
| } |