当前位置: 首页>>代码示例>>Python>>正文


Python v8_types.cpp_template_type函数代码示例

本文整理汇总了Python中v8_types.cpp_template_type函数的典型用法代码示例。如果您正苦于以下问题:Python cpp_template_type函数的具体用法?Python cpp_template_type怎么用?Python cpp_template_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cpp_template_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: union_member_argument_context

def union_member_argument_context(idl_type, index):
    """Returns a context of union member for argument."""
    this_cpp_value = 'result%d' % index
    this_cpp_type = idl_type.cpp_type
    this_cpp_type_initializer = idl_type.cpp_type_initializer
    cpp_return_value = this_cpp_value

    if not idl_type.cpp_type_has_null_value:
        this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type)
        this_cpp_type_initializer = ''
        cpp_return_value = '%s.get()' % this_cpp_value

    if idl_type.is_string_type:
        null_check_value = '!%s.isNull()' % this_cpp_value
    else:
        null_check_value = this_cpp_value

    return {
        'cpp_type': this_cpp_type,
        'cpp_type_initializer': this_cpp_type_initializer,
        'cpp_value': this_cpp_value,
        'null_check_value': null_check_value,
        'v8_set_return_value': idl_type.v8_set_return_value(
            cpp_value=cpp_return_value,
            release=idl_type.release),
    }
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_WebKit,代码行数:26,代码来源:v8_methods.py

示例2: constructor_context

def constructor_context(interface, constructor):
    # [RaisesException=Constructor]
    is_constructor_raises_exception = \
        interface.extended_attributes.get('RaisesException') == 'Constructor'

    return {
        'arguments': [v8_methods.argument_context(interface, constructor, argument, index)
                      for index, argument in enumerate(constructor.arguments)],
        'cpp_type': cpp_template_type(
            cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
            cpp_name(interface)),
        'cpp_value': v8_methods.cpp_value(
            interface, constructor, len(constructor.arguments)),
        'has_exception_state':
            is_constructor_raises_exception or
            any(argument for argument in constructor.arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.v8_conversion_needs_exception_state),
        'is_call_with_document':
            # [ConstructorCallWith=Document]
            has_extended_attribute_value(interface,
                'ConstructorCallWith', 'Document'),
        'is_call_with_execution_context':
            # [ConstructorCallWith=ExecutionContext]
            has_extended_attribute_value(interface,
                'ConstructorCallWith', 'ExecutionContext'),
        'is_constructor': True,
        'is_named_constructor': False,
        'is_raises_exception': is_constructor_raises_exception,
        'number_of_required_arguments':
            number_of_required_arguments(constructor),
    }
开发者ID:335969568,项目名称:Blink-1,代码行数:32,代码来源:v8_interface.py

示例3: argument_context

def argument_context(interface, method, argument, index, is_visible=True):
    extended_attributes = argument.extended_attributes
    idl_type = argument.idl_type
    if is_visible:
        idl_type.add_includes_for_type(extended_attributes)
    this_cpp_value = cpp_value(interface, method, index)
    is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type

    # [LegacyInterfaceTypeChecking]
    has_type_checking_interface = (
        not is_legacy_interface_type_checking(interface, method) and
        idl_type.is_wrapper_type)

    set_default_value = argument.set_default_value
    this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes,
                                           raw_type=True,
                                           used_as_variadic_argument=argument.is_variadic)
    context = {
        'cpp_type': (
            v8_types.cpp_template_type('Nullable', this_cpp_type)
            if idl_type.is_explicit_nullable and not argument.is_variadic
            else this_cpp_type),
        'cpp_value': this_cpp_value,
        # FIXME: check that the default value's type is compatible with the argument's
        'set_default_value': set_default_value,
        'enum_type': idl_type.enum_type,
        'enum_values': idl_type.enum_values,
        'handle': '%sHandle' % argument.name,
        # FIXME: remove once [Default] removed and just use argument.default_value
        'has_default': 'Default' in extended_attributes or set_default_value,
        'has_type_checking_interface': has_type_checking_interface,
        # Dictionary is special-cased, but arrays and sequences shouldn't be
        'idl_type': idl_type.base_type,
        'idl_type_object': idl_type,
        'index': index,
        'is_callback_function': idl_type.is_callback_function,
        'is_callback_interface': idl_type.is_callback_interface,
        # FIXME: Remove generic 'Dictionary' special-casing
        'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary',
        'is_explicit_nullable': idl_type.is_explicit_nullable,
        'is_nullable': idl_type.is_nullable,
        'is_optional': argument.is_optional,
        'is_variadic': argument.is_variadic,
        'is_variadic_wrapper_type': is_variadic_wrapper_type,
        'is_wrapper_type': idl_type.is_wrapper_type,
        'name': argument.name,
        'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes,
        'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value),
        'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True),
        'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(interface.name, method, argument, index),
    }
    context.update({
        'is_optional_without_default_value':
            context['is_optional'] and
            not context['has_default'] and
            not context['is_dictionary'] and
            not context['is_callback_interface'],
    })
    return context
