| Index: third_party/WebKit/Source/bindings/scripts/code_generator_v8.py
|
| diff --git a/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py b/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py
|
| index 49d6c05b36def62e7d2104f42df02347005f8edb..094959eadcf339d17622442dae155ff150713b42 100644
|
| --- a/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py
|
| +++ b/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py
|
| @@ -76,6 +76,7 @@ from idl_definitions import Visitor
|
| import idl_types
|
| from idl_types import IdlType
|
| from v8_attributes import attribute_filters
|
| +import v8_callback_function
|
| import v8_callback_interface
|
| import v8_dictionary
|
| from v8_globals import includes, interfaces
|
| @@ -124,6 +125,8 @@ def set_global_type_info(info_provider):
|
| interfaces_info = info_provider.interfaces_info
|
| idl_types.set_ancestors(interfaces_info['ancestors'])
|
| IdlType.set_callback_interfaces(interfaces_info['callback_interfaces'])
|
| + IdlType.set_experimental_callback_functions(
|
| + info_provider.callback_functions)
|
| IdlType.set_dictionaries(interfaces_info['dictionaries'])
|
| IdlType.set_enums(info_provider.enumerations)
|
| IdlType.set_implemented_as_interfaces(interfaces_info['implemented_as_interfaces'])
|
| @@ -416,6 +419,44 @@ class CodeGeneratorUnionType(object):
|
| return outputs
|
|
|
|
|
| +class CodeGeneratorCallbackFunction(object):
|
| + def __init__(self, info_provider, cache_dir, output_dir, target_component):
|
| + self.info_provider = info_provider
|
| + self.jinja_env = initialize_jinja_env(cache_dir)
|
| + self.output_dir = output_dir
|
| + self.target_component = target_component
|
| + set_global_type_info(info_provider)
|
| +
|
| + def generate_code_internal(self, callback_function):
|
| + header_template = self.jinja_env.get_template('callback_function.h')
|
| + cpp_template = self.jinja_env.get_template('callback_function.cpp')
|
| + template_context = v8_callback_function.callback_function_context(
|
| + callback_function)
|
| + template_context['header_includes'].add(
|
| + self.info_provider.include_path_for_export)
|
| + template_context['header_includes'] = normalize_and_sort_includes(
|
| + template_context['header_includes'])
|
| + template_context['code_generator'] = module_pyname
|
| + template_context['exported'] = self.info_provider.specifier_for_export
|
| + header_text = header_template.render(template_context)
|
| + cpp_text = cpp_template.render(template_context)
|
| + header_path = posixpath.join(self.output_dir, 'V8%s.h' % callback_function.name)
|
| + cpp_path = posixpath.join(self.output_dir, 'V8%s.cpp' % callback_function.name)
|
| + return (
|
| + (header_path, header_text),
|
| + (cpp_path, cpp_text),
|
| + )
|
| +
|
| + def generate_code(self):
|
| + callback_functions = self.info_provider.callback_functions
|
| + if not callback_functions:
|
| + return ()
|
| + outputs = set()
|
| + for callback_function in callback_functions.itervalues():
|
| + outputs.update(self.generate_code_internal(callback_function))
|
| + return outputs
|
| +
|
| +
|
| def initialize_jinja_env(cache_dir):
|
| jinja_env = jinja2.Environment(
|
| loader=jinja2.FileSystemLoader(templates_dir),
|
|
|