| Index: Source/bindings/scripts/v8_blink_in_js.py
|
| diff --git a/Source/bindings/scripts/v8_blink_in_js.py b/Source/bindings/scripts/v8_blink_in_js.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bd70695f96bcf95928112d1214a7917c8b2071fb
|
| --- /dev/null
|
| +++ b/Source/bindings/scripts/v8_blink_in_js.py
|
| @@ -0,0 +1,83 @@
|
| +# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""Generate template values for V8BlinkInJSInterface.
|
| +
|
| +Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
|
| +"""
|
| +
|
| +from idl_types import IdlType
|
| +from v8_globals import includes
|
| +import v8_types
|
| +import v8_utilities
|
| +
|
| +BLINK_IN_JS_INTERFACE_H_INCLUDES = frozenset([
|
| + 'bindings/v8/V8Binding.h',
|
| +])
|
| +
|
| +BLINK_IN_JS_INTERFACE_CPP_INCLUDES = frozenset([
|
| + 'bindings/core/v8/V8Window.h',
|
| + 'bindings/v8/BlinkInJSController.h',
|
| + 'core/dom/ScriptForbiddenScope.h',
|
| + 'core/frame/LocalFrame.h',
|
| +])
|
| +
|
| +
|
| +def generate_blink_in_js_interface(blink_in_js_interface):
|
| + includes.clear()
|
| + includes.update(BLINK_IN_JS_INTERFACE_CPP_INCLUDES)
|
| + return {
|
| + 'cpp_class': blink_in_js_interface.name,
|
| + 'v8_class': v8_utilities.v8_class_name(blink_in_js_interface),
|
| + 'header_includes': set(BLINK_IN_JS_INTERFACE_H_INCLUDES),
|
| + 'forward_declarations': forward_declarations(blink_in_js_interface),
|
| + 'methods': [generate_method(operation)
|
| + for operation in blink_in_js_interface.operations],
|
| + }
|
| +
|
| +
|
| +def forward_declarations(blink_in_js_interface):
|
| + declarations = set(['LocalFrame'])
|
| + for operation in blink_in_js_interface.operations:
|
| + if operation.idl_type.is_wrapper_type:
|
| + declarations.add(operation.idl_type.base_type)
|
| + for argument in operation.arguments:
|
| + if argument.idl_type.is_wrapper_type:
|
| + declarations.add(argument.idl_type.base_type)
|
| + return sorted(declarations)
|
| +
|
| +
|
| +def generate_method(operation):
|
| + extended_attributes = operation.extended_attributes
|
| + idl_type = operation.idl_type
|
| + idl_type_str = str(idl_type)
|
| + contents = {
|
| + 'cpp_type': idl_type.cpp_type_args(used_as_primitive_type=True),
|
| + 'name': operation.name,
|
| + 'v8_value_to_cpp_value': v8_types.v8_value_to_cpp_value(
|
| + idl_type, extended_attributes, 'v8Value', 0, isolate='scriptState->isolate()')
|
| + if idl_type.name != 'void' else '',
|
| + }
|
| + contents.update(generate_arguments_contents(operation.arguments, idl_type))
|
| + return contents
|
| +
|
| +
|
| +def generate_arguments_contents(arguments, idl_type):
|
| + def generate_argument(argument):
|
| + return {
|
| + 'handle': '%sHandle' % argument.name,
|
| + 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value(
|
| + argument.name, isolate='scriptState->isolate()',
|
| + creation_context='scriptState->context()->Global()'),
|
| + }
|
| +
|
| + argument_declarations = ['LocalFrame* frame']
|
| + argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args(used_as_argument=True), argument.name)
|
| + for argument in arguments])
|
| + if idl_type.name != 'void':
|
| + argument_declarations.append('%s* %s' % (idl_type.cpp_type, 'output'))
|
| + return {
|
| + 'argument_declarations': argument_declarations,
|
| + 'arguments': [generate_argument(argument) for argument in arguments],
|
| + }
|
|
|