开发者ID:eval1749,项目名称:evita,代码行数:59,代码来源:v8_methods.py

示例4: argument_context

def argument_context(interface, method, argument, index, is_visible=True):
    extended_attributes = argument.extended_attributes
    idl_type = argument.idl_type
    if is_visible:
        idl_type.add_includes_for_type(extended_attributes)
    this_cpp_value = cpp_value(interface, method, index)
    is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type

    # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking]
    has_type_checking_interface = (
        not is_legacy_interface_type_checking(interface, method) and
        idl_type.is_wrapper_type)

    if ('ImplementedInPrivateScript' in extended_attributes and
        not idl_type.is_wrapper_type and
        not idl_type.is_basic_type):
        raise Exception('Private scripts supports only primitive types and DOM wrappers.')

    set_default_value = argument.set_default_value
    this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes,
                                           raw_type=True,
                                           used_as_variadic_argument=argument.is_variadic)
    return {
        'cpp_type': (
            v8_types.cpp_template_type('Nullable', this_cpp_type)
            if idl_type.is_explicit_nullable and not argument.is_variadic
            else this_cpp_type),
        'cpp_value': this_cpp_value,
        # FIXME: check that the default value's type is compatible with the argument's
        'set_default_value': set_default_value,
        'enum_type': idl_type.enum_type,
        'enum_values': idl_type.enum_values,
        'handle': '%sHandle' % argument.name,
        # FIXME: remove once [Default] removed and just use argument.default_value
        'has_default': 'Default' in extended_attributes or set_default_value,
        'has_type_checking_interface': has_type_checking_interface,
        # Dictionary is special-cased, but arrays and sequences shouldn't be
        'idl_type': idl_type.base_type,
        'idl_type_object': idl_type,
        'index': index,
        'is_callback_function': idl_type.is_callback_function,
        'is_callback_interface': idl_type.is_callback_interface,
        # FIXME: Remove generic 'Dictionary' special-casing
        'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary',
        'is_explicit_nullable': idl_type.is_explicit_nullable,
        'is_nullable': idl_type.is_nullable,
        'is_optional': argument.is_optional,
        'is_variadic': argument.is_variadic,
        'is_variadic_wrapper_type': is_variadic_wrapper_type,
        'is_wrapper_type': idl_type.is_wrapper_type,
        'name': argument.name,
        'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
            argument.name, isolate='scriptState->isolate()',
            creation_context='scriptState->context()->Global()'),
        'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes,
        'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value),
        'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True),
        'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argument, index),
    }
开发者ID:dstockwell,项目名称:blink,代码行数:59,代码来源:v8_methods.py

示例5: generate_constructor

def generate_constructor(interface, constructor):
    return {
        "argument_list": constructor_argument_list(interface, constructor),
        "arguments": [
            v8_methods.generate_argument(interface, constructor, argument, index)
            for index, argument in enumerate(constructor.arguments)
        ],
        "cpp_type": cpp_template_type(cpp_ptr_type("RefPtr", "RawPtr", gc_type(interface)), cpp_name(interface)),
        "has_exception_state":
        # [RaisesException=Constructor]
        interface.extended_attributes.get("RaisesException") == "Constructor"
        or any(
            argument
            for argument in constructor.arguments
            if argument.idl_type.name == "SerializedScriptValue" or argument.idl_type.is_integer_type
        ),
        "is_constructor": True,
        "is_named_constructor": False,
        "is_variadic": False,  # Required for overload resolution
        "number_of_required_arguments": number_of_required_arguments(constructor),
    }
开发者ID:zanxi,项目名称:bitpop,代码行数:21,代码来源:v8_interface.py

示例6: union_member_argument_context

def union_member_argument_context(idl_type, index):
    """Returns a context of union member for argument."""
    this_cpp_value = "result%d" % index
    this_cpp_type = idl_type.cpp_type
    this_cpp_type_initializer = idl_type.cpp_type_initializer
    cpp_return_value = this_cpp_value

    if not idl_type.cpp_type_has_null_value:
        this_cpp_type = v8_types.cpp_template_type("Nullable", this_cpp_type)
        this_cpp_type_initializer = ""
        cpp_return_value = "%s.get()" % this_cpp_value

    if idl_type.is_string_type:
        null_check_value = "!%s.isNull()" % this_cpp_value
    else:
        null_check_value = this_cpp_value

    return {
        "cpp_type": this_cpp_type,
        "cpp_type_initializer": this_cpp_type_initializer,
        "cpp_value": this_cpp_value,
        "null_check_value": null_check_value,
    }
开发者ID:takaaptech,项目名称:sky_engine,代码行数:23,代码来源:v8_methods.py

示例7: generate_constructor

