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..c5af2ae7fa04489a65567ed443e4da5fb3b7d378 100644 |
--- a/Source/bindings/scripts/code_generator_v8.py |
+++ b/Source/bindings/scripts/code_generator_v8.py |
@@ -209,6 +209,10 @@ def v8_class_name(interface): |
return v8_type(interface.name) |
+def values_for_extended_attributes(extended_attributes, key): |
+ return extended_attributes.get(key, '').split('|') |
Nils Barth (inactive)
2013/08/06 05:45:18
Extended attributes are internally a bit tricky;
I
alancutter (OOO until 2018)
2013/08/07 00:40:24
Sounds good! Done.
|
+ |
+ |
class CodeGeneratorV8: |
def __init__(self, definitions, interface_name, output_directory, relative_dir_posix, idl_directories, verbose=False): |
self.idl_definitions = definitions |
@@ -254,12 +258,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 +327,7 @@ class CodeGeneratorV8: |
def argument_declaration(argument): |
return '%s %s' % (cpp_type(argument.data_type, 'raw'), argument.name) |
+ call_with_this_handle = 'ThisValue' in values_for_extended_attributes(operation.extended_attributes, 'CallWith') |
Nils Barth (inactive)
2013/08/06 05:45:18
Using above functions, this can be rewritten as:
c
alancutter (OOO until 2018)
2013/08/07 00:40:24
Done.
|
arguments = [] |
custom = 'Custom' in operation.extended_attributes |
if not custom: |
@@ -331,6 +336,7 @@ 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_handle': call_with_this_handle, |
'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'), |
'name': operation.name, |
'arguments': arguments, |