def generate_constructor(interface, constructor):
    arguments_need_try_catch = any(v8_methods.argument_needs_try_catch(argument)
                                   for argument in constructor.arguments)

    return {
        'arguments': [v8_methods.generate_argument(interface, constructor, argument, index)
                      for index, argument in enumerate(constructor.arguments)],
        'arguments_need_try_catch': arguments_need_try_catch,
        'cpp_type': cpp_template_type(
            cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
            cpp_name(interface)),
        'cpp_value': v8_methods.cpp_value(
            interface, constructor, len(constructor.arguments)),
        'has_exception_state':
            # [RaisesException=Constructor]
            interface.extended_attributes.get('RaisesException') == 'Constructor' or
            any(argument for argument in constructor.arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.is_integer_type),
        'is_constructor': True,
        'is_named_constructor': False,
        'number_of_required_arguments':
            number_of_required_arguments(constructor),
    }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:24,代码来源:v8_interface.py

示例8: interface_context

def interface_context(interface):
    includes.clear()
    includes.update(INTERFACE_CPP_INCLUDES)
    header_includes = set(INTERFACE_H_INCLUDES)

    parent_interface = interface.parent
    if parent_interface:
        header_includes.update(v8_types.includes_for_interface(parent_interface))
    extended_attributes = interface.extended_attributes

    # [ActiveDOMObject]
    is_active_dom_object = 'ActiveDOMObject' in extended_attributes

    # [CheckSecurity]
    is_check_security = 'CheckSecurity' in extended_attributes
    if is_check_security:
        includes.add('bindings/core/v8/BindingSecurity.h')

    # [DependentLifetime]
    is_dependent_lifetime = 'DependentLifetime' in extended_attributes

    # [Iterable]
    iterator_method = None
    if 'Iterable' in extended_attributes:
        iterator_operation = IdlOperation(interface.idl_name)
        iterator_operation.name = 'iterator'
        iterator_operation.idl_type = IdlType('Iterator')
        iterator_operation.extended_attributes['RaisesException'] = None
        iterator_operation.extended_attributes['CallWith'] = 'ScriptState'
        iterator_method = v8_methods.method_context(interface,
                                                    iterator_operation)

    # [MeasureAs]
    is_measure_as = 'MeasureAs' in extended_attributes
    if is_measure_as:
        includes.add('core/frame/UseCounter.h')

    # [SetWrapperReferenceFrom]
    reachable_node_function = extended_attributes.get('SetWrapperReferenceFrom')
    if reachable_node_function:
        includes.update(['bindings/core/v8/V8GCController.h',
                         'core/dom/Element.h'])

    # [SetWrapperReferenceTo]
    set_wrapper_reference_to_list = [{
        'name': argument.name,
        # FIXME: properly should be:
        # 'cpp_type': argument.idl_type.cpp_type_args(raw_type=True),
        # (if type is non-wrapper type like NodeFilter, normally RefPtr)
        # Raw pointers faster though, and NodeFilter hacky anyway.
        'cpp_type': argument.idl_type.implemented_as + '*',
        'idl_type': argument.idl_type,
        'v8_type': v8_types.v8_type(argument.idl_type.name),
    } for argument in extended_attributes.get('SetWrapperReferenceTo', [])]
    for set_wrapper_reference_to in set_wrapper_reference_to_list:
        set_wrapper_reference_to['idl_type'].add_includes_for_type()

    # [NotScriptWrappable]
    is_script_wrappable = 'NotScriptWrappable' not in extended_attributes

    # [Custom=Wrap], [SetWrapperReferenceFrom]
    has_visit_dom_wrapper = (
        has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
        reachable_node_function or
        set_wrapper_reference_to_list)

    this_gc_type = gc_type(interface)

    wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Node') else 'ObjectClassId')

    context = {
        'conditional_string': conditional_string(interface),  # [Conditional]
        'cpp_class': cpp_name(interface),
        'gc_type': this_gc_type,
        # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699
        'has_access_check_callbacks': (is_check_security and
                                       interface.name != 'Window' and
                                       interface.name != 'EventTarget'),
        'has_custom_legacy_call_as_function': has_extended_attribute_value(interface, 'Custom', 'LegacyCallAsFunction'),  # [Custom=LegacyCallAsFunction]
        'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'ToV8'),  # [Custom=ToV8]
        'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wrap'),  # [Custom=Wrap]
        'has_visit_dom_wrapper': has_visit_dom_wrapper,
        'header_includes': header_includes,
        'interface_name': interface.name,
        'is_active_dom_object': is_active_dom_object,
        'is_check_security': is_check_security,
        'is_dependent_lifetime': is_dependent_lifetime,
        'is_event_target': inherits_interface(interface.name, 'EventTarget'),
        'is_exception': interface.is_exception,
        'is_node': inherits_interface(interface.name, 'Node'),
        'is_script_wrappable': is_script_wrappable,
        'iterator_method': iterator_method,
        'lifetime': 'Dependent'
            if (has_visit_dom_wrapper or
                is_active_dom_object or
                is_dependent_lifetime)
            else 'Independent',
        'measure_as': v8_utilities.measure_as(interface),  # [MeasureAs]
        'parent_interface': parent_interface,
        'pass_cpp_type': cpp_template_type(
#.........这里部分代码省略.........
开发者ID:335969568,项目名称:Blink-1,代码行数:101,代码来源:v8_interface.py

示例9: method_context

def method_context(interface, method):
    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    is_static = method.is_static
    name = method.name

    idl_type.add_includes_for_type()
    this_cpp_value = cpp_value(interface, method, len(arguments))

    def function_template():
        if is_static:
            return "functionTemplate"
        if "Unforgeable" in extended_attributes:
            return "instanceTemplate"
        return "prototypeTemplate"

    is_implemented_in_private_script = "ImplementedInPrivateScript" in extended_attributes
    if is_implemented_in_private_script:
        includes.add("bindings/core/v8/PrivateScriptRunner.h")
        includes.add("core/frame/LocalFrame.h")
        includes.add("platform/ScriptForbiddenScope.h")

    # [OnlyExposedToPrivateScript]
    is_only_exposed_to_private_script = "OnlyExposedToPrivateScript" in extended_attributes

    is_call_with_script_arguments = has_extended_attribute_value(method, "CallWith", "ScriptArguments")
    if is_call_with_script_arguments:
        includes.update(["bindings/core/v8/ScriptCallStackFactory.h", "core/inspector/ScriptArguments.h"])
    is_call_with_script_state = has_extended_attribute_value(method, "CallWith", "ScriptState")
    if is_call_with_script_state:
        includes.add("bindings/core/v8/ScriptState.h")
    is_check_security_for_node = "CheckSecurity" in extended_attributes
    if is_check_security_for_node:
        includes.add("bindings/core/v8/BindingSecurity.h")
    is_custom_element_callbacks = "CustomElementCallbacks" in extended_attributes
    if is_custom_element_callbacks:
        includes.add("core/dom/custom/CustomElementProcessingStack.h")

    is_do_not_check_security = "DoNotCheckSecurity" in extended_attributes

    is_check_security_for_frame = (
        has_extended_attribute_value(interface, "CheckSecurity", "Frame") and not is_do_not_check_security
    )

    is_check_security_for_window = (
        has_extended_attribute_value(interface, "CheckSecurity", "Window") and not is_do_not_check_security
    )

    is_raises_exception = "RaisesException" in extended_attributes

    return {
        "activity_logging_world_list": v8_utilities.activity_logging_world_list(method),  # [ActivityLogging]
        "arguments": [argument_context(interface, method, argument, index) for index, argument in enumerate(arguments)],
        "argument_declarations_for_private_script": argument_declarations_for_private_script(interface, method),
        "conditional_string": v8_utilities.conditional_string(method),
        "cpp_type": (
            v8_types.cpp_template_type("Nullable", idl_type.cpp_type)
            if idl_type.is_explicit_nullable
            else idl_type.cpp_type
        ),
        "cpp_value": this_cpp_value,
        "cpp_type_initializer": idl_type.cpp_type_initializer,
        "custom_registration_extended_attributes": CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
            extended_attributes.iterkeys()
        ),
        "deprecate_as": v8_utilities.deprecate_as(method),  # [DeprecateAs]
        "exposed_test": v8_utilities.exposed(method, interface),  # [Exposed]
        "function_template": function_template(),
        "has_custom_registration": is_static
        or v8_utilities.has_extended_attribute(method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
        "has_exception_state": is_raises_exception
        or is_check_security_for_frame
        or is_check_security_for_window
        or any(
            argument
            for argument in arguments
            if (
                argument.idl_type.name == "SerializedScriptValue"
                or argument_conversion_needs_exception_state(method, argument)
            )
        ),
        "idl_type": idl_type.base_type,
        "is_call_with_execution_context": has_extended_attribute_value(method, "CallWith", "ExecutionContext"),
        "is_call_with_script_arguments": is_call_with_script_arguments,
        "is_call_with_script_state": is_call_with_script_state,
        "is_check_security_for_frame": is_check_security_for_frame,
        "is_check_security_for_node": is_check_security_for_node,
        "is_check_security_for_window": is_check_security_for_window,
        "is_custom": "Custom" in extended_attributes,
        "is_custom_element_callbacks": is_custom_element_callbacks,
        "is_do_not_check_security": is_do_not_check_security,
        "is_do_not_check_signature": "DoNotCheckSignature" in extended_attributes,
        "is_explicit_nullable": idl_type.is_explicit_nullable,
        "is_implemented_in_private_script": is_implemented_in_private_script,
        "is_partial_interface_member": "PartialInterfaceImplementedAs" in extended_attributes,
        "is_per_world_bindings": "PerWorldBindings" in extended_attributes,
        "is_raises_exception": is_raises_exception,
        "is_read_only": "Unforgeable" in extended_attributes,
        "is_static": is_static,
#.........这里部分代码省略.........
开发者ID:wulala-wuwu,项目名称:Blink,代码行数:101,代码来源:v8_methods.py

示例10: member_cpp_type

 def member_cpp_type():
     member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True)
     if idl_type.impl_should_use_nullable_container:
         return v8_types.cpp_template_type("Nullable", member_cpp_type)
     return member_cpp_type
开发者ID:wulala-wuwu,项目名称:Blink,代码行数:5,代码来源:v8_dictionary.py

示例11: method_context

def method_context(interface, method):
    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    is_static = method.is_static
    name = method.name
    return_promise = idl_type.name == 'Promise'

    idl_type.add_includes_for_type()
    this_cpp_value = cpp_value(interface, method, len(arguments))

    def function_template():
        if is_static:
            return 'functionTemplate'
        if 'Unforgeable' in extended_attributes:
            return 'instanceTemplate'
        return 'prototypeTemplate'

    is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
    if is_implemented_in_private_script:
        includes.add('bindings/core/v8/PrivateScriptRunner.h')
        includes.add('core/frame/LocalFrame.h')
        includes.add('platform/ScriptForbiddenScope.h')

    # [OnlyExposedToPrivateScript]
    is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended_attributes

    is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
    if is_call_with_script_arguments:
        includes.update(['bindings/core/v8/ScriptCallStackFactory.h',
                         'core/inspector/ScriptArguments.h'])
    is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
    if is_call_with_script_state:
        includes.add('bindings/core/v8/ScriptState.h')
    is_check_security_for_node = 'CheckSecurity' in extended_attributes
    if is_check_security_for_node:
        includes.add('bindings/core/v8/BindingSecurity.h')
    is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
    if is_custom_element_callbacks:
        includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')

    is_check_security_for_frame = (
        'CheckSecurity' in interface.extended_attributes and
        'DoNotCheckSecurity' not in extended_attributes)
    is_raises_exception = 'RaisesException' in extended_attributes

    arguments_need_try_catch = (
        any(argument_needs_try_catch(argument, return_promise)
            for argument in arguments))

    return {
        'activity_logging_world_list': v8_utilities.activity_logging_world_list(method),  # [ActivityLogging]
        'arguments': [argument_context(interface, method, argument, index)
                      for index, argument in enumerate(arguments)],
        'argument_declarations_for_private_script':
            argument_declarations_for_private_script(interface, method),
        'arguments_need_try_catch': arguments_need_try_catch,
        'conditional_string': v8_utilities.conditional_string(method),
        'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
                     if idl_type.is_explicit_nullable else idl_type.cpp_type),
        'cpp_value': this_cpp_value,
        'cpp_type_initializer': idl_type.cpp_type_initializer,
        'custom_registration_extended_attributes':
            CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
                extended_attributes.iterkeys()),
        'deprecate_as': v8_utilities.deprecate_as(method),  # [DeprecateAs]
        'exposed_test': v8_utilities.exposed(method, interface),  # [Exposed]
        'function_template': function_template(),
        'has_custom_registration': is_static or
            v8_utilities.has_extended_attribute(
                method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
        'has_exception_state':
            is_raises_exception or
            is_check_security_for_frame or
            interface.name == 'EventTarget' or  # FIXME: merge with is_check_security_for_frame http://crbug.com/383699
            any(argument for argument in arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.may_raise_exception_on_conversion),
        'idl_type': idl_type.base_type,
        'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
        'is_call_with_script_arguments': is_call_with_script_arguments,
        'is_call_with_script_state': is_call_with_script_state,
        'is_check_security_for_frame': is_check_security_for_frame,
        'is_check_security_for_node': is_check_security_for_node,
        'is_custom': 'Custom' in extended_attributes,
        'is_custom_element_callbacks': is_custom_element_callbacks,
        'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes,
        'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attributes,
        'is_explicit_nullable': idl_type.is_explicit_nullable,
        'is_implemented_in_private_script': is_implemented_in_private_script,
        'is_partial_interface_member':
            'PartialInterfaceImplementedAs' in extended_attributes,
        'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
        'is_raises_exception': is_raises_exception,
        'is_read_only': 'Unforgeable' in extended_attributes,
        'is_static': is_static,
        'is_variadic': arguments and arguments[-1].is_variadic,
        'measure_as': v8_utilities.measure_as(method),  # [MeasureAs]
        'name': name,
        'number_of_arguments': len(arguments),
#.........这里部分代码省略.........
开发者ID:darktears,项目名称:blink-crosswalk,代码行数:101,代码来源:v8_methods.py

示例12: method_context

def method_context(interface, method):
    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    is_static = method.is_static
    name = method.name

    idl_type.add_includes_for_type()
    this_cpp_value = cpp_value(interface, method, len(arguments))

    def function_template():
        if is_static:
            return 'functionTemplate'
        return 'prototypeTemplate'

    is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
    if is_call_with_script_arguments:
        includes.update(['bindings/core/v8/ScriptCallStackFactory.h',
                         'core/inspector/ScriptArguments.h'])
    is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
    if is_call_with_script_state:
        includes.add('bindings/core/v8/ScriptState.h')

    is_raises_exception = 'RaisesException' in extended_attributes

    arguments_need_try_catch = (
        any(argument_needs_try_catch(method, argument)
            for argument in arguments))

    return {
        'arguments': [argument_context(interface, method, argument, index)
                      for index, argument in enumerate(arguments)],
        'arguments_need_try_catch': arguments_need_try_catch,
        'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
                     if idl_type.is_explicit_nullable else idl_type.cpp_type),
        'cpp_value': this_cpp_value,
        'cpp_type_initializer': idl_type.cpp_type_initializer,
        'custom_registration_extended_attributes':
            CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
                extended_attributes.iterkeys()),
        'exposed_test': v8_utilities.exposed(method, interface),  # [Exposed]
        'function_template': function_template(),
        'has_custom_registration': is_static or
            v8_utilities.has_extended_attribute(
                method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
        'has_exception_state':
            is_raises_exception or
            any(argument for argument in arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.may_raise_exception_on_conversion),
        'idl_type': idl_type.base_type,
        'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
        'is_call_with_script_arguments': is_call_with_script_arguments,
        'is_call_with_script_state': is_call_with_script_state,
        'is_custom': 'Custom' in extended_attributes,
        'is_explicit_nullable': idl_type.is_explicit_nullable,
        'is_partial_interface_member':
            'PartialInterfaceImplementedAs' in extended_attributes,
        'is_raises_exception': is_raises_exception,
        'is_static': is_static,
        'is_variadic': arguments and arguments[-1].is_variadic,
        'name': name,
        'number_of_arguments': len(arguments),
        'number_of_required_arguments': len([
            argument for argument in arguments
            if not (argument.is_optional or argument.is_variadic)]),
        'number_of_required_or_variadic_arguments': len([
            argument for argument in arguments
            if not argument.is_optional]),
        'union_arguments': idl_type.union_arguments,
        'use_local_result': use_local_result(method),
    }
开发者ID:MitchRudominer,项目名称:engine,代码行数:72,代码来源:v8_methods.py

示例13: method_context

def method_context(interface, method):
    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    is_static = method.is_static
    name = method.name

    idl_type.add_includes_for_type()
    this_cpp_value = cpp_value(interface, method, len(arguments))

    def function_template():
        if is_static:
            return "functionTemplate"
        return "prototypeTemplate"

    is_call_with_script_arguments = has_extended_attribute_value(method, "CallWith", "ScriptArguments")
    if is_call_with_script_arguments:
        includes.update(["bindings/core/v8/ScriptCallStackFactory.h", "core/inspector/ScriptArguments.h"])
    is_call_with_script_state = has_extended_attribute_value(method, "CallWith", "ScriptState")
    if is_call_with_script_state:
        includes.add("bindings/core/v8/ScriptState.h")
    is_custom_element_callbacks = "CustomElementCallbacks" in extended_attributes
    if is_custom_element_callbacks:
        includes.add("sky/engine/core/dom/custom/custom_element_callback_scope.h")

    is_raises_exception = "RaisesException" in extended_attributes

    arguments_need_try_catch = any(argument_needs_try_catch(method, argument) for argument in arguments)

    return {
        "arguments": [argument_context(interface, method, argument, index) for index, argument in enumerate(arguments)],
        "arguments_need_try_catch": arguments_need_try_catch,
        "cpp_type": (
            v8_types.cpp_template_type("Nullable", idl_type.cpp_type)
            if idl_type.is_explicit_nullable
            else idl_type.cpp_type
        ),
        "cpp_value": this_cpp_value,
        "cpp_type_initializer": idl_type.cpp_type_initializer,
        "custom_registration_extended_attributes": CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
            extended_attributes.iterkeys()
        ),
        "exposed_test": v8_utilities.exposed(method, interface),  # [Exposed]
        "function_template": function_template(),
        "has_custom_registration": is_static
        or v8_utilities.has_extended_attribute(method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
        "has_exception_state": is_raises_exception
        or any(
            argument
            for argument in arguments
            if argument.idl_type.name == "SerializedScriptValue" or argument.idl_type.may_raise_exception_on_conversion
        ),
        "idl_type": idl_type.base_type,
        "is_call_with_execution_context": has_extended_attribute_value(method, "CallWith", "ExecutionContext"),
        "is_call_with_script_arguments": is_call_with_script_arguments,
        "is_call_with_script_state": is_call_with_script_state,
        "is_custom": "Custom" in extended_attributes,
        "is_custom_element_callbacks": is_custom_element_callbacks,
        "is_explicit_nullable": idl_type.is_explicit_nullable,
        "is_partial_interface_member": "PartialInterfaceImplementedAs" in extended_attributes,
        "is_raises_exception": is_raises_exception,
        "is_static": is_static,
        "is_variadic": arguments and arguments[-1].is_variadic,
        "name": name,
        "number_of_arguments": len(arguments),
        "number_of_required_arguments": len(
            [argument for argument in arguments if not (argument.is_optional or argument.is_variadic)]
        ),
        "number_of_required_or_variadic_arguments": len(
            [argument for argument in arguments if not argument.is_optional]
        ),
        "union_arguments": idl_type.union_arguments,
        "use_local_result": use_local_result(method),
    }
开发者ID:takaaptech,项目名称:sky_engine,代码行数:74,代码来源:v8_methods.py

示例14: method_context

def method_context(interface, method, is_visible=True):
    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    is_static = method.is_static
    name = method.name

    if is_visible:
        idl_type.add_includes_for_type(extended_attributes)

    this_cpp_value = cpp_value(interface, method, len(arguments))

    is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
    if is_implemented_in_private_script:
        includes.add('bindings/core/v8/PrivateScriptRunner.h')
        includes.add('core/frame/LocalFrame.h')
        includes.add('platform/ScriptForbiddenScope.h')

    # [OnlyExposedToPrivateScript]
    is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended_attributes

    is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
    if is_call_with_script_arguments:
        includes.update(['bindings/core/v8/ScriptCallStackFactory.h',
                         'core/inspector/ScriptArguments.h'])
    is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
    is_call_with_this_value = has_extended_attribute_value(method, 'CallWith', 'ThisValue')
    if is_call_with_script_state or is_call_with_this_value:
        includes.add('bindings/core/v8/ScriptState.h')
    is_check_security_for_node = 'CheckSecurity' in extended_attributes
    if is_check_security_for_node:
        includes.add('bindings/core/v8/BindingSecurity.h')
    is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
    if is_custom_element_callbacks:
        includes.add('core/dom/custom/CustomElementProcessingStack.h')

    is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes

    is_check_security_for_frame = (
        has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
        not is_do_not_check_security)

    is_check_security_for_window = (
        has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and
        not is_do_not_check_security)

    is_raises_exception = 'RaisesException' in extended_attributes
    is_custom_call_prologue = has_extended_attribute_value(method, 'Custom', 'CallPrologue')
    is_custom_call_epilogue = has_extended_attribute_value(method, 'Custom', 'CallEpilogue')
    is_post_message = 'PostMessage' in extended_attributes
    if is_post_message:
        includes.add('bindings/core/v8/SerializedScriptValueFactory.h')
        includes.add('core/dom/DOMArrayBuffer.h')
        includes.add('core/dom/MessagePort.h')

    if 'LenientThis' in extended_attributes:
        raise Exception('[LenientThis] is not supported for operations.')

    return {
        'activity_logging_world_list': v8_utilities.activity_logging_world_list(method),  # [ActivityLogging]
        'arguments': [argument_context(interface, method, argument, index, is_visible=is_visible)
                      for index, argument in enumerate(arguments)],
        'argument_declarations_for_private_script':
            argument_declarations_for_private_script(interface, method),
        'conditional_string': v8_utilities.conditional_string(method),
        'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
                     if idl_type.is_explicit_nullable else idl_type.cpp_type),
        'cpp_value': this_cpp_value,
        'cpp_type_initializer': idl_type.cpp_type_initializer,
        'custom_registration_extended_attributes':
            CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
                extended_attributes.iterkeys()),
        'deprecate_as': v8_utilities.deprecate_as(method),  # [DeprecateAs]
        'exposed_test': v8_utilities.exposed(method, interface),  # [Exposed]
        # TODO(yukishiino): Retire has_custom_registration flag.  Should be
        # replaced with V8DOMConfiguration::PropertyLocationConfiguration.
        'has_custom_registration':
            is_static or
            is_unforgeable(interface, method) or
            v8_utilities.has_extended_attribute(
                method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
        'has_exception_state':
            is_raises_exception or
            is_check_security_for_frame or
            is_check_security_for_window or
            any(argument for argument in arguments
                if (argument.idl_type.name == 'SerializedScriptValue' or
                    argument_conversion_needs_exception_state(method, argument))),
        'idl_type': idl_type.base_type,
        'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
        'is_call_with_script_arguments': is_call_with_script_arguments,
        'is_call_with_script_state': is_call_with_script_state,
        'is_call_with_this_value': is_call_with_this_value,
        'is_check_security_for_frame': is_check_security_for_frame,
        'is_check_security_for_node': is_check_security_for_node,
        'is_check_security_for_window': is_check_security_for_window,
        'is_custom': 'Custom' in extended_attributes and
            not (is_custom_call_prologue or is_custom_call_epilogue),
        'is_custom_call_prologue': is_custom_call_prologue,
        'is_custom_call_epilogue': is_custom_call_epilogue,
#.........这里部分代码省略.........
开发者ID:dstockwell,项目名称:blink,代码行数:101,代码来源:v8_methods.py

示例15: method_context

def method_context(interface, method, is_visible=True):
    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    is_static = method.is_static
    name = method.name

    if is_visible:
        idl_type.add_includes_for_type(extended_attributes)

    this_cpp_value = cpp_value(interface, method, len(arguments))

    is_implemented_in_private_script = "ImplementedInPrivateScript" in extended_attributes
    if is_implemented_in_private_script:
        includes.add("bindings/core/v8/PrivateScriptRunner.h")
        includes.add("core/frame/LocalFrame.h")
        includes.add("platform/ScriptForbiddenScope.h")

    # [OnlyExposedToPrivateScript]
    is_only_exposed_to_private_script = "OnlyExposedToPrivateScript" in extended_attributes

    is_call_with_script_arguments = has_extended_attribute_value(method, "CallWith", "ScriptArguments")
    if is_call_with_script_arguments:
        includes.update(["bindings/core/v8/ScriptCallStack.h", "core/inspector/ScriptArguments.h"])
    is_call_with_script_state = has_extended_attribute_value(method, "CallWith", "ScriptState")
    is_call_with_this_value = has_extended_attribute_value(method, "CallWith", "ThisValue")
    if is_call_with_script_state or is_call_with_this_value:
        includes.add("bindings/core/v8/ScriptState.h")

    # [CheckSecurity]
    is_do_not_check_security = "DoNotCheckSecurity" in extended_attributes
    is_check_security_for_receiver = (
        has_extended_attribute_value(interface, "CheckSecurity", "Receiver") and not is_do_not_check_security
    )
    is_check_security_for_return_value = has_extended_attribute_value(method, "CheckSecurity", "ReturnValue")
    if is_check_security_for_receiver or is_check_security_for_return_value:
        includes.add("bindings/core/v8/BindingSecurity.h")

    is_ce_reactions = "CEReactions" in extended_attributes
    if is_ce_reactions:
        includes.add("core/dom/custom/CEReactionsScope.h")
    is_custom_element_callbacks = "CustomElementCallbacks" in extended_attributes
    if is_custom_element_callbacks:
        includes.add("core/dom/custom/V0CustomElementProcessingStack.h")

    is_raises_exception = "RaisesException" in extended_attributes
    is_custom_call_prologue = has_extended_attribute_value(method, "Custom", "CallPrologue")
    is_custom_call_epilogue = has_extended_attribute_value(method, "Custom", "CallEpilogue")
    is_post_message = "PostMessage" in extended_attributes
    if is_post_message:
        includes.add("bindings/core/v8/SerializedScriptValueFactory.h")
        includes.add("bindings/core/v8/Transferables.h")

    if "LenientThis" in extended_attributes:
        raise Exception("[LenientThis] is not supported for operations.")

    argument_contexts = [
        argument_context(interface, method, argument, index, is_visible=is_visible)
        for index, argument in enumerate(arguments)
    ]

    return {
        "activity_logging_world_list": v8_utilities.activity_logging_world_list(method),  # [ActivityLogging]
        "arguments": argument_contexts,
        "argument_declarations_for_private_script": argument_declarations_for_private_script(interface, method),
        "cpp_type": (
            v8_types.cpp_template_type("Nullable", idl_type.cpp_type)
            if idl_type.is_explicit_nullable
            else idl_type.cpp_type
        ),
        "cpp_value": this_cpp_value,
        "cpp_type_initializer": idl_type.cpp_type_initializer,
        "custom_registration_extended_attributes": CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
            extended_attributes.iterkeys()
        ),
        "deprecate_as": v8_utilities.deprecate_as(method),  # [DeprecateAs]
        "do_not_test_new_object": "DoNotTestNewObject" in extended_attributes,
        "exposed_test": v8_utilities.exposed(method, interface),  # [Exposed]
        # TODO(yukishiino): Retire has_custom_registration flag.  Should be
        # replaced with V8DOMConfiguration::PropertyLocationConfiguration.
        "has_custom_registration": v8_utilities.has_extended_attribute(method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
        "has_exception_state": is_raises_exception
        or is_check_security_for_receiver
        or any(
            argument
            for argument in arguments
            if (
                argument.idl_type.name == "SerializedScriptValue"
                or argument_conversion_needs_exception_state(method, argument)
            )
        ),
        "has_optional_argument_without_default_value": any(
            True for argument_context in argument_contexts if argument_context["is_optional_without_default_value"]
        ),
        "idl_type": idl_type.base_type,
        "is_call_with_execution_context": has_extended_attribute_value(method, "CallWith", "ExecutionContext"),
        "is_call_with_script_arguments": is_call_with_script_arguments,
        "is_call_with_script_state": is_call_with_script_state,
        "is_call_with_this_value": is_call_with_this_value,
        "is_ce_reactions": is_ce_reactions,
#.........这里部分代码省略.........
开发者ID:endlessm,项目名称:chromium-browser,代码行数:101,代码来源:v8_methods.py


注:本文中的v8_types.cpp_template_type函